@useinsider/guido 2.1.0-beta.e2153c2 → 2.1.0-beta.e4c3fa1
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/components/organisms/base/Toaster.vue.js +4 -4
- package/dist/components/organisms/base/Toaster.vue2.js +12 -9
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
- package/dist/composables/useRecommendation.js +9 -9
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +36 -33
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +16 -14
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +13 -12
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +37 -27
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +16 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +30 -32
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +173 -102
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +46 -38
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +16 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +269 -215
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +10 -10
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +14 -14
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +225 -102
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +94 -53
- package/dist/guido.css +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -2
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +6 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +33 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +24 -14
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +49 -17
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var R = Object.defineProperty;
|
|
2
|
-
var _ = (
|
|
3
|
-
var c = (
|
|
4
|
-
import { currencyLocationMaps as l, currencyOperators as
|
|
2
|
+
var _ = (i, o, e) => o in i ? R(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
|
|
3
|
+
var c = (i, o, e) => _(i, typeof o != "symbol" ? o + "" : o, e);
|
|
4
|
+
import { currencyLocationMaps as l, currencyOperators as a, currencyDecimalCounts as h } from "../../../../../enums/extensions/recommendationBlock.js";
|
|
5
5
|
import { UEAttr as m } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
-
import { CommonControl as
|
|
7
|
-
import { RecommendationConfigService as
|
|
8
|
-
import { useRecommendationExtensionStore as
|
|
9
|
-
import { setCurrencyAttributes as S, updatePricesInPlace as
|
|
10
|
-
const
|
|
6
|
+
import { CommonControl as p } from "../../../common-control.js";
|
|
7
|
+
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
8
|
+
import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
|
|
9
|
+
import { setCurrencyAttributes as S, updatePricesInPlace as N } from "./utils.js";
|
|
10
|
+
const E = "recommendation-currency-control", t = {
|
|
11
11
|
CURRENCY: "currencyCode",
|
|
12
12
|
CURRENCY_LOCATION: "currencyAlignment",
|
|
13
13
|
CURRENCY_SYMBOL: "currencySymbol",
|
|
@@ -15,16 +15,16 @@ const y = "recommendation-currency-control", t = {
|
|
|
15
15
|
CURRENCY_DECIMAL_SEPARATOR: "currencyDecimalSeparator",
|
|
16
16
|
CURRENCY_DECIMAL_COUNT: "currencyDecimalCount"
|
|
17
17
|
};
|
|
18
|
-
class
|
|
18
|
+
class Y extends p {
|
|
19
19
|
constructor() {
|
|
20
20
|
super(...arguments);
|
|
21
21
|
// Store is used ONLY for API-fetched data (currency list), not for config
|
|
22
|
-
c(this, "store",
|
|
22
|
+
c(this, "store", d());
|
|
23
23
|
c(this, "storeUnsubscription", () => {
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
getId() {
|
|
27
|
-
return
|
|
27
|
+
return E;
|
|
28
28
|
}
|
|
29
29
|
getTemplate() {
|
|
30
30
|
return `
|
|
@@ -52,13 +52,13 @@ class D extends d {
|
|
|
52
52
|
this._GuSelect({
|
|
53
53
|
name: t.CURRENCY_THOUSAND_SEPARATOR,
|
|
54
54
|
placeholder: "Select Thousand Separator",
|
|
55
|
-
options:
|
|
55
|
+
options: a
|
|
56
56
|
}),
|
|
57
57
|
this._GuLabel({ text: "Decimal Separator" }),
|
|
58
58
|
this._GuSelect({
|
|
59
59
|
name: t.CURRENCY_DECIMAL_SEPARATOR,
|
|
60
60
|
placeholder: "Select Decimal Separator",
|
|
61
|
-
options:
|
|
61
|
+
options: a
|
|
62
62
|
}),
|
|
63
63
|
this._GuLabel({ text: "Decimal Count" }),
|
|
64
64
|
this._GuSelect({
|
|
@@ -82,7 +82,7 @@ class D extends d {
|
|
|
82
82
|
this.storeUnsubscription();
|
|
83
83
|
}
|
|
84
84
|
_setFormValues() {
|
|
85
|
-
const e =
|
|
85
|
+
const e = s.getConfig(this.currentNode), { currency: r } = e;
|
|
86
86
|
this.api.updateValues({
|
|
87
87
|
[t.CURRENCY]: `price.${r.code}`,
|
|
88
88
|
[t.CURRENCY_LOCATION]: r.alignment === "before" ? "0" : "1",
|
|
@@ -96,12 +96,12 @@ class D extends d {
|
|
|
96
96
|
const { store: e } = this, r = {
|
|
97
97
|
[t.CURRENCY]: e.currencyList,
|
|
98
98
|
[t.CURRENCY_LOCATION]: l,
|
|
99
|
-
[t.CURRENCY_THOUSAND_SEPARATOR]:
|
|
100
|
-
[t.CURRENCY_DECIMAL_SEPARATOR]:
|
|
99
|
+
[t.CURRENCY_THOUSAND_SEPARATOR]: a,
|
|
100
|
+
[t.CURRENCY_DECIMAL_SEPARATOR]: a,
|
|
101
101
|
[t.CURRENCY_DECIMAL_COUNT]: h
|
|
102
102
|
};
|
|
103
|
-
Object.entries(r).forEach(([
|
|
104
|
-
this.api.setUIEAttribute(
|
|
103
|
+
Object.entries(r).forEach(([C, n]) => {
|
|
104
|
+
this.api.setUIEAttribute(C, m.SELECTPICKER.items, n);
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
@@ -114,17 +114,17 @@ class D extends d {
|
|
|
114
114
|
_updateCurrency(e, r = !1) {
|
|
115
115
|
if (!this.currentNode)
|
|
116
116
|
return;
|
|
117
|
-
const n = { ...
|
|
118
|
-
|
|
117
|
+
const n = { ...s.getConfig(this.currentNode).currency, ...e };
|
|
118
|
+
s.updateConfig(
|
|
119
119
|
this.api,
|
|
120
120
|
this.currentNode,
|
|
121
121
|
{ currency: n },
|
|
122
122
|
"Updated currency settings"
|
|
123
123
|
);
|
|
124
|
-
const
|
|
124
|
+
const u = this.api.getDocumentModifier();
|
|
125
125
|
S({
|
|
126
126
|
currentNode: this.currentNode,
|
|
127
|
-
documentModifier:
|
|
127
|
+
documentModifier: u,
|
|
128
128
|
currency: n
|
|
129
129
|
}), this.store.patchCurrentBlockConfig({
|
|
130
130
|
currencySettings: {
|
|
@@ -136,22 +136,19 @@ class D extends d {
|
|
|
136
136
|
decimalSeparator: n.decimalSeparator,
|
|
137
137
|
thousandSeparator: n.thousandSeparator
|
|
138
138
|
}
|
|
139
|
-
}, { triggerRefetch: r }),
|
|
139
|
+
}, { triggerRefetch: r }), N({
|
|
140
140
|
currentNode: this.currentNode,
|
|
141
|
-
documentModifier:
|
|
142
|
-
}) || N({
|
|
143
|
-
currentNode: this.currentNode,
|
|
144
|
-
documentModifier: a
|
|
141
|
+
documentModifier: u
|
|
145
142
|
});
|
|
146
143
|
}
|
|
147
144
|
_onCurrencyChange(e) {
|
|
148
145
|
const [, r] = e.includes(".") ? e.split(".") : [null, e];
|
|
149
|
-
this._updateCurrency({
|
|
146
|
+
s.getConfig(this.currentNode).currency.code !== r && (this._updateCurrency({
|
|
150
147
|
code: r,
|
|
151
148
|
symbol: r
|
|
152
149
|
}, !0), this.api.updateValues({
|
|
153
150
|
[t.CURRENCY_SYMBOL]: r
|
|
154
|
-
});
|
|
151
|
+
}));
|
|
155
152
|
}
|
|
156
153
|
_onCurrencyLocationChange(e) {
|
|
157
154
|
this._updateCurrency({
|
|
@@ -172,8 +169,9 @@ class D extends d {
|
|
|
172
169
|
});
|
|
173
170
|
}
|
|
174
171
|
_onDecimalCountChange(e) {
|
|
172
|
+
const r = parseInt(e);
|
|
175
173
|
this._updateCurrency({
|
|
176
|
-
decimalCount:
|
|
174
|
+
decimalCount: Number.isNaN(r) ? 2 : r
|
|
177
175
|
});
|
|
178
176
|
}
|
|
179
177
|
_listenToFormUpdates() {
|
|
@@ -204,6 +202,6 @@ class D extends d {
|
|
|
204
202
|
}
|
|
205
203
|
}
|
|
206
204
|
export {
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
E as CURRENCY_CONTROL_ID,
|
|
206
|
+
Y as CurrencyControl
|
|
209
207
|
};
|
|
@@ -1,65 +1,77 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { CommonControl as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var C = (d, c, t) => c in d ? g(d, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[c] = t;
|
|
3
|
+
var i = (d, c, t) => C(d, typeof c != "symbol" ? c + "" : c, t);
|
|
4
|
+
import { CommonControl as p } from "../../../common-control.js";
|
|
5
|
+
import { DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
6
|
+
import { RecommendationConfigService as m } from "../../services/configService.js";
|
|
7
|
+
import { useRecommendationExtensionStore as y } from "../../store/recommendation.js";
|
|
8
|
+
import { AlgorithmControl as R } from "./algorithm.js";
|
|
9
|
+
import { ALGORITHM_CONTROL_ID as H } from "./algorithm.js";
|
|
10
|
+
import { CurrencyControl as b } from "./currency.js";
|
|
11
|
+
import { CURRENCY_CONTROL_ID as K } from "./currency.js";
|
|
12
|
+
import { FiltersControl as N } from "./filters.js";
|
|
13
|
+
import { FILTERS_CONTROL_ID as J } from "./filters.js";
|
|
14
|
+
import { LocaleControl as _ } from "./locale.js";
|
|
15
|
+
import { LOCALE_CONTROL_ID as X } from "./locale.js";
|
|
16
|
+
import { ProductLayoutControl as S } from "./productLayout.js";
|
|
17
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as tt } from "./productLayout.js";
|
|
18
|
+
import { ShuffleControl as I } from "./shuffle.js";
|
|
19
|
+
import { SHUFFLE_CONTROL_ID as ot } from "./shuffle.js";
|
|
20
|
+
import { getBlockElement as P, updateProductContentInPlace as L, regenerateProductRowsWithStyles as T } from "./utils.js";
|
|
21
|
+
import { adjustProductsToSize as nt, formatProductPrice as st, getCardComposition as it, getCurrentLayout as at, reapplySpacing as ct, regenerateMobileProductRows as lt, regenerateProductRows as ut, setCurrencyAttributes as dt, updatePricesInPlace as mt, updateSingleProductContent as ht } from "./utils.js";
|
|
22
|
+
import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
23
|
+
const k = "recommendation-id", D = "ui-elements-recommendation-block";
|
|
24
|
+
class W extends p {
|
|
24
25
|
constructor() {
|
|
25
26
|
super(...arguments);
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
i(this, "store", y());
|
|
28
|
+
i(this, "storeUnsubscription", () => {
|
|
28
29
|
});
|
|
29
30
|
// Sub-control instances for lifecycle management
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
i(this, "algorithmControl", null);
|
|
32
|
+
i(this, "localeControl", null);
|
|
33
|
+
i(this, "currencyControl", null);
|
|
34
|
+
i(this, "productLayoutControl", null);
|
|
35
|
+
i(this, "filtersControl", null);
|
|
36
|
+
i(this, "shuffleControl", null);
|
|
36
37
|
/**
|
|
37
38
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
i(this, "_debouncedFetchProducts", h(() => {
|
|
40
41
|
this.store.fetchRecommendationProducts();
|
|
41
42
|
}, 500));
|
|
42
43
|
/**
|
|
43
|
-
* Debounced
|
|
44
|
-
*
|
|
44
|
+
* Debounced content update when products arrive from API.
|
|
45
|
+
*
|
|
46
|
+
* Tries in-place update first (preserves user-applied styles) — this succeeds
|
|
47
|
+
* when the product count matches the DOM (algorithm/locale/currency changes).
|
|
48
|
+
*
|
|
49
|
+
* Falls back to full regeneration when product count differs from DOM — this
|
|
50
|
+
* happens after "Number of Products" changes where the DOM still has the old
|
|
51
|
+
* count. The store pads products to the configured size, so in-place only
|
|
52
|
+
* fails when the size actually changed.
|
|
45
53
|
*/
|
|
46
|
-
|
|
54
|
+
i(this, "_debouncedRegenerateWithProducts", h(() => {
|
|
47
55
|
const t = this.store.recommendationProducts;
|
|
48
56
|
if (!this.currentNode || !this.api)
|
|
49
57
|
return;
|
|
50
58
|
const e = this.api.getDocumentModifier();
|
|
51
|
-
|
|
59
|
+
L({
|
|
52
60
|
currentNode: this.currentNode,
|
|
53
61
|
documentModifier: e,
|
|
54
62
|
products: t
|
|
55
|
-
}) ||
|
|
63
|
+
}) || T({
|
|
64
|
+
currentNode: this.currentNode,
|
|
65
|
+
documentModifier: e,
|
|
66
|
+
products: t
|
|
67
|
+
});
|
|
56
68
|
}, 100));
|
|
57
69
|
}
|
|
58
70
|
getId() {
|
|
59
|
-
return
|
|
71
|
+
return D;
|
|
60
72
|
}
|
|
61
73
|
getTemplate() {
|
|
62
|
-
return this.algorithmControl = new
|
|
74
|
+
return this.algorithmControl = new R(), this.localeControl = new _(), this.currencyControl = new b(), this.productLayoutControl = new S(), this.filtersControl = new N(), this.shuffleControl = new I(), `
|
|
63
75
|
<div class="recommendation-controls-container">
|
|
64
76
|
${this.algorithmControl.getTemplate()}
|
|
65
77
|
${this.localeControl.getTemplate()}
|
|
@@ -79,26 +91,11 @@ class $ extends h {
|
|
|
79
91
|
}
|
|
80
92
|
await this._fetchBlockData(t), this._initializeSubControls();
|
|
81
93
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Immediately regenerate products with styles (no debounce)
|
|
84
|
-
* Used for initial load after fetch completes
|
|
85
|
-
*/
|
|
86
|
-
_regenerateWithProducts(t) {
|
|
87
|
-
if (!this.currentNode || !this.api) {
|
|
88
|
-
console.warn("[Recommendation] Cannot regenerate - missing currentNode or api");
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
b({
|
|
92
|
-
currentNode: this.currentNode,
|
|
93
|
-
documentModifier: this.api.getDocumentModifier(),
|
|
94
|
-
products: t
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
94
|
onTemplateNodeUpdated(t) {
|
|
98
|
-
var
|
|
95
|
+
var s;
|
|
99
96
|
super.onTemplateNodeUpdated(t);
|
|
100
97
|
const e = this._getRecommendationIdFromNode(t);
|
|
101
|
-
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((
|
|
98
|
+
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((s = this.store.blockStates[e]) != null && s.isInitialized) && this._fetchBlockData(e), [
|
|
102
99
|
this.algorithmControl,
|
|
103
100
|
this.localeControl,
|
|
104
101
|
this.currencyControl,
|
|
@@ -106,8 +103,8 @@ class $ extends h {
|
|
|
106
103
|
this.filtersControl,
|
|
107
104
|
this.shuffleControl
|
|
108
105
|
].forEach((r) => {
|
|
109
|
-
var
|
|
110
|
-
r != null && r.api && (r.currentNode = t, (
|
|
106
|
+
var n;
|
|
107
|
+
r != null && r.api && (r.currentNode = t, (n = r.onTemplateNodeUpdated) == null || n.call(r, t));
|
|
111
108
|
});
|
|
112
109
|
}
|
|
113
110
|
onDestroy() {
|
|
@@ -152,7 +149,7 @@ class $ extends h {
|
|
|
152
149
|
* values are being prepared for the upcoming initial fetch.
|
|
153
150
|
*/
|
|
154
151
|
_syncNodeConfigToStore() {
|
|
155
|
-
const t =
|
|
152
|
+
const t = m.getConfig(this.currentNode);
|
|
156
153
|
this.store.patchCurrentBlockConfig({
|
|
157
154
|
strategy: t.strategy,
|
|
158
155
|
language: t.language,
|
|
@@ -172,22 +169,84 @@ class $ extends h {
|
|
|
172
169
|
}, { triggerRefetch: !1 });
|
|
173
170
|
}
|
|
174
171
|
/**
|
|
175
|
-
* Fetches initial data for a block
|
|
172
|
+
* Fetches initial data for a block in three phases:
|
|
173
|
+
* 1. Shared reference data (algorithms, currencies, filters) — parallel
|
|
174
|
+
* 2. Smart defaults for new blocks (currency, algorithm) — sequential
|
|
175
|
+
* 3. Product data with correct defaults — sequential
|
|
176
|
+
*
|
|
176
177
|
* Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
|
|
177
178
|
* Marks the block as initialized to prevent redundant fetches on re-selection.
|
|
178
179
|
*/
|
|
179
180
|
async _fetchBlockData(t) {
|
|
180
181
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
181
|
-
this.store.fetchRecommendationFilters(),
|
|
182
182
|
this.store.fetchRecommendationCreateData(),
|
|
183
|
-
this.store.
|
|
184
|
-
])).forEach((o,
|
|
185
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${[
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
183
|
+
this.store.fetchRecommendationFilters()
|
|
184
|
+
])).forEach((o, s) => {
|
|
185
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][s]} failed`, o.reason);
|
|
186
|
+
}), this._applySmartDefaults();
|
|
187
|
+
try {
|
|
188
|
+
await this.store.fetchRecommendationProducts();
|
|
189
|
+
} catch (o) {
|
|
190
|
+
console.warn("Recommendation block: fetchRecommendationProducts failed", o);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Applies smart defaults for newly dropped blocks.
|
|
195
|
+
*
|
|
196
|
+
* For new blocks (config still matches hardcoded defaults), validates that
|
|
197
|
+
* the default currency and algorithm are available from the API response.
|
|
198
|
+
* If not, falls back to the first available option.
|
|
199
|
+
*
|
|
200
|
+
* Saved templates with user-customized config are left unchanged because
|
|
201
|
+
* their values won't match the hardcoded defaults.
|
|
202
|
+
*/
|
|
203
|
+
_applySmartDefaults() {
|
|
204
|
+
if (!this.currentNode || !this.api)
|
|
205
|
+
return;
|
|
206
|
+
const t = m.getConfig(this.currentNode), e = {};
|
|
207
|
+
let o = null, s = null, r = null;
|
|
208
|
+
if (t.currency.code === a.currency.code) {
|
|
209
|
+
const { currencyList: n } = this.store;
|
|
210
|
+
n.length > 0 && (n.some(
|
|
211
|
+
(u) => u.value === `price.${a.currency.code}`
|
|
212
|
+
) || (o = n[0].value.replace("price.", ""), e.currency = {
|
|
213
|
+
...a.currency,
|
|
214
|
+
code: o,
|
|
215
|
+
symbol: o
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
if (t.strategy === a.strategy) {
|
|
219
|
+
const n = this.store.getActivePredictiveAlgorithms;
|
|
220
|
+
n.length > 0 && (n.some(
|
|
221
|
+
(u) => u.value === a.strategy
|
|
222
|
+
) || (s = n[0].value, e.strategy = s));
|
|
223
|
+
}
|
|
224
|
+
if (t.language === a.language) {
|
|
225
|
+
const n = this.store.getLanguages;
|
|
226
|
+
n.length > 0 && (n.some(
|
|
227
|
+
(u) => u.value === a.language
|
|
228
|
+
) || (r = n[0].value, e.language = r));
|
|
229
|
+
}
|
|
230
|
+
!o && !s && !r || (m.updateConfig(
|
|
231
|
+
this.api,
|
|
232
|
+
this.currentNode,
|
|
233
|
+
e,
|
|
234
|
+
"Applied smart defaults"
|
|
235
|
+
), this.store.patchCurrentBlockConfig({
|
|
236
|
+
...o ? {
|
|
237
|
+
currencySettings: {
|
|
238
|
+
name: o,
|
|
239
|
+
value: o,
|
|
240
|
+
symbol: o,
|
|
241
|
+
alignment: a.currency.alignment === "before" ? "0" : "1",
|
|
242
|
+
decimalCount: a.currency.decimalCount.toString(),
|
|
243
|
+
decimalSeparator: a.currency.decimalSeparator,
|
|
244
|
+
thousandSeparator: a.currency.thousandSeparator
|
|
245
|
+
}
|
|
246
|
+
} : {},
|
|
247
|
+
...s ? { strategy: s } : {},
|
|
248
|
+
...r ? { language: r } : {}
|
|
249
|
+
}, { triggerRefetch: !1 }));
|
|
191
250
|
}
|
|
192
251
|
/**
|
|
193
252
|
* Reads the recommendation-id attribute from the block element within the node
|
|
@@ -196,11 +255,11 @@ class $ extends h {
|
|
|
196
255
|
const e = P(t);
|
|
197
256
|
if (!e || !("getAttribute" in e))
|
|
198
257
|
return null;
|
|
199
|
-
const o = e.getAttribute(
|
|
258
|
+
const o = e.getAttribute(k);
|
|
200
259
|
if (!o)
|
|
201
260
|
return null;
|
|
202
|
-
const
|
|
203
|
-
return Number.isNaN(
|
|
261
|
+
const s = parseInt(o);
|
|
262
|
+
return Number.isNaN(s) ? null : s;
|
|
204
263
|
}
|
|
205
264
|
/**
|
|
206
265
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -208,43 +267,55 @@ class $ extends h {
|
|
|
208
267
|
* Uses configVersion counter (incremented only by patchCurrentBlockConfig)
|
|
209
268
|
* to distinguish user-initiated config changes from internal mutations
|
|
210
269
|
* (e.g., fetchRecommendationCreateData setting preferred currency).
|
|
270
|
+
*
|
|
271
|
+
* Tracks currentRecommendationId to detect block switches. When the user
|
|
272
|
+
* selects a different recommendation block, the proxy getters (e.g.,
|
|
273
|
+
* recommendationProducts) return the new block's data — a different array
|
|
274
|
+
* reference that would be falsely detected as "new products arrived".
|
|
275
|
+
* We skip that tick and update tracking references instead.
|
|
211
276
|
*/
|
|
212
277
|
_listenStateUpdates() {
|
|
213
278
|
const { store: t } = this;
|
|
214
|
-
let e = t.recommendationProducts, o = t.$state.configVersion;
|
|
279
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, s = t.currentRecommendationId;
|
|
215
280
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
281
|
+
const r = t.currentRecommendationId;
|
|
282
|
+
if (r !== s) {
|
|
283
|
+
s = r, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const n = t.$state.configVersion;
|
|
287
|
+
n !== o && (o = n, this._debouncedFetchProducts());
|
|
288
|
+
const l = t.recommendationProducts, u = l !== e, f = Array.isArray(l) && l.length > 0;
|
|
289
|
+
u && f && (e = l, this._debouncedRegenerateWithProducts());
|
|
220
290
|
});
|
|
221
291
|
}
|
|
222
292
|
}
|
|
223
293
|
export {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
294
|
+
H as ALGORITHM_CONTROL_ID,
|
|
295
|
+
R as AlgorithmControl,
|
|
296
|
+
D as CONTROL_BLOCK_ID,
|
|
297
|
+
K as CURRENCY_CONTROL_ID,
|
|
298
|
+
b as CurrencyControl,
|
|
299
|
+
J as FILTERS_CONTROL_ID,
|
|
300
|
+
N as FiltersControl,
|
|
301
|
+
X as LOCALE_CONTROL_ID,
|
|
302
|
+
_ as LocaleControl,
|
|
303
|
+
tt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
304
|
+
S as ProductLayoutControl,
|
|
305
|
+
W as RecommendationBlockControl,
|
|
306
|
+
ot as SHUFFLE_CONTROL_ID,
|
|
307
|
+
I as ShuffleControl,
|
|
308
|
+
nt as adjustProductsToSize,
|
|
309
|
+
st as formatProductPrice,
|
|
239
310
|
P as getBlockElement,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
311
|
+
it as getCardComposition,
|
|
312
|
+
at as getCurrentLayout,
|
|
313
|
+
ct as reapplySpacing,
|
|
314
|
+
lt as regenerateMobileProductRows,
|
|
315
|
+
ut as regenerateProductRows,
|
|
316
|
+
T as regenerateProductRowsWithStyles,
|
|
317
|
+
dt as setCurrencyAttributes,
|
|
318
|
+
mt as updatePricesInPlace,
|
|
319
|
+
L as updateProductContentInPlace,
|
|
320
|
+
ht as updateSingleProductContent
|
|
250
321
|
};
|
|
@@ -2,20 +2,20 @@ var s = Object.defineProperty;
|
|
|
2
2
|
var r = (o, t, e) => t in o ? s(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
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
|
|
5
|
+
import { CommonControl as c } from "../../../common-control.js";
|
|
6
6
|
import { RecommendationConfigService as i } from "../../services/configService.js";
|
|
7
|
-
import { useRecommendationExtensionStore as
|
|
8
|
-
const
|
|
7
|
+
import { useRecommendationExtensionStore as g } from "../../store/recommendation.js";
|
|
8
|
+
const m = "recommendation-locale-control", n = {
|
|
9
9
|
LOCALE: "language"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class E extends c {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments);
|
|
14
14
|
// Store is used ONLY for API-fetched data (language options), not for config
|
|
15
|
-
a(this, "store",
|
|
15
|
+
a(this, "store", g());
|
|
16
16
|
}
|
|
17
17
|
getId() {
|
|
18
|
-
return
|
|
18
|
+
return m;
|
|
19
19
|
}
|
|
20
20
|
getTemplate() {
|
|
21
21
|
return `
|
|
@@ -51,7 +51,7 @@ class C extends m {
|
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
_onLocaleChange(e) {
|
|
54
|
-
this.currentNode
|
|
54
|
+
!this.currentNode || i.getConfig(this.currentNode).language === e || (i.updateConfig(
|
|
55
55
|
this.api,
|
|
56
56
|
this.currentNode,
|
|
57
57
|
{ language: e },
|
|
@@ -65,6 +65,6 @@ class C extends m {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
export {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
m as LOCALE_CONTROL_ID,
|
|
69
|
+
E as LocaleControl
|
|
70
70
|
};
|