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