@useinsider/guido 3.18.1-beta.e9a6c91 → 3.18.1-beta.fefef3c
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/README.md +21 -3
- package/dist/@types/config/schemas.js +59 -51
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +72 -70
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -9
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +83 -72
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +24 -22
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -26
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
- package/dist/composables/useCustomInterfaceAppearance.js +46 -42
- package/dist/composables/useHtmlValidator.js +79 -84
- package/dist/composables/useLegacyStrategyConversion.js +61 -0
- package/dist/composables/useRecommendation.js +18 -21
- package/dist/enums/extensions/recommendationBlock.js +25 -29
- package/dist/extensions/Blocks/Recommendation/block.js +39 -43
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +72 -71
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +70 -40
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +45 -44
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +108 -138
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +72 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +7 -7
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +12 -21
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +93 -84
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +54 -50
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +44 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +0 -4
- package/dist/src/services/recommendationApi.d.ts +2 -1
- package/dist/src/stores/config.d.ts +322 -0
- package/dist/src/stores/onboarding.d.ts +421 -0
- package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
- package/dist/static/assets/icons/line-info.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +74 -43
- package/dist/stores/config.js +74 -60
- package/dist/stores/onboarding.js +6 -1
- package/dist/utils/templatePreparation.js +50 -50
- package/package.json +1 -1
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { BlockId as
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
7
|
-
import { Block as
|
|
8
|
-
import { CURRENT_CONFIG_VERSION as
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var B = (a, c, t) => c in a ? R(a, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[c] = t;
|
|
3
|
+
var p = (a, c, t) => B(a, typeof c != "symbol" ? c + "" : c, t);
|
|
4
|
+
import { useConfig as D } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as y } from "../../../enums/block.js";
|
|
6
|
+
import { getMigrationBannerHtml as C } from "../../../utils/migrationBannerHtml.js";
|
|
7
|
+
import { Block as b, BlockCompositionType as A, ModificationDescription as g } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
+
import { CURRENT_CONFIG_VERSION as E, PRE_RRS_CONFIG_VERSION as S } from "./constants/defaultConfig.js";
|
|
9
9
|
import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
|
|
10
|
-
import { regenerateMobileProductRows as
|
|
11
|
-
import { ensureMobileCssRulesExist as
|
|
10
|
+
import { regenerateMobileProductRows as N } from "./controls/main/utils.js";
|
|
11
|
+
import { ensureMobileCssRulesExist as h, setMobileLayoutOptOut as f, hasMobileLayoutOptOut as O } from "./controls/mobileLayout/cssRules.js";
|
|
12
12
|
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
13
13
|
import { useRecommendationExtensionStore as d } from "./store/recommendation.js";
|
|
14
|
-
import { getDefaultTemplate as
|
|
15
|
-
import { useRecommendationBlockWarning as
|
|
16
|
-
const
|
|
17
|
-
let
|
|
18
|
-
class
|
|
14
|
+
import { getDefaultTemplate as M } from "./templates/grid/template.js";
|
|
15
|
+
import { useRecommendationBlockWarning as w } from "./useRecommendationBlockWarning.js";
|
|
16
|
+
const _ = y.Recommendation, u = "recommendation-block-v2", I = "hide-price";
|
|
17
|
+
let k = !1;
|
|
18
|
+
class W extends b {
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
21
|
/**
|
|
22
22
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
23
23
|
* This avoids generating a new (different) ID in onCreated().
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
p(this, "_pendingBlockId", null);
|
|
26
26
|
}
|
|
27
27
|
getId() {
|
|
28
|
-
return
|
|
28
|
+
return _;
|
|
29
29
|
}
|
|
30
30
|
getIcon() {
|
|
31
31
|
return "recommendation-icon";
|
|
32
32
|
}
|
|
33
33
|
getBlockCompositionType() {
|
|
34
|
-
return
|
|
34
|
+
return A.CONTAINER;
|
|
35
35
|
}
|
|
36
36
|
getName() {
|
|
37
37
|
return this.api.translate("Recommendation Block");
|
|
@@ -42,8 +42,8 @@ class j extends E {
|
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
getSettingsPanelTitleHtml() {
|
|
45
|
-
return
|
|
46
|
-
|
|
45
|
+
return C(
|
|
46
|
+
_,
|
|
47
47
|
this.api.translate("Recommendation Block"),
|
|
48
48
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
49
49
|
);
|
|
@@ -66,7 +66,7 @@ class j extends E {
|
|
|
66
66
|
*/
|
|
67
67
|
getTemplate() {
|
|
68
68
|
const t = this._generateNextId();
|
|
69
|
-
return this._pendingBlockId = t,
|
|
69
|
+
return this._pendingBlockId = t, M(t);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* Called when a new block is dropped into the template
|
|
@@ -89,27 +89,23 @@ class j extends E {
|
|
|
89
89
|
}
|
|
90
90
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
91
91
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
92
|
-
const
|
|
92
|
+
const { config: n, wasFreshDrop: o } = s.initializeConfig(
|
|
93
93
|
this.api,
|
|
94
94
|
t,
|
|
95
95
|
{
|
|
96
96
|
recommendationId: i,
|
|
97
|
-
configVersion:
|
|
98
|
-
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
99
|
-
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
100
|
-
// at save for a block the user never configured.
|
|
101
|
-
...o ? { strategy: "" } : {}
|
|
97
|
+
configVersion: D().isFeatureEnabled("reusableRecommendationStrategy") ? E : S
|
|
102
98
|
}
|
|
103
|
-
),
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
99
|
+
), r = d();
|
|
100
|
+
if (r.setCurrentBlock(i), this._stampHidePrice(t, n.priceHideIfSameAsDiscounted), o) {
|
|
101
|
+
h(this.api);
|
|
102
|
+
const l = this._getBlockElement(t);
|
|
103
|
+
l && (f(this.api, l, !0), N({
|
|
108
104
|
currentNode: t,
|
|
109
105
|
documentModifier: this.api.getDocumentModifier()
|
|
110
106
|
}));
|
|
111
107
|
}
|
|
112
|
-
|
|
108
|
+
r.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 }), this._warnIfMultipleBlocks();
|
|
113
109
|
}
|
|
114
110
|
/**
|
|
115
111
|
* Called when the document changes or template is loaded
|
|
@@ -131,11 +127,11 @@ class j extends E {
|
|
|
131
127
|
}
|
|
132
128
|
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
133
129
|
try {
|
|
134
|
-
|
|
130
|
+
k || (h(this.api), k = !0);
|
|
135
131
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
136
132
|
if (i) {
|
|
137
133
|
const n = !e.mobileLayoutEnabled;
|
|
138
|
-
|
|
134
|
+
O(i) !== n && f(this.api, i, n);
|
|
139
135
|
}
|
|
140
136
|
} catch {
|
|
141
137
|
}
|
|
@@ -165,7 +161,7 @@ class j extends E {
|
|
|
165
161
|
*/
|
|
166
162
|
_warnIfMultipleBlocks() {
|
|
167
163
|
try {
|
|
168
|
-
|
|
164
|
+
w().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
169
165
|
} catch {
|
|
170
166
|
}
|
|
171
167
|
}
|
|
@@ -215,9 +211,9 @@ class j extends E {
|
|
|
215
211
|
if (!o)
|
|
216
212
|
return;
|
|
217
213
|
let r = -1;
|
|
218
|
-
for (let
|
|
219
|
-
if (n[
|
|
220
|
-
r =
|
|
214
|
+
for (let l = 0; l < n.length; l++)
|
|
215
|
+
if (n[l] === o) {
|
|
216
|
+
r = l;
|
|
221
217
|
break;
|
|
222
218
|
}
|
|
223
219
|
if (r <= 0)
|
|
@@ -297,7 +293,7 @@ class j extends E {
|
|
|
297
293
|
*/
|
|
298
294
|
_stampHidePrice(t, e) {
|
|
299
295
|
const i = this._getBlockElement(t);
|
|
300
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(
|
|
296
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(I, String(e)).apply(new g("Stamp hide-price"));
|
|
301
297
|
}
|
|
302
298
|
/**
|
|
303
299
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -305,7 +301,7 @@ class j extends E {
|
|
|
305
301
|
*/
|
|
306
302
|
_healHidePriceAttr(t) {
|
|
307
303
|
const e = this._getBlockElement(t);
|
|
308
|
-
if (!e || !("getAttribute" in e) || e.getAttribute(
|
|
304
|
+
if (!e || !("getAttribute" in e) || e.getAttribute(I) !== null)
|
|
309
305
|
return;
|
|
310
306
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
311
307
|
this._stampHidePrice(t, i);
|
|
@@ -342,6 +338,6 @@ class j extends E {
|
|
|
342
338
|
}
|
|
343
339
|
}
|
|
344
340
|
export {
|
|
345
|
-
|
|
346
|
-
|
|
341
|
+
_ as BLOCK_ID,
|
|
342
|
+
W as RecommendationBlock
|
|
347
343
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var C = (
|
|
3
|
-
var
|
|
2
|
+
var C = (g, l, t) => l in g ? m(g, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[l] = t;
|
|
3
|
+
var r = (g, l, t) => C(g, typeof l != "symbol" ? l + "" : l, t);
|
|
4
4
|
import { useConfig as p } from "../../../../../composables/useConfig.js";
|
|
5
5
|
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { CommonControl as N } from "../../../common-control.js";
|
|
@@ -12,9 +12,9 @@ import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
|
12
12
|
import { AlgorithmControl as T } from "./algorithm.js";
|
|
13
13
|
import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
|
|
14
14
|
import { CurrencyControl as P } from "./currency.js";
|
|
15
|
-
import { CURRENCY_CONTROL_ID as
|
|
15
|
+
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
17
|
-
import { FILTERS_CONTROL_ID as
|
|
17
|
+
import { FILTERS_CONTROL_ID as ht } from "./filters.js";
|
|
18
18
|
import { LayoutOrientationControl as O } from "./layoutOrientation.js";
|
|
19
19
|
import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
|
|
20
20
|
import { LocaleControl as L } from "./locale.js";
|
|
@@ -29,38 +29,38 @@ import { ShuffleControl as F } from "./shuffle.js";
|
|
|
29
29
|
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
30
|
import { StrategyControl as w } from "./strategy.js";
|
|
31
31
|
import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
|
|
32
|
-
import { setCurrencyAttributes as A, getBlockElement as
|
|
33
|
-
import { adjustProductsToSize as kt, formatProductPrice as Dt, getCardComposition as Ft, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as
|
|
34
|
-
import { useDebounceFn as
|
|
32
|
+
import { setCurrencyAttributes as A, getBlockElement as B, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as kt, formatProductPrice as Dt, getCardComposition as Ft, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as Bt, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
|
|
34
|
+
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
35
|
const $ = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
37
37
|
constructor() {
|
|
38
38
|
super(...arguments);
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
r(this, "store", R());
|
|
40
|
+
r(this, "storeUnsubscription", () => {
|
|
41
41
|
});
|
|
42
42
|
// blockId -> fingerprint of the node config as it looked at the last sync.
|
|
43
|
-
|
|
43
|
+
r(this, "syncedConfigs", /* @__PURE__ */ new Map());
|
|
44
44
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
45
45
|
// re-render's single apply() — one user action must cost one undo press.
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
r(this, "pendingNodeConfigWrite", null);
|
|
47
|
+
r(this, "pendingConfigFlushTimer", null);
|
|
48
48
|
// Sub-control instances for lifecycle management
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
r(this, "algorithmControl", null);
|
|
50
|
+
r(this, "localeControl", null);
|
|
51
|
+
r(this, "currencyControl", null);
|
|
52
|
+
r(this, "productCountControl", null);
|
|
53
|
+
r(this, "productLayoutControl", null);
|
|
54
|
+
r(this, "filtersControl", null);
|
|
55
|
+
r(this, "shuffleControl", null);
|
|
56
|
+
r(this, "pricePlacementControl", null);
|
|
57
|
+
r(this, "layoutOrientationControl", null);
|
|
58
|
+
r(this, "strategyControl", null);
|
|
59
|
+
r(this, "rrsEnabled", !1);
|
|
60
60
|
/**
|
|
61
61
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
r(this, "_debouncedFetchProducts", f(async () => {
|
|
64
64
|
try {
|
|
65
65
|
await this.store.fetchRecommendationProducts();
|
|
66
66
|
} finally {
|
|
@@ -78,16 +78,16 @@ class at extends N {
|
|
|
78
78
|
* count. The store pads products to the configured size, so in-place only
|
|
79
79
|
* fails when the size actually changed.
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
r(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
82
82
|
const t = this.store.recommendationProducts;
|
|
83
83
|
if (!this.currentNode || !this.api)
|
|
84
84
|
return;
|
|
85
85
|
const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
86
|
-
if (
|
|
86
|
+
if (v(this.currentNode)) {
|
|
87
87
|
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
x({
|
|
91
91
|
currentNode: this.currentNode,
|
|
92
92
|
documentModifier: e,
|
|
93
93
|
products: t
|
|
@@ -142,14 +142,14 @@ class at extends N {
|
|
|
142
142
|
const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
|
|
143
143
|
if (!e)
|
|
144
144
|
return;
|
|
145
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t),
|
|
146
|
-
e.classList.toggle("strategy-block",
|
|
145
|
+
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !n;
|
|
146
|
+
e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
|
|
147
147
|
}
|
|
148
148
|
async onRender() {
|
|
149
149
|
var o;
|
|
150
150
|
b(this.api);
|
|
151
151
|
const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
|
|
152
|
-
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode),
|
|
152
|
+
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
|
|
153
153
|
this._initializeSubControls();
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
@@ -161,9 +161,9 @@ class at extends N {
|
|
|
161
161
|
const e = this._getRecommendationIdFromNode(t);
|
|
162
162
|
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigIfChanged(e), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
|
|
163
163
|
this._initializeSubControls();
|
|
164
|
-
}), this._subControls.forEach((
|
|
165
|
-
var
|
|
166
|
-
|
|
164
|
+
}), this._subControls.forEach((n) => {
|
|
165
|
+
var s;
|
|
166
|
+
n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
onDestroy() {
|
|
@@ -210,11 +210,11 @@ class at extends N {
|
|
|
210
210
|
const t = this.store.currentRecommendationId;
|
|
211
211
|
if (!this.currentNode || !this.api || t === null)
|
|
212
212
|
return;
|
|
213
|
-
const { filters: e, strategyId: o, size:
|
|
213
|
+
const { filters: e, strategyId: o, size: n, nodeConfigVersion: s } = this.store.recommendationConfigs;
|
|
214
214
|
this.pendingNodeConfigWrite = {
|
|
215
215
|
blockId: t,
|
|
216
216
|
node: this.currentNode,
|
|
217
|
-
updates: { filters: e, strategyId: o, size:
|
|
217
|
+
updates: { filters: e, strategyId: o, size: n, configVersion: s }
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
@@ -257,11 +257,12 @@ class at extends N {
|
|
|
257
257
|
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
258
258
|
}
|
|
259
259
|
_syncNodeConfigToStore() {
|
|
260
|
-
var
|
|
261
|
-
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((
|
|
260
|
+
var n;
|
|
261
|
+
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
|
|
262
262
|
this.store.patchCurrentBlockConfig({
|
|
263
263
|
strategy: t.strategy,
|
|
264
264
|
strategyId: t.strategyId,
|
|
265
|
+
nodeConfigVersion: t.configVersion,
|
|
265
266
|
language: t.language,
|
|
266
267
|
size: t.size,
|
|
267
268
|
productIds: t.productIds,
|
|
@@ -300,8 +301,8 @@ class at extends N {
|
|
|
300
301
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
301
302
|
this.store.fetchRecommendationCreateData(),
|
|
302
303
|
this.store.fetchRecommendationFilters()
|
|
303
|
-
])).forEach((o,
|
|
304
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
304
|
+
])).forEach((o, n) => {
|
|
305
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
|
|
305
306
|
}), this._applySmartDefaults();
|
|
306
307
|
try {
|
|
307
308
|
await this.store.fetchRecommendationProducts();
|
|
@@ -323,30 +324,30 @@ class at extends N {
|
|
|
323
324
|
if (!this.currentNode || !this.api)
|
|
324
325
|
return;
|
|
325
326
|
const t = c.getConfig(this.currentNode), e = {};
|
|
326
|
-
let o = null,
|
|
327
|
+
let o = null, n = null, s = null;
|
|
327
328
|
if (t.currency.code === a.currency.code) {
|
|
328
|
-
const { currencyList:
|
|
329
|
-
|
|
329
|
+
const { currencyList: i } = this.store;
|
|
330
|
+
i.length > 0 && (i.some(
|
|
330
331
|
(d) => d.value === `price.${a.currency.code}`
|
|
331
|
-
) || (o =
|
|
332
|
+
) || (o = i[0].value.replace("price.", ""), e.currency = {
|
|
332
333
|
...a.currency,
|
|
333
334
|
code: o,
|
|
334
335
|
symbol: o
|
|
335
336
|
}));
|
|
336
337
|
}
|
|
337
338
|
if (t.strategy === a.strategy) {
|
|
338
|
-
const
|
|
339
|
-
|
|
339
|
+
const i = this.store.getActivePredictiveAlgorithms;
|
|
340
|
+
i.length > 0 && (i.some(
|
|
340
341
|
(d) => d.value === a.strategy
|
|
341
|
-
) || (
|
|
342
|
+
) || (n = i[0].value, e.strategy = n));
|
|
342
343
|
}
|
|
343
344
|
if (t.language === a.language) {
|
|
344
|
-
const
|
|
345
|
-
|
|
345
|
+
const i = this.store.getLanguages;
|
|
346
|
+
i.length > 0 && (i.some(
|
|
346
347
|
(d) => d.value === a.language
|
|
347
|
-
) || (
|
|
348
|
+
) || (s = i[0].value, e.language = s));
|
|
348
349
|
}
|
|
349
|
-
!o && !
|
|
350
|
+
!o && !n && !s || (c.updateConfig(
|
|
350
351
|
this.api,
|
|
351
352
|
this.currentNode,
|
|
352
353
|
e,
|
|
@@ -367,22 +368,22 @@ class at extends N {
|
|
|
367
368
|
thousandSeparator: a.currency.thousandSeparator
|
|
368
369
|
}
|
|
369
370
|
} : {},
|
|
370
|
-
...
|
|
371
|
-
...
|
|
371
|
+
...n ? { strategy: n } : {},
|
|
372
|
+
...s ? { language: s } : {}
|
|
372
373
|
}, { triggerRefetch: !1 }));
|
|
373
374
|
}
|
|
374
375
|
/**
|
|
375
376
|
* Reads the recommendation-id attribute from the block element within the node
|
|
376
377
|
*/
|
|
377
378
|
_getRecommendationIdFromNode(t) {
|
|
378
|
-
const e =
|
|
379
|
+
const e = B(t);
|
|
379
380
|
if (!e || !("getAttribute" in e))
|
|
380
381
|
return null;
|
|
381
382
|
const o = e.getAttribute(I);
|
|
382
383
|
if (!o)
|
|
383
384
|
return null;
|
|
384
|
-
const
|
|
385
|
-
return Number.isNaN(
|
|
385
|
+
const n = parseInt(o);
|
|
386
|
+
return Number.isNaN(n) ? null : n;
|
|
386
387
|
}
|
|
387
388
|
/**
|
|
388
389
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -399,17 +400,17 @@ class at extends N {
|
|
|
399
400
|
*/
|
|
400
401
|
_listenStateUpdates() {
|
|
401
402
|
const { store: t } = this;
|
|
402
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
403
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
|
|
403
404
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
404
|
-
const
|
|
405
|
-
if (
|
|
406
|
-
|
|
405
|
+
const s = t.currentRecommendationId;
|
|
406
|
+
if (s !== n) {
|
|
407
|
+
n = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
407
408
|
return;
|
|
408
409
|
}
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
const u = t.recommendationProducts, d = u !== e,
|
|
412
|
-
d &&
|
|
410
|
+
const i = t.$state.configVersion;
|
|
411
|
+
i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
|
|
412
|
+
const u = t.recommendationProducts, d = u !== e, h = Array.isArray(u) && u.length > 0;
|
|
413
|
+
d && h && (e = u, this._debouncedRegenerateWithProducts());
|
|
413
414
|
});
|
|
414
415
|
}
|
|
415
416
|
}
|
|
@@ -417,9 +418,9 @@ export {
|
|
|
417
418
|
ut as ALGORITHM_CONTROL_ID,
|
|
418
419
|
T as AlgorithmControl,
|
|
419
420
|
$ as CONTROL_BLOCK_ID,
|
|
420
|
-
|
|
421
|
+
gt as CURRENCY_CONTROL_ID,
|
|
421
422
|
P as CurrencyControl,
|
|
422
|
-
|
|
423
|
+
ht as FILTERS_CONTROL_ID,
|
|
423
424
|
S as FiltersControl,
|
|
424
425
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
425
426
|
yt as LOCALE_CONTROL_ID,
|
|
@@ -438,15 +439,15 @@ export {
|
|
|
438
439
|
w as StrategyControl,
|
|
439
440
|
kt as adjustProductsToSize,
|
|
440
441
|
Dt as formatProductPrice,
|
|
441
|
-
|
|
442
|
+
B as getBlockElement,
|
|
442
443
|
Ft as getCardComposition,
|
|
443
444
|
wt as getCurrentLayout,
|
|
444
445
|
At as getMainContainerTbody,
|
|
445
|
-
|
|
446
|
-
|
|
446
|
+
v as isPartnerManagedBlock,
|
|
447
|
+
Bt as regenerateMobileProductRows,
|
|
447
448
|
U as regenerateProductRowsWithStyles,
|
|
448
449
|
A as setCurrencyAttributes,
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
450
|
+
vt as updatePricesInPlace,
|
|
451
|
+
x as updateProductContentInPlace,
|
|
452
|
+
xt as updateSingleProductContent
|
|
452
453
|
};
|