@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.
- package/dist/extensions/Blocks/Recommendation/block.js +40 -6
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +64 -0
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +9 -4
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +17 -9
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +48 -54
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +42 -36
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +51 -27
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +146 -73
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +49 -35
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +23 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +41 -41
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +27 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +79 -67
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +85 -79
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +8 -4
- package/dist/extensions/Blocks/Recommendation/services/configService.js +239 -0
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +30 -28
- package/dist/extensions/Blocks/Recommendation/templates/horizontal/elementRenderer.js +49 -25
- package/dist/extensions/Blocks/Recommendation/templates/horizontal/template.js +18 -19
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +44 -101
- package/dist/extensions/Blocks/Recommendation/templates/vertical/elementRenderer.js +60 -35
- package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
- package/dist/extensions/Blocks/common-control.js +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +214 -157
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +34 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -2
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +12 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +3 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +13 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +30 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +4 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +13 -2
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
- package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +154 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
- package/package.json +1 -1
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { currencyLocationMaps as
|
|
5
|
-
import { UEAttr as
|
|
6
|
-
import { CommonControl as
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
18
|
+
class Y extends m {
|
|
17
19
|
constructor() {
|
|
18
20
|
super(...arguments);
|
|
19
|
-
|
|
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
|
|
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:
|
|
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:
|
|
41
|
+
name: t.CURRENCY_LOCATION,
|
|
37
42
|
placeholder: "Select Currency Location",
|
|
38
|
-
options:
|
|
43
|
+
options: u
|
|
39
44
|
}),
|
|
40
45
|
this._GuLabel({ text: "Currency Symbol" }),
|
|
41
|
-
this.
|
|
42
|
-
name:
|
|
43
|
-
placeholder: "
|
|
44
|
-
|
|
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:
|
|
53
|
+
name: t.CURRENCY_THOUSAND_SEPARATOR,
|
|
49
54
|
placeholder: "Select Thousand Separator",
|
|
50
|
-
options:
|
|
55
|
+
options: s
|
|
51
56
|
}),
|
|
52
57
|
this._GuLabel({ text: "Decimal Separator" }),
|
|
53
58
|
this._GuSelect({
|
|
54
|
-
name:
|
|
59
|
+
name: t.CURRENCY_DECIMAL_SEPARATOR,
|
|
55
60
|
placeholder: "Select Decimal Separator",
|
|
56
|
-
options:
|
|
61
|
+
options: s
|
|
57
62
|
}),
|
|
58
63
|
this._GuLabel({ text: "Decimal Count" }),
|
|
59
64
|
this._GuSelect({
|
|
60
|
-
name:
|
|
65
|
+
name: t.CURRENCY_DECIMAL_COUNT,
|
|
61
66
|
placeholder: "Select Decimal Count",
|
|
62
|
-
options:
|
|
67
|
+
options: l
|
|
63
68
|
})
|
|
64
69
|
])}
|
|
65
70
|
</div>
|
|
66
71
|
`;
|
|
67
72
|
}
|
|
68
73
|
onRender() {
|
|
69
|
-
this._initializeSelectItems(), this._setFormValues(),
|
|
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 {
|
|
85
|
+
const e = C.getConfig(this.currentNode), { currency: r } = e;
|
|
73
86
|
this.api.updateValues({
|
|
74
|
-
[
|
|
75
|
-
[
|
|
76
|
-
[
|
|
77
|
-
[
|
|
78
|
-
[
|
|
79
|
-
[
|
|
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:
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
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(
|
|
92
|
-
this.api.setUIEAttribute(
|
|
103
|
+
Object.entries(r).forEach(([n, i]) => {
|
|
104
|
+
this.api.setUIEAttribute(n, _.SELECTPICKER.items, i);
|
|
93
105
|
});
|
|
94
106
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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:
|
|
101
|
-
value:
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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(
|
|
117
|
-
this._onCurrencyChange(
|
|
118
|
-
}),
|
|
119
|
-
e
|
|
120
|
-
|
|
121
|
-
e
|
|
122
|
-
|
|
123
|
-
e
|
|
124
|
-
|
|
125
|
-
this.
|
|
126
|
-
|
|
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
|
-
|
|
133
|
-
|
|
205
|
+
N as CURRENCY_CONTROL_ID,
|
|
206
|
+
Y as CurrencyControl
|
|
134
207
|
};
|
|
@@ -1,54 +1,55 @@
|
|
|
1
1
|
var a = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
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
|
|
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
|
|
10
|
+
import { FiltersControl as d } from "./filters.js";
|
|
11
11
|
import { FILTERS_CONTROL_ID as A } from "./filters.js";
|
|
12
|
-
import { LocaleControl as
|
|
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
|
|
19
|
-
const
|
|
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
|
-
|
|
27
|
-
|
|
25
|
+
"shuffleProducts",
|
|
26
|
+
"currencySettings"
|
|
27
|
+
]), _ = "ui-elements-recommendation-block";
|
|
28
|
+
class F extends m {
|
|
28
29
|
constructor() {
|
|
29
30
|
super(...arguments);
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
r(this, "store", c());
|
|
32
|
+
r(this, "storeUnsubscription", () => {
|
|
32
33
|
});
|
|
33
34
|
// Sub-control instances for lifecycle management
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
44
|
+
r(this, "_debouncedFetchProducts", y(() => {
|
|
44
45
|
this.store.fetchRecommendationProducts();
|
|
45
46
|
}, 500));
|
|
46
47
|
}
|
|
47
48
|
getId() {
|
|
48
|
-
return
|
|
49
|
+
return _;
|
|
49
50
|
}
|
|
50
51
|
getTemplate() {
|
|
51
|
-
return this.algorithmControl = new u(), this.localeControl = new
|
|
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,
|
|
68
|
+
])).forEach((t, o) => {
|
|
68
69
|
t.status === "rejected" && console.warn(`Recommendation block: ${[
|
|
69
70
|
"fetchRecommendationFilters",
|
|
70
71
|
"fetchRecommendationCreateData",
|
|
71
72
|
"fetchRecommendationProducts"
|
|
72
|
-
][
|
|
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
|
|
85
|
-
return (
|
|
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
|
|
102
|
-
t && (t.api = this.api, t.currentNode = this.currentNode, (
|
|
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((
|
|
112
|
-
if ("payload" in
|
|
113
|
-
const t =
|
|
114
|
-
t && Object.keys(t).some((l) =>
|
|
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
|
-
|
|
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
|
-
|
|
140
|
+
d as FiltersControl,
|
|
127
141
|
z as LOCALE_CONTROL_ID,
|
|
128
|
-
|
|
142
|
+
f as LocaleControl,
|
|
129
143
|
Y as PRODUCT_LAYOUT_CONTROL_ID,
|
|
130
144
|
p as ProductLayoutControl,
|
|
131
|
-
|
|
145
|
+
F as RecommendationBlockControl,
|
|
132
146
|
B as SHUFFLE_CONTROL_ID,
|
|
133
147
|
R as ShuffleControl
|
|
134
148
|
};
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
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
|
|
6
|
-
import {
|
|
7
|
-
|
|
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
|
|
11
|
+
class C extends m {
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
13
|
-
|
|
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
|
|
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
|
|
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.
|
|
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
|
-
|
|
72
|
+
g as LOCALE_CONTROL_ID,
|
|
63
73
|
C as LocaleControl
|
|
64
74
|
};
|