@useinsider/guido 2.0.0-beta.1c331b8 → 2.0.0-beta.1f72712

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 (52) hide show
  1. package/dist/extensions/Blocks/Recommendation/block.js +40 -6
  2. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +64 -0
  3. package/dist/extensions/Blocks/Recommendation/constants/layout.js +9 -4
  4. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +17 -9
  5. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +48 -54
  6. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +42 -36
  7. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +51 -27
  8. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +146 -73
  9. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +49 -35
  10. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +23 -13
  11. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +41 -41
  12. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +27 -16
  13. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +79 -67
  14. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +1 -1
  15. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +3 -3
  16. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +85 -79
  17. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +8 -4
  18. package/dist/extensions/Blocks/Recommendation/services/configService.js +239 -0
  19. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +30 -28
  20. package/dist/extensions/Blocks/Recommendation/templates/horizontal/elementRenderer.js +49 -25
  21. package/dist/extensions/Blocks/Recommendation/templates/horizontal/template.js +18 -19
  22. package/dist/extensions/Blocks/Recommendation/templates/utils.js +44 -101
  23. package/dist/extensions/Blocks/Recommendation/templates/vertical/elementRenderer.js +60 -35
  24. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
  25. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
  26. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  27. package/dist/extensions/Blocks/common-control.js +1 -1
  28. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +214 -157
  29. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  30. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +34 -0
  31. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
  32. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -2
  33. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +10 -0
  34. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +12 -0
  35. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +3 -1
  36. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +13 -1
  37. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +30 -1
  38. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +19 -0
  39. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +9 -0
  40. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +4 -2
  41. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +8 -0
  42. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +19 -0
  43. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +13 -2
  44. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
  45. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
  46. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
  47. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
  48. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +154 -0
  49. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
  50. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  51. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  52. package/package.json +1 -1
