@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,7 +1,12 @@
1
- const _ = 3, R = 3, O = 9, D = 4;
1
+ const _ = 3, A = 3, C = 9, P = 4, o = 10, t = 20, R = 0, c = 50, n = 5;
2
2
  export {
3
- R as DEFAULT_CARDS_IN_ROW,
3
+ A as DEFAULT_CARDS_IN_ROW,
4
+ o as DEFAULT_COLUMN_SPACING,
4
5
  _ as DEFAULT_PRODUCTS_PER_ROW,
5
- D as MAX_PRODUCTS_PER_ROW,
6
- O as MAX_PRODUCT_COUNT
6
+ t as DEFAULT_ROW_SPACING,
7
+ P as MAX_PRODUCTS_PER_ROW,
8
+ C as MAX_PRODUCT_COUNT,
9
+ c as MAX_SPACING,
10
+ R as MIN_SPACING,
11
+ n as SPACING_STEP
7
12
  };
@@ -1,12 +1,13 @@
1
- import { ModificationDescription as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CommonControl as i } from "../../../common-control.js";
1
+ import { ModificationDescription as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as s } from "../../../common-control.js";
3
+ import { getCurrentLayout as l } from "../main/utils.js";
3
4
  const u = "recommendation-card-background-color-control", e = {
4
5
  CARD_BACKGROUND_COLOR: "cardBackgroundColor"
5
- }, c = {
6
+ }, a = {
6
7
  VERTICAL: ".product-card-segment",
7
8
  HORIZONTAL: ".product-card-wrapper"
8
9
  };
