@useinsider/guido 3.21.2-beta.4b0fed7 → 3.21.2-beta.4c14c74
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/useSave.js +75 -68
- package/dist/composables/validators/useHtmlDocumentCountValidator.js +22 -0
- 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 +29 -68
- package/dist/config/migrator/recommendation/htmlBuilder.js +200 -283
- package/dist/config/migrator/recommendation/settingsMapper.js +32 -35
- package/dist/config/migrator/recommendationMigrator.js +29 -32
- package/dist/extensions/Blocks/Items/controls/button/link.js +14 -17
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +14 -17
- package/dist/extensions/Blocks/Items/controls/image/link.js +14 -17
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +9 -10
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +24 -25
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -13
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +29 -30
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -16
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +25 -26
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +27 -28
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +75 -80
- package/dist/extensions/Blocks/Recommendation/block.js +24 -33
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +7 -7
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +13 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +229 -208
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +15 -15
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +10 -10
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +2 -1
- package/dist/extensions/Blocks/common-control.js +62 -55
- package/dist/services/templateLibraryApi.js +36 -31
- package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +3 -0
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +1 -3
- package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -20
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +11 -4
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +2 -3
- package/dist/src/extensions/Blocks/common-control.d.ts +2 -0
- package/dist/src/utils/templatePreparation.d.ts +2 -1
- package/dist/utils/pairProductVariables.js +98 -90
- package/dist/utils/templatePreparation.js +30 -30
- package/package.json +1 -1
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var N = (u, c, e) => c in u ? _(u, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[c] = e;
|
|
3
|
+
var s = (u, c, e) => N(u, typeof c != "symbol" ? c + "" : c, e);
|
|
4
4
|
import { useConfig as g } from "../../../../../composables/useConfig.js";
|
|
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 { registerNodeConfigWriter as
|
|
13
|
-
import { AlgorithmControl as
|
|
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
|
|
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 L } from "../../utils/nodeConfigWriter.js";
|
|
13
|
+
import { AlgorithmControl as E } from "./algorithm.js";
|
|
14
|
+
import { ALGORITHM_CONTROL_ID as _e } from "./algorithm.js";
|
|
15
|
+
import { CurrencyControl as F } 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
23
|
import { PricePlacementControl as A } from "./pricePlacement.js";
|
|
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
|
|
24
|
+
import { PRICE_PLACEMENT_CONTROL_ID as be } from "./pricePlacement.js";
|
|
25
|
+
import { ProductCountControl as w } from "./productCount.js";
|
|
26
|
+
import { PRODUCT_COUNT_CONTROL_ID as Le } from "./productCount.js";
|
|
27
|
+
import { ProductLayoutControl as V } from "./productLayout.js";
|
|
28
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Fe } 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
32
|
import { STRATEGY_CONTROL_ID as Ae } from "./strategy.js";
|
|
33
|
-
import { setCurrencyAttributes as
|
|
34
|
-
import { adjustProductsToSize as
|
|
35
|
-
import { useDebounceFn as
|
|
36
|
-
const
|
|
37
|
-
class
|
|
33
|
+
import { setCurrencyAttributes as M, getBlockElement as G, isPartnerManagedBlock as $, updateProductContentInPlace as z, 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 $e, updatePricesInPlace as ze, 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 {
|
|
38
38
|
constructor() {
|
|
39
39
|
super(...arguments);
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
s(this, "store", k());
|
|
41
|
+
s(this, "storeUnsubscription", () => {
|
|
42
42
|
});
|
|
43
43
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
44
44
|
// re-render's single apply() — one user action must cost one undo press.
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
s(this, "pendingNodeConfigWrite", null);
|
|
46
|
+
s(this, "pendingConfigFlushTimer", null);
|
|
47
47
|
// What the panel still owes the block it watches — finished outside the panel on teardown
|
|
48
48
|
// and block switch. A new generation tells debounced work queued for the old one to stand down.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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);
|
|
54
54
|
// Sub-control instances for lifecycle management
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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);
|
|
66
66
|
/**
|
|
67
67
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
s(this, "_debouncedFetchProducts", C(async (e, t) => {
|
|
70
70
|
if (t !== this.panelGeneration)
|
|
71
71
|
return;
|
|
72
|
-
const
|
|
72
|
+
const n = this._getBlockConfigVersion(e);
|
|
73
73
|
try {
|
|
74
|
-
await (e === null ? this.store.fetchRecommendationProducts() : this.store.fetchRecommendationProductsForBlock(e)), t === this.panelGeneration && (this.fetchedConfigVersion = Math.max(this.fetchedConfigVersion,
|
|
74
|
+
await (e === null ? this.store.fetchRecommendationProducts() : this.store.fetchRecommendationProductsForBlock(e)), t === this.panelGeneration && (this.fetchedConfigVersion = Math.max(this.fetchedConfigVersion, n));
|
|
75
75
|
} finally {
|
|
76
|
-
t === this.panelGeneration &&
|
|
76
|
+
t === this.panelGeneration && n === this._getBlockConfigVersion(e) && this._scheduleConfigFlush();
|
|
77
77
|
}
|
|
78
78
|
}, 500));
|
|
79
79
|
/**
|
|
@@ -87,11 +87,11 @@ class Ce extends R {
|
|
|
87
87
|
* count. The store pads products to the configured size, so in-place only
|
|
88
88
|
* fails when the size actually changed.
|
|
89
89
|
*/
|
|
90
|
-
|
|
90
|
+
s(this, "_debouncedRegenerateWithProducts", C((e) => {
|
|
91
91
|
if (e !== this.panelGeneration || !this.currentNode || !this.api)
|
|
92
92
|
return;
|
|
93
|
-
const t = this._getRecommendationIdFromNode(this.currentNode),
|
|
94
|
-
if (t === null ||
|
|
93
|
+
const t = this._getRecommendationIdFromNode(this.currentNode), n = this.store.currentRecommendationId;
|
|
94
|
+
if (t === null || n === null || t === n || !this.store.blockStates[t]) {
|
|
95
95
|
this.hasUnrenderedProducts = !1, this._regenerateWithProducts();
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
@@ -100,13 +100,13 @@ class Ce extends R {
|
|
|
100
100
|
try {
|
|
101
101
|
this._regenerateWithProducts();
|
|
102
102
|
} finally {
|
|
103
|
-
this.store.setCurrentBlock(
|
|
103
|
+
this.store.setCurrentBlock(n);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
}, 100));
|
|
107
107
|
}
|
|
108
108
|
getId() {
|
|
109
|
-
return
|
|
109
|
+
return Y;
|
|
110
110
|
}
|
|
111
111
|
get _subControls() {
|
|
112
112
|
return [
|
|
@@ -125,9 +125,9 @@ class Ce extends R {
|
|
|
125
125
|
getTemplate() {
|
|
126
126
|
var e;
|
|
127
127
|
return this.rrsEnabled = g().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
128
|
-
var
|
|
129
|
-
return (
|
|
130
|
-
}), this.algorithmControl = new
|
|
128
|
+
var n;
|
|
129
|
+
return (n = t == null ? void 0 : t.onDestroy) == null ? void 0 : n.call(t);
|
|
130
|
+
}), this.algorithmControl = new E(), this.localeControl = new v(), this.currencyControl = new F(), this.productCountControl = new w(), this.productLayoutControl = new V(), this.filtersControl = new D(), this.shuffleControl = new W(), this.pricePlacementControl = new A(), this.layoutOrientationControl = new U(), this.strategyControl = this.rrsEnabled ? new x() : null, this._subControls.forEach((t) => {
|
|
131
131
|
t && (t.api = this.api);
|
|
132
132
|
}), `
|
|
133
133
|
<div class="recommendation-controls-container">
|
|
@@ -145,36 +145,29 @@ class Ce extends R {
|
|
|
145
145
|
`;
|
|
146
146
|
}
|
|
147
147
|
_showControlsForBlock(e) {
|
|
148
|
-
var
|
|
149
|
-
const t = (
|
|
148
|
+
var r;
|
|
149
|
+
const t = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
|
|
150
150
|
if (!t)
|
|
151
151
|
return;
|
|
152
|
-
const
|
|
153
|
-
t.classList.toggle("strategy-block",
|
|
152
|
+
const n = this._getRecommendationIdFromNode(e) === null ? null : l.getConfig(e), o = this.rrsEnabled && !!n && (!!(n != null && n.strategyId) || ((n == null ? void 0 : n.configVersion) ?? 0) >= R), i = this.rrsEnabled && !!n && !o;
|
|
153
|
+
t.classList.toggle("strategy-block", o), t.classList.toggle("legacy-strategy-block", i);
|
|
154
154
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
O(this.api);
|
|
158
|
-
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
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)) {
|
|
160
|
-
this._initializeSubControls();
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
await this._fetchBlockData(t), this._initializeSubControls();
|
|
155
|
+
onRender() {
|
|
156
|
+
T(this.api), this.forgetLastPanelNode(), this._listenStateUpdates();
|
|
164
157
|
}
|
|
165
158
|
onTemplateNodeUpdated(e) {
|
|
166
|
-
var
|
|
159
|
+
var n;
|
|
167
160
|
super.onTemplateNodeUpdated(e);
|
|
168
161
|
const t = this._getRecommendationIdFromNode(e);
|
|
169
|
-
t !== null && t !== this.store.currentRecommendationId && this.store.setCurrentBlock(t), t !== null && this._syncNodeConfigIfChanged(t), this._showControlsForBlock(e), t !== null && !((
|
|
162
|
+
t !== null && t !== this.store.currentRecommendationId && this.store.setCurrentBlock(t), t !== null && this._syncNodeConfigIfChanged(t), this._showControlsForBlock(e), this._renderWithPanelNode(t), t !== null && !((n = this.store.blockStates[t]) != null && n.isInitialized) && this._fetchBlockData(t).then(() => {
|
|
170
163
|
this._initializeSubControls();
|
|
171
|
-
}), this._subControls.forEach((
|
|
164
|
+
}), this._subControls.forEach((o) => {
|
|
172
165
|
var i;
|
|
173
|
-
|
|
166
|
+
o != null && o.api && (o.currentNode = e, (i = o.onTemplateNodeUpdated) == null || i.call(o, e));
|
|
174
167
|
});
|
|
175
168
|
}
|
|
176
169
|
onDestroy() {
|
|
177
|
-
this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
|
|
170
|
+
this.panelGeneration++, this.isPanelAlive = !1, this.isAwaitingPanelNode = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
|
|
178
171
|
var t;
|
|
179
172
|
return (t = e == null ? void 0 : e.onDestroy) == null ? void 0 : t.call(e);
|
|
180
173
|
});
|
|
@@ -184,11 +177,23 @@ class Ce extends R {
|
|
|
184
177
|
* Each sub-control manages its own form values and event listeners
|
|
185
178
|
*/
|
|
186
179
|
_initializeSubControls() {
|
|
187
|
-
this._subControls.forEach((e) => {
|
|
180
|
+
this.currentNode && this._subControls.forEach((e) => {
|
|
188
181
|
var t;
|
|
189
182
|
e && (e.api = this.api, e.currentNode = this.currentNode, (t = e.onRender) == null || t.call(e));
|
|
190
183
|
});
|
|
191
184
|
}
|
|
185
|
+
// The panel's own node, not the store's last focused block, decides what to render; the caller
|
|
186
|
+
// fetches an uninitialized block once its config is synced.
|
|
187
|
+
_renderWithPanelNode(e) {
|
|
188
|
+
var t;
|
|
189
|
+
if (!(!this.isAwaitingPanelNode || e === null)) {
|
|
190
|
+
if (this.isAwaitingPanelNode = !1, (t = this.store.blockStates[e]) != null && t.isInitialized) {
|
|
191
|
+
this._initializeSubControls();
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender());
|
|
195
|
+
}
|
|
196
|
+
}
|
|
192
197
|
/**
|
|
193
198
|
* Syncs persisted node config into the Pinia store's block state.
|
|
194
199
|
*
|
|
@@ -219,13 +224,13 @@ class Ce extends R {
|
|
|
219
224
|
const t = this.store.blockStates[e];
|
|
220
225
|
if (!t)
|
|
221
226
|
return;
|
|
222
|
-
const
|
|
223
|
-
t.syncedConfigFingerprint =
|
|
227
|
+
const n = JSON.stringify(l.getConfig(this.currentNode)), o = t.syncedConfigFingerprint;
|
|
228
|
+
t.syncedConfigFingerprint = n, o !== n && ((i = this.pendingNodeConfigWrite) == null ? void 0 : i.blockId) !== e && this._syncNodeConfigToStore();
|
|
224
229
|
}
|
|
225
230
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
226
231
|
_isPendingStrategyIdChange() {
|
|
227
232
|
const e = this.pendingNodeConfigWrite;
|
|
228
|
-
return e ?
|
|
233
|
+
return e ? l.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
|
|
229
234
|
}
|
|
230
235
|
_capturePendingNodeConfigWrite() {
|
|
231
236
|
const e = this.store.currentRecommendationId, t = e === null ? void 0 : this.store.blockStates[e];
|
|
@@ -240,15 +245,15 @@ class Ce extends R {
|
|
|
240
245
|
return !e || t !== null && e.blockId !== t ? null : e;
|
|
241
246
|
}
|
|
242
247
|
_getNodeConfigUpdates(e) {
|
|
243
|
-
const { filters: t, strategy:
|
|
248
|
+
const { filters: t, strategy: n, strategyId: o, size: i, productIds: r, nodeConfigVersion: h } = e, { partnerName: d } = g();
|
|
244
249
|
return {
|
|
245
250
|
filters: t,
|
|
246
|
-
strategy:
|
|
247
|
-
strategyId:
|
|
251
|
+
strategy: n,
|
|
252
|
+
strategyId: o,
|
|
248
253
|
size: i,
|
|
249
|
-
productIds:
|
|
250
|
-
configVersion:
|
|
251
|
-
...
|
|
254
|
+
productIds: r,
|
|
255
|
+
configVersion: h,
|
|
256
|
+
...d.value ? { partnerName: d.value } : {}
|
|
252
257
|
};
|
|
253
258
|
}
|
|
254
259
|
/**
|
|
@@ -263,7 +268,7 @@ class Ce extends R {
|
|
|
263
268
|
*/
|
|
264
269
|
_stagePendingNodeConfig(e) {
|
|
265
270
|
const t = this._pendingWriteForNode();
|
|
266
|
-
return !t || !this.currentNode ? !1 : (
|
|
271
|
+
return !t || !this.currentNode ? !1 : (l.stageConfig(e, this.currentNode, t.updates), !0);
|
|
267
272
|
}
|
|
268
273
|
/**
|
|
269
274
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -287,15 +292,15 @@ class Ce extends R {
|
|
|
287
292
|
const e = this.pendingNodeConfigWrite;
|
|
288
293
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !(!e || !this.api)) {
|
|
289
294
|
if (e.blockId !== this.store.currentRecommendationId || !this.currentNode) {
|
|
290
|
-
const { blockId: t, updates:
|
|
291
|
-
!
|
|
295
|
+
const { blockId: t, updates: n } = e;
|
|
296
|
+
!m(t, n, f) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
|
|
292
297
|
return;
|
|
293
298
|
}
|
|
294
|
-
|
|
299
|
+
O(this.currentNode, e.updates) && l.updateConfig(
|
|
295
300
|
this.api,
|
|
296
301
|
this.currentNode,
|
|
297
302
|
e.updates,
|
|
298
|
-
|
|
303
|
+
b(this.currentNode, e.updates, f)
|
|
299
304
|
);
|
|
300
305
|
}
|
|
301
306
|
}
|
|
@@ -306,12 +311,12 @@ class Ce extends R {
|
|
|
306
311
|
/** The Product Ids label when the pending write moves the node's ids; the caller's default otherwise. */
|
|
307
312
|
_pendingDescription() {
|
|
308
313
|
const e = this._pendingWriteForNode();
|
|
309
|
-
if (!(!e || !this.currentNode || !
|
|
310
|
-
return
|
|
314
|
+
if (!(!e || !this.currentNode || !B(this.currentNode, e.updates)))
|
|
315
|
+
return L;
|
|
311
316
|
}
|
|
312
317
|
_syncNodeConfigToStore() {
|
|
313
|
-
var
|
|
314
|
-
const e =
|
|
318
|
+
var o;
|
|
319
|
+
const e = l.getConfig(this.currentNode), t = this.store.currentRecommendationId, n = t !== null && ((o = this.store.blockStates[t]) == null ? void 0 : o.isInitialized);
|
|
315
320
|
this.store.patchCurrentBlockConfig({
|
|
316
321
|
strategy: e.strategy,
|
|
317
322
|
strategyId: e.strategyId,
|
|
@@ -326,7 +331,7 @@ class Ce extends R {
|
|
|
326
331
|
// Only sync filters from node config during initial load.
|
|
327
332
|
// After initialization, the Pinia store is the source of truth
|
|
328
333
|
// for filters (edited via the filter drawer).
|
|
329
|
-
...
|
|
334
|
+
...n ? {} : { filters: e.filters },
|
|
330
335
|
shuffleProducts: e.shuffleProducts,
|
|
331
336
|
priceMovedToNextLine: e.priceMovedToNextLine,
|
|
332
337
|
priceHideIfSameAsDiscounted: e.priceHideIfSameAsDiscounted,
|
|
@@ -347,74 +352,90 @@ class Ce extends R {
|
|
|
347
352
|
* 2. Smart defaults for new blocks (currency, algorithm) — sequential
|
|
348
353
|
* 3. Product data with correct defaults — sequential
|
|
349
354
|
*
|
|
350
|
-
*
|
|
355
|
+
* Called from onTemplateNodeUpdated() once the node config is synced.
|
|
351
356
|
* Marks the block as initialized to prevent redundant fetches on re-selection.
|
|
352
357
|
*/
|
|
353
358
|
async _fetchBlockData(e) {
|
|
354
359
|
if (e !== null && this.store.markBlockInitialized(e), (await Promise.allSettled([
|
|
355
360
|
this.store.fetchRecommendationCreateData(),
|
|
356
361
|
this.store.fetchRecommendationFilters()
|
|
357
|
-
])).forEach((
|
|
358
|
-
|
|
362
|
+
])).forEach((o, i) => {
|
|
363
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][i]} failed`, o.reason);
|
|
359
364
|
}), e !== null && this.store.currentRecommendationId !== e) {
|
|
360
365
|
this._refreshOutsidePanel(e, !0);
|
|
361
366
|
return;
|
|
362
367
|
}
|
|
363
368
|
this._applySmartDefaults();
|
|
364
|
-
const
|
|
369
|
+
const n = this._getBlockConfigVersion(e);
|
|
365
370
|
try {
|
|
366
371
|
await this.store.fetchRecommendationProducts();
|
|
367
|
-
} catch (
|
|
368
|
-
console.warn("Recommendation block: fetchRecommendationProducts failed",
|
|
372
|
+
} catch (o) {
|
|
373
|
+
console.warn("Recommendation block: fetchRecommendationProducts failed", o);
|
|
369
374
|
}
|
|
370
|
-
e !== null && !this._isPanelOn(e) && this._refreshOutsidePanel(e, this._getBlockConfigVersion(e) !==
|
|
375
|
+
e !== null && !this._isPanelOn(e) && this._refreshOutsidePanel(e, this._getBlockConfigVersion(e) !== n);
|
|
371
376
|
}
|
|
372
377
|
_isPanelOn(e) {
|
|
373
378
|
return this.isPanelAlive && this.store.currentRecommendationId === e;
|
|
374
379
|
}
|
|
375
380
|
/**
|
|
376
|
-
*
|
|
377
|
-
*
|
|
381
|
+
* Applies smart defaults for newly dropped blocks.
|
|
382
|
+
*
|
|
383
|
+
* For new blocks (config still matches hardcoded defaults), validates that
|
|
384
|
+
* the default currency and algorithm are available from the API response.
|
|
385
|
+
* If not, falls back to the first available option.
|
|
386
|
+
*
|
|
387
|
+
* Saved templates with user-customized config are left unchanged because
|
|
388
|
+
* their values won't match the hardcoded defaults.
|
|
378
389
|
*/
|
|
379
390
|
_applySmartDefaults() {
|
|
380
391
|
if (!this.currentNode || !this.api)
|
|
381
392
|
return;
|
|
382
|
-
const e =
|
|
383
|
-
let
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
393
|
+
const e = l.getConfig(this.currentNode), t = {};
|
|
394
|
+
let n = null, o = null, i = null;
|
|
395
|
+
if (e.currency.code === a.currency.code) {
|
|
396
|
+
const { currencyList: r } = this.store;
|
|
397
|
+
r.length > 0 && (r.some(
|
|
398
|
+
(d) => d.value === `price.${a.currency.code}`
|
|
399
|
+
) || (n = r[0].value.replace("price.", ""), t.currency = {
|
|
400
|
+
...a.currency,
|
|
401
|
+
code: n,
|
|
402
|
+
symbol: n
|
|
403
|
+
}));
|
|
404
|
+
}
|
|
405
|
+
if (e.strategy === a.strategy) {
|
|
406
|
+
const r = this.store.getActivePredictiveAlgorithms;
|
|
407
|
+
r.length > 0 && (r.some(
|
|
408
|
+
(d) => d.value === a.strategy
|
|
409
|
+
) || (o = r[0].value, t.strategy = o));
|
|
410
|
+
}
|
|
411
|
+
if (e.language === a.language) {
|
|
412
|
+
const r = this.store.getLanguages;
|
|
413
|
+
r.length > 0 && (r.some(
|
|
414
|
+
(d) => d.value === a.language
|
|
415
|
+
) || (i = r[0].value, t.language = i));
|
|
394
416
|
}
|
|
395
|
-
|
|
396
|
-
l.length > 0 && !l.some((a) => a.value === e.language) && (i = l[0].value, t.language = i), !(!o && !n && !i) && (d.updateConfig(
|
|
417
|
+
!n && !o && !i || (l.updateConfig(
|
|
397
418
|
this.api,
|
|
398
419
|
this.currentNode,
|
|
399
420
|
t,
|
|
400
421
|
"Applied smart defaults"
|
|
401
|
-
),
|
|
422
|
+
), n && t.currency && M({
|
|
402
423
|
currentNode: this.currentNode,
|
|
403
424
|
documentModifier: this.api.getDocumentModifier(),
|
|
404
425
|
currency: t.currency
|
|
405
426
|
}), this.store.patchCurrentBlockConfig({
|
|
406
|
-
...
|
|
427
|
+
...n ? {
|
|
407
428
|
currencySettings: {
|
|
408
|
-
name:
|
|
409
|
-
value:
|
|
410
|
-
symbol:
|
|
411
|
-
alignment:
|
|
412
|
-
decimalCount:
|
|
413
|
-
decimalSeparator:
|
|
414
|
-
thousandSeparator:
|
|
429
|
+
name: n,
|
|
430
|
+
value: n,
|
|
431
|
+
symbol: n,
|
|
432
|
+
alignment: a.currency.alignment === "before" ? "0" : "1",
|
|
433
|
+
decimalCount: a.currency.decimalCount.toString(),
|
|
434
|
+
decimalSeparator: a.currency.decimalSeparator,
|
|
435
|
+
thousandSeparator: a.currency.thousandSeparator
|
|
415
436
|
}
|
|
416
437
|
} : {},
|
|
417
|
-
...
|
|
438
|
+
...o ? { strategy: o } : {},
|
|
418
439
|
...i ? { language: i } : {}
|
|
419
440
|
}, { triggerRefetch: !1 }));
|
|
420
441
|
}
|
|
@@ -422,33 +443,33 @@ class Ce extends R {
|
|
|
422
443
|
* Reads the recommendation-id attribute from the block element within the node
|
|
423
444
|
*/
|
|
424
445
|
_getRecommendationIdFromNode(e) {
|
|
425
|
-
const t =
|
|
446
|
+
const t = G(e);
|
|
426
447
|
if (!t || !("getAttribute" in t))
|
|
427
448
|
return null;
|
|
428
|
-
const
|
|
429
|
-
if (!
|
|
449
|
+
const n = t.getAttribute(I);
|
|
450
|
+
if (!n)
|
|
430
451
|
return null;
|
|
431
|
-
const
|
|
432
|
-
return Number.isNaN(
|
|
452
|
+
const o = parseInt(n);
|
|
453
|
+
return Number.isNaN(o) ? null : o;
|
|
433
454
|
}
|
|
434
455
|
/**
|
|
435
456
|
* Lands what the panel still owes its block before it stops watching it: the config now, the
|
|
436
457
|
* products through a block-scoped refresh. Never throws — it runs from Stripo's teardown.
|
|
437
458
|
*/
|
|
438
|
-
_finishBlockOutsidePanel({ blockId: e, fetchedConfigVersion: t, hasUnrenderedProducts:
|
|
459
|
+
_finishBlockOutsidePanel({ blockId: e, fetchedConfigVersion: t, hasUnrenderedProducts: n } = this._trackedBlockSnapshot()) {
|
|
439
460
|
try {
|
|
440
461
|
this._flushPendingNodeConfig();
|
|
441
|
-
const
|
|
442
|
-
if (e === null || !
|
|
462
|
+
const o = e === null ? void 0 : this.store.blockStates[e];
|
|
463
|
+
if (e === null || !o)
|
|
443
464
|
return;
|
|
444
|
-
const i = t !==
|
|
445
|
-
i && !
|
|
465
|
+
const i = t !== o.configVersion;
|
|
466
|
+
i && !m(
|
|
446
467
|
e,
|
|
447
|
-
this._getNodeConfigUpdates(
|
|
448
|
-
|
|
449
|
-
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i ||
|
|
450
|
-
} catch (
|
|
451
|
-
console.error("[recommendation] finishing the block outside the panel failed",
|
|
468
|
+
this._getNodeConfigUpdates(o.recommendationConfigs),
|
|
469
|
+
f
|
|
470
|
+
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i || n) && this._refreshOutsidePanel(e, i);
|
|
471
|
+
} catch (o) {
|
|
472
|
+
console.error("[recommendation] finishing the block outside the panel failed", o);
|
|
452
473
|
}
|
|
453
474
|
}
|
|
454
475
|
_trackedBlockSnapshot() {
|
|
@@ -459,14 +480,14 @@ class Ce extends R {
|
|
|
459
480
|
};
|
|
460
481
|
}
|
|
461
482
|
_refreshOutsidePanel(e, t) {
|
|
462
|
-
|
|
463
|
-
pickUpdates: (
|
|
483
|
+
S(e, {
|
|
484
|
+
pickUpdates: (n) => this._getNodeConfigUpdates(n),
|
|
464
485
|
description: "Update recommendation configuration",
|
|
465
486
|
fetch: t
|
|
466
|
-
}).then((
|
|
467
|
-
!
|
|
468
|
-
}).catch((
|
|
469
|
-
console.error("[recommendation] refresh outside the panel failed",
|
|
487
|
+
}).then((n) => {
|
|
488
|
+
!n && this.store.blockStates[e] && console.error("[recommendation] refresh outside the panel did not reach a node", { blockId: e });
|
|
489
|
+
}).catch((n) => {
|
|
490
|
+
console.error("[recommendation] refresh outside the panel failed", n);
|
|
470
491
|
});
|
|
471
492
|
}
|
|
472
493
|
_getBlockConfigVersion(e) {
|
|
@@ -481,25 +502,25 @@ class Ce extends R {
|
|
|
481
502
|
this.hasUnrenderedProducts = !0;
|
|
482
503
|
return;
|
|
483
504
|
}
|
|
484
|
-
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(),
|
|
505
|
+
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), n = this._pendingDescription(), o = this._stagePendingNodeConfig(t);
|
|
485
506
|
if ($(this.currentNode)) {
|
|
486
|
-
|
|
487
|
-
new
|
|
507
|
+
o && (t.apply(
|
|
508
|
+
new y(n ?? "Update recommendation configuration")
|
|
488
509
|
), this._consumePendingNodeConfig());
|
|
489
510
|
return;
|
|
490
511
|
}
|
|
491
|
-
|
|
512
|
+
z({
|
|
492
513
|
currentNode: this.currentNode,
|
|
493
514
|
documentModifier: t,
|
|
494
515
|
products: e,
|
|
495
|
-
description:
|
|
496
|
-
onApplied:
|
|
497
|
-
}) ||
|
|
516
|
+
description: n,
|
|
517
|
+
onApplied: o ? () => this._consumePendingNodeConfig() : void 0
|
|
518
|
+
}) || H({
|
|
498
519
|
currentNode: this.currentNode,
|
|
499
520
|
documentModifier: t,
|
|
500
521
|
products: e,
|
|
501
|
-
description:
|
|
502
|
-
}) &&
|
|
522
|
+
description: n
|
|
523
|
+
}) && o && this._consumePendingNodeConfig();
|
|
503
524
|
}
|
|
504
525
|
// Spent only once it landed with the cards (never when another block's write stayed unstaged):
|
|
505
526
|
// kept alive, it blocks the store resync an Undo needs and the flush writes the undone ids back.
|
|
@@ -521,55 +542,55 @@ class Ce extends R {
|
|
|
521
542
|
*/
|
|
522
543
|
_listenStateUpdates() {
|
|
523
544
|
const { store: e } = this;
|
|
524
|
-
let t = e.recommendationProducts,
|
|
525
|
-
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion =
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
528
|
-
const
|
|
529
|
-
this.panelGeneration++, this.trackedBlockId =
|
|
545
|
+
let t = e.recommendationProducts, n = this._getBlockConfigVersion(e.currentRecommendationId);
|
|
546
|
+
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = n, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
|
|
547
|
+
const o = e.currentRecommendationId;
|
|
548
|
+
if (o !== this.trackedBlockId) {
|
|
549
|
+
const p = this._trackedBlockSnapshot();
|
|
550
|
+
this.panelGeneration++, this.trackedBlockId = o, t = e.recommendationProducts, n = this._getBlockConfigVersion(o), this.fetchedConfigVersion = n, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(p);
|
|
530
551
|
return;
|
|
531
552
|
}
|
|
532
|
-
const i = this._getBlockConfigVersion(
|
|
533
|
-
i !==
|
|
534
|
-
const
|
|
535
|
-
|
|
553
|
+
const i = this._getBlockConfigVersion(o);
|
|
554
|
+
i !== n && (n = i, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(o, this.panelGeneration));
|
|
555
|
+
const r = e.recommendationProducts, h = r !== t, d = Array.isArray(r) && r.length > 0;
|
|
556
|
+
h && d && (t = r, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
|
|
536
557
|
});
|
|
537
558
|
}
|
|
538
559
|
}
|
|
539
560
|
export {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
561
|
+
_e as ALGORITHM_CONTROL_ID,
|
|
562
|
+
E as AlgorithmControl,
|
|
563
|
+
Y as CONTROL_BLOCK_ID,
|
|
564
|
+
ye as CURRENCY_CONTROL_ID,
|
|
565
|
+
F as CurrencyControl,
|
|
566
|
+
Re as FILTERS_CONTROL_ID,
|
|
567
|
+
D as FiltersControl,
|
|
568
|
+
ke as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
569
|
+
Te as LOCALE_CONTROL_ID,
|
|
570
|
+
U as LayoutOrientationControl,
|
|
571
|
+
v as LocaleControl,
|
|
572
|
+
be as PRICE_PLACEMENT_CONTROL_ID,
|
|
573
|
+
Le as PRODUCT_COUNT_CONTROL_ID,
|
|
574
|
+
Fe as PRODUCT_LAYOUT_CONTROL_ID,
|
|
554
575
|
A as PricePlacementControl,
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
576
|
+
w as ProductCountControl,
|
|
577
|
+
V as ProductLayoutControl,
|
|
578
|
+
me as RecommendationBlockControl,
|
|
579
|
+
Ue as SHUFFLE_CONTROL_ID,
|
|
559
580
|
Ae as STRATEGY_CONTROL_ID,
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
581
|
+
W as ShuffleControl,
|
|
582
|
+
x as StrategyControl,
|
|
583
|
+
Ve as adjustProductsToSize,
|
|
584
|
+
We as formatProductPrice,
|
|
585
|
+
G as getBlockElement,
|
|
586
|
+
xe as getCardComposition,
|
|
587
|
+
Me as getCurrentLayout,
|
|
588
|
+
Ge as getMainContainerTbody,
|
|
568
589
|
$ as isPartnerManagedBlock,
|
|
569
590
|
$e as regenerateMobileProductRows,
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
591
|
+
H as regenerateProductRowsWithStyles,
|
|
592
|
+
M as setCurrencyAttributes,
|
|
593
|
+
ze as updatePricesInPlace,
|
|
594
|
+
z as updateProductContentInPlace,
|
|
595
|
+
He as updateSingleProductContent
|
|
575
596
|
};
|