@useinsider/guido 2.0.0-beta.e73ba15 → 2.0.0-beta.edc1f0a

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 (23) hide show
  1. package/dist/extensions/Blocks/Recommendation/constants/layout.js +9 -4
  2. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +21 -41
  3. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +37 -48
  4. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +80 -39
  5. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +22 -35
  6. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +72 -70
  7. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +1 -1
  8. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +3 -3
  9. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +71 -84
  10. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +8 -4
  11. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +16 -14
  12. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +27 -16
  13. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  14. package/dist/extensions/Blocks/common-control.js +1 -1
  15. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  16. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +10 -0
  17. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +0 -10
  18. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +8 -0
  19. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -1
  20. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +1 -5
  21. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
  22. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  23. package/package.json +1 -1
@@ -1,112 +1,114 @@
1
1
  import { ModificationDescription as s } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CONTAINER_SELECTOR as y } from "../../constants/selectors.js";
3
- import { useRecommendationExtensionStore as S } from "../../store/recommendation.js";
4
- import { prepareProductRows as A } from "../../templates/index.js";
5
- import { DEFAULT_CARD_COMPOSITION as d, getDefaultProducts as b } from "../../templates/utils.js";
6
- const f = "ins-recommendation-v3-block-v2";
7
- function p(e) {
8
- if (!e)
2
+ import { CONTAINER_SELECTOR as S } from "../../constants/selectors.js";
3
+ import { useRecommendationExtensionStore as A } from "../../store/recommendation.js";
4
+ import { prepareProductRows as b } from "../../templates/index.js";
5
+ import { hasGetStyle as d, isTdNode as C } from "../../utils/tagName.js";
6
+ import { DEFAULT_CARD_COMPOSITION as f, getDefaultProducts as h } from "../../templates/utils.js";
7
+ const m = "ins-recommendation-v3-block-v2";
8
+ function p(r) {
9
+ if (!r)
9
10
  return null;
10
- if ("getAttribute" in e) {
11
- const t = e.getAttribute("class");
12
- if (t && t.includes(f))
13
- return e;
11
+ if ("getAttribute" in r) {
12
+ const t = r.getAttribute("class");
13
+ if (t && t.includes(m))
14
+ return r;
14
15
  }
15
- return "querySelector" in e ? e.querySelector(`.${f}`) : null;
16
+ return "querySelector" in r ? r.querySelector(`.${m}`) : null;
16
17
  }
17
- function m(e) {
18
- const t = p(e);
18
+ function g(r) {
19
+ const t = p(r);
19
20
  return !t || !("getAttribute" in t) ? "vertical" : t.getAttribute("data-layout") === "horizontal" ? "horizontal" : "vertical";
20
21
  }
21
- function C(e) {
22
- const t = p(e);
22
+ function w(r) {
23
+ const t = p(r);
23
24
  if (!t || !("getAttribute" in t))
24
- return d;
25
- const r = t.getAttribute("data-card-composition");
26
- return r ? r.split(",").filter(Boolean) : d;
25
+ return f;
26
+ const e = t.getAttribute("data-card-composition");
27
+ return e ? e.split(",").filter(Boolean) : f;
27
28
  }
28
- function R(e) {
29
- const { currentNode: t, documentModifier: r, afterRegenerate: o } = e;
29
+ function I(r) {
30
+ const { currentNode: t, documentModifier: e, afterRegenerate: o } = r;
30
31
  if (!t || !("querySelector" in t))
31
32
  return;
32
- const a = t.querySelector(y);
33
+ const a = t.querySelector(S);
33
34
  if (!a)
34
35
  return;
35
- const c = S(), i = c.recommendationProducts.length > 0 ? c.recommendationProducts : b(), { cardsInRow: l } = c.recommendationConfigs, n = C(t), u = m(t), g = A(i, u, {
36
+ const n = A(), c = n.recommendationProducts.length > 0 ? n.recommendationProducts : h(), { cardsInRow: l } = n.recommendationConfigs, i = w(t), u = g(t), y = b(c, u, {
36
37
  productsPerRow: l,
37
- composition: n
38
+ composition: i
38
39
  });
39
- r.modifyHtml(a).setInnerHtml(g).apply(new s("Updated product")), o == null || o();
40
+ e.modifyHtml(a).setInnerHtml(y).apply(new s("Updated product")), o == null || o();
40
41
  }
41
- function h(e, t, r, o) {
42
- const c = `0 ${Math.floor(r / 2)}px`;
43
- let i = !1;
42
+ function E(r, t, e, o) {
43
+ const n = `0 ${Math.floor(e / 2)}px`;
44
+ let c = !1;
44
45
  return o === "vertical" ? Array.from(
45
- e.querySelectorAll(".attribute-cell")
46
- ).forEach((n) => {
47
- t.modifyHtml(n).setStyle("padding", c), i = !0;
46
+ r.querySelectorAll(".attribute-cell")
47
+ ).forEach((i) => {
48
+ t.modifyHtml(i).setStyle("padding", n), c = !0;
48
49
  }) : Array.from(
49
- e.querySelectorAll(".product-card-wrapper")
50
- ).forEach((n) => {
51
- "parentNode" in n && n.parentNode && typeof n.parentNode == "object" && "tagName" in n.parentNode && n.parentNode.tagName === "TD" && (t.modifyHtml(n.parentNode).setStyle("padding", c), i = !0);
52
- }), i;
53
- }
54
- function E(e, t, r) {
55
- const o = `${r}px`, a = Array.from(e.querySelectorAll(".spacer"));
56
- let c = !1;
57
- return a.forEach((i) => {
58
- t.modifyHtml(i).setStyle("height", o), c = !0;
50
+ r.querySelectorAll(".product-card-wrapper")
51
+ ).forEach((i) => {
52
+ const u = "parentNode" in i ? i.parentNode : null;
53
+ u && C(u) && (t.modifyHtml(u).setStyle("padding", n), c = !0);
59
54
  }), c;
60
55
  }
61
- function P(e) {
62
- const { currentNode: t, documentModifier: r } = e;
56
+ function k(r, t, e) {
57
+ const o = `${e}px`, a = Array.from(r.querySelectorAll(".spacer"));
58
+ let n = !1;
59
+ return a.forEach((c) => {
60
+ t.modifyHtml(c).setStyle("height", o), n = !0;
61
+ }), n;
62
+ }
63
+ function v(r) {
64
+ const { currentNode: t, documentModifier: e } = r;
63
65
  if (!t)
64
66
  return;
65
67
  const o = p(t);
66
68
  if (!o || !("getAttribute" in o))
67
69
  return;
68
- const a = o.getAttribute("data-column-spacing"), c = o.getAttribute("data-row-spacing"), i = m(t);
70
+ const a = o.getAttribute("data-column-spacing"), n = o.getAttribute("data-row-spacing"), c = g(t);
69
71
  let l = !1;
70
72
  if (a) {
71
- const n = parseInt(a);
72
- Number.isNaN(n) || (l = h(
73
+ const i = parseInt(a);
74
+ Number.isNaN(i) || (l = E(
73
75
  t,
74
- r,
75
- n,
76
- i
76
+ e,
77
+ i,
78
+ c
77
79
  ));
78
80
  }
79
- if (c) {
80
- const n = parseInt(c);
81
- if (!Number.isNaN(n)) {
82
- const u = E(t, r, n);
81
+ if (n) {
82
+ const i = parseInt(n);
83
+ if (!Number.isNaN(i)) {
84
+ const u = k(t, e, i);
83
85
  l = l || u;
84
86
  }
85
87
  }
86
- l && r.apply(new s("Reapply spacing after regeneration"));
88
+ l && e.apply(new s("Reapply spacing after regeneration"));
87
89
  }
88
- function H(e) {
89
- if (!e)
90
+ function x(r) {
91
+ if (!r)
90
92
  return null;
91
- const t = e.querySelector(".product-card-segment"), r = e.querySelector(".product-card-wrapper");
93
+ const t = r.querySelector(".product-card-segment"), e = r.querySelector(".product-card-wrapper");
92
94
  let o = null;
93
- return t && "getStyle" in t && (o = t.getStyle("background-color")), (!o || o === "transparent") && r && "getStyle" in r && (o = r.getStyle("background-color")), o;
95
+ return t && d(t) && (o = t.getStyle("background-color") ?? null), (!o || o === "transparent") && e && d(e) && (o = e.getStyle("background-color") ?? null), o;
94
96
  }
95
- function I(e) {
96
- const { currentNode: t, documentModifier: r, bgColor: o, layout: a } = e;
97
+ function O(r) {
98
+ const { currentNode: t, documentModifier: e, bgColor: o, layout: a } = r;
97
99
  if (!o || o === "transparent" || !t)
98
100
  return;
99
- const c = a === "vertical" ? ".product-card-segment" : ".product-card-wrapper", i = Array.from(t.querySelectorAll(c));
100
- i.length !== 0 && (i.forEach((l) => {
101
- r.modifyHtml(l).setStyle("background-color", o);
102
- }), r.apply(new s("Apply card background color")));
101
+ const n = a === "vertical" ? ".product-card-segment" : ".product-card-wrapper", c = Array.from(t.querySelectorAll(n));
102
+ c.length !== 0 && (c.forEach((l) => {
103
+ e.modifyHtml(l).setStyle("background-color", o);
104
+ }), e.apply(new s("Apply card background color")));
103
105
  }
104
106
  export {
105
- I as applyCardBackgroundColor,
107
+ O as applyCardBackgroundColor,
106
108
  p as getBlockElement,
107
- C as getCardComposition,
108
- H as getCurrentCardBackgroundColor,
109
- m as getCurrentLayout,
110
- P as reapplySpacing,
111
- R as regenerateProductRows
109
+ w as getCardComposition,
110
+ x as getCurrentCardBackgroundColor,
111
+ g as getCurrentLayout,
112
+ v as reapplySpacing,
113
+ I as regenerateProductRows
112
114
  };
@@ -64,7 +64,7 @@ class b extends a {
64
64
  }
65
65
  _listenToFormUpdates() {
66
66
  this.api.onValueChanged("omnibusDiscountTextAfter", (t) => {
67
- this._onTextChange(t);
67
+ typeof t == "string" && this._onTextChange(t);
68
68
  });
69
69
  }
70
70
  }
@@ -5,7 +5,7 @@ import { RecommendationControlId as d } from "../../constants/controlIds.js";
5
5
  import { CONTAINER_SELECTOR as T } from "../../constants/selectors.js";
6
6
  import { preserveTextStyles as f } from "../../utils/preserveTextStyles.js";
7
7
  const i = "data-text-before", u = "", p = ".omnibus-text-before";
8
- class B extends l {
8
+ class g extends l {
9
9
  getId() {
10
10
  return d.OMNIBUS_DISCOUNT_TEXT_BEFORE;
11
11
  }
@@ -64,10 +64,10 @@ class B extends l {
64
64
  }
65
65
  _listenToFormUpdates() {
66
66
  this.api.onValueChanged("omnibusDiscountTextBefore", (e) => {
67
- this._onTextChange(e);
67
+ typeof e == "string" && this._onTextChange(e);
68
68
  });
69
69
  }
70
70
  }
71
71
  export {
72
- B as OmnibusDiscountTextBeforeControl
72
+ g as OmnibusDiscountTextBeforeControl
73
73
  };
@@ -1,78 +1,67 @@
1
- var A = Object.defineProperty;
2
- var y = (n, i, t) => i in n ? A(n, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[i] = t;
3
- var p = (n, i, t) => y(n, typeof i != "symbol" ? i + "" : i, t);
4
- import { ModificationDescription as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as b } from "../../../common-control.js";
6
- import { useRecommendationExtensionStore as P } from "../../store/recommendation.js";
7
- import { useDebounceFn as N } from "../../../../../node_modules/@vueuse/shared/index.js";
8
- const O = "recommendation-spacing-control", a = {
1
+ var P = Object.defineProperty;
2
+ var G = (o, i, t) => i in o ? P(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
3
+ var l = (o, i, t) => G(o, typeof i != "symbol" ? i + "" : i, t);
4
+ import { ModificationDescription as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as I } from "../../../common-control.js";
6
+ import { SPACING_STEP as N, MAX_SPACING as _, MIN_SPACING as f, DEFAULT_COLUMN_SPACING as c, DEFAULT_ROW_SPACING as b } from "../../constants/layout.js";
7
+ import { useRecommendationExtensionStore as L } from "../../store/recommendation.js";
8
+ import { safeGetStyle as d, safeGetParent as V } from "../../utils/tagName.js";
9
+ import { getCurrentLayout as m } from "../main/utils.js";
10
+ import { useDebounceFn as y } from "../../../../../node_modules/@vueuse/shared/index.js";
11
+ const w = "recommendation-spacing-control", s = {
9
12
  COLUMN_SPACING: "columnSpacing",
10
13
  COLUMN_SPACING_LABEL: "columnSpacingLabel",
11
14
  ROW_SPACING: "rowSpacing"
12
- }, _ = {
15
+ }, A = {
13
16
  COLUMN_SPACING: "data-column-spacing",
14
17
  ROW_SPACING: "data-row-spacing"
15
- }, s = {
16
- COLUMN_SPACING: 10,
17
- // 5px on each side = 10px total
18
- ROW_SPACING: 20
19
- }, u = {
20
- MIN_SPACING: 0,
21
- MAX_SPACING: 50,
22
- STEP: 5
23
18
  };
24
- function S(n, i) {
25
- return !n || !("getStyle" in n) ? null : n.getStyle(i);
26
- }
27
- function I(n) {
28
- return !n || !("parent" in n) || typeof n.parent != "function" ? null : n.parent();
29
- }
30
- function C(n, i) {
31
- if (!n)
19
+ function h(o, i) {
20
+ if (!o)
32
21
  return i;
33
- const t = parseFloat(n);
22
+ const t = parseFloat(o);
34
23
  return Number.isNaN(t) ? i : t;
35
24
  }
36
- class w extends b {
25
+ class q extends I {
37
26
  constructor() {
38
27
  super(...arguments);
39
- p(this, "store", P());
40
- p(this, "unsubscribeOrientation", null);
28
+ l(this, "store", L());
29
+ l(this, "unsubscribeOrientation", null);
41
30
  /**
42
31
  * Debounced version of _onColumnSpacingChange
43
32
  * Prevents excessive DOM updates when user rapidly adjusts the counter
44
33
  */
45
- p(this, "_debouncedOnColumnSpacingChange", N((t) => {
34
+ l(this, "_debouncedOnColumnSpacingChange", y((t) => {
46
35
  this._onColumnSpacingChange(t);
47
36
  }, 300));
48
37
  /**
49
38
  * Debounced version of _onRowSpacingChange
50
39
  * Prevents excessive DOM updates when user rapidly adjusts the counter
51
40
  */
52
- p(this, "_debouncedOnRowSpacingChange", N((t) => {
41
+ l(this, "_debouncedOnRowSpacingChange", y((t) => {
53
42
  this._onRowSpacingChange(t);
54
43
  }, 300));
55
44
  }
56
45
  getId() {
57
- return O;
46
+ return w;
58
47
  }
59
48
  getTemplate() {
60
49
  return `
61
50
  <div class="spacing-control-container">
62
51
  ${this._GuTwoColumns([
63
- this._GuLabel({ text: "Column Spacing (px)", name: a.COLUMN_SPACING_LABEL }),
52
+ this._GuLabel({ text: "Column Spacing (px)", name: s.COLUMN_SPACING_LABEL }),
64
53
  this._GuCounter({
65
- name: a.COLUMN_SPACING,
66
- minValue: u.MIN_SPACING,
67
- maxValue: u.MAX_SPACING,
68
- step: u.STEP
54
+ name: s.COLUMN_SPACING,
55
+ minValue: f,
56
+ maxValue: _,
57
+ step: N
69
58
  }),
70
59
  this._GuLabel({ text: "Row Spacing (px)" }),
71
60
  this._GuCounter({
72
- name: a.ROW_SPACING,
73
- minValue: u.MIN_SPACING,
74
- maxValue: u.MAX_SPACING,
75
- step: u.STEP
61
+ name: s.ROW_SPACING,
62
+ minValue: f,
63
+ maxValue: _,
64
+ step: N
76
65
  })
77
66
  ])}
78
67
  </div>
@@ -84,14 +73,8 @@ class w extends b {
84
73
  onTemplateNodeUpdated(t) {
85
74
  super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateColumnSpacingVisibility();
86
75
  }
87
- /**
88
- * Gets the current layout orientation from the block's data attribute
89
- */
90
- _getCurrentLayout() {
91
- if (!this.currentNode || !("querySelector" in this.currentNode))
92
- return "vertical";
93
- const t = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
94
- return !t || !("getAttribute" in t) ? "vertical" : t.getAttribute("data-layout") === "horizontal" ? "horizontal" : "vertical";
76
+ onDestroy() {
77
+ this.unsubscribeOrientation && (this.unsubscribeOrientation(), this.unsubscribeOrientation = null);
95
78
  }
96
79
  /**
97
80
  * Updates column spacing visibility based on layout orientation
@@ -99,17 +82,21 @@ class w extends b {
99
82
  * Reads from store first for reliability, falls back to DOM
100
83
  */
101
84
  _updateColumnSpacingVisibility() {
102
- const r = (this.store.recommendationConfigs.orientation || this._getCurrentLayout()) === "vertical";
103
- this.api.setVisibility(a.COLUMN_SPACING, r), this.api.setVisibility(a.COLUMN_SPACING_LABEL, r);
85
+ if (!this.api)
86
+ return;
87
+ const n = (this.store.recommendationConfigs.orientation || m(this.currentNode)) === "vertical";
88
+ this.api.setVisibility(s.COLUMN_SPACING, n), this.api.setVisibility(s.COLUMN_SPACING_LABEL, n);
104
89
  }
105
90
  /**
106
91
  * Reads spacing values from data attributes or returns defaults
107
92
  */
108
93
  _setFormValues() {
94
+ if (!this.api)
95
+ return;
109
96
  const t = this._getStoredColumnSpacing(), e = this._getStoredRowSpacing();
110
97
  this.api.updateValues({
111
- [a.COLUMN_SPACING]: t,
112
- [a.ROW_SPACING]: e
98
+ [s.COLUMN_SPACING]: t,
99
+ [s.ROW_SPACING]: e
113
100
  });
114
101
  }
115
102
  /**
@@ -120,28 +107,28 @@ class w extends b {
120
107
  */
121
108
  _getStoredColumnSpacing() {
122
109
  if (!this.currentNode)
123
- return s.COLUMN_SPACING;
124
- if (this._getCurrentLayout() === "vertical") {
125
- const o = this.currentNode.querySelector(".recommendation-attribute-row"), f = o == null ? void 0 : o.querySelector("td"), g = S(f, "padding");
126
- if (!g)
127
- return s.COLUMN_SPACING;
128
- const m = g.trim().split(/\s+/);
129
- return m.length < 2 ? s.COLUMN_SPACING : C(m[1], s.COLUMN_SPACING / 2) * 2;
110
+ return c;
111
+ if (m(this.currentNode) === "vertical") {
112
+ const r = this.currentNode.querySelector(".recommendation-attribute-row"), O = r == null ? void 0 : r.querySelector("td"), S = d(O, "padding");
113
+ if (!S)
114
+ return c;
115
+ const C = S.trim().split(/\s+/);
116
+ return C.length < 2 ? c : h(C[1], c / 2) * 2;
130
117
  }
131
- const e = this.currentNode.querySelector(".product-card-wrapper"), r = I(e), l = S(r, "padding");
132
- if (!l)
133
- return s.COLUMN_SPACING;
134
- const c = l.trim().split(/\s+/);
135
- return c.length < 2 ? s.COLUMN_SPACING : C(c[1], s.COLUMN_SPACING / 2) * 2;
118
+ const e = this.currentNode.querySelector(".product-card-wrapper"), n = V(e), u = d(n, "padding");
119
+ if (!u)
120
+ return c;
121
+ const a = u.trim().split(/\s+/);
122
+ return a.length < 2 ? c : h(a[1], c / 2) * 2;
136
123
  }
137
124
  /**
138
125
  * Gets stored row spacing from the first spacer element's height style
139
126
  */
140
127
  _getStoredRowSpacing() {
141
128
  if (!this.currentNode)
142
- return s.ROW_SPACING;
143
- const t = this.currentNode.querySelector(".spacer"), e = S(t, "height");
144
- return C(e, s.ROW_SPACING);
129
+ return b;
130
+ const t = this.currentNode.querySelector(".spacer"), e = d(t, "height");
131
+ return h(e, b);
145
132
  }
146
133
  /**
147
134
  * Handles column spacing changes.
@@ -152,16 +139,16 @@ class w extends b {
152
139
  if (!this.currentNode)
153
140
  return;
154
141
  this._storeColumnSpacing(t);
155
- const e = this._getCurrentLayout(), r = this.api.getDocumentModifier(), c = `0 ${t / 2}px`;
142
+ const e = m(this.currentNode), n = this.api.getDocumentModifier(), a = `0 ${t / 2}px`;
156
143
  e === "vertical" ? Array.from(
157
144
  this.currentNode.querySelectorAll(".attribute-cell")
158
- ).forEach((o) => {
159
- r.modifyHtml(o).setStyle("padding", c);
145
+ ).forEach((r) => {
146
+ n.modifyHtml(r).setStyle("padding", a);
160
147
  }) : Array.from(
161
148
  this.currentNode.querySelectorAll(".product-card-wrapper")
162
- ).forEach((o) => {
163
- "parent" in o && o.parent() && r.modifyHtml(o.parent()).setStyle("padding", c);
164
- }), r.apply(new d(`Update column spacing to ${t}px`));
149
+ ).forEach((r) => {
150
+ "parent" in r && r.parent() && n.modifyHtml(r.parent()).setStyle("padding", a);
151
+ }), n.apply(new p(`Update column spacing to ${t}px`));
165
152
  }
166
153
  /**
167
154
  * Handles row spacing changes
@@ -176,10 +163,10 @@ class w extends b {
176
163
  );
177
164
  if (!e.length)
178
165
  return;
179
- const r = this.api.getDocumentModifier(), l = `${t}px`;
180
- e.forEach((c) => {
181
- r.modifyHtml(c).setStyle("height", l);
182
- }), r.apply(new d(`Update row spacing to ${t}px`));
166
+ const n = this.api.getDocumentModifier(), u = `${t}px`;
167
+ e.forEach((a) => {
168
+ n.modifyHtml(a).setStyle("height", u);
169
+ }), n.apply(new p(`Update row spacing to ${t}px`));
183
170
  }
184
171
  /**
185
172
  * Stores column spacing value in block data attribute
@@ -188,7 +175,7 @@ class w extends b {
188
175
  if (!this.currentNode)
189
176
  return;
190
177
  const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
191
- e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(_.COLUMN_SPACING, t.toString()).apply(new d("Store column spacing"));
178
+ e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(A.COLUMN_SPACING, t.toString()).apply(new p("Store column spacing"));
192
179
  }
193
180
  /**
194
181
  * Stores row spacing value in block data attribute
@@ -197,13 +184,13 @@ class w extends b {
197
184
  if (!this.currentNode)
198
185
  return;
199
186
  const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
200
- e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(_.ROW_SPACING, t.toString()).apply(new d("Store row spacing"));
187
+ e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(A.ROW_SPACING, t.toString()).apply(new p("Store row spacing"));
201
188
  }
202
189
  _listenToFormUpdates() {
203
- this.api.onValueChanged(a.COLUMN_SPACING, (t) => {
190
+ this.api.onValueChanged(s.COLUMN_SPACING, (t) => {
204
191
  const e = parseInt(t);
205
192
  Number.isNaN(e) || this._debouncedOnColumnSpacingChange(e);
206
- }), this.api.onValueChanged(a.ROW_SPACING, (t) => {
193
+ }), this.api.onValueChanged(s.ROW_SPACING, (t) => {
207
194
  const e = parseInt(t);
208
195
  Number.isNaN(e) || this._debouncedOnRowSpacingChange(e);
209
196
  });
@@ -219,6 +206,6 @@ class w extends b {
219
206
  }
220
207
  }
221
208
  export {
222
- O as SPACING_CONTROL_ID,
223
- w as SpacingControl
209
+ w as SPACING_CONTROL_ID,
210
+ q as SpacingControl
224
211
  };
@@ -1,15 +1,19 @@
1
1
  const n = `/* Utils */
2
2
  .es-180w { width: 180px; }
3
3
 
4
- /* Recommendation Controls */
5
- .recommendation-controls-container > .container {
6
- padding: 16px;
4
+ /* Recommendation Controls - Main settings panel separators */
5
+ .recommendation-controls-container > div {
6
+ border-bottom: 1px solid #e0e0e0;
7
7
  }
8
8
 
9
- .recommendation-controls-container > .container:first-child {
9
+ .recommendation-controls-container > div:first-child {
10
10
  padding-top: 0;
11
11
  }
12
12
 
13
+ .recommendation-controls-container > div:last-child {
14
+ border-bottom: none;
15
+ }
16
+
13
17
  .container:has(.recommendation-controls-container) {
14
18
  padding: 0
15
19
  }
@@ -1,14 +1,14 @@
1
1
  import { RecommendationFeedSourceMaps as u, PriceAttributes as c } from "../../../../enums/extensions/recommendationBlock.js";
2
2
  import { useRecommendationApi as p } from "../../../../services/recommendationApi.js";
3
3
  import { useConfigStore as m } from "../../../../stores/config.js";
4
- import { defineStore as d } from "pinia";
5
- import { DEFAULT_CARDS_IN_ROW as f } from "../constants/layout.js";
4
+ import { defineStore as f } from "pinia";
5
+ import { DEFAULT_CARDS_IN_ROW as d } from "../constants/layout.js";
6
6
  import { generateCompleteFilterQuery as l } from "../utils/filterUtil.js";
7
- const n = p(), g = () => ({
7
+ const s = p(), g = () => ({
8
8
  recommendationCampaignUrls: {},
9
9
  recommendationProducts: [],
10
10
  recommendationConfigs: {
11
- cardsInRow: f,
11
+ cardsInRow: d,
12
12
  currencySettings: {
13
13
  name: "USD",
14
14
  value: "USD",
@@ -135,7 +135,7 @@ const n = p(), g = () => ({
135
135
  filterSelectionDrawerStatus: !1,
136
136
  filterList: {},
137
137
  filterGroup: 1
138
- }), S = d("guidoRecommendationExtension", {
138
+ }), S = f("guidoRecommendationExtension", {
139
139
  state: () => g(),
140
140
  getters: {
141
141
  hasFilters: (e) => !!e.recommendationConfigs.filters.length,
@@ -179,13 +179,13 @@ const n = p(), g = () => ({
179
179
  activePredictiveAlgorithms: e,
180
180
  languages: t,
181
181
  currencies: r
182
- } = await n.fetchRecommendationCreateData();
182
+ } = await s.fetchRecommendationCreateData();
183
183
  this.activePredictiveAlgorithms = e, this.languages = t;
184
184
  const [i] = r;
185
185
  this.recommendationConfigs.currencySettings.name = i.text, this.recommendationConfigs.currencySettings.value = i.value, this.currencyList = r, this.filterStatus = !!this.recommendationConfigs.filters.length;
186
186
  },
187
187
  async fetchRecommendationFilters() {
188
- const e = await n.fetchRecommendationFilters();
188
+ const e = await s.fetchRecommendationFilters();
189
189
  this.filterList = e;
190
190
  },
191
191
  addFilterGroup(e) {
@@ -225,13 +225,15 @@ const n = p(), g = () => ({
225
225
  }
226
226
  },
227
227
  addFilter(e) {
228
- const t = [...this.recommendationConfigs.filters], r = t.findLastIndex((i) => i.filterGroup === e.filterGroup);
229
- r !== -1 ? t.splice(r + 1, 0, {
228
+ const t = [...this.recommendationConfigs.filters], i = t.filter(
229
+ (a) => a.filterGroup === e.filterGroup
230
+ ).length + 1, o = t.findLastIndex((a) => a.filterGroup === e.filterGroup);
231
+ o !== -1 ? t.splice(o + 1, 0, {
230
232
  ...e,
231
- filterNumber: r + 2
233
+ filterNumber: i
232
234
  }) : t.push({
233
235
  ...e,
234
- filterNumber: 1
236
+ filterNumber: i
235
237
  }), this.$patch({
236
238
  recommendationConfigs: {
237
239
  filters: t
@@ -242,11 +244,11 @@ const n = p(), g = () => ({
242
244
  return l(this.recommendationConfigs.filters);
243
245
  },
244
246
  async fetchRecommendationProducts() {
245
- var s;
246
- const e = this.recommendationConfigs.filters.filter((a) => a.isValid), t = l(e), r = ((s = u.find((a) => a.key === this.recommendationConfigs.strategy)) == null ? void 0 : s.path) || "", i = m(), o = await n.fetchRecommendationProducts(
247
+ var a;
248
+ const e = this.recommendationConfigs.filters.filter((n) => n.isValid), t = l(e), r = ((a = u.find((n) => n.key === this.recommendationConfigs.strategy)) == null ? void 0 : a.path) || "", i = m(), o = await s.fetchRecommendationProducts(
247
249
  r,
248
250
  {
249
- // TODO: Here will be optimized and filled carefully
251
+ // Note: {itemId} and {campaignId} are template placeholders replaced at runtime
250
252
  locale: this.recommendationConfigs.language,
251
253
  currency: this.recommendationConfigs.currencySettings.value,
252
254
  partnerName: i.partnerName,
@@ -1,25 +1,36 @@
1
- function a(n) {
2
- return "getInnerHTML" in n && typeof n.getInnerHTML == "function" ? n.getInnerHTML() : "innerHTML" in n ? n.innerHTML : "";
1
+ function p(t) {
2
+ const r = {
3
+ "&": "&amp;",
4
+ "<": "&lt;",
5
+ ">": "&gt;",
6
+ '"': "&quot;",
7
+ "'": "&#39;"
8
+ };
9
+ return t.replace(/[&<>"']/g, (n) => r[n]);
3
10
  }
4
- function H(n, t) {
5
- if (!n)
6
- return t;
7
- const r = a(n);
8
- if (!r || r.trim() === "" || !/<(strong|em|u|s|b|i)\b/i.test(r))
9
- return t;
10
- const i = [], s = [];
11
- let o = r.trim();
11
+ function m(t) {
12
+ return "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML() : "innerHTML" in t ? t.innerHTML : "";
13
+ }
14
+ function T(t, r) {
15
+ const n = p(r);
16
+ if (!t)
17
+ return n;
18
+ const e = m(t);
19
+ if (!e || e.trim() === "" || !/<(strong|em|u|s|b|i)\b/i.test(e))
20
+ return n;
21
+ const i = [], o = [];
22
+ let c = e.trim();
12
23
  for (; ; ) {
13
- const u = o.match(/^<(strong|em|u|s|b|i)(\s[^>]*)?>(.*)$/is);
24
+ const u = c.match(/^<(strong|em|u|s|b|i)(\s[^>]*)?>(.*)$/is);
14
25
  if (!u)
15
26
  break;
16
- const [, e, f = "", g] = u, c = new RegExp(`</${e}>$`, "i");
17
- if (!c.test(g))
27
+ const [, s, f = "", g] = u, a = new RegExp(`</${s}>$`, "i");
28
+ if (!a.test(g))
18
29
  break;
19
- i.push(`<${e}${f}>`), s.unshift(`</${e}>`), o = g.replace(c, "").trim();
30
+ i.push(`<${s}${f}>`), o.unshift(`</${s}>`), c = g.replace(a, "").trim();
20
31
  }
21
- return i.length > 0 ? i.join("") + t + s.join("") : t;
32
+ return i.length > 0 ? i.join("") + n + o.join("") : n;
22
33
  }
23
34
  export {
24
- H as preserveTextStyles
35
+ T as preserveTextStyles
25
36
  };