@useinsider/guido 3.19.0-beta.dcea8c0 → 3.19.0-beta.e110e88
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/composables/useLegacyStrategyConversion.js +19 -23
- package/dist/extensions/Blocks/Recommendation/block.js +22 -20
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +87 -70
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +209 -203
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +108 -84
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -21
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +55 -16
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +13 -2
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +3 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
- package/package.json +2 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { useToaster as
|
|
1
|
+
import { useRecommendation as I } from "./useRecommendation.js";
|
|
2
|
+
import { useToaster as C } from "./useToaster.js";
|
|
3
3
|
import { useTranslations as v } from "./useTranslations.js";
|
|
4
4
|
import { ToasterTypeOptions as g } from "../enums/toaster.js";
|
|
5
5
|
import "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
6
6
|
import { CURRENT_CONFIG_VERSION as L } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
7
7
|
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
8
|
-
import { resolveMigrationTarget as
|
|
9
|
-
import { commitBlockChangeOutsidePanel as
|
|
10
|
-
import { useConfigStore as
|
|
8
|
+
import { resolveMigrationTarget as R, buildLegacyMigrationPayload as T } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
|
|
9
|
+
import { commitBlockChangeOutsidePanel as h } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
|
|
10
|
+
import { useConfigStore as k } from "../stores/config.js";
|
|
11
11
|
const F = () => {
|
|
12
|
-
const e = b(), r =
|
|
12
|
+
const e = b(), r = k(), { buildCampaignUrl: m } = I(), { showToaster: i } = C(), c = v();
|
|
13
13
|
return { convertLegacyStrategy: async () => {
|
|
14
14
|
const t = e.currentRecommendationId;
|
|
15
15
|
if (t === null || !e.isLegacyStrategyBlock || e.legacyConversionLoading)
|
|
16
16
|
return "";
|
|
17
|
-
const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s =
|
|
17
|
+
const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = R({
|
|
18
18
|
campaignId: r.campaignId,
|
|
19
19
|
templateLibraryId: r.templateLibraryId
|
|
20
|
-
}), S =
|
|
20
|
+
}), S = T({
|
|
21
21
|
blockId: t,
|
|
22
22
|
url: m(String(t)),
|
|
23
23
|
campaignId: r.campaignId,
|
|
@@ -29,34 +29,30 @@ const F = () => {
|
|
|
29
29
|
let o;
|
|
30
30
|
try {
|
|
31
31
|
o = await e.convertLegacyStrategy(S, s);
|
|
32
|
-
} catch (
|
|
33
|
-
return console.error("[useLegacyStrategyConversion] migration failed",
|
|
32
|
+
} catch (n) {
|
|
33
|
+
return console.error("[useLegacyStrategyConversion] migration failed", n), i({
|
|
34
34
|
type: g.Error,
|
|
35
|
-
message:
|
|
36
|
-
actionButton: {
|
|
37
|
-
text: a("ds-steps.create-recommendation-strategy"),
|
|
38
|
-
onClick: () => e.openStrategyCreation()
|
|
39
|
-
}
|
|
35
|
+
message: c("email-editor.legacy-strategy-update-failed")
|
|
40
36
|
}), "";
|
|
41
37
|
}
|
|
42
38
|
try {
|
|
43
39
|
await e.fetchStrategyProductsForBlock(t);
|
|
44
|
-
} catch (
|
|
45
|
-
console.error("[useLegacyStrategyConversion] product refetch failed",
|
|
40
|
+
} catch (n) {
|
|
41
|
+
console.error("[useLegacyStrategyConversion] product refetch failed", n);
|
|
46
42
|
}
|
|
47
|
-
const
|
|
48
|
-
return
|
|
43
|
+
const a = e.blockStates[t];
|
|
44
|
+
return a ? h(
|
|
49
45
|
t,
|
|
50
46
|
{
|
|
51
47
|
strategyId: o,
|
|
52
|
-
size:
|
|
48
|
+
size: a.recommendationConfigs.size,
|
|
53
49
|
configVersion: L
|
|
54
50
|
},
|
|
55
|
-
|
|
51
|
+
a.recommendationProducts,
|
|
56
52
|
"Converted legacy recommendation strategy"
|
|
57
|
-
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), o) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f),
|
|
53
|
+
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), o) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), i({
|
|
58
54
|
type: g.Error,
|
|
59
|
-
message:
|
|
55
|
+
message: c("email-editor.legacy-strategy-update-failed")
|
|
60
56
|
}), "") : o;
|
|
61
57
|
} };
|
|
62
58
|
};
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var C = (l, c, t) => c in l ? b(l, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[c] = t;
|
|
3
|
+
var d = (l, c, t) => C(l, typeof c != "symbol" ? c + "" : c, t);
|
|
4
4
|
import { useConfig as h } from "../../../composables/useConfig.js";
|
|
5
5
|
import { BlockId as D } from "../../../enums/block.js";
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
6
|
+
import { getMigrationBannerHtml as A } from "../../../utils/migrationBannerHtml.js";
|
|
7
7
|
import { Block as E, BlockCompositionType as S, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
8
|
import { CURRENT_CONFIG_VERSION as N, PRE_RRS_CONFIG_VERSION as O } from "./constants/defaultConfig.js";
|
|
9
9
|
import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
|
|
10
10
|
import { regenerateMobileProductRows as M } from "./controls/main/utils.js";
|
|
11
11
|
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as w } from "./controls/mobileLayout/cssRules.js";
|
|
12
12
|
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
13
|
-
import { useRecommendationExtensionStore as
|
|
13
|
+
import { useRecommendationExtensionStore as g } from "./store/recommendation.js";
|
|
14
14
|
import { getDefaultTemplate as T } from "./templates/grid/template.js";
|
|
15
15
|
import { useRecommendationBlockWarning as x } from "./useRecommendationBlockWarning.js";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
import { registerNodeConfigWriter as H } from "./utils/nodeConfigWriter.js";
|
|
17
|
+
import { refreshDuplicatedStrategyBlocks as $ } from "./utils/strategyCommit.js";
|
|
18
|
+
const k = D.Recommendation, u = "recommendation-block-v2", y = "hide-price";
|
|
19
|
+
let B = !1;
|
|
20
|
+
class Y extends E {
|
|
19
21
|
constructor() {
|
|
20
22
|
super();
|
|
21
23
|
/**
|
|
22
24
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
23
25
|
* This avoids generating a new (different) ID in onCreated().
|
|
24
26
|
*/
|
|
25
|
-
|
|
27
|
+
d(this, "_pendingBlockId", null);
|
|
26
28
|
/** Ids already reset under their new name, so the deferred pass skips their stale snapshot. */
|
|
27
|
-
|
|
29
|
+
d(this, "_resetSourceIds", /* @__PURE__ */ new Set());
|
|
28
30
|
}
|
|
29
31
|
getId() {
|
|
30
32
|
return k;
|
|
@@ -44,7 +46,7 @@ class j extends E {
|
|
|
44
46
|
);
|
|
45
47
|
}
|
|
46
48
|
getSettingsPanelTitleHtml() {
|
|
47
|
-
return
|
|
49
|
+
return A(
|
|
48
50
|
k,
|
|
49
51
|
this.api.translate("Recommendation Block"),
|
|
50
52
|
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.")
|
|
@@ -102,7 +104,7 @@ class j extends E {
|
|
|
102
104
|
// at save for a block the user never configured.
|
|
103
105
|
...o ? { strategy: "" } : {}
|
|
104
106
|
}
|
|
105
|
-
), f =
|
|
107
|
+
), f = g();
|
|
106
108
|
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), a) {
|
|
107
109
|
I(this.api);
|
|
108
110
|
const _ = this._getBlockElement(t);
|
|
@@ -133,7 +135,7 @@ class j extends E {
|
|
|
133
135
|
}
|
|
134
136
|
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
135
137
|
try {
|
|
136
|
-
|
|
138
|
+
B || (I(this.api), B = !0);
|
|
137
139
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
138
140
|
if (i) {
|
|
139
141
|
const n = !e.mobileLayoutEnabled;
|
|
@@ -151,7 +153,7 @@ class j extends E {
|
|
|
151
153
|
*/
|
|
152
154
|
onDelete(t) {
|
|
153
155
|
const e = this._getRecommendationId(t);
|
|
154
|
-
e &&
|
|
156
|
+
e && g().removeBlockState(e);
|
|
155
157
|
}
|
|
156
158
|
/**
|
|
157
159
|
* Warns (dark advisory toaster) when the design holds more than one live
|
|
@@ -199,7 +201,7 @@ class j extends E {
|
|
|
199
201
|
_scheduleArrivalReset(t) {
|
|
200
202
|
h().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
|
|
201
203
|
const e = this._getRecommendationId(t);
|
|
202
|
-
e !== null && e > 0 && !this._resetSourceIds.delete(e) &&
|
|
204
|
+
e !== null && e > 0 && !this._resetSourceIds.delete(e) && g().resetArrivedBlock(e);
|
|
203
205
|
}, 0);
|
|
204
206
|
}
|
|
205
207
|
/**
|
|
@@ -255,8 +257,8 @@ class j extends E {
|
|
|
255
257
|
}
|
|
256
258
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
257
259
|
_handleDuplicate(t, e) {
|
|
258
|
-
const i = this._reassignDuplicateId(t, e), n =
|
|
259
|
-
n.cloneBlockState(e, i), n.setCurrentBlock(i), h().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e),
|
|
260
|
+
const i = this._reassignDuplicateId(t, e), n = g();
|
|
261
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i), h().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), H(this.api), $(e, i, s.getConfig(t)).catch((o) => console.error("[recommendation] refreshing a duplicated strategy failed", o))), this._warnIfMultipleBlocks();
|
|
260
262
|
}
|
|
261
263
|
/**
|
|
262
264
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -312,7 +314,7 @@ class j extends E {
|
|
|
312
314
|
*/
|
|
313
315
|
_stampHidePrice(t, e) {
|
|
314
316
|
const i = this._getBlockElement(t);
|
|
315
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(
|
|
317
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(y, String(e)).apply(new p("Stamp hide-price"));
|
|
316
318
|
}
|
|
317
319
|
/**
|
|
318
320
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -320,7 +322,7 @@ class j extends E {
|
|
|
320
322
|
*/
|
|
321
323
|
_healHidePriceAttr(t) {
|
|
322
324
|
const e = this._getBlockElement(t);
|
|
323
|
-
if (!e || !("getAttribute" in e) || e.getAttribute(
|
|
325
|
+
if (!e || !("getAttribute" in e) || e.getAttribute(y) !== null)
|
|
324
326
|
return;
|
|
325
327
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
326
328
|
this._stampHidePrice(t, i);
|
|
@@ -358,5 +360,5 @@ class j extends E {
|
|
|
358
360
|
}
|
|
359
361
|
export {
|
|
360
362
|
k as BLOCK_ID,
|
|
361
|
-
|
|
363
|
+
Y as RecommendationBlock
|
|
362
364
|
};
|
|
@@ -9,28 +9,28 @@ import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
|
9
9
|
import { RecommendationConfigService as l } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
11
11
|
import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
12
|
-
import { AlgorithmControl as
|
|
12
|
+
import { AlgorithmControl as P } from "./algorithm.js";
|
|
13
13
|
import { ALGORITHM_CONTROL_ID as dt } from "./algorithm.js";
|
|
14
|
-
import { CurrencyControl as
|
|
14
|
+
import { CurrencyControl as T } from "./currency.js";
|
|
15
15
|
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
17
17
|
import { FILTERS_CONTROL_ID as ft } 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
|
-
import { LocaleControl as
|
|
20
|
+
import { LocaleControl as k } from "./locale.js";
|
|
21
21
|
import { LOCALE_CONTROL_ID as yt } from "./locale.js";
|
|
22
|
-
import { PricePlacementControl as
|
|
22
|
+
import { PricePlacementControl as L } from "./pricePlacement.js";
|
|
23
23
|
import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
|
|
24
24
|
import { ProductCountControl as E } from "./productCount.js";
|
|
25
25
|
import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
|
|
26
26
|
import { ProductLayoutControl as F } from "./productLayout.js";
|
|
27
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
27
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Pt } from "./productLayout.js";
|
|
28
28
|
import { ShuffleControl as D } from "./shuffle.js";
|
|
29
29
|
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
|
-
import { StrategyControl as
|
|
31
|
-
import { STRATEGY_CONTROL_ID as
|
|
32
|
-
import { setCurrencyAttributes as
|
|
33
|
-
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as
|
|
30
|
+
import { StrategyControl as B } from "./strategy.js";
|
|
31
|
+
import { STRATEGY_CONTROL_ID as kt } from "./strategy.js";
|
|
32
|
+
import { setCurrencyAttributes as w, getBlockElement as A, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as Bt, getMainContainerTbody as wt, regenerateMobileProductRows as At, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
|
|
34
34
|
import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
35
|
const W = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
@@ -77,23 +77,21 @@ class at extends N {
|
|
|
77
77
|
* fails when the size actually changed.
|
|
78
78
|
*/
|
|
79
79
|
i(this, "_debouncedRegenerateWithProducts", h(() => {
|
|
80
|
-
const t = this.store.recommendationProducts;
|
|
81
80
|
if (!this.currentNode || !this.api)
|
|
82
81
|
return;
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
82
|
+
const t = this._getRecommendationIdFromNode(this.currentNode), e = this.store.currentRecommendationId;
|
|
83
|
+
if (t === null || e === null || t === e || !this.store.blockStates[t]) {
|
|
84
|
+
this._regenerateWithProducts();
|
|
86
85
|
return;
|
|
87
86
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
87
|
+
if (this.store.blockStates[t].recommendationProducts.length) {
|
|
88
|
+
this.store.setCurrentBlock(t);
|
|
89
|
+
try {
|
|
90
|
+
this._regenerateWithProducts();
|
|
91
|
+
} finally {
|
|
92
|
+
this.store.setCurrentBlock(e);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
97
95
|
}, 100));
|
|
98
96
|
}
|
|
99
97
|
getId() {
|
|
@@ -118,7 +116,7 @@ class at extends N {
|
|
|
118
116
|
return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
|
|
119
117
|
var o;
|
|
120
118
|
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
121
|
-
}), this.algorithmControl = new
|
|
119
|
+
}), this.algorithmControl = new P(), this.localeControl = new k(), this.currencyControl = new T(), this.productCountControl = new E(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new L(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new B() : null, this._subControls.forEach((e) => {
|
|
122
120
|
e && (e.api = this.api);
|
|
123
121
|
}), `
|
|
124
122
|
<div class="recommendation-controls-container">
|
|
@@ -136,12 +134,12 @@ class at extends N {
|
|
|
136
134
|
`;
|
|
137
135
|
}
|
|
138
136
|
_showControlsForBlock(t) {
|
|
139
|
-
var
|
|
140
|
-
const e = (
|
|
137
|
+
var n;
|
|
138
|
+
const e = (n = this.getContainer()) == null ? void 0 : n.querySelector(".recommendation-controls-container");
|
|
141
139
|
if (!e)
|
|
142
140
|
return;
|
|
143
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null : l.getConfig(t),
|
|
144
|
-
e.classList.toggle("strategy-block",
|
|
141
|
+
const o = this._getRecommendationIdFromNode(t) === null ? null : l.getConfig(t), r = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !r;
|
|
142
|
+
e.classList.toggle("strategy-block", r), e.classList.toggle("legacy-strategy-block", s);
|
|
145
143
|
}
|
|
146
144
|
async onRender() {
|
|
147
145
|
var o;
|
|
@@ -159,9 +157,9 @@ class at extends N {
|
|
|
159
157
|
const e = this._getRecommendationIdFromNode(t);
|
|
160
158
|
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(() => {
|
|
161
159
|
this._initializeSubControls();
|
|
162
|
-
}), this._subControls.forEach((
|
|
160
|
+
}), this._subControls.forEach((r) => {
|
|
163
161
|
var s;
|
|
164
|
-
|
|
162
|
+
r != null && r.api && (r.currentNode = t, (s = r.onTemplateNodeUpdated) == null || s.call(r, t));
|
|
165
163
|
});
|
|
166
164
|
}
|
|
167
165
|
onDestroy() {
|
|
@@ -209,8 +207,8 @@ class at extends N {
|
|
|
209
207
|
const e = this.store.blockStates[t];
|
|
210
208
|
if (!e)
|
|
211
209
|
return;
|
|
212
|
-
const o = JSON.stringify(l.getConfig(this.currentNode)),
|
|
213
|
-
e.syncedConfigFingerprint = o,
|
|
210
|
+
const o = JSON.stringify(l.getConfig(this.currentNode)), r = e.syncedConfigFingerprint;
|
|
211
|
+
e.syncedConfigFingerprint = o, r !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
214
212
|
}
|
|
215
213
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
216
214
|
_isPendingStrategyIdChange() {
|
|
@@ -221,11 +219,11 @@ class at extends N {
|
|
|
221
219
|
const t = this.store.currentRecommendationId;
|
|
222
220
|
if (!this.currentNode || !this.api || t === null)
|
|
223
221
|
return;
|
|
224
|
-
const { filters: e, strategy: o, strategyId:
|
|
222
|
+
const { filters: e, strategy: o, strategyId: r, size: s, nodeConfigVersion: n } = this.store.recommendationConfigs;
|
|
225
223
|
this.pendingNodeConfigWrite = {
|
|
226
224
|
blockId: t,
|
|
227
225
|
node: this.currentNode,
|
|
228
|
-
updates: { filters: e, strategy: o, strategyId:
|
|
226
|
+
updates: { filters: e, strategy: o, strategyId: r, size: s, configVersion: n }
|
|
229
227
|
};
|
|
230
228
|
}
|
|
231
229
|
/**
|
|
@@ -268,8 +266,8 @@ class at extends N {
|
|
|
268
266
|
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size || l.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
269
267
|
}
|
|
270
268
|
_syncNodeConfigToStore() {
|
|
271
|
-
var
|
|
272
|
-
const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((
|
|
269
|
+
var r;
|
|
270
|
+
const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
|
|
273
271
|
this.store.patchCurrentBlockConfig({
|
|
274
272
|
strategy: t.strategy,
|
|
275
273
|
strategyId: t.strategyId,
|
|
@@ -312,8 +310,8 @@ class at extends N {
|
|
|
312
310
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
313
311
|
this.store.fetchRecommendationCreateData(),
|
|
314
312
|
this.store.fetchRecommendationFilters()
|
|
315
|
-
])).forEach((o,
|
|
316
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
313
|
+
])).forEach((o, r) => {
|
|
314
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, o.reason);
|
|
317
315
|
}), this._applySmartDefaults();
|
|
318
316
|
try {
|
|
319
317
|
await this.store.fetchRecommendationProducts();
|
|
@@ -335,35 +333,35 @@ class at extends N {
|
|
|
335
333
|
if (!this.currentNode || !this.api)
|
|
336
334
|
return;
|
|
337
335
|
const t = l.getConfig(this.currentNode), e = {};
|
|
338
|
-
let o = null,
|
|
336
|
+
let o = null, r = null, s = null;
|
|
339
337
|
if (t.currency.code === a.currency.code) {
|
|
340
|
-
const { currencyList:
|
|
341
|
-
|
|
338
|
+
const { currencyList: n } = this.store;
|
|
339
|
+
n.length > 0 && (n.some(
|
|
342
340
|
(u) => u.value === `price.${a.currency.code}`
|
|
343
|
-
) || (o =
|
|
341
|
+
) || (o = n[0].value.replace("price.", ""), e.currency = {
|
|
344
342
|
...a.currency,
|
|
345
343
|
code: o,
|
|
346
344
|
symbol: o
|
|
347
345
|
}));
|
|
348
346
|
}
|
|
349
347
|
if (t.strategy === a.strategy) {
|
|
350
|
-
const
|
|
351
|
-
|
|
348
|
+
const n = this.store.getActivePredictiveAlgorithms;
|
|
349
|
+
n.length > 0 && (n.some(
|
|
352
350
|
(u) => u.value === a.strategy
|
|
353
|
-
) || (
|
|
351
|
+
) || (r = n[0].value, e.strategy = r));
|
|
354
352
|
}
|
|
355
353
|
if (t.language === a.language) {
|
|
356
|
-
const
|
|
357
|
-
|
|
354
|
+
const n = this.store.getLanguages;
|
|
355
|
+
n.length > 0 && (n.some(
|
|
358
356
|
(u) => u.value === a.language
|
|
359
|
-
) || (s =
|
|
357
|
+
) || (s = n[0].value, e.language = s));
|
|
360
358
|
}
|
|
361
|
-
!o && !
|
|
359
|
+
!o && !r && !s || (l.updateConfig(
|
|
362
360
|
this.api,
|
|
363
361
|
this.currentNode,
|
|
364
362
|
e,
|
|
365
363
|
"Applied smart defaults"
|
|
366
|
-
), o && e.currency &&
|
|
364
|
+
), o && e.currency && w({
|
|
367
365
|
currentNode: this.currentNode,
|
|
368
366
|
documentModifier: this.api.getDocumentModifier(),
|
|
369
367
|
currency: e.currency
|
|
@@ -379,7 +377,7 @@ class at extends N {
|
|
|
379
377
|
thousandSeparator: a.currency.thousandSeparator
|
|
380
378
|
}
|
|
381
379
|
} : {},
|
|
382
|
-
...
|
|
380
|
+
...r ? { strategy: r } : {},
|
|
383
381
|
...s ? { language: s } : {}
|
|
384
382
|
}, { triggerRefetch: !1 }));
|
|
385
383
|
}
|
|
@@ -387,14 +385,33 @@ class at extends N {
|
|
|
387
385
|
* Reads the recommendation-id attribute from the block element within the node
|
|
388
386
|
*/
|
|
389
387
|
_getRecommendationIdFromNode(t) {
|
|
390
|
-
const e =
|
|
388
|
+
const e = A(t);
|
|
391
389
|
if (!e || !("getAttribute" in e))
|
|
392
390
|
return null;
|
|
393
391
|
const o = e.getAttribute(I);
|
|
394
392
|
if (!o)
|
|
395
393
|
return null;
|
|
396
|
-
const
|
|
397
|
-
return Number.isNaN(
|
|
394
|
+
const r = parseInt(o);
|
|
395
|
+
return Number.isNaN(r) ? null : r;
|
|
396
|
+
}
|
|
397
|
+
/** Draws the current block's products into this panel's node. */
|
|
398
|
+
_regenerateWithProducts() {
|
|
399
|
+
if (!this.currentNode || !this.api)
|
|
400
|
+
return;
|
|
401
|
+
const t = this.store.recommendationProducts, e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
402
|
+
if (v(this.currentNode)) {
|
|
403
|
+
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
x({
|
|
407
|
+
currentNode: this.currentNode,
|
|
408
|
+
documentModifier: e,
|
|
409
|
+
products: t
|
|
410
|
+
}) || U({
|
|
411
|
+
currentNode: this.currentNode,
|
|
412
|
+
documentModifier: e,
|
|
413
|
+
products: t
|
|
414
|
+
});
|
|
398
415
|
}
|
|
399
416
|
/**
|
|
400
417
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -411,15 +428,15 @@ class at extends N {
|
|
|
411
428
|
*/
|
|
412
429
|
_listenStateUpdates() {
|
|
413
430
|
const { store: t } = this;
|
|
414
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
431
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
|
|
415
432
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
416
433
|
const s = t.currentRecommendationId;
|
|
417
|
-
if (s !==
|
|
418
|
-
|
|
434
|
+
if (s !== r) {
|
|
435
|
+
r = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
419
436
|
return;
|
|
420
437
|
}
|
|
421
|
-
const
|
|
422
|
-
|
|
438
|
+
const n = t.$state.configVersion;
|
|
439
|
+
n !== o && (o = n, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
|
|
423
440
|
const d = t.recommendationProducts, u = d !== e, f = Array.isArray(d) && d.length > 0;
|
|
424
441
|
u && f && (e = d, this._debouncedRegenerateWithProducts());
|
|
425
442
|
});
|
|
@@ -427,37 +444,37 @@ class at extends N {
|
|
|
427
444
|
}
|
|
428
445
|
export {
|
|
429
446
|
dt as ALGORITHM_CONTROL_ID,
|
|
430
|
-
|
|
447
|
+
P as AlgorithmControl,
|
|
431
448
|
W as CONTROL_BLOCK_ID,
|
|
432
449
|
gt as CURRENCY_CONTROL_ID,
|
|
433
|
-
|
|
450
|
+
T as CurrencyControl,
|
|
434
451
|
ft as FILTERS_CONTROL_ID,
|
|
435
452
|
S as FiltersControl,
|
|
436
453
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
437
454
|
yt as LOCALE_CONTROL_ID,
|
|
438
455
|
O as LayoutOrientationControl,
|
|
439
|
-
|
|
456
|
+
k as LocaleControl,
|
|
440
457
|
_t as PRICE_PLACEMENT_CONTROL_ID,
|
|
441
458
|
Rt as PRODUCT_COUNT_CONTROL_ID,
|
|
442
|
-
|
|
443
|
-
|
|
459
|
+
Pt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
460
|
+
L as PricePlacementControl,
|
|
444
461
|
E as ProductCountControl,
|
|
445
462
|
F as ProductLayoutControl,
|
|
446
463
|
at as RecommendationBlockControl,
|
|
447
464
|
St as SHUFFLE_CONTROL_ID,
|
|
448
|
-
|
|
465
|
+
kt as STRATEGY_CONTROL_ID,
|
|
449
466
|
D as ShuffleControl,
|
|
450
|
-
|
|
467
|
+
B as StrategyControl,
|
|
451
468
|
Et as adjustProductsToSize,
|
|
452
469
|
Ft as formatProductPrice,
|
|
453
|
-
|
|
470
|
+
A as getBlockElement,
|
|
454
471
|
Dt as getCardComposition,
|
|
455
|
-
|
|
456
|
-
|
|
472
|
+
Bt as getCurrentLayout,
|
|
473
|
+
wt as getMainContainerTbody,
|
|
457
474
|
v as isPartnerManagedBlock,
|
|
458
|
-
|
|
475
|
+
At as regenerateMobileProductRows,
|
|
459
476
|
U as regenerateProductRowsWithStyles,
|
|
460
|
-
|
|
477
|
+
w as setCurrencyAttributes,
|
|
461
478
|
vt as updatePricesInPlace,
|
|
462
479
|
x as updateProductContentInPlace,
|
|
463
480
|
xt as updateSingleProductContent
|