@useinsider/guido 3.22.0-beta.e1b5da2 → 3.22.0-beta.e9b6f94
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 +35 -4
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +118 -108
- package/dist/composables/useEditorOpenMetrics.js +167 -0
- package/dist/composables/useStripo.js +93 -82
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -22
- package/dist/config/migrator/recommendation/compositionMapper.js +49 -56
- package/dist/config/migrator/recommendation/extractors.js +40 -100
- package/dist/config/migrator/recommendation/htmlBuilder.js +207 -285
- package/dist/config/migrator/recommendation/settingsMapper.js +36 -37
- package/dist/config/migrator/recommendation/themeMapper.js +41 -53
- package/dist/config/migrator/recommendationMigrator.js +61 -68
- package/dist/config/migrator/unsubscribeMigrator.js +60 -87
- package/dist/extensions/Blocks/Recommendation/block.js +24 -33
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +19 -20
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +163 -148
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +22 -23
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +18 -19
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +91 -82
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +2 -3
- package/dist/guido.css +1 -1
- package/dist/library.js +12 -10
- package/dist/package.json.js +6 -4
- package/dist/public/prefetchRuntime.js +4 -0
- package/dist/src/composables/useEditorOpenMetrics.d.ts +27 -0
- package/dist/src/composables/useStripo.d.ts +2 -1
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +1 -3
- package/dist/src/config/migrator/recommendation/extractors.d.ts +6 -35
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +1 -3
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +1 -3
- package/dist/src/config/migrator/recommendation/types.d.ts +1 -11
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +8 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +13 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +19 -2
- package/dist/src/library.d.ts +1 -0
- package/dist/src/public/prefetchRuntime.d.ts +1 -0
- package/dist/src/utils/runtimePrefetch.d.ts +4 -0
- package/dist/src/utils/stripoRuntime.d.ts +3 -0
- package/dist/static/stripo-runtime-manifest.json.js +9 -0
- package/dist/utils/runtimePrefetch.js +26 -0
- package/dist/utils/stripoRuntime.js +13 -0
- package/package.json +6 -1
- package/dist/extensions/Blocks/Recommendation/utils/inlinePriceOrder.js +0 -12
- package/dist/src/extensions/Blocks/Recommendation/utils/inlinePriceOrder.d.ts +0 -9
|
@@ -1,73 +1,72 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { ModificationDescription as
|
|
6
|
-
import { CommonControl as
|
|
7
|
-
import { RRS_CONFIG_VERSION as
|
|
8
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
9
|
-
import { RecommendationConfigService as
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
import { refreshBlockOutsidePanel as
|
|
12
|
-
import {
|
|
13
|
-
import { registerNodeConfigWriter as b, writeBlockConfigOutsidePanel as p, hasEditedConfigChange as B, pickConfigDescription as F, isProductIdsChange as D, PRODUCT_IDS_DESCRIPTION as L } from "../../utils/nodeConfigWriter.js";
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var N = (u, d, e) => d in u ? _(u, d, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[d] = e;
|
|
3
|
+
var s = (u, d, e) => N(u, typeof d != "symbol" ? d + "" : d, e);
|
|
4
|
+
import { useConfig as g } from "../../../../../composables/useConfig.js";
|
|
5
|
+
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
+
import { CommonControl as P } from "../../../common-control.js";
|
|
7
|
+
import { RRS_CONFIG_VERSION as R, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
9
|
+
import { RecommendationConfigService as l } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as k } from "../../store/recommendation.js";
|
|
11
|
+
import { refreshBlockOutsidePanel as S } from "../../utils/blockRefresh.js";
|
|
12
|
+
import { registerNodeConfigWriter as T, writeBlockConfigOutsidePanel as m, hasEditedConfigChange as O, pickConfigDescription as b, isProductIdsChange as B, PRODUCT_IDS_DESCRIPTION as F } from "../../utils/nodeConfigWriter.js";
|
|
14
13
|
import { AlgorithmControl as E } from "./algorithm.js";
|
|
15
|
-
import { ALGORITHM_CONTROL_ID as
|
|
16
|
-
import { CurrencyControl as
|
|
17
|
-
import { CURRENCY_CONTROL_ID as
|
|
18
|
-
import { FiltersControl as
|
|
19
|
-
import { FILTERS_CONTROL_ID as
|
|
20
|
-
import { LayoutOrientationControl as
|
|
21
|
-
import { LAYOUT_ORIENTATION_CONTROL_ID as
|
|
22
|
-
import { LocaleControl as
|
|
23
|
-
import { LOCALE_CONTROL_ID as
|
|
24
|
-
import { PricePlacementControl as
|
|
25
|
-
import { PRICE_PLACEMENT_CONTROL_ID as
|
|
26
|
-
import { ProductCountControl as
|
|
27
|
-
import { PRODUCT_COUNT_CONTROL_ID as
|
|
28
|
-
import { ProductLayoutControl as
|
|
29
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
30
|
-
import { ShuffleControl as
|
|
31
|
-
import { SHUFFLE_CONTROL_ID as
|
|
32
|
-
import { StrategyControl as
|
|
33
|
-
import { STRATEGY_CONTROL_ID as
|
|
34
|
-
import { setCurrencyAttributes as
|
|
35
|
-
import { adjustProductsToSize as
|
|
36
|
-
import { useDebounceFn as
|
|
37
|
-
const
|
|
38
|
-
class
|
|
14
|
+
import { ALGORITHM_CONTROL_ID as _e } from "./algorithm.js";
|
|
15
|
+
import { CurrencyControl as L } from "./currency.js";
|
|
16
|
+
import { CURRENCY_CONTROL_ID as ye } from "./currency.js";
|
|
17
|
+
import { FiltersControl as D } from "./filters.js";
|
|
18
|
+
import { FILTERS_CONTROL_ID as Re } from "./filters.js";
|
|
19
|
+
import { LayoutOrientationControl as U } from "./layoutOrientation.js";
|
|
20
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as ke } from "./layoutOrientation.js";
|
|
21
|
+
import { LocaleControl as v } from "./locale.js";
|
|
22
|
+
import { LOCALE_CONTROL_ID as Te } from "./locale.js";
|
|
23
|
+
import { PricePlacementControl as w } from "./pricePlacement.js";
|
|
24
|
+
import { PRICE_PLACEMENT_CONTROL_ID as be } from "./pricePlacement.js";
|
|
25
|
+
import { ProductCountControl as A } from "./productCount.js";
|
|
26
|
+
import { PRODUCT_COUNT_CONTROL_ID as Fe } from "./productCount.js";
|
|
27
|
+
import { ProductLayoutControl as V } from "./productLayout.js";
|
|
28
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Le } from "./productLayout.js";
|
|
29
|
+
import { ShuffleControl as W } from "./shuffle.js";
|
|
30
|
+
import { SHUFFLE_CONTROL_ID as Ue } from "./shuffle.js";
|
|
31
|
+
import { StrategyControl as x } from "./strategy.js";
|
|
32
|
+
import { STRATEGY_CONTROL_ID as we } from "./strategy.js";
|
|
33
|
+
import { setCurrencyAttributes as M, getBlockElement as G, isPartnerManagedBlock as z, updateProductContentInPlace as $, regenerateProductRowsWithStyles as H } from "./utils.js";
|
|
34
|
+
import { adjustProductsToSize as Ve, formatProductPrice as We, getCardComposition as xe, getCurrentLayout as Me, getMainContainerTbody as Ge, regenerateMobileProductRows as ze, updatePricesInPlace as $e, updateSingleProductContent as He } from "./utils.js";
|
|
35
|
+
import { useDebounceFn as C } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
36
|
+
const f = "Update recommendation filters", Y = "ui-elements-recommendation-block";
|
|
37
|
+
class me extends P {
|
|
39
38
|
constructor() {
|
|
40
39
|
super(...arguments);
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
s(this, "store", k());
|
|
41
|
+
s(this, "storeUnsubscription", () => {
|
|
43
42
|
});
|
|
44
43
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
45
44
|
// re-render's single apply() — one user action must cost one undo press.
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
s(this, "pendingNodeConfigWrite", null);
|
|
46
|
+
s(this, "pendingConfigFlushTimer", null);
|
|
48
47
|
// What the panel still owes the block it watches — finished outside the panel on teardown
|
|
49
48
|
// and block switch. A new generation tells debounced work queued for the old one to stand down.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
s(this, "trackedBlockId", null);
|
|
50
|
+
s(this, "fetchedConfigVersion", 0);
|
|
51
|
+
s(this, "hasUnrenderedProducts", !1);
|
|
52
|
+
s(this, "panelGeneration", 0);
|
|
53
|
+
s(this, "isPanelAlive", !0);
|
|
55
54
|
// Sub-control instances for lifecycle management
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
s(this, "algorithmControl", null);
|
|
56
|
+
s(this, "localeControl", null);
|
|
57
|
+
s(this, "currencyControl", null);
|
|
58
|
+
s(this, "productCountControl", null);
|
|
59
|
+
s(this, "productLayoutControl", null);
|
|
60
|
+
s(this, "filtersControl", null);
|
|
61
|
+
s(this, "shuffleControl", null);
|
|
62
|
+
s(this, "pricePlacementControl", null);
|
|
63
|
+
s(this, "layoutOrientationControl", null);
|
|
64
|
+
s(this, "strategyControl", null);
|
|
65
|
+
s(this, "rrsEnabled", !1);
|
|
67
66
|
/**
|
|
68
67
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
69
68
|
*/
|
|
70
|
-
|
|
69
|
+
s(this, "_debouncedFetchProducts", C(async (e, t) => {
|
|
71
70
|
if (t !== this.panelGeneration)
|
|
72
71
|
return;
|
|
73
72
|
const o = this._getBlockConfigVersion(e);
|
|
@@ -88,7 +87,7 @@ class _e extends I {
|
|
|
88
87
|
* count. The store pads products to the configured size, so in-place only
|
|
89
88
|
* fails when the size actually changed.
|
|
90
89
|
*/
|
|
91
|
-
|
|
90
|
+
s(this, "_debouncedRegenerateWithProducts", C((e) => {
|
|
92
91
|
if (e !== this.panelGeneration || !this.currentNode || !this.api)
|
|
93
92
|
return;
|
|
94
93
|
const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
|
|
@@ -107,7 +106,7 @@ class _e extends I {
|
|
|
107
106
|
}, 100));
|
|
108
107
|
}
|
|
109
108
|
getId() {
|
|
110
|
-
return
|
|
109
|
+
return Y;
|
|
111
110
|
}
|
|
112
111
|
get _subControls() {
|
|
113
112
|
return [
|
|
@@ -125,10 +124,10 @@ class _e extends I {
|
|
|
125
124
|
}
|
|
126
125
|
getTemplate() {
|
|
127
126
|
var e;
|
|
128
|
-
return this.rrsEnabled =
|
|
127
|
+
return this.rrsEnabled = g().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
129
128
|
var o;
|
|
130
129
|
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
131
|
-
}), this.algorithmControl = new E(), this.localeControl = new
|
|
130
|
+
}), this.algorithmControl = new E(), this.localeControl = new v(), this.currencyControl = new L(), this.productCountControl = new A(), this.productLayoutControl = new V(), this.filtersControl = new D(), this.shuffleControl = new W(), this.pricePlacementControl = new w(), this.layoutOrientationControl = new U(), this.strategyControl = this.rrsEnabled ? new x() : null, this._subControls.forEach((t) => {
|
|
132
131
|
t && (t.api = this.api);
|
|
133
132
|
}), `
|
|
134
133
|
<div class="recommendation-controls-container">
|
|
@@ -146,16 +145,16 @@ class _e extends I {
|
|
|
146
145
|
`;
|
|
147
146
|
}
|
|
148
147
|
_showControlsForBlock(e) {
|
|
149
|
-
var
|
|
150
|
-
const t = (
|
|
148
|
+
var r;
|
|
149
|
+
const t = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
|
|
151
150
|
if (!t)
|
|
152
151
|
return;
|
|
153
|
-
const o = this._getRecommendationIdFromNode(e) === null ? null :
|
|
152
|
+
const o = this._getRecommendationIdFromNode(e) === null ? null : l.getConfig(e), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= R), i = this.rrsEnabled && !!o && !n;
|
|
154
153
|
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", i);
|
|
155
154
|
}
|
|
156
155
|
async onRender() {
|
|
157
156
|
var o;
|
|
158
|
-
|
|
157
|
+
T(this.api);
|
|
159
158
|
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
160
159
|
if (t !== null && this.store.setCurrentBlock(t), e !== null && this._syncNodeConfigIfChanged(e), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), t !== null && ((o = this.store.blockStates[t]) != null && o.isInitialized)) {
|
|
161
160
|
this._initializeSubControls();
|
|
@@ -220,13 +219,13 @@ class _e extends I {
|
|
|
220
219
|
const t = this.store.blockStates[e];
|
|
221
220
|
if (!t)
|
|
222
221
|
return;
|
|
223
|
-
const o = JSON.stringify(
|
|
222
|
+
const o = JSON.stringify(l.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
|
|
224
223
|
t.syncedConfigFingerprint = o, n !== o && ((i = this.pendingNodeConfigWrite) == null ? void 0 : i.blockId) !== e && this._syncNodeConfigToStore();
|
|
225
224
|
}
|
|
226
225
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
227
226
|
_isPendingStrategyIdChange() {
|
|
228
227
|
const e = this.pendingNodeConfigWrite;
|
|
229
|
-
return e ?
|
|
228
|
+
return e ? l.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
|
|
230
229
|
}
|
|
231
230
|
_capturePendingNodeConfigWrite() {
|
|
232
231
|
const e = this.store.currentRecommendationId, t = e === null ? void 0 : this.store.blockStates[e];
|
|
@@ -241,15 +240,15 @@ class _e extends I {
|
|
|
241
240
|
return !e || t !== null && e.blockId !== t ? null : e;
|
|
242
241
|
}
|
|
243
242
|
_getNodeConfigUpdates(e) {
|
|
244
|
-
const { filters: t, strategy: o, strategyId: n, size: i, productIds:
|
|
243
|
+
const { filters: t, strategy: o, strategyId: n, size: i, productIds: r, nodeConfigVersion: h } = e, { partnerName: c } = g();
|
|
245
244
|
return {
|
|
246
245
|
filters: t,
|
|
247
246
|
strategy: o,
|
|
248
247
|
strategyId: n,
|
|
249
248
|
size: i,
|
|
250
|
-
productIds:
|
|
251
|
-
configVersion:
|
|
252
|
-
...
|
|
249
|
+
productIds: r,
|
|
250
|
+
configVersion: h,
|
|
251
|
+
...c.value ? { partnerName: c.value } : {}
|
|
253
252
|
};
|
|
254
253
|
}
|
|
255
254
|
/**
|
|
@@ -264,7 +263,7 @@ class _e extends I {
|
|
|
264
263
|
*/
|
|
265
264
|
_stagePendingNodeConfig(e) {
|
|
266
265
|
const t = this._pendingWriteForNode();
|
|
267
|
-
return !t || !this.currentNode ? !1 : (
|
|
266
|
+
return !t || !this.currentNode ? !1 : (l.stageConfig(e, this.currentNode, t.updates), !0);
|
|
268
267
|
}
|
|
269
268
|
/**
|
|
270
269
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -289,14 +288,14 @@ class _e extends I {
|
|
|
289
288
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !(!e || !this.api)) {
|
|
290
289
|
if (e.blockId !== this.store.currentRecommendationId || !this.currentNode) {
|
|
291
290
|
const { blockId: t, updates: o } = e;
|
|
292
|
-
!
|
|
291
|
+
!m(t, o, f) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
|
|
293
292
|
return;
|
|
294
293
|
}
|
|
295
|
-
|
|
294
|
+
O(this.currentNode, e.updates) && l.updateConfig(
|
|
296
295
|
this.api,
|
|
297
296
|
this.currentNode,
|
|
298
297
|
e.updates,
|
|
299
|
-
|
|
298
|
+
b(this.currentNode, e.updates, f)
|
|
300
299
|
);
|
|
301
300
|
}
|
|
302
301
|
}
|
|
@@ -307,14 +306,14 @@ class _e extends I {
|
|
|
307
306
|
/** The Product Ids label when the pending write moves the node's ids; the caller's default otherwise. */
|
|
308
307
|
_pendingDescription() {
|
|
309
308
|
const e = this._pendingWriteForNode();
|
|
310
|
-
if (!(!e || !this.currentNode || !
|
|
311
|
-
return
|
|
309
|
+
if (!(!e || !this.currentNode || !B(this.currentNode, e.updates)))
|
|
310
|
+
return F;
|
|
312
311
|
}
|
|
313
312
|
_syncNodeConfigToStore() {
|
|
314
313
|
var n;
|
|
315
|
-
const e =
|
|
314
|
+
const e = l.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
316
315
|
this.store.patchCurrentBlockConfig({
|
|
317
|
-
strategy:
|
|
316
|
+
strategy: e.strategy,
|
|
318
317
|
strategyId: e.strategyId,
|
|
319
318
|
nodeConfigVersion: e.configVersion,
|
|
320
319
|
language: e.language,
|
|
@@ -374,45 +373,61 @@ class _e extends I {
|
|
|
374
373
|
return this.isPanelAlive && this.store.currentRecommendationId === e;
|
|
375
374
|
}
|
|
376
375
|
/**
|
|
377
|
-
*
|
|
378
|
-
*
|
|
376
|
+
* Applies smart defaults for newly dropped blocks.
|
|
377
|
+
*
|
|
378
|
+
* For new blocks (config still matches hardcoded defaults), validates that
|
|
379
|
+
* the default currency and algorithm are available from the API response.
|
|
380
|
+
* If not, falls back to the first available option.
|
|
381
|
+
*
|
|
382
|
+
* Saved templates with user-customized config are left unchanged because
|
|
383
|
+
* their values won't match the hardcoded defaults.
|
|
379
384
|
*/
|
|
380
385
|
_applySmartDefaults() {
|
|
381
386
|
if (!this.currentNode || !this.api)
|
|
382
387
|
return;
|
|
383
|
-
const e =
|
|
388
|
+
const e = l.getConfig(this.currentNode), t = {};
|
|
384
389
|
let o = null, n = null, i = null;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
390
|
+
if (e.currency.code === a.currency.code) {
|
|
391
|
+
const { currencyList: r } = this.store;
|
|
392
|
+
r.length > 0 && (r.some(
|
|
393
|
+
(c) => c.value === `price.${a.currency.code}`
|
|
394
|
+
) || (o = r[0].value.replace("price.", ""), t.currency = {
|
|
395
|
+
...a.currency,
|
|
396
|
+
code: o,
|
|
397
|
+
symbol: o
|
|
398
|
+
}));
|
|
399
|
+
}
|
|
400
|
+
if (e.strategy === a.strategy) {
|
|
401
|
+
const r = this.store.getActivePredictiveAlgorithms;
|
|
402
|
+
r.length > 0 && (r.some(
|
|
403
|
+
(c) => c.value === a.strategy
|
|
404
|
+
) || (n = r[0].value, t.strategy = n));
|
|
405
|
+
}
|
|
406
|
+
if (e.language === a.language) {
|
|
407
|
+
const r = this.store.getLanguages;
|
|
408
|
+
r.length > 0 && (r.some(
|
|
409
|
+
(c) => c.value === a.language
|
|
410
|
+
) || (i = r[0].value, t.language = i));
|
|
395
411
|
}
|
|
396
|
-
|
|
397
|
-
l.length > 0 && !l.some((a) => a.value === e.language) && (i = l[0].value, t.language = i), !(!o && !n && !i) && (d.updateConfig(
|
|
412
|
+
!o && !n && !i || (l.updateConfig(
|
|
398
413
|
this.api,
|
|
399
414
|
this.currentNode,
|
|
400
415
|
t,
|
|
401
416
|
"Applied smart defaults"
|
|
402
|
-
), o && t.currency &&
|
|
417
|
+
), o && t.currency && M({
|
|
403
418
|
currentNode: this.currentNode,
|
|
404
419
|
documentModifier: this.api.getDocumentModifier(),
|
|
405
420
|
currency: t.currency
|
|
406
421
|
}), this.store.patchCurrentBlockConfig({
|
|
407
|
-
...o
|
|
422
|
+
...o ? {
|
|
408
423
|
currencySettings: {
|
|
409
424
|
name: o,
|
|
410
425
|
value: o,
|
|
411
426
|
symbol: o,
|
|
412
|
-
alignment:
|
|
413
|
-
decimalCount:
|
|
414
|
-
decimalSeparator:
|
|
415
|
-
thousandSeparator:
|
|
427
|
+
alignment: a.currency.alignment === "before" ? "0" : "1",
|
|
428
|
+
decimalCount: a.currency.decimalCount.toString(),
|
|
429
|
+
decimalSeparator: a.currency.decimalSeparator,
|
|
430
|
+
thousandSeparator: a.currency.thousandSeparator
|
|
416
431
|
}
|
|
417
432
|
} : {},
|
|
418
433
|
...n ? { strategy: n } : {},
|
|
@@ -423,10 +438,10 @@ class _e extends I {
|
|
|
423
438
|
* Reads the recommendation-id attribute from the block element within the node
|
|
424
439
|
*/
|
|
425
440
|
_getRecommendationIdFromNode(e) {
|
|
426
|
-
const t =
|
|
441
|
+
const t = G(e);
|
|
427
442
|
if (!t || !("getAttribute" in t))
|
|
428
443
|
return null;
|
|
429
|
-
const o = t.getAttribute(
|
|
444
|
+
const o = t.getAttribute(I);
|
|
430
445
|
if (!o)
|
|
431
446
|
return null;
|
|
432
447
|
const n = parseInt(o);
|
|
@@ -443,10 +458,10 @@ class _e extends I {
|
|
|
443
458
|
if (e === null || !n)
|
|
444
459
|
return;
|
|
445
460
|
const i = t !== n.configVersion;
|
|
446
|
-
i && !
|
|
461
|
+
i && !m(
|
|
447
462
|
e,
|
|
448
463
|
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
449
|
-
|
|
464
|
+
f
|
|
450
465
|
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i || o) && this._refreshOutsidePanel(e, i);
|
|
451
466
|
} catch (n) {
|
|
452
467
|
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
@@ -460,7 +475,7 @@ class _e extends I {
|
|
|
460
475
|
};
|
|
461
476
|
}
|
|
462
477
|
_refreshOutsidePanel(e, t) {
|
|
463
|
-
|
|
478
|
+
S(e, {
|
|
464
479
|
pickUpdates: (o) => this._getNodeConfigUpdates(o),
|
|
465
480
|
description: "Update recommendation configuration",
|
|
466
481
|
fetch: t
|
|
@@ -483,19 +498,19 @@ class _e extends I {
|
|
|
483
498
|
return;
|
|
484
499
|
}
|
|
485
500
|
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = this._pendingDescription(), n = this._stagePendingNodeConfig(t);
|
|
486
|
-
if (
|
|
501
|
+
if (z(this.currentNode)) {
|
|
487
502
|
n && (t.apply(
|
|
488
|
-
new
|
|
503
|
+
new y(o ?? "Update recommendation configuration")
|
|
489
504
|
), this._consumePendingNodeConfig());
|
|
490
505
|
return;
|
|
491
506
|
}
|
|
492
|
-
|
|
507
|
+
$({
|
|
493
508
|
currentNode: this.currentNode,
|
|
494
509
|
documentModifier: t,
|
|
495
510
|
products: e,
|
|
496
511
|
description: o,
|
|
497
512
|
onApplied: n ? () => this._consumePendingNodeConfig() : void 0
|
|
498
|
-
}) ||
|
|
513
|
+
}) || H({
|
|
499
514
|
currentNode: this.currentNode,
|
|
500
515
|
documentModifier: t,
|
|
501
516
|
products: e,
|
|
@@ -526,51 +541,51 @@ class _e extends I {
|
|
|
526
541
|
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
|
|
527
542
|
const n = e.currentRecommendationId;
|
|
528
543
|
if (n !== this.trackedBlockId) {
|
|
529
|
-
const
|
|
530
|
-
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(
|
|
544
|
+
const p = this._trackedBlockSnapshot();
|
|
545
|
+
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(p);
|
|
531
546
|
return;
|
|
532
547
|
}
|
|
533
548
|
const i = this._getBlockConfigVersion(n);
|
|
534
549
|
i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, this.panelGeneration));
|
|
535
|
-
const
|
|
536
|
-
|
|
550
|
+
const r = e.recommendationProducts, h = r !== t, c = Array.isArray(r) && r.length > 0;
|
|
551
|
+
h && c && (t = r, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
|
|
537
552
|
});
|
|
538
553
|
}
|
|
539
554
|
}
|
|
540
555
|
export {
|
|
541
|
-
|
|
556
|
+
_e as ALGORITHM_CONTROL_ID,
|
|
542
557
|
E as AlgorithmControl,
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
558
|
+
Y as CONTROL_BLOCK_ID,
|
|
559
|
+
ye as CURRENCY_CONTROL_ID,
|
|
560
|
+
L as CurrencyControl,
|
|
561
|
+
Re as FILTERS_CONTROL_ID,
|
|
562
|
+
D as FiltersControl,
|
|
563
|
+
ke as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
564
|
+
Te as LOCALE_CONTROL_ID,
|
|
565
|
+
U as LayoutOrientationControl,
|
|
566
|
+
v as LocaleControl,
|
|
567
|
+
be as PRICE_PLACEMENT_CONTROL_ID,
|
|
568
|
+
Fe as PRODUCT_COUNT_CONTROL_ID,
|
|
569
|
+
Le as PRODUCT_LAYOUT_CONTROL_ID,
|
|
570
|
+
w as PricePlacementControl,
|
|
571
|
+
A as ProductCountControl,
|
|
572
|
+
V as ProductLayoutControl,
|
|
573
|
+
me as RecommendationBlockControl,
|
|
574
|
+
Ue as SHUFFLE_CONTROL_ID,
|
|
575
|
+
we as STRATEGY_CONTROL_ID,
|
|
576
|
+
W as ShuffleControl,
|
|
577
|
+
x as StrategyControl,
|
|
578
|
+
Ve as adjustProductsToSize,
|
|
579
|
+
We as formatProductPrice,
|
|
580
|
+
G as getBlockElement,
|
|
581
|
+
xe as getCardComposition,
|
|
582
|
+
Me as getCurrentLayout,
|
|
583
|
+
Ge as getMainContainerTbody,
|
|
584
|
+
z as isPartnerManagedBlock,
|
|
585
|
+
ze as regenerateMobileProductRows,
|
|
586
|
+
H as regenerateProductRowsWithStyles,
|
|
587
|
+
M as setCurrencyAttributes,
|
|
588
|
+
$e as updatePricesInPlace,
|
|
589
|
+
$ as updateProductContentInPlace,
|
|
590
|
+
He as updateSingleProductContent
|
|
576
591
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ATTR_PRODUCT_PRICE as
|
|
1
|
+
import { ATTR_PRODUCT_PRICE as f, ATTR_PRODUCT_OLD_PRICE as O } from "../../constants/selectors.js";
|
|
2
2
|
import { DEFAULT_PRODUCTS_PER_ROW as w } from "../../constants/layout.js";
|
|
3
|
-
import { createBlockTemplate as A, getDefaultProducts as g, DEFAULTS as U, buildSpacer as h, DEFAULT_CARD_COMPOSITION as Y, buildElementRenderer as B, buildCellOptions as
|
|
4
|
-
import { DEFAULT_CELL_PADDING as
|
|
5
|
-
import { resolveInlinePriceOrder as y } from "../../utils/inlinePriceOrder.js";
|
|
3
|
+
import { createBlockTemplate as A, getDefaultProducts as g, DEFAULTS as U, buildSpacer as h, DEFAULT_CARD_COMPOSITION as Y, buildElementRenderer as B, resolveInlinePriceOrder as F, buildCellOptions as I, DEFAULT_CARD_VISIBILITY as W } from "../utils.js";
|
|
4
|
+
import { DEFAULT_CELL_PADDING as k, renderInlineGridPriceCell as H, buildFillerCell as x, gridElementRenderer as y } from "./elementRenderer.js";
|
|
6
5
|
const G = `
|
|
7
6
|
<tr class="recommendation-product-row">
|
|
8
7
|
<td>
|
|
@@ -29,29 +28,29 @@ const G = `
|
|
|
29
28
|
{-{-CELLS-}-}
|
|
30
29
|
</tr>
|
|
31
30
|
`;
|
|
32
|
-
function j(t, r,
|
|
33
|
-
const { cellPadding: s =
|
|
34
|
-
return L.filter((l) =>
|
|
35
|
-
const _ = (a == null ? void 0 : a[l]) ??
|
|
31
|
+
function j(t, r, o, e = Y, c = {}, i = {}) {
|
|
32
|
+
const { cellPadding: s = k, cardBackgroundColor: u, visibility: a, priceInline: n = !1 } = i, d = (100 / r).toFixed(2), p = r - t.length, T = p > 0 ? x(d, s).repeat(p) : "", m = B(o, e, c), R = F(e), L = n ? e.filter((l) => l !== R.skip) : e, C = I(f, i), P = I(O, i);
|
|
33
|
+
return L.filter((l) => m[l]).map((l) => {
|
|
34
|
+
const _ = (a == null ? void 0 : a[l]) ?? W[l] ?? !0, b = _ ? "" : 'style="display: none;"', S = I(l, i, e), D = t.map((E) => (n && l === R.anchor ? H(
|
|
36
35
|
E,
|
|
37
36
|
R.originalFirst,
|
|
38
37
|
C,
|
|
39
38
|
P,
|
|
40
39
|
u
|
|
41
|
-
) :
|
|
42
|
-
return V.replace("{-{-ATTR_TYPE-}-}", l).replace("{-{-VISIBILITY-}-}", _ ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", b).replace("{-{-CELLS-}-}",
|
|
40
|
+
) : m[l](E, S)).replace("<td", `<td width="${d}%"`)).join("");
|
|
41
|
+
return V.replace("{-{-ATTR_TYPE-}-}", l).replace("{-{-VISIBILITY-}-}", _ ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", b).replace("{-{-CELLS-}-}", D + T);
|
|
43
42
|
}).join("");
|
|
44
43
|
}
|
|
45
|
-
function v(t, r,
|
|
44
|
+
function v(t, r, o, e, c = {}, i = {}) {
|
|
46
45
|
const s = [];
|
|
47
|
-
for (let
|
|
48
|
-
s.push(t.slice(
|
|
46
|
+
for (let n = 0; n < t.length; n += r)
|
|
47
|
+
s.push(t.slice(n, n + r));
|
|
49
48
|
const u = h(i.rowSpacingPx);
|
|
50
|
-
return s.map((
|
|
49
|
+
return s.map((n, d) => {
|
|
51
50
|
const p = j(
|
|
52
|
-
o,
|
|
53
|
-
r,
|
|
54
51
|
n,
|
|
52
|
+
r,
|
|
53
|
+
o,
|
|
55
54
|
e,
|
|
56
55
|
c,
|
|
57
56
|
i
|
|
@@ -59,22 +58,22 @@ function v(t, r, n, e, c = {}, i = {}) {
|
|
|
59
58
|
return d > 0 ? u + T : T;
|
|
60
59
|
}).join("");
|
|
61
60
|
}
|
|
62
|
-
function M(t, r,
|
|
61
|
+
function M(t, r, o, e = {}, c = {}) {
|
|
63
62
|
return v(
|
|
64
63
|
t,
|
|
65
64
|
r,
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
y,
|
|
66
|
+
o,
|
|
68
67
|
e,
|
|
69
68
|
c
|
|
70
69
|
);
|
|
71
70
|
}
|
|
72
|
-
function
|
|
73
|
-
const r = t ? `ins-recommendation-v3-block-${t}` : void 0,
|
|
74
|
-
return
|
|
71
|
+
function Q(t) {
|
|
72
|
+
const r = t ? `ins-recommendation-v3-block-${t}` : void 0, o = A("grid", r), e = g(), c = M(e, w);
|
|
73
|
+
return o.replace("{-{-TITLE-}-}", U.TITLE).replace("{-{-PRODUCT_ROWS-}-}", c).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
|
|
75
74
|
}
|
|
76
75
|
export {
|
|
77
|
-
|
|
76
|
+
Q as getDefaultTemplate,
|
|
78
77
|
j as prepareGridAttributeRows,
|
|
79
78
|
v as prepareGridProductRows,
|
|
80
79
|
M as prepareProductRows
|