@useinsider/guido 3.21.0-beta.0df5409 → 3.21.0-beta.23f347e
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/useActionsApi.js +63 -80
- package/dist/composables/useGuidoStateBridge.js +3 -3
- package/dist/composables/useStripo.js +8 -8
- package/dist/config/compiler/htmlCompilerRules.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +29 -33
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +83 -78
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +2 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +12 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +86 -104
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +210 -222
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +50 -48
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +21 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +40 -44
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +19 -14
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +119 -112
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +23 -18
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +231 -257
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +20 -24
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +7 -6
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +151 -113
- package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +11 -20
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +50 -106
- package/dist/package.json.js +1 -1
- package/dist/src/composables/useActionsApi.d.ts +1 -5
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +6 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +5 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +11 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +3 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +5 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +8 -8
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +11 -21
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +13 -19
- package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +8 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +5 -9
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +13 -13
- package/dist/src/stores/editor.d.ts +1 -3
- package/dist/static/styles/components/tabs.css.js +5 -0
- package/dist/stores/editor.js +0 -5
- package/package.json +2 -2
- package/dist/extensions/Blocks/Recommendation/utils/currencySettings.js +0 -25
- package/dist/src/extensions/Blocks/Recommendation/utils/currencySettings.d.ts +0 -6
|
@@ -1,75 +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 {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
class _e extends R {
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var y = (h, c, e) => c in h ? _(h, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[c] = e;
|
|
3
|
+
var i = (h, c, e) => y(h, typeof c != "symbol" ? c + "" : c, e);
|
|
4
|
+
import { useConfig as g } from "../../../../../composables/useConfig.js";
|
|
5
|
+
import { ModificationDescription as N } 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 k } from "../../constants/selectors.js";
|
|
9
|
+
import { RecommendationConfigService as l } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
|
|
11
|
+
import { refreshBlockOutsidePanel as S } from "../../utils/blockRefresh.js";
|
|
12
|
+
import { registerNodeConfigWriter as T, writeBlockConfigOutsidePanel as m, hasEditedConfigChange as b } from "../../utils/nodeConfigWriter.js";
|
|
13
|
+
import { AlgorithmControl as O } from "./algorithm.js";
|
|
14
|
+
import { ALGORITHM_CONTROL_ID as me } from "./algorithm.js";
|
|
15
|
+
import { CurrencyControl as B } from "./currency.js";
|
|
16
|
+
import { CURRENCY_CONTROL_ID as pe } from "./currency.js";
|
|
17
|
+
import { FiltersControl as L } from "./filters.js";
|
|
18
|
+
import { FILTERS_CONTROL_ID as ye } from "./filters.js";
|
|
19
|
+
import { LayoutOrientationControl as E } from "./layoutOrientation.js";
|
|
20
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as Pe } from "./layoutOrientation.js";
|
|
21
|
+
import { LocaleControl as F } from "./locale.js";
|
|
22
|
+
import { LOCALE_CONTROL_ID as ke } from "./locale.js";
|
|
23
|
+
import { PricePlacementControl as D } from "./pricePlacement.js";
|
|
24
|
+
import { PRICE_PLACEMENT_CONTROL_ID as Se } from "./pricePlacement.js";
|
|
25
|
+
import { ProductCountControl as U } from "./productCount.js";
|
|
26
|
+
import { PRODUCT_COUNT_CONTROL_ID as be } from "./productCount.js";
|
|
27
|
+
import { ProductLayoutControl as v } from "./productLayout.js";
|
|
28
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Be } from "./productLayout.js";
|
|
29
|
+
import { ShuffleControl as w } from "./shuffle.js";
|
|
30
|
+
import { SHUFFLE_CONTROL_ID as Ee } from "./shuffle.js";
|
|
31
|
+
import { StrategyControl as A } from "./strategy.js";
|
|
32
|
+
import { STRATEGY_CONTROL_ID as De } from "./strategy.js";
|
|
33
|
+
import { setCurrencyAttributes as V, getBlockElement as x, isPartnerManagedBlock as W, updateProductContentInPlace as M, regenerateProductRowsWithStyles as G } from "./utils.js";
|
|
34
|
+
import { adjustProductsToSize as ve, formatProductPrice as we, getCardComposition as Ae, getCurrentLayout as Ve, getMainContainerTbody as xe, regenerateMobileProductRows as We, updatePricesInPlace as Me, updateSingleProductContent as Ge } from "./utils.js";
|
|
35
|
+
import { useDebounceFn as C } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
36
|
+
const f = "Update recommendation filters", z = "ui-elements-recommendation-block";
|
|
37
|
+
class he extends P {
|
|
39
38
|
constructor() {
|
|
40
39
|
super(...arguments);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
s(this, "unregisterConfigFlush", () => {
|
|
40
|
+
i(this, "store", I());
|
|
41
|
+
i(this, "storeUnsubscription", () => {
|
|
45
42
|
});
|
|
46
43
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
47
44
|
// re-render's single apply() — one user action must cost one undo press.
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
i(this, "pendingNodeConfigWrite", null);
|
|
46
|
+
i(this, "pendingConfigFlushTimer", null);
|
|
50
47
|
// What the panel still owes the block it watches — finished outside the panel on teardown
|
|
51
48
|
// and block switch. A new generation tells debounced work queued for the old one to stand down.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
i(this, "trackedBlockId", null);
|
|
50
|
+
i(this, "fetchedConfigVersion", 0);
|
|
51
|
+
i(this, "hasUnrenderedProducts", !1);
|
|
52
|
+
i(this, "panelGeneration", 0);
|
|
53
|
+
i(this, "isPanelAlive", !0);
|
|
57
54
|
// Sub-control instances for lifecycle management
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
i(this, "algorithmControl", null);
|
|
56
|
+
i(this, "localeControl", null);
|
|
57
|
+
i(this, "currencyControl", null);
|
|
58
|
+
i(this, "productCountControl", null);
|
|
59
|
+
i(this, "productLayoutControl", null);
|
|
60
|
+
i(this, "filtersControl", null);
|
|
61
|
+
i(this, "shuffleControl", null);
|
|
62
|
+
i(this, "pricePlacementControl", null);
|
|
63
|
+
i(this, "layoutOrientationControl", null);
|
|
64
|
+
i(this, "strategyControl", null);
|
|
65
|
+
i(this, "rrsEnabled", !1);
|
|
69
66
|
/**
|
|
70
67
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
71
68
|
*/
|
|
72
|
-
|
|
69
|
+
i(this, "_debouncedFetchProducts", C(async (e, t) => {
|
|
73
70
|
if (t !== this.panelGeneration)
|
|
74
71
|
return;
|
|
75
72
|
const o = this._getBlockConfigVersion(e);
|
|
@@ -90,7 +87,7 @@ class _e extends R {
|
|
|
90
87
|
* count. The store pads products to the configured size, so in-place only
|
|
91
88
|
* fails when the size actually changed.
|
|
92
89
|
*/
|
|
93
|
-
|
|
90
|
+
i(this, "_debouncedRegenerateWithProducts", C((e) => {
|
|
94
91
|
if (e !== this.panelGeneration || !this.currentNode || !this.api)
|
|
95
92
|
return;
|
|
96
93
|
const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
|
|
@@ -109,7 +106,7 @@ class _e extends R {
|
|
|
109
106
|
}, 100));
|
|
110
107
|
}
|
|
111
108
|
getId() {
|
|
112
|
-
return
|
|
109
|
+
return z;
|
|
113
110
|
}
|
|
114
111
|
get _subControls() {
|
|
115
112
|
return [
|
|
@@ -127,10 +124,10 @@ class _e extends R {
|
|
|
127
124
|
}
|
|
128
125
|
getTemplate() {
|
|
129
126
|
var e;
|
|
130
|
-
return this.rrsEnabled =
|
|
127
|
+
return this.rrsEnabled = g().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
131
128
|
var o;
|
|
132
129
|
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
133
|
-
}), this.algorithmControl = new
|
|
130
|
+
}), this.algorithmControl = new O(), this.localeControl = new F(), this.currencyControl = new B(), this.productCountControl = new U(), this.productLayoutControl = new v(), this.filtersControl = new L(), this.shuffleControl = new w(), this.pricePlacementControl = new D(), this.layoutOrientationControl = new E(), this.strategyControl = this.rrsEnabled ? new A() : null, this._subControls.forEach((t) => {
|
|
134
131
|
t && (t.api = this.api);
|
|
135
132
|
}), `
|
|
136
133
|
<div class="recommendation-controls-container">
|
|
@@ -148,16 +145,16 @@ class _e extends R {
|
|
|
148
145
|
`;
|
|
149
146
|
}
|
|
150
147
|
_showControlsForBlock(e) {
|
|
151
|
-
var
|
|
152
|
-
const t = (
|
|
148
|
+
var s;
|
|
149
|
+
const t = (s = this.getContainer()) == null ? void 0 : s.querySelector(".recommendation-controls-container");
|
|
153
150
|
if (!t)
|
|
154
151
|
return;
|
|
155
|
-
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), r = this.rrsEnabled && !!o && !n;
|
|
156
153
|
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", r);
|
|
157
154
|
}
|
|
158
155
|
async onRender() {
|
|
159
156
|
var o;
|
|
160
|
-
|
|
157
|
+
T(this.api);
|
|
161
158
|
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
162
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)) {
|
|
163
160
|
this._initializeSubControls();
|
|
@@ -177,7 +174,7 @@ class _e extends R {
|
|
|
177
174
|
});
|
|
178
175
|
}
|
|
179
176
|
onDestroy() {
|
|
180
|
-
this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this.
|
|
177
|
+
this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
|
|
181
178
|
var t;
|
|
182
179
|
return (t = e == null ? void 0 : e.onDestroy) == null ? void 0 : t.call(e);
|
|
183
180
|
});
|
|
@@ -222,66 +219,45 @@ class _e extends R {
|
|
|
222
219
|
const t = this.store.blockStates[e];
|
|
223
220
|
if (!t)
|
|
224
221
|
return;
|
|
225
|
-
const o = JSON.stringify(
|
|
222
|
+
const o = JSON.stringify(l.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
|
|
226
223
|
t.syncedConfigFingerprint = o, n !== o && ((r = this.pendingNodeConfigWrite) == null ? void 0 : r.blockId) !== e && this._syncNodeConfigToStore();
|
|
227
224
|
}
|
|
228
225
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
229
226
|
_isPendingStrategyIdChange() {
|
|
230
|
-
const e = this.
|
|
231
|
-
return e
|
|
227
|
+
const e = this.pendingNodeConfigWrite;
|
|
228
|
+
return e ? l.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
|
|
232
229
|
}
|
|
233
230
|
_capturePendingNodeConfigWrite() {
|
|
234
|
-
const e = this.store.currentRecommendationId;
|
|
235
|
-
!this.currentNode || !this.api || e === null || !
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
_pendingUpdates() {
|
|
240
|
-
const e = this.pendingNodeConfigWrite, t = e ? this.store.blockStates[e.blockId] : void 0;
|
|
241
|
-
return t ? this._getNodeConfigUpdates(t.recommendationConfigs) : null;
|
|
242
|
-
}
|
|
243
|
-
// Another block's pending write must never be staged on, or drive the redraw of, the panel node.
|
|
244
|
-
_pendingUpdatesForCurrentNode() {
|
|
245
|
-
var e;
|
|
246
|
-
return !this.currentNode || ((e = this.pendingNodeConfigWrite) == null ? void 0 : e.blockId) !== this._getRecommendationIdFromNode(this.currentNode) ? null : this._pendingUpdates();
|
|
231
|
+
const e = this.store.currentRecommendationId, t = e === null ? void 0 : this.store.blockStates[e];
|
|
232
|
+
!this.currentNode || !this.api || e === null || !t || (this.pendingNodeConfigWrite = {
|
|
233
|
+
blockId: e,
|
|
234
|
+
updates: this._getNodeConfigUpdates(t.recommendationConfigs)
|
|
235
|
+
});
|
|
247
236
|
}
|
|
248
237
|
_getNodeConfigUpdates(e) {
|
|
249
|
-
const {
|
|
250
|
-
filters: t,
|
|
251
|
-
strategy: o,
|
|
252
|
-
strategyId: n,
|
|
253
|
-
size: r,
|
|
254
|
-
productIds: i,
|
|
255
|
-
language: a,
|
|
256
|
-
shuffleProducts: c,
|
|
257
|
-
currencySettings: g,
|
|
258
|
-
nodeConfigVersion: P
|
|
259
|
-
} = e, { partnerName: f } = m();
|
|
238
|
+
const { filters: t, strategy: o, strategyId: n, size: r, nodeConfigVersion: s } = e, { partnerName: d } = g();
|
|
260
239
|
return {
|
|
261
240
|
filters: t,
|
|
262
241
|
strategy: o,
|
|
263
242
|
strategyId: n,
|
|
264
243
|
size: r,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
shuffleProducts: c,
|
|
268
|
-
currency: B(g),
|
|
269
|
-
configVersion: P,
|
|
270
|
-
...f.value ? { partnerName: f.value } : {}
|
|
244
|
+
configVersion: s,
|
|
245
|
+
...d.value ? { partnerName: d.value } : {}
|
|
271
246
|
};
|
|
272
247
|
}
|
|
273
248
|
/**
|
|
274
249
|
* Accumulates the pending write into `documentModifier` without applying, so the
|
|
275
250
|
* caller's apply() commits config and re-render as ONE undo entry.
|
|
276
|
-
*
|
|
251
|
+
*
|
|
252
|
+
* Deliberately does not consume the pending record: the product helpers call
|
|
253
|
+
* apply() only when they actually changed something, so this batch may never be
|
|
254
|
+
* committed and the flush has to stay able to write it standalone.
|
|
255
|
+
* @param documentModifier - The batch to accumulate into
|
|
256
|
+
* @returns Whether anything was staged
|
|
277
257
|
*/
|
|
278
258
|
_stagePendingNodeConfig(e) {
|
|
279
|
-
const t = this.
|
|
280
|
-
|
|
281
|
-
return _(e, this.currentNode, t), N(d.getConfig(this.currentNode), t);
|
|
282
|
-
}
|
|
283
|
-
_consumePendingNodeConfig() {
|
|
284
|
-
this.pendingNodeConfigWrite = null, this._clearConfigFlush();
|
|
259
|
+
const t = this.pendingNodeConfigWrite;
|
|
260
|
+
return !t || !this.currentNode ? !1 : (l.stageConfig(e, this.currentNode, t.updates), !0);
|
|
285
261
|
}
|
|
286
262
|
/**
|
|
287
263
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -296,25 +272,30 @@ class _e extends R {
|
|
|
296
272
|
_clearConfigFlush() {
|
|
297
273
|
this.pendingConfigFlushTimer !== null && (clearTimeout(this.pendingConfigFlushTimer), this.pendingConfigFlushTimer = null);
|
|
298
274
|
}
|
|
299
|
-
|
|
300
|
-
|
|
275
|
+
/**
|
|
276
|
+
* Writes the deferred change standalone when the batch it was staged into never
|
|
277
|
+
* committed. Always targets a LIVE node — a captured one is an immutable snapshot
|
|
278
|
+
* the intervening re-render staled, and saveConfig swallows that failure.
|
|
279
|
+
*/
|
|
301
280
|
_flushPendingNodeConfig() {
|
|
302
|
-
const e = this.pendingNodeConfigWrite
|
|
303
|
-
if (this.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
281
|
+
const e = this.pendingNodeConfigWrite;
|
|
282
|
+
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !(!e || !this.api)) {
|
|
283
|
+
if (e.blockId !== this.store.currentRecommendationId || !this.currentNode) {
|
|
284
|
+
const { blockId: t, updates: o } = e;
|
|
285
|
+
!m(t, o, f) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
b(this.currentNode, e.updates) && l.updateConfig(
|
|
289
|
+
this.api,
|
|
290
|
+
this.currentNode,
|
|
291
|
+
e.updates,
|
|
292
|
+
f
|
|
293
|
+
);
|
|
308
294
|
}
|
|
309
|
-
const n = N(d.getConfig(this.currentNode), t);
|
|
310
|
-
if (n === null)
|
|
311
|
-
return !1;
|
|
312
|
-
const r = this.api.getDocumentModifier();
|
|
313
|
-
return _(r, this.currentNode, t), r.apply(new C(n)), !0;
|
|
314
295
|
}
|
|
315
296
|
_syncNodeConfigToStore() {
|
|
316
297
|
var n;
|
|
317
|
-
const e =
|
|
298
|
+
const e = l.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
318
299
|
this.store.patchCurrentBlockConfig({
|
|
319
300
|
strategy: e.strategy,
|
|
320
301
|
strategyId: e.strategyId,
|
|
@@ -333,7 +314,15 @@ class _e extends R {
|
|
|
333
314
|
shuffleProducts: e.shuffleProducts,
|
|
334
315
|
priceMovedToNextLine: e.priceMovedToNextLine,
|
|
335
316
|
priceHideIfSameAsDiscounted: e.priceHideIfSameAsDiscounted,
|
|
336
|
-
currencySettings:
|
|
317
|
+
currencySettings: {
|
|
318
|
+
name: e.currency.code,
|
|
319
|
+
value: e.currency.code,
|
|
320
|
+
symbol: e.currency.symbol,
|
|
321
|
+
alignment: e.currency.alignment === "before" ? "0" : "1",
|
|
322
|
+
decimalCount: e.currency.decimalCount.toString(),
|
|
323
|
+
decimalSeparator: e.currency.decimalSeparator,
|
|
324
|
+
thousandSeparator: e.currency.thousandSeparator
|
|
325
|
+
}
|
|
337
326
|
}, { triggerRefetch: !1 });
|
|
338
327
|
}
|
|
339
328
|
/**
|
|
@@ -380,41 +369,51 @@ class _e extends R {
|
|
|
380
369
|
_applySmartDefaults() {
|
|
381
370
|
if (!this.currentNode || !this.api)
|
|
382
371
|
return;
|
|
383
|
-
const e =
|
|
372
|
+
const e = l.getConfig(this.currentNode), t = {};
|
|
384
373
|
let o = null, n = null, r = null;
|
|
385
|
-
if (e.currency.code ===
|
|
386
|
-
const { currencyList:
|
|
387
|
-
|
|
388
|
-
(
|
|
389
|
-
) || (o =
|
|
390
|
-
...
|
|
374
|
+
if (e.currency.code === a.currency.code) {
|
|
375
|
+
const { currencyList: s } = this.store;
|
|
376
|
+
s.length > 0 && (s.some(
|
|
377
|
+
(u) => u.value === `price.${a.currency.code}`
|
|
378
|
+
) || (o = s[0].value.replace("price.", ""), t.currency = {
|
|
379
|
+
...a.currency,
|
|
391
380
|
code: o,
|
|
392
381
|
symbol: o
|
|
393
382
|
}));
|
|
394
383
|
}
|
|
395
|
-
if (e.strategy ===
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
(
|
|
399
|
-
) || (n =
|
|
384
|
+
if (e.strategy === a.strategy) {
|
|
385
|
+
const s = this.store.getActivePredictiveAlgorithms;
|
|
386
|
+
s.length > 0 && (s.some(
|
|
387
|
+
(u) => u.value === a.strategy
|
|
388
|
+
) || (n = s[0].value, t.strategy = n));
|
|
400
389
|
}
|
|
401
|
-
if (e.language ===
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
(
|
|
405
|
-
) || (r =
|
|
390
|
+
if (e.language === a.language) {
|
|
391
|
+
const s = this.store.getLanguages;
|
|
392
|
+
s.length > 0 && (s.some(
|
|
393
|
+
(u) => u.value === a.language
|
|
394
|
+
) || (r = s[0].value, t.language = r));
|
|
406
395
|
}
|
|
407
|
-
!o && !n && !r || (
|
|
396
|
+
!o && !n && !r || (l.updateConfig(
|
|
408
397
|
this.api,
|
|
409
398
|
this.currentNode,
|
|
410
399
|
t,
|
|
411
400
|
"Applied smart defaults"
|
|
412
|
-
), o && t.currency &&
|
|
401
|
+
), o && t.currency && V({
|
|
413
402
|
currentNode: this.currentNode,
|
|
414
403
|
documentModifier: this.api.getDocumentModifier(),
|
|
415
404
|
currency: t.currency
|
|
416
405
|
}), this.store.patchCurrentBlockConfig({
|
|
417
|
-
...o
|
|
406
|
+
...o ? {
|
|
407
|
+
currencySettings: {
|
|
408
|
+
name: o,
|
|
409
|
+
value: o,
|
|
410
|
+
symbol: o,
|
|
411
|
+
alignment: a.currency.alignment === "before" ? "0" : "1",
|
|
412
|
+
decimalCount: a.currency.decimalCount.toString(),
|
|
413
|
+
decimalSeparator: a.currency.decimalSeparator,
|
|
414
|
+
thousandSeparator: a.currency.thousandSeparator
|
|
415
|
+
}
|
|
416
|
+
} : {},
|
|
418
417
|
...n ? { strategy: n } : {},
|
|
419
418
|
...r ? { language: r } : {}
|
|
420
419
|
}, { triggerRefetch: !1 }));
|
|
@@ -423,10 +422,10 @@ class _e extends R {
|
|
|
423
422
|
* Reads the recommendation-id attribute from the block element within the node
|
|
424
423
|
*/
|
|
425
424
|
_getRecommendationIdFromNode(e) {
|
|
426
|
-
const t =
|
|
425
|
+
const t = x(e);
|
|
427
426
|
if (!t || !("getAttribute" in t))
|
|
428
427
|
return null;
|
|
429
|
-
const o = t.getAttribute(
|
|
428
|
+
const o = t.getAttribute(k);
|
|
430
429
|
if (!o)
|
|
431
430
|
return null;
|
|
432
431
|
const n = parseInt(o);
|
|
@@ -436,18 +435,20 @@ class _e extends R {
|
|
|
436
435
|
* Lands what the panel still owes its block before it stops watching it: the config now, the
|
|
437
436
|
* products through a block-scoped refresh. Never throws — it runs from Stripo's teardown.
|
|
438
437
|
*/
|
|
439
|
-
_finishBlockOutsidePanel(e = this._trackedBlockSnapshot()) {
|
|
440
|
-
var r;
|
|
441
|
-
const { blockId: t, fetchedConfigVersion: o, hasUnrenderedProducts: n } = e;
|
|
438
|
+
_finishBlockOutsidePanel({ blockId: e, fetchedConfigVersion: t, hasUnrenderedProducts: o } = this._trackedBlockSnapshot()) {
|
|
442
439
|
try {
|
|
443
|
-
const i = t === null ? void 0 : this.store.blockStates[t], a = i !== void 0 && o !== i.configVersion;
|
|
444
|
-
if (t !== null && i && (a || n)) {
|
|
445
|
-
((r = this.pendingNodeConfigWrite) == null ? void 0 : r.blockId) === t && this._consumePendingNodeConfig(), this._flushPendingNodeConfig(), this._refreshOutsidePanel(t, a);
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
440
|
this._flushPendingNodeConfig();
|
|
449
|
-
|
|
450
|
-
|
|
441
|
+
const n = e === null ? void 0 : this.store.blockStates[e];
|
|
442
|
+
if (e === null || !n)
|
|
443
|
+
return;
|
|
444
|
+
const r = t !== n.configVersion;
|
|
445
|
+
r && !m(
|
|
446
|
+
e,
|
|
447
|
+
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
448
|
+
f
|
|
449
|
+
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (r || o) && this._refreshOutsidePanel(e, r);
|
|
450
|
+
} catch (n) {
|
|
451
|
+
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
451
452
|
}
|
|
452
453
|
}
|
|
453
454
|
_trackedBlockSnapshot() {
|
|
@@ -458,7 +459,7 @@ class _e extends R {
|
|
|
458
459
|
};
|
|
459
460
|
}
|
|
460
461
|
_refreshOutsidePanel(e, t) {
|
|
461
|
-
|
|
462
|
+
S(e, {
|
|
462
463
|
pickUpdates: (o) => this._getNodeConfigUpdates(o),
|
|
463
464
|
description: "Update recommendation configuration",
|
|
464
465
|
fetch: t
|
|
@@ -476,32 +477,20 @@ class _e extends R {
|
|
|
476
477
|
_regenerateWithProducts() {
|
|
477
478
|
if (!this.currentNode || !this.api)
|
|
478
479
|
return;
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
), r !== void 0 && this._consumePendingNodeConfig();
|
|
483
|
-
};
|
|
484
|
-
if (H(e)) {
|
|
485
|
-
i(!1);
|
|
480
|
+
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(t);
|
|
481
|
+
if (W(this.currentNode)) {
|
|
482
|
+
o && (t.apply(new N("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
486
483
|
return;
|
|
487
484
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
}
|
|
498
|
-
}) || (a = j({
|
|
499
|
-
currentNode: e,
|
|
500
|
-
documentModifier: o,
|
|
501
|
-
products: t,
|
|
502
|
-
stageOnly: !0,
|
|
503
|
-
configOverrides: n
|
|
504
|
-
})), i(a);
|
|
485
|
+
M({
|
|
486
|
+
currentNode: this.currentNode,
|
|
487
|
+
documentModifier: t,
|
|
488
|
+
products: e
|
|
489
|
+
}) || G({
|
|
490
|
+
currentNode: this.currentNode,
|
|
491
|
+
documentModifier: t,
|
|
492
|
+
products: e
|
|
493
|
+
});
|
|
505
494
|
}
|
|
506
495
|
/**
|
|
507
496
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -522,52 +511,51 @@ class _e extends R {
|
|
|
522
511
|
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
|
|
523
512
|
const n = e.currentRecommendationId;
|
|
524
513
|
if (n !== this.trackedBlockId) {
|
|
525
|
-
const
|
|
526
|
-
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(
|
|
514
|
+
const p = this._trackedBlockSnapshot();
|
|
515
|
+
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(p);
|
|
527
516
|
return;
|
|
528
517
|
}
|
|
529
518
|
const r = this._getBlockConfigVersion(n);
|
|
530
519
|
r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, this.panelGeneration));
|
|
531
|
-
const
|
|
532
|
-
|
|
520
|
+
const s = e.recommendationProducts, d = s !== t, u = Array.isArray(s) && s.length > 0;
|
|
521
|
+
d && u && (t = s, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
|
|
533
522
|
});
|
|
534
523
|
}
|
|
535
524
|
}
|
|
536
525
|
export {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
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
|
-
Je as updateSingleProductContent
|
|
526
|
+
me as ALGORITHM_CONTROL_ID,
|
|
527
|
+
O as AlgorithmControl,
|
|
528
|
+
z as CONTROL_BLOCK_ID,
|
|
529
|
+
pe as CURRENCY_CONTROL_ID,
|
|
530
|
+
B as CurrencyControl,
|
|
531
|
+
ye as FILTERS_CONTROL_ID,
|
|
532
|
+
L as FiltersControl,
|
|
533
|
+
Pe as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
534
|
+
ke as LOCALE_CONTROL_ID,
|
|
535
|
+
E as LayoutOrientationControl,
|
|
536
|
+
F as LocaleControl,
|
|
537
|
+
Se as PRICE_PLACEMENT_CONTROL_ID,
|
|
538
|
+
be as PRODUCT_COUNT_CONTROL_ID,
|
|
539
|
+
Be as PRODUCT_LAYOUT_CONTROL_ID,
|
|
540
|
+
D as PricePlacementControl,
|
|
541
|
+
U as ProductCountControl,
|
|
542
|
+
v as ProductLayoutControl,
|
|
543
|
+
he as RecommendationBlockControl,
|
|
544
|
+
Ee as SHUFFLE_CONTROL_ID,
|
|
545
|
+
De as STRATEGY_CONTROL_ID,
|
|
546
|
+
w as ShuffleControl,
|
|
547
|
+
A as StrategyControl,
|
|
548
|
+
ve as adjustProductsToSize,
|
|
549
|
+
we as formatProductPrice,
|
|
550
|
+
x as getBlockElement,
|
|
551
|
+
Ae as getCardComposition,
|
|
552
|
+
Ve as getCurrentLayout,
|
|
553
|
+
xe as getMainContainerTbody,
|
|
554
|
+
W as isPartnerManagedBlock,
|
|
555
|
+
We as regenerateMobileProductRows,
|
|
556
|
+
G as regenerateProductRowsWithStyles,
|
|
557
|
+
V as setCurrencyAttributes,
|
|
558
|
+
Me as updatePricesInPlace,
|
|
559
|
+
M as updateProductContentInPlace,
|
|
560
|
+
Ge as updateSingleProductContent
|
|
573
561
|
};
|