@@ -1,25 +1,30 @@
1
- var l = Object.defineProperty;
2
- var _ = (n, o, t) => o in n ? l(n, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[o] = t;
3
- var s = (n, o, t) => _(n, typeof o != "symbol" ? o + "" : o, t);
4
- import { currencyLocationMaps as i, currencyOperators as r, currencyDecimalCounts as a } from "../../../../../enums/extensions/recommendationBlock.js";
5
- import { UEAttr as E } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
- import { CommonControl as u } from "../../../common-control.js";
7
- import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
8
- const S = "recommendation-currency-control", e = {
9
- CURRENCY: "value",
10
- CURRENCY_LOCATION: "alignment",
11
- CURRENCY_SYMBOL: "symbol",
12
- CURRENCY_THOUSAND_SEPARATOR: "thousandSeparator",
13
- CURRENCY_DECIMAL_SEPARATOR: "decimalSeparator",
14
- CURRENCY_DECIMAL_COUNT: "decimalCount"
1
+ var h = Object.defineProperty;
2
+ var R = (a, o, e) => o in a ? h(a, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[o] = e;
3
+ var c = (a, o, e) => R(a, typeof o != "symbol" ? o + "" : o, e);
4
+ import { currencyLocationMaps as u, currencyOperators as s, currencyDecimalCounts as l } from "../../../../../enums/extensions/recommendationBlock.js";
5
+ import { UEAttr as _ } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { CommonControl as m } from "../../../common-control.js";
7
+ import { RecommendationConfigService as C } from "../../services/configService.js";
8
+ import { useRecommendationExtensionStore as p } from "../../store/recommendation.js";
9
+ import { setCurrencyAttributes as d, regenerateProductRows as S, reapplySpacing as E } from "./utils.js";
10
+ const N = "recommendation-currency-control", t = {
11
+ CURRENCY: "currencyCode",
12
+ CURRENCY_LOCATION: "currencyAlignment",
13
+ CURRENCY_SYMBOL: "currencySymbol",
14
+ CURRENCY_THOUSAND_SEPARATOR: "currencyThousandSeparator",
15
+ CURRENCY_DECIMAL_SEPARATOR: "currencyDecimalSeparator",
16
+ CURRENCY_DECIMAL_COUNT: "currencyDecimalCount"
15
17
  };
16
- class p extends u {
18
+ class Y extends m {
17
19
  constructor() {
18
20
  super(...arguments);
19
- s(this, "store", m());
21
+ // Store is used ONLY for API-fetched data (currency list), not for config
22
+ c(this, "store", p());
23
+ c(this, "storeUnsubscription", () => {
24
+ });
20
25
  }
21
26
  getId() {
22
- return S;
27
+ return N;
23
28
  }
24
29
  getTemplate() {
25
30
  return `
@@ -27,108 +32,176 @@ class p extends u {
27
32
  ${this._GuTwoColumns([
28
33
  this._GuLabel({ text: "Currency" }),
29
34
  this._GuSelect({
30
- name: e.CURRENCY,
35
+ name: t.CURRENCY,
31
36
  placeholder: "Select Currency",
32
37
  options: this.store.currencyList
33
38
  }),
34
39
  this._GuLabel({ text: "Currency Location" }),
35
40
  this._GuSelect({
36
- name: e.CURRENCY_LOCATION,
41
+ name: t.CURRENCY_LOCATION,
37
42
  placeholder: "Select Currency Location",
38
- options: i
43
+ options: u
39
44
  }),
40
45
  this._GuLabel({ text: "Currency Symbol" }),
41
- this._GuSelect({
42
- name: e.CURRENCY_SYMBOL,
43
- placeholder: "Select Currency Symbol",
44
- options: this.store.getCurrencySymbolList
46
+ this._GuTextInput({
47
+ name: t.CURRENCY_SYMBOL,
48
+ placeholder: "Enter Currency Symbol",
49
+ className: "es-180w"
45
50
  }),
46
51
  this._GuLabel({ text: "Thousand Separator" }),
47
52
  this._GuSelect({
48
- name: e.CURRENCY_THOUSAND_SEPARATOR,
53
+ name: t.CURRENCY_THOUSAND_SEPARATOR,
49
54
  placeholder: "Select Thousand Separator",
50
- options: r
55
+ options: s
51
56
  }),
52
57
  this._GuLabel({ text: "Decimal Separator" }),
53
58
  this._GuSelect({
54
- name: e.CURRENCY_DECIMAL_SEPARATOR,
59
+ name: t.CURRENCY_DECIMAL_SEPARATOR,
55
60
  placeholder: "Select Decimal Separator",
56
- options: r
61
+ options: s
57
62
  }),
58
63
  this._GuLabel({ text: "Decimal Count" }),
59
64
  this._GuSelect({
60
- name: e.CURRENCY_DECIMAL_COUNT,
65
+ name: t.CURRENCY_DECIMAL_COUNT,
61
66
  placeholder: "Select Decimal Count",
62
- options: a
67
+ options: l
63
68
  })
64
69
  ])}
65
70
  </div>
66
71
  `;
67
72
  }
68
73
  onRender() {
69
- this._initializeSelectItems(), this._setFormValues(), this._listenToFormUpdates();
74
+ this._initializeSelectItems(), this._setFormValues(), setTimeout(() => {
75
+ this._listenToFormUpdates();
76
+ }, 0), this._subscribeToStoreChanges();
77
+ }
78
+ onTemplateNodeUpdated(e) {
79
+ super.onTemplateNodeUpdated(e), this._setFormValues();
80
+ }
81
+ onDestroy() {
82
+ this.storeUnsubscription();
70
83
  }
71
84
  _setFormValues() {
72
- const { currencySettings: t } = this.store.recommendationConfigs;
85
+ const e = C.getConfig(this.currentNode), { currency: r } = e;
73
86
  this.api.updateValues({
74
- [e.CURRENCY]: t.value,
75
- [e.CURRENCY_LOCATION]: t.alignment,
76
- [e.CURRENCY_SYMBOL]: t.symbol,
77
- [e.CURRENCY_THOUSAND_SEPARATOR]: t.thousandSeparator,
78
- [e.CURRENCY_DECIMAL_SEPARATOR]: t.decimalSeparator,
79
- [e.CURRENCY_DECIMAL_COUNT]: t.decimalCount
87
+ [t.CURRENCY]: `price.${r.code}`,
88
+ [t.CURRENCY_LOCATION]: r.alignment === "before" ? "0" : "1",
89
+ [t.CURRENCY_SYMBOL]: r.symbol,
90
+ [t.CURRENCY_THOUSAND_SEPARATOR]: r.thousandSeparator,
91
+ [t.CURRENCY_DECIMAL_SEPARATOR]: r.decimalSeparator,
92
+ [t.CURRENCY_DECIMAL_COUNT]: r.decimalCount.toString()
80
93
  });
81
94
  }
82
95
  _initializeSelectItems() {
83
- const { store: t } = this, C = {
84
- [e.CURRENCY]: t.currencyList,
85
- [e.CURRENCY_LOCATION]: i,
86
- [e.CURRENCY_SYMBOL]: t.getCurrencySymbolList,
87
- [e.CURRENCY_THOUSAND_SEPARATOR]: r,
88
- [e.CURRENCY_DECIMAL_SEPARATOR]: r,
89
- [e.CURRENCY_DECIMAL_COUNT]: a
96
+ const { store: e } = this, r = {
97
+ [t.CURRENCY]: e.currencyList,
98
+ [t.CURRENCY_LOCATION]: u,
99
+ [t.CURRENCY_THOUSAND_SEPARATOR]: s,
100
+ [t.CURRENCY_DECIMAL_SEPARATOR]: s,
101
+ [t.CURRENCY_DECIMAL_COUNT]: l
90
102
  };
91
- Object.entries(C).forEach(([c, R]) => {
92
- this.api.setUIEAttribute(c, E.SELECTPICKER.items, R);
103
+ Object.entries(r).forEach(([n, i]) => {
104
+ this.api.setUIEAttribute(n, _.SELECTPICKER.items, i);
93
105
  });
94
106
  }
95
- _onCurrencyChange(t) {
96
- const [, C] = t.split(".");
97
- this.store.$patch({
107
+ _updateCurrency(e) {
108
+ if (!this.currentNode)
109
+ return;
110
+ const n = { ...C.getConfig(this.currentNode).currency, ...e };
111
+ C.updateConfig(
112
+ this.api,
113
+ this.currentNode,
114
+ { currency: n },
115
+ "Updated currency settings"
116
+ );
117
+ const i = this.api.getDocumentModifier();
118
+ d({
119
+ currentNode: this.currentNode,
120
+ documentModifier: i,
121
+ currency: n
122
+ }), this.store.$patch({
98
123
  recommendationConfigs: {
99
124
  currencySettings: {
100
- name: C,
101
- value: C
125
+ name: n.code,
126
+ value: n.code,
127
+ symbol: n.symbol,
128
+ alignment: n.alignment === "before" ? "0" : "1",
129
+ decimalCount: n.decimalCount.toString(),
130
+ decimalSeparator: n.decimalSeparator,
131
+ thousandSeparator: n.thousandSeparator
102
132
  }
103
133
  }
134
+ }), S({
135
+ currentNode: this.currentNode,
136
+ documentModifier: i,
137
+ afterRegenerate: () => {
138
+ E({
139
+ currentNode: this.currentNode,
140
+ documentModifier: i
141
+ });
142
+ }
104
143
  });
105
144
  }
106
- _onCurrencyConfigChange(t, C) {
107
- this.store.$patch({
108
- recommendationConfigs: {
109
- currencySettings: {
110
- [t]: C
111
- }
112
- }
145
+ _onCurrencyChange(e) {
146
+ const [, r] = e.includes(".") ? e.split(".") : [null, e];
147
+ this._updateCurrency({
148
+ code: r,
149
+ symbol: r
150
+ }), this.api.updateValues({
151
+ [t.CURRENCY_SYMBOL]: r
152
+ });
153
+ }
154
+ _onCurrencyLocationChange(e) {
155
+ this._updateCurrency({
156
+ alignment: e === "0" ? "before" : "after"
157
+ });
158
+ }
159
+ _onCurrencySymbolChange(e) {
160
+ this._updateCurrency({ symbol: e });
161
+ }
162
+ _onThousandSeparatorChange(e) {
163
+ this._updateCurrency({
164
+ thousandSeparator: e
165
+ });
166
+ }
167
+ _onDecimalSeparatorChange(e) {
168
+ this._updateCurrency({
169
+ decimalSeparator: e
170
+ });
171
+ }
172
+ _onDecimalCountChange(e) {
173
+ this._updateCurrency({
174
+ decimalCount: parseInt(e) || 2
113
175
  });
114
176
  }
115
177
  _listenToFormUpdates() {
116
- this.api.onValueChanged(e.CURRENCY, (C) => {
117
- this._onCurrencyChange(C);
118
- }), [
119
- e.CURRENCY_LOCATION,
120
- e.CURRENCY_SYMBOL,
121
- e.CURRENCY_THOUSAND_SEPARATOR,
122
- e.CURRENCY_DECIMAL_SEPARATOR,
123
- e.CURRENCY_DECIMAL_COUNT
124
- ].forEach((C) => {
125
- this.api.onValueChanged(C, (c) => {
126
- this._onCurrencyConfigChange(C, c);
127
- });
178
+ this.api.onValueChanged(t.CURRENCY, (e) => {
179
+ this._onCurrencyChange(e);
180
+ }), this.api.onValueChanged(t.CURRENCY_LOCATION, (e) => {
181
+ this._onCurrencyLocationChange(e);
182
+ }), this.api.onValueChanged(t.CURRENCY_SYMBOL, (e) => {
183
+ this._onCurrencySymbolChange(e);
184
+ }), this.api.onValueChanged(t.CURRENCY_THOUSAND_SEPARATOR, (e) => {
185
+ this._onThousandSeparatorChange(e);
186
+ }), this.api.onValueChanged(t.CURRENCY_DECIMAL_SEPARATOR, (e) => {
187
+ this._onDecimalSeparatorChange(e);
188
+ }), this.api.onValueChanged(t.CURRENCY_DECIMAL_COUNT, (e) => {
189
+ this._onDecimalCountChange(e);
190
+ });
191
+ }
192
+ /**
193
+ * Subscribe to store changes to update currency selects when API data arrives
194
+ * This handles the case where the control renders before currency list is loaded
195
+ */
196
+ _subscribeToStoreChanges() {
197
+ let e = this.store.currencyList.length;
198
+ this.storeUnsubscription = this.store.$subscribe(() => {
199
+ const r = this.store.currencyList.length;
200
+ r > 0 && r !== e && (e = r, this._initializeSelectItems(), this._setFormValues());
128
201
  });
129
202
  }
130
203
  }
131
204
  export {
132
- S as CURRENCY_CONTROL_ID,
133
- p as CurrencyControl
205
+ N as CURRENCY_CONTROL_ID,
206
+ Y as CurrencyControl
134
207
  };
@@ -1,54 +1,55 @@
1
1
  var a = Object.defineProperty;
2
- var c = (n, r, o) => r in n ? a(n, r, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[r] = o;
3
- var e = (n, r, o) => c(n, typeof r != "symbol" ? r + "" : r, o);
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 h } from "../../store/recommendation.js";
5
+ import { useRecommendationExtensionStore as c } from "../../store/recommendation.js";
6
6
  import { AlgorithmControl as u } from "./algorithm.js";
7
7
  import { ALGORITHM_CONTROL_ID as x } from "./algorithm.js";
8
8
  import { CurrencyControl as C } from "./currency.js";
9
9
  import { CURRENCY_CONTROL_ID as k } from "./currency.js";
10
- import { FiltersControl as f } from "./filters.js";
10
+ import { FiltersControl as d } from "./filters.js";
11
11
  import { FILTERS_CONTROL_ID as A } from "./filters.js";
12
- import { LocaleControl as d } from "./locale.js";
12
+ import { LocaleControl as f } from "./locale.js";
13
13
  import { LOCALE_CONTROL_ID as z } from "./locale.js";
14
14
  import { ProductLayoutControl as p } from "./productLayout.js";
15
15
  import { PRODUCT_LAYOUT_CONTROL_ID as Y } from "./productLayout.js";
16
16
  import { ShuffleControl as R } from "./shuffle.js";
17
17
  import { SHUFFLE_CONTROL_ID as B } from "./shuffle.js";
18
- import { useDebounceFn as _ } from "../../../../../node_modules/@vueuse/shared/index.js";
19
- const y = /* @__PURE__ */ new Set([
18
+ import { useDebounceFn as y } from "../../../../../node_modules/@vueuse/shared/index.js";
19
+ const T = /* @__PURE__ */ new Set([
20
20
  "size",
21
21
  "strategy",
22
22
  "filters",
23
23
  "productIds",
24
24
  "language",
25
- "shuffleProducts"
26
- ]), L = "ui-elements-recommendation-block";
27
- class P extends m {
25
+ "shuffleProducts",
26
+ "currencySettings"
27
+ ]), _ = "ui-elements-recommendation-block";
28
+ class F extends m {
28
29
  constructor() {
29
30
  super(...arguments);
30
- e(this, "store", h());
31
- e(this, "storeUnsubscription", () => {
31
+ r(this, "store", c());
32
+ r(this, "storeUnsubscription", () => {
32
33
  });
33
34
  // Sub-control instances for lifecycle management
34
- e(this, "algorithmControl", null);
35
- e(this, "localeControl", null);
36
- e(this, "currencyControl", null);
37
- e(this, "productLayoutControl", null);
38
- e(this, "filtersControl", null);
39
- e(this, "shuffleControl", null);
35
+ r(this, "algorithmControl", null);
36
+ r(this, "localeControl", null);
37
+ r(this, "currencyControl", null);
38
+ r(this, "productLayoutControl", null);
39
+ r(this, "filtersControl", null);
40
+ r(this, "shuffleControl", null);
40
41
  /**
41
42
  * Debounced product fetch to prevent rapid API calls during config changes
42
43
  */
43
- e(this, "_debouncedFetchProducts", _(() => {
44
+ r(this, "_debouncedFetchProducts", y(() => {
44
45
  this.store.fetchRecommendationProducts();
45
46
  }, 500));
46
47
  }
47
48
  getId() {
48
- return L;
49
+ return _;
49
50
  }
50
51
  getTemplate() {
51
- return this.algorithmControl = new u(), this.localeControl = new d(), this.currencyControl = new C(), this.productLayoutControl = new p(), this.filtersControl = new f(), this.shuffleControl = new R(), `
52
+ return this.algorithmControl = new u(), this.localeControl = new f(), this.currencyControl = new C(), this.productLayoutControl = new p(), this.filtersControl = new d(), this.shuffleControl = new R(), `
52
53
  <div class="recommendation-controls-container">
53
54
  ${this.algorithmControl.getTemplate()}
54
55
  ${this.localeControl.getTemplate()}
@@ -64,14 +65,27 @@ class P extends m {
64
65
  this.store.fetchRecommendationFilters(),
65
66
  this.store.fetchRecommendationCreateData(),
66
67
  this.store.fetchRecommendationProducts()
67
- ])).forEach((t, s) => {
68
+ ])).forEach((t, o) => {
68
69
  t.status === "rejected" && console.warn(`Recommendation block: ${[
69
70
  "fetchRecommendationFilters",
70
71
  "fetchRecommendationCreateData",
71
72
  "fetchRecommendationProducts"
72
- ][s]} failed`, t.reason);
73
+ ][o]} failed`, t.reason);
73
74
  }), this._initializeSubControls(), this._listenStateUpdates();
74
75
  }
76
+ onTemplateNodeUpdated(e) {
77
+ super.onTemplateNodeUpdated(e), [
78
+ this.algorithmControl,
79
+ this.localeControl,
80
+ this.currencyControl,
81
+ this.productLayoutControl,
82
+ this.filtersControl,
83
+ this.shuffleControl
84
+ ].forEach((o) => {
85
+ var i;
86
+ o != null && o.api && (o.currentNode = e, (i = o.onTemplateNodeUpdated) == null || i.call(o, e));
87
+ });
88
+ }
75
89
  onDestroy() {
76
90
  this.storeUnsubscription(), [
77
91
  this.algorithmControl,
@@ -81,8 +95,8 @@ class P extends m {
81
95
  this.filtersControl,
82
96
  this.shuffleControl
83
97
  ].forEach((t) => {
84
- var s;
85
- return (s = t == null ? void 0 : t.onDestroy) == null ? void 0 : s.call(t);
98
+ var o;
99
+ return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
86
100
  });
87
101
  }
88
102
  /**
@@ -98,8 +112,8 @@ class P extends m {
98
112
  this.filtersControl,
99
113
  this.shuffleControl
100
114
  ].forEach((t) => {
101
- var s;
102
- t && (t.api = this.api, t.currentNode = this.currentNode, (s = t.onRender) == null || s.call(t));
115
+ var o;
116
+ t && (t.api = this.api, t.currentNode = this.currentNode, (o = t.onRender) == null || o.call(t));
103
117
  });
104
118
  }
105
119
  /**
@@ -108,10 +122,10 @@ class P extends m {
108
122
  * Uses debounce to prevent rapid API calls
109
123
  */
110
124
  _listenStateUpdates() {
111
- this.storeUnsubscription = this.store.$subscribe((o) => {
112
- if ("payload" in o) {
113
- const t = o.payload.recommendationConfigs;
114
- t && Object.keys(t).some((l) => y.has(l)) && this._debouncedFetchProducts();
125
+ this.storeUnsubscription = this.store.$subscribe((e) => {
126
+ if ("payload" in e) {
127
+ const t = e.payload.recommendationConfigs;
128
+ t && Object.keys(t).some((l) => T.has(l)) && this._debouncedFetchProducts();
115
129
  }
116
130
  });
117
131
  }
@@ -119,16 +133,16 @@ class P extends m {
119
133
  export {
120
134
  x as ALGORITHM_CONTROL_ID,
121
135
  u as AlgorithmControl,
122
- L as CONTROL_BLOCK_ID,
136
+ _ as CONTROL_BLOCK_ID,
123
137
  k as CURRENCY_CONTROL_ID,
124
138
  C as CurrencyControl,
125
139
  A as FILTERS_CONTROL_ID,
126
- f as FiltersControl,
140
+ d as FiltersControl,
127
141
  z as LOCALE_CONTROL_ID,
128
- d as LocaleControl,
142
+ f as LocaleControl,
129
143
  Y as PRODUCT_LAYOUT_CONTROL_ID,
130
144
  p as ProductLayoutControl,
131
- P as RecommendationBlockControl,
145
+ F as RecommendationBlockControl,
132
146
  B as SHUFFLE_CONTROL_ID,
133
147
  R as ShuffleControl
134
148
  };
@@ -1,19 +1,21 @@
1
- var a = Object.defineProperty;
2
- var i = (o, t, e) => t in o ? a(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var s = (o, t, e) => i(o, typeof t != "symbol" ? t + "" : t, e);
1
+ var s = Object.defineProperty;
2
+ var r = (o, t, e) => t in o ? s(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var a = (o, t, e) => r(o, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { UEAttr as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as r } from "../../../common-control.js";
6
- import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
7
- const c = "recommendation-locale-control", n = {
5
+ import { CommonControl as m } from "../../../common-control.js";
6
+ import { RecommendationConfigService as i } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as c } from "../../store/recommendation.js";
8
+ const g = "recommendation-locale-control", n = {
8
9
  LOCALE: "language"
9
10
  };
10
- class C extends r {
11
+ class C extends m {
11
12
  constructor() {
12
13
  super(...arguments);
13
- s(this, "store", m());
14
+ // Store is used ONLY for API-fetched data (language options), not for config
15
+ a(this, "store", c());
14
16
  }
15
17
  getId() {
16
- return c;
18
+ return g;
17
19
  }
18
20
  getTemplate() {
19
21
  return `
@@ -32,8 +34,11 @@ class C extends r {
32
34
  onRender() {
33
35
  this._initializeSelectItems(), this._setFormValues(), this._listenToFormUpdates();
34
36
  }
37
+ onTemplateNodeUpdated(e) {
38
+ super.onTemplateNodeUpdated(e), this._setFormValues();
39
+ }
35
40
  _setFormValues() {
36
- const { recommendationConfigs: e } = this.store;
41
+ const e = i.getConfig(this.currentNode);
37
42
  this.api.updateValues({
38
43
  [n.LOCALE]: e.language
39
44
  });
@@ -46,11 +51,16 @@ class C extends r {
46
51
  );
47
52
  }
48
53
  _onLocaleChange(e) {
49
- this.store.$patch({
54
+ this.currentNode && (i.updateConfig(
55
+ this.api,
56
+ this.currentNode,
57
+ { language: e },
58
+ `Changed language to ${e}`
59
+ ), this.store.$patch({
50
60
  recommendationConfigs: {
51
61
  language: e
52
62
  }
53
- });
63
+ }));
54
64
  }
55
65
  _listenToFormUpdates() {
56
66
  this.api.onValueChanged(n.LOCALE, (e) => {
@@ -59,6 +69,6 @@ class C extends r {
59
69
  }
60
70
  }
61
71
  export {
62
- c as LOCALE_CONTROL_ID,
72
+ g as LOCALE_CONTROL_ID,
63
73
  C as LocaleControl
64
74
  };