9
- class g extends i {
10
+ class _ extends s {
10
11
  getId() {
11
12
  return u;
12
13
  }
@@ -23,43 +24,22 @@ class g extends i {
23
24
  onRender() {
24
25
  this._setFormValues(), this._listenToFormUpdates();
25
26
  }
26
- onTemplateNodeUpdated(t) {
27
- super.onTemplateNodeUpdated(t), this._setFormValues();
27
+ onTemplateNodeUpdated(r) {
28
+ super.onTemplateNodeUpdated(r), this._setFormValues();
28
29
  }
29
30
  _setFormValues() {
30
- const t = this._getCurrentCardBackgroundColor();
31
+ const r = this._getCurrentCardBackgroundColor();
31
32
  this.api.updateValues({
32
- [e.CARD_BACKGROUND_COLOR]: t
33
+ [e.CARD_BACKGROUND_COLOR]: r
33
34
  });
34
35
  }
35
- /**
36
- * Gets the block element - either currentNode itself or as a descendant
37
- * The currentNode could BE the block element or contain it
38
- */
39
- _getBlockElement() {
40
- if (!this.currentNode)
41
- return null;
42
- if ("getAttribute" in this.currentNode) {
43
- const t = this.currentNode.getAttribute("class");
44
- if (t && t.includes("ins-recommendation-v3-block-v2"))
45
- return this.currentNode;
46
- }
47
- return "querySelector" in this.currentNode ? this.currentNode.querySelector(".ins-recommendation-v3-block-v2") : null;
48
- }
49
- /**
50
- * Gets the current layout orientation from the block's data attribute
51
- */
52
- _getCurrentLayout() {
53
- const t = this._getBlockElement();
54
- return !t || !("getAttribute" in t) ? "vertical" : t.getAttribute("data-layout") === "horizontal" ? "horizontal" : "vertical";
55
- }
56
36
  /**
57
37
  * Gets the appropriate selector based on layout
58
38
  * Vertical: .product-card-segment (inner table per product cell)
59
39
  * Horizontal: .product-card-wrapper (table per product row)
60
40
  */
61
41
  _getCardSelector() {
62
- return this._getCurrentLayout() === "vertical" ? c.VERTICAL : c.HORIZONTAL;
42
+ return l(this.currentNode) === "vertical" ? a.VERTICAL : a.HORIZONTAL;
63
43
  }
64
44
  /**
65
45
  * Reads the current background color from the first product card element
@@ -68,33 +48,33 @@ class g extends i {
68
48
  _getCurrentCardBackgroundColor() {
69
49
  if (!this.currentNode || !("querySelectorAll" in this.currentNode))
70
50
  return "transparent";
71
- const t = this._getCardSelector(), r = this.currentNode.querySelector(t);
72
- return !r || !("getStyle" in r) ? "transparent" : r.getStyle("background-color") || "transparent";
51
+ const r = this._getCardSelector(), t = this.currentNode.querySelector(r);
52
+ return !t || !("getStyle" in t) ? "transparent" : t.getStyle("background-color") || "transparent";
73
53
  }
74
54
  /**
75
55
  * Handles card background color changes
76
56
  * Applies the color to all product card elements based on layout
77
57
  */
78
- _onCardBackgroundColorChange(t) {
58
+ _onCardBackgroundColorChange(r) {
79
59
  if (!this.currentNode || !("querySelectorAll" in this.currentNode))
80
60
  return;
81
- const r = this._getCardSelector(), o = Array.from(
82
- this.currentNode.querySelectorAll(r)
61
+ const t = this._getCardSelector(), o = Array.from(
62
+ this.currentNode.querySelectorAll(t)
83
63
  );
84
64
  if (o.length === 0)
85
65
  return;
86
66
  const n = this.api.getDocumentModifier();
87
- o.forEach((a) => {
88
- n.modifyHtml(a).setStyle("background-color", t);
89
- }), n.apply(new l("Update card background color"));
67
+ o.forEach((c) => {
68
+ n.modifyHtml(c).setStyle("background-color", r);
69
+ }), n.apply(new d("Update card background color"));
90
70
  }
91
71
  _listenToFormUpdates() {
92
- this.api.onValueChanged(e.CARD_BACKGROUND_COLOR, (t) => {
93
- this._onCardBackgroundColorChange(t);
72
+ this.api.onValueChanged(e.CARD_BACKGROUND_COLOR, (r) => {
73
+ this._onCardBackgroundColorChange(r);
94
74
  });
95
75
  }
96
76
  }
97
77
  export {
98
78
  u as CARD_BACKGROUND_COLOR_CONTROL_ID,
99
- g as CardBackgroundColorControl
79
+ _ as CardBackgroundColorControl
100
80
  };
@@ -1,29 +1,31 @@
1
- var f = Object.defineProperty;
2
- var C = (a, n, t) => n in a ? f(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
- var c = (a, n, t) => C(a, typeof n != "symbol" ? n + "" : n, t);
4
- import { ModificationDescription as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as g } from "../../../common-control.js";
6
- import { ATTR_PRODUCT_IMAGE as O, ATTR_PRODUCT_NAME as A, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_OLD_PRICE as N, ATTR_PRODUCT_OMNIBUS_PRICE as E, ATTR_PRODUCT_OMNIBUS_DISCOUNT as D, ATTR_PRODUCT_BUTTON as v } from "../../constants/selectors.js";
7
- import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
8
- const V = "ui-elements-recommendation-card-composition", S = {
1
+ var T = Object.defineProperty;
2
+ var C = (a, n, t) => n in a ? T(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
+ var l = (a, n, t) => C(a, typeof n != "symbol" ? n + "" : n, t);
4
+ import { ModificationDescription as u } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as f } from "../../../common-control.js";
6
+ import { ATTR_PRODUCT_IMAGE as O, ATTR_PRODUCT_NAME as g, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_OLD_PRICE as A, ATTR_PRODUCT_OMNIBUS_PRICE as D, ATTR_PRODUCT_OMNIBUS_DISCOUNT as N, ATTR_PRODUCT_BUTTON as V } from "../../constants/selectors.js";
7
+ import { useRecommendationExtensionStore as E } from "../../store/recommendation.js";
8
+ import { getTableDisplayValue as I } from "../../utils/tagName.js";
9
+ import { getCurrentLayout as P } from "../main/utils.js";
10
+ const S = "ui-elements-recommendation-card-composition", k = {
9
11
  ORDERABLE: "cardComposition"
10
- }, b = ".recommendation-attribute-row", P = ".product-card-wrapper > tbody", y = "data-card-composition", p = "data-attribute-type", h = "data-visibility", s = [
12
+ }, c = ".recommendation-attribute-row", v = ".product-card-wrapper > tbody", _ = "data-card-composition", d = "data-attribute-type", m = "data-visibility", s = [
11
13
  { key: O, label: "Product Image", visible: !0 },
12
- { key: A, label: "Product Name", visible: !0 },
14
+ { key: g, label: "Product Name", visible: !0 },
13
15
  { key: R, label: "Product Price", visible: !0 },
14
- { key: N, label: "Product Original Price", visible: !0 },
15
- { key: E, label: "Omnibus Price", visible: !1 },
16
- { key: D, label: "Omnibus Discount", visible: !1 },
17
- { key: v, label: "Product Button", visible: !0 }
16
+ { key: A, label: "Product Original Price", visible: !0 },
17
+ { key: D, label: "Omnibus Price", visible: !1 },
18
+ { key: N, label: "Omnibus Discount", visible: !1 },
19
+ { key: V, label: "Product Button", visible: !0 }
18
20
  ];
19
- class x extends g {
21
+ class H extends f {
20
22
  constructor() {
21
23
  super(...arguments);
22
- c(this, "store", I());
23
- c(this, "unsubscribeOrientation", null);
24
+ l(this, "store", E());
25
+ l(this, "unsubscribeOrientation", null);
24
26
  }
25
27
  getId() {
26
- return V;
28
+ return S;
27
29
  }
28
30
  getTemplate() {
29
31
  const t = s.map((e) => ({
@@ -34,7 +36,7 @@ class x extends g {
34
36
  return `
35
37
  <div class="container" data-card-composition-control>
36
38
  ${this._GuLabel({ text: "Card Element Order & Visibility" })}
37
- ${this._GuOrderable(S.ORDERABLE, t)}
39
+ ${this._GuOrderable(k.ORDERABLE, t)}
38
40
  </div>
39
41
  `;
40
42
  }
@@ -85,7 +87,7 @@ class x extends g {
85
87
  _readCompositionFromNode() {
86
88
  if (!this.currentNode || !("getAttribute" in this.currentNode))
87
89
  return s.map((e) => e.key);
88
- const t = this.currentNode.getAttribute(y);
90
+ const t = this.currentNode.getAttribute(_);
89
91
  return t ? t.split(",").filter(Boolean) : s.map((e) => e.key);
90
92
  }
91
93
  /**
@@ -101,7 +103,7 @@ class x extends g {
101
103
  _readVisibilityFromRows() {
102
104
  if (!this.currentNode)
103
105
  return this._getDefaultVisibilities();
104
- const t = Array.from(this.currentNode.querySelectorAll(b)), e = this._extractVisibilityFromRows(t);
106
+ const t = Array.from(this.currentNode.querySelectorAll(c)), e = this._extractVisibilityFromRows(t);
105
107
  return this._mergeWithDefaults(e);
106
108
  }
107
109
  /**
@@ -118,7 +120,7 @@ class x extends g {
118
120
  return t.forEach((i) => {
119
121
  if (!("getAttribute" in i))
120
122
  return;
121
- const o = i.getAttribute(p), r = i.getAttribute(h);
123
+ const o = i.getAttribute(d), r = i.getAttribute(m);
122
124
  o && r !== null && (e[o] = this._parseVisibilityValue(r));
123
125
  }), e;
124
126
  }
@@ -146,7 +148,7 @@ class x extends g {
146
148
  if (!this.currentNode)
147
149
  return;
148
150
  const e = this._getCurrentLayout();
149
- this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(y, t.join(",")).apply(new d("Update card composition")), e === "vertical" && this._reorderProductAttributes(t);
151
+ this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(_, t.join(",")).apply(new u("Update card composition")), e === "vertical" && this._reorderProductAttributes(t);
150
152
  }
151
153
  /**
152
154
  * Reorders attribute rows within each product card based on composition order
@@ -155,21 +157,21 @@ class x extends g {
155
157
  _reorderProductAttributes(t) {
156
158
  if (!this.currentNode)
157
159
  return;
158
- const e = this.currentNode.querySelectorAll(P);
160
+ const e = this.currentNode.querySelectorAll(v);
159
161
  if (!(e != null && e.length))
160
162
  return;
161
163
  const i = this.api.getDocumentModifier();
162
164
  e.forEach((o) => {
163
165
  const r = this._buildCompositionHtml(o, t);
164
166
  i.modifyHtml(o).setInnerHtml(r);
165
- }), i.apply(new d("Reorder product attributes"));
167
+ }), i.apply(new u("Reorder product attributes"));
166
168
  }
167
169
  /**
168
170
  * Builds HTML string with attributes ordered according to composition
169
171
  */
170
172
  _buildCompositionHtml(t, e) {
171
173
  return e.reduce((i, o) => {
172
- const r = t.querySelector(`${b}[${p}="${o}"]`);
174
+ const r = t.querySelector(`${c}[${d}="${o}"]`);
173
175
  return r && "getOuterHTML" in r ? i + r.getOuterHTML() : i;
174
176
  }, "");
175
177
  }
@@ -182,33 +184,20 @@ class x extends g {
182
184
  _applyVisibilityToBlock(t, e) {
183
185
  if (!this.currentNode)
184
186
  return;
185
- const i = this.currentNode.querySelectorAll(`${b}[${p}="${t}"]`);
187
+ const i = this.currentNode.querySelectorAll(`${c}[${d}="${t}"]`);
186
188
  if (!(i != null && i.length))
187
189
  return;
188
- const o = e ? "1" : "0", r = `Set ${t} visibility to ${e ? "visible" : "hidden"}`, m = this.api.getDocumentModifier();
189
- i.forEach((l) => {
190
- let u = "TR";
191
- if ("tagName" in l && l.tagName)
192
- u = l.tagName.toUpperCase();
193
- else if ("getTagName" in l) {
194
- const _ = l;
195
- typeof _.getTagName == "function" && (u = _.getTagName().toUpperCase());
196
- }
197
- const T = e ? u === "TD" || u === "BLOCK_IMAGE" || u === "BLOCK_BUTTON" ? "table-cell" : "table-row" : "none";
198
- m.modifyHtml(l).setStyle("display", T).setAttribute(h, o);
199
- }), m.apply(new d(r));
190
+ const o = e ? "1" : "0", r = `Set ${t} visibility to ${e ? "visible" : "hidden"}`, b = this.api.getDocumentModifier();
191
+ i.forEach((p) => {
192
+ const y = I(p), h = e ? y : "none";
193
+ b.modifyHtml(p).setStyle("display", h).setAttribute(m, o);
194
+ }), b.apply(new u(r));
200
195
  }
201
196
  /**
202
197
  * Gets the current layout orientation from store or DOM
203
198
  */
204
199
  _getCurrentLayout() {
205
- const t = this.store.recommendationConfigs.orientation;
206
- if (t)
207
- return t;
208
- if (!this.currentNode || !("querySelector" in this.currentNode))
209
- return "vertical";
210
- const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
211
- return !e || !("getAttribute" in e) ? "vertical" : e.getAttribute("data-layout") === "horizontal" ? "horizontal" : "vertical";
200
+ return this.store.recommendationConfigs.orientation || P(this.currentNode);
212
201
  }
213
202
  /**
214
203
  * Updates orderable state based on layout orientation
@@ -238,6 +227,6 @@ class x extends g {
238
227
  }
239
228
  }
240
229
  export {
241
- V as COMPOSITION_CONTROL_BLOCK_ID,
242
- x as RecommendationCardCompositionControl
230
+ S as COMPOSITION_CONTROL_BLOCK_ID,
231
+ H as RecommendationCardCompositionControl
243
232
  };
@@ -1,25 +1,33 @@
1
- var l = Object.defineProperty;
2
- var a = (s, n, t) => n in s ? l(s, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[n] = t;
3
- var r = (s, n, t) => a(s, typeof n != "symbol" ? n + "" : n, t);
1
+ var a = Object.defineProperty;
2
+ var h = (n, s, e) => s in n ? a(n, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[s] = e;
3
+ var r = (n, s, e) => h(n, typeof s != "symbol" ? s + "" : s, e);
4
4
  import { CommonControl as m } from "../../../common-control.js";
5
- import { useRecommendationExtensionStore as c } from "../../store/recommendation.js";
5
+ import { useRecommendationExtensionStore as u } from "../../store/recommendation.js";
6
6
  import { AlgorithmControl as C } from "./algorithm.js";
7
- import { ALGORITHM_CONTROL_ID as U } from "./algorithm.js";
8
- import { CurrencyControl as h } from "./currency.js";
9
- import { CURRENCY_CONTROL_ID as $ } from "./currency.js";
10
- import { FiltersControl as u } from "./filters.js";
11
- import { FILTERS_CONTROL_ID as F } from "./filters.js";
7
+ import { ALGORITHM_CONTROL_ID as x } from "./algorithm.js";
8
+ import { CurrencyControl as c } from "./currency.js";
9
+ import { CURRENCY_CONTROL_ID as k } from "./currency.js";
10
+ import { FiltersControl as d } from "./filters.js";
11
+ import { FILTERS_CONTROL_ID as A } from "./filters.js";
12
12
  import { LocaleControl as f } from "./locale.js";
13
- import { LOCALE_CONTROL_ID as A } from "./locale.js";
14
- import { ProductLayoutControl as d } from "./productLayout.js";
15
- import { PRODUCT_LAYOUT_CONTROL_ID as v } from "./productLayout.js";
16
- import { ShuffleControl as p } from "./shuffle.js";
13
+ import { LOCALE_CONTROL_ID as z } from "./locale.js";
14
+ import { ProductLayoutControl as p } from "./productLayout.js";
15
+ import { PRODUCT_LAYOUT_CONTROL_ID as Y } from "./productLayout.js";
16
+ import { ShuffleControl as R } from "./shuffle.js";
17
17
  import { SHUFFLE_CONTROL_ID as B } from "./shuffle.js";
18
- const R = "ui-elements-recommendation-block";
19
- class I extends m {
18
+ import { useDebounceFn as y } from "../../../../../node_modules/@vueuse/shared/index.js";
19
+ const T = /* @__PURE__ */ new Set([
20
+ "size",
21
+ "strategy",
22
+ "filters",
23
+ "productIds",
24
+ "language",
25
+ "shuffleProducts"
26
+ ]), _ = "ui-elements-recommendation-block";
27
+ class F extends m {
20
28
  constructor() {
21
29
  super(...arguments);
22
- r(this, "store", c());
30
+ r(this, "store", u());
23
31
  r(this, "storeUnsubscription", () => {
24
32
  });
25
33
  // Sub-control instances for lifecycle management
@@ -29,12 +37,18 @@ class I extends m {
29
37
  r(this, "productLayoutControl", null);
30
38
  r(this, "filtersControl", null);
31
39
  r(this, "shuffleControl", null);
40
+ /**
41
+ * Debounced product fetch to prevent rapid API calls during config changes
42
+ */
43
+ r(this, "_debouncedFetchProducts", y(() => {
44
+ this.store.fetchRecommendationProducts();
45
+ }, 500));
32
46
  }
33
47
  getId() {
34
- return R;
48
+ return _;
35
49
  }
36
50
  getTemplate() {
37
- return this.algorithmControl = new C(), this.localeControl = new f(), this.currencyControl = new h(), this.productLayoutControl = new d(), this.filtersControl = new u(), this.shuffleControl = new p(), `
51
+ return this.algorithmControl = new C(), this.localeControl = new f(), this.currencyControl = new c(), this.productLayoutControl = new p(), this.filtersControl = new d(), this.shuffleControl = new R(), `
38
52
  <div class="recommendation-controls-container">
39
53
  ${this.algorithmControl.getTemplate()}
40
54
  ${this.localeControl.getTemplate()}
@@ -50,17 +64,39 @@ class I extends m {
50
64
  this.store.fetchRecommendationFilters(),
51
65
  this.store.fetchRecommendationCreateData(),
52
66
  this.store.fetchRecommendationProducts()
53
- ])).forEach((o, e) => {
54
- o.status === "rejected" && console.warn(`Recommendation block: ${[
67
+ ])).forEach((t, o) => {
68
+ t.status === "rejected" && console.warn(`Recommendation block: ${[
55
69
  "fetchRecommendationFilters",
56
70
  "fetchRecommendationCreateData",
57
71
  "fetchRecommendationProducts"
58
- ][e]} failed`, o.reason);
72
+ ][o]} failed`, t.reason);
59
73
  }), this._initializeSubControls(), this._listenStateUpdates();
60
74
  }
75
+ onTemplateNodeUpdated(e) {
76
+ super.onTemplateNodeUpdated(e), [
77
+ this.algorithmControl,
78
+ this.localeControl,
79
+ this.currencyControl,
80
+ this.productLayoutControl,
81
+ this.filtersControl,
82
+ this.shuffleControl
83
+ ].forEach((o) => {
84
+ var i;
85
+ o != null && o.api && (o.currentNode = e, (i = o.onTemplateNodeUpdated) == null || i.call(o, e));
86
+ });
87
+ }
61
88
  onDestroy() {
62
- var t, o, e, i;
63
- this.storeUnsubscription(), (o = (t = this.filtersControl) == null ? void 0 : t.onDestroy) == null || o.call(t), (i = (e = this.productLayoutControl) == null ? void 0 : e.onDestroy) == null || i.call(e);
89
+ this.storeUnsubscription(), [
90
+ this.algorithmControl,
91
+ this.localeControl,
92
+ this.currencyControl,
93
+ this.productLayoutControl,
94
+ this.filtersControl,
95
+ this.shuffleControl
96
+ ].forEach((t) => {
97
+ var o;
98
+ return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
99
+ });
64
100
  }
65
101
  /**
66
102
  * Initialize all sub-controls with the shared API context
@@ -74,33 +110,38 @@ class I extends m {
74
110
  this.productLayoutControl,
75
111
  this.filtersControl,
76
112
  this.shuffleControl
77
- ].forEach((o) => {
78
- var e;
79
- o && (o.api = this.api, o.currentNode = this.currentNode, (e = o.onRender) == null || e.call(o));
113
+ ].forEach((t) => {
114
+ var o;
115
+ t && (t.api = this.api, t.currentNode = this.currentNode, (o = t.onRender) == null || o.call(t));
80
116
  });
81
117
  }
82
118
  /**
83
119
  * Listen to store changes that require product refresh
120
+ * Only triggers for meaningful config changes (size, strategy, filters, etc.)
121
+ * Uses debounce to prevent rapid API calls
84
122
  */
85
123
  _listenStateUpdates() {
86
- this.storeUnsubscription = this.store.$subscribe((t) => {
87
- "payload" in t && t.payload.recommendationConfigs && this.store.fetchRecommendationProducts();
124
+ this.storeUnsubscription = this.store.$subscribe((e) => {
125
+ if ("payload" in e) {
126
+ const t = e.payload.recommendationConfigs;
127
+ t && Object.keys(t).some((l) => T.has(l)) && this._debouncedFetchProducts();
128
+ }
88
129
  });
89
130
  }
90
131
  }
91
132
  export {
92
- U as ALGORITHM_CONTROL_ID,
133
+ x as ALGORITHM_CONTROL_ID,
93
134
  C as AlgorithmControl,
94
- R as CONTROL_BLOCK_ID,
95
- $ as CURRENCY_CONTROL_ID,
96
- h as CurrencyControl,
97
- F as FILTERS_CONTROL_ID,
98
- u as FiltersControl,
99
- A as LOCALE_CONTROL_ID,
135
+ _ as CONTROL_BLOCK_ID,
136
+ k as CURRENCY_CONTROL_ID,
137
+ c as CurrencyControl,
138
+ A as FILTERS_CONTROL_ID,
139
+ d as FiltersControl,
140
+ z as LOCALE_CONTROL_ID,
100
141
  f as LocaleControl,
101
- v as PRODUCT_LAYOUT_CONTROL_ID,
102
- d as ProductLayoutControl,
103
- I as RecommendationBlockControl,
142
+ Y as PRODUCT_LAYOUT_CONTROL_ID,
143
+ p as ProductLayoutControl,
144
+ F as RecommendationBlockControl,
104
145
  B as SHUFFLE_CONTROL_ID,
105
- p as ShuffleControl
146
+ R as ShuffleControl
106
147
  };
@@ -1,44 +1,43 @@
1
- var u = Object.defineProperty;
2
- var d = (i, o, t) => o in i ? u(i, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[o] = t;
3
- var s = (i, o, t) => d(i, typeof o != "symbol" ? o + "" : o, t);
4
- import { UEAttr as a } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as c } from "../../../common-control.js";
6
- import { MAX_PRODUCT_COUNT as _, MAX_PRODUCTS_PER_ROW as R } from "../../constants/layout.js";
7
- import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
8
- import { getCurrentLayout as C, regenerateProductRows as h, reapplySpacing as l } from "./utils.js";
1
+ var a = Object.defineProperty;
2
+ var u = (i, o, t) => o in i ? a(i, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[o] = t;
3
+ var n = (i, o, t) => u(i, typeof o != "symbol" ? o + "" : o, t);
4
+ import { CommonControl as d } from "../../../common-control.js";
5
+ import { MAX_PRODUCT_COUNT as c, MAX_PRODUCTS_PER_ROW as _ } from "../../constants/layout.js";
6
+ import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
7
+ import { getCurrentLayout as m, regenerateProductRows as h, reapplySpacing as C } from "./utils.js";
9
8
  import { useDebounceFn as p } from "../../../../../node_modules/@vueuse/shared/index.js";
10
- const O = "recommendation-product-layout-control", e = {
9
+ const l = "recommendation-product-layout-control", e = {
11
10
  PRODUCT_COUNT: "size",
12
11
  PRODUCT_IN_ROW: "cardsInRow",
13
12
  PRODUCT_IN_ROW_LABEL: "cardsInRowLabel"
14
13
  };
15
- class D extends c {
14
+ class b extends d {
16
15
  constructor() {
17
16
  super(...arguments);
18
- s(this, "store", m());
19
- s(this, "storeUnsubscription", () => {
17
+ n(this, "store", R());
18
+ n(this, "storeUnsubscription", () => {
20
19
  });
21
- s(this, "_debouncedRegenerateProductRows", p(() => {
20
+ n(this, "_debouncedRegenerateProductRows", p(() => {
22
21
  this._regenerateProductRows();
23
22
  }, 500));
24
23
  }
25
24
  getId() {
26
- return O;
25
+ return l;
27
26
  }
28
27
  getTemplate() {
29
28
  return `
30
29
  <div class="product-layout-control-container">
31
30
  ${this._GuTwoColumns([
32
31
  this._GuLabel({ text: "Number of Products" }),
33
- this._GuCounter({ name: e.PRODUCT_COUNT, maxValue: _ }),
32
+ this._GuCounter({ name: e.PRODUCT_COUNT, maxValue: c }),
34
33
  this._GuLabel({ text: "Products in One Row", name: e.PRODUCT_IN_ROW_LABEL }),
35
- this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: R })
34
+ this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: _ })
36
35
  ])}
37
36
  </div>
38
37
  `;
39
38
  }
40
39
  onRender() {
41
- this._initializeCounterValues(), this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates();
40
+ this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates();
42
41
  }
43
42
  onTemplateNodeUpdated(t) {
44
43
  super.onTemplateNodeUpdated(t), this._updateProductsInRowVisibility();
@@ -53,25 +52,13 @@ class D extends c {
53
52
  [e.PRODUCT_IN_ROW]: t.cardsInRow
54
53
  });
55
54
  }
56
- _initializeCounterValues() {
57
- const { recommendationConfigs: t } = this.store;
58
- this.api.setUIEAttribute(
59
- e.PRODUCT_COUNT,
60
- a.SELECTPICKER.items,
61
- Number(t.size)
62
- ), this.api.setUIEAttribute(
63
- e.PRODUCT_IN_ROW,
64
- a.SELECTPICKER.items,
65
- t.cardsInRow
66
- );
67
- }
68
55
  /**
69
56
  * Updates "Products in One Row" visibility based on layout orientation
70
57
  * This control is hidden for horizontal layout (products always take full width)
71
58
  * Reads from store first (reliable during state transitions), falls back to DOM
72
59
  */
73
60
  _updateProductsInRowVisibility() {
74
- const r = (this.store.recommendationConfigs.orientation || C(this.currentNode)) === "vertical";
61
+ const r = (this.store.recommendationConfigs.orientation || m(this.currentNode)) === "vertical";
75
62
  this.api.setVisibility(e.PRODUCT_IN_ROW, r), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, r);
76
63
  }
77
64
  _onProductCountChange(t) {
@@ -93,7 +80,7 @@ class D extends c {
93
80
  currentNode: this.currentNode,
94
81
  documentModifier: this.api.getDocumentModifier(),
95
82
  afterRegenerate: () => {
96
- l({
83
+ C({
97
84
  currentNode: this.currentNode,
98
85
  documentModifier: this.api.getDocumentModifier()
99
86
  });
@@ -113,12 +100,12 @@ class D extends c {
113
100
  _listenStateUpdates() {
114
101
  let t = this.store.recommendationConfigs.orientation;
115
102
  this.storeUnsubscription = this.store.$subscribe(() => {
116
- const n = this.store.recommendationConfigs.orientation;
117
- n !== t && (t = n, this._updateProductsInRowVisibility());
103
+ const s = this.store.recommendationConfigs.orientation;
104
+ s !== t && (t = s, this._updateProductsInRowVisibility());
118
105
  });
119
106
  }
120
107
  }
121
108
  export {
122
- O as PRODUCT_LAYOUT_CONTROL_ID,
123
- D as ProductLayoutControl
109
+ l as PRODUCT_LAYOUT_CONTROL_ID,
110
+ b as ProductLayoutControl
124
111
  };