@useinsider/guido 3.20.0 → 3.20.1-beta.04cd240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composables/useLegacyStrategyConversion.js +16 -16
- package/dist/composables/useStripo.js +11 -10
- package/dist/composables/useVersionHistoryApi.js +42 -37
- package/dist/config/compiler/itemsCompilerRules.js +21 -5
- package/dist/config/compiler/utils/itemsCompilerUtils.js +64 -17
- package/dist/config/migrator/itemsBlockMigrator.js +112 -108
- package/dist/extensions/Blocks/Items/block.js +76 -64
- package/dist/extensions/Blocks/Items/constants/cardWidth.js +20 -0
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +60 -49
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +163 -149
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +1 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +102 -78
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +313 -210
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +15 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +17 -12
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +92 -84
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +219 -193
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +23 -18
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +1 -2
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +6 -6
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +12 -9
- package/dist/extensions/Blocks/Recommendation/extension.js +4 -2
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +4 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +240 -190
- package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +19 -0
- package/dist/extensions/Blocks/Recommendation/utils/blockUrlConfig.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +72 -70
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +69 -60
- package/dist/extensions/Blocks/Recommendation/utils/followUpApply.js +34 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +73 -28
- package/dist/extensions/Blocks/Recommendation/utils/restoreRefresh.js +36 -0
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +39 -20
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +271 -192
- package/dist/package.json.js +1 -1
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +10 -0
- package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +8 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +12 -0
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +40 -0
- package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +11 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +22 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +1 -18
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +10 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +2 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +28 -6
- package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/blockUrlConfig.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/followUpApply.d.ts +20 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +15 -2
- package/dist/src/extensions/Blocks/Recommendation/utils/restoreRefresh.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
- package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +22 -0
- package/dist/src/stores/editor.d.ts +3 -1
- package/dist/src/utils/liquidProtection.d.ts +3 -0
- package/dist/static/styles/components/button.css.js +5 -0
- package/dist/stores/editor.js +5 -0
- package/dist/utils/liquidProtection.js +5 -0
- package/dist/utils/templatePreparation.js +61 -85
- package/package.json +3 -3
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
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";
|
|
6
5
|
import { CommonControl as N } from "../../../common-control.js";
|
|
7
|
-
import { RRS_CONFIG_VERSION as
|
|
8
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
9
|
-
import { RecommendationConfigService as
|
|
6
|
+
import { RRS_CONFIG_VERSION as P, DEFAULT_NODE_CONFIG as l } from "../../constants/defaultConfig.js";
|
|
7
|
+
import { RECOMMENDATION_ID_ATTR as k } from "../../constants/selectors.js";
|
|
8
|
+
import { RecommendationConfigService as d } from "../../services/configService.js";
|
|
10
9
|
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
11
|
-
import {
|
|
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
|
-
|
|
36
|
-
|
|
10
|
+
import { refreshBlockOutsidePanel as I } from "../../utils/blockRefresh.js";
|
|
11
|
+
import { captureUndoTop as S, isUndoTopUnchanged as b, applyFollowUp as T } from "../../utils/followUpApply.js";
|
|
12
|
+
import { registerNodeConfigWriter as O, writeBlockConfigOutsidePanel as m, hasEditedConfigChange as B } from "../../utils/nodeConfigWriter.js";
|
|
13
|
+
import { AlgorithmControl as U } from "./algorithm.js";
|
|
14
|
+
import { ALGORITHM_CONTROL_ID as pe } from "./algorithm.js";
|
|
15
|
+
import { CurrencyControl as E } from "./currency.js";
|
|
16
|
+
import { CURRENCY_CONTROL_ID as ye } from "./currency.js";
|
|
17
|
+
import { FiltersControl as L } from "./filters.js";
|
|
18
|
+
import { FILTERS_CONTROL_ID as Pe } from "./filters.js";
|
|
19
|
+
import { LayoutOrientationControl as F } from "./layoutOrientation.js";
|
|
20
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as Re } from "./layoutOrientation.js";
|
|
21
|
+
import { LocaleControl as w } from "./locale.js";
|
|
22
|
+
import { LOCALE_CONTROL_ID as Se } from "./locale.js";
|
|
23
|
+
import { PricePlacementControl as A } from "./pricePlacement.js";
|
|
24
|
+
import { PRICE_PLACEMENT_CONTROL_ID as Te } from "./pricePlacement.js";
|
|
25
|
+
import { ProductCountControl as D } 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 Ee } from "./productLayout.js";
|
|
29
|
+
import { ShuffleControl as V } from "./shuffle.js";
|
|
30
|
+
import { SHUFFLE_CONTROL_ID as Fe } from "./shuffle.js";
|
|
31
|
+
import { StrategyControl as x } from "./strategy.js";
|
|
32
|
+
import { STRATEGY_CONTROL_ID as Ae } from "./strategy.js";
|
|
33
|
+
import { setCurrencyAttributes as W, getBlockElement as G, isPartnerManagedBlock as M, updateProductContentInPlace as z, regenerateProductRowsWithStyles as $ } from "./utils.js";
|
|
34
|
+
import { adjustProductsToSize as ve, formatProductPrice as Ve, getCardComposition as xe, getCurrencyAttributesFromBlock as We, getCurrentLayout as Ge, getMainContainerTbody as Me, regenerateMobileProductRows as ze, updatePricesInPlace as $e, updateSingleProductContent as He } from "./utils.js";
|
|
35
|
+
import { useDebounceFn as C } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
36
|
+
const f = "Update recommendation filters", H = "ui-elements-recommendation-block";
|
|
37
|
+
class ge extends N {
|
|
37
38
|
constructor() {
|
|
38
39
|
super(...arguments);
|
|
39
40
|
i(this, "store", R());
|
|
@@ -43,6 +44,14 @@ class at extends N {
|
|
|
43
44
|
// re-render's single apply() — one user action must cost one undo press.
|
|
44
45
|
i(this, "pendingNodeConfigWrite", null);
|
|
45
46
|
i(this, "pendingConfigFlushTimer", null);
|
|
47
|
+
// What the panel still owes the block it watches — finished outside the panel on teardown
|
|
48
|
+
// and block switch. A new generation tells debounced work queued for the old one to stand down.
|
|
49
|
+
i(this, "trackedBlockId", null);
|
|
50
|
+
i(this, "fetchedConfigVersion", 0);
|
|
51
|
+
i(this, "hasUnrenderedProducts", !1);
|
|
52
|
+
i(this, "followUpAnchor", null);
|
|
53
|
+
i(this, "panelGeneration", 0);
|
|
54
|
+
i(this, "isPanelAlive", !0);
|
|
46
55
|
// Sub-control instances for lifecycle management
|
|
47
56
|
i(this, "algorithmControl", null);
|
|
48
57
|
i(this, "localeControl", null);
|
|
@@ -58,11 +67,15 @@ class at extends N {
|
|
|
58
67
|
/**
|
|
59
68
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
60
69
|
*/
|
|
61
|
-
i(this, "_debouncedFetchProducts",
|
|
70
|
+
i(this, "_debouncedFetchProducts", C(async (e, t) => {
|
|
71
|
+
if (t !== this.panelGeneration)
|
|
72
|
+
return;
|
|
73
|
+
this.followUpAnchor = S();
|
|
74
|
+
const o = this._getBlockConfigVersion(e);
|
|
62
75
|
try {
|
|
63
|
-
await this.store.fetchRecommendationProducts();
|
|
76
|
+
await (e === null ? this.store.fetchRecommendationProducts() : this.store.fetchRecommendationProductsForBlock(e)), t === this.panelGeneration && (this.fetchedConfigVersion = Math.max(this.fetchedConfigVersion, o));
|
|
64
77
|
} finally {
|
|
65
|
-
this._scheduleConfigFlush();
|
|
78
|
+
t === this.panelGeneration && this._scheduleConfigFlush();
|
|
66
79
|
}
|
|
67
80
|
}, 500));
|
|
68
81
|
/**
|
|
@@ -76,28 +89,26 @@ class at extends N {
|
|
|
76
89
|
* count. The store pads products to the configured size, so in-place only
|
|
77
90
|
* fails when the size actually changed.
|
|
78
91
|
*/
|
|
79
|
-
i(this, "_debouncedRegenerateWithProducts",
|
|
80
|
-
|
|
81
|
-
if (!this.currentNode || !this.api)
|
|
92
|
+
i(this, "_debouncedRegenerateWithProducts", C((e) => {
|
|
93
|
+
if (e !== this.panelGeneration || !this.currentNode || !this.api)
|
|
82
94
|
return;
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
95
|
+
const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
|
|
96
|
+
if (t === null || o === null || t === o || !this.store.blockStates[t]) {
|
|
97
|
+
this.hasUnrenderedProducts = !1, this._regenerateWithProducts();
|
|
86
98
|
return;
|
|
87
99
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
100
|
+
if (this.store.blockStates[t].recommendationProducts.length) {
|
|
101
|
+
this.store.setCurrentBlock(t);
|
|
102
|
+
try {
|
|
103
|
+
this._regenerateWithProducts();
|
|
104
|
+
} finally {
|
|
105
|
+
this.store.setCurrentBlock(o);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
97
108
|
}, 100));
|
|
98
109
|
}
|
|
99
110
|
getId() {
|
|
100
|
-
return
|
|
111
|
+
return H;
|
|
101
112
|
}
|
|
102
113
|
get _subControls() {
|
|
103
114
|
return [
|
|
@@ -114,15 +125,15 @@ class at extends N {
|
|
|
114
125
|
];
|
|
115
126
|
}
|
|
116
127
|
getTemplate() {
|
|
117
|
-
var
|
|
118
|
-
return this.rrsEnabled =
|
|
128
|
+
var e;
|
|
129
|
+
return this.rrsEnabled = g().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
119
130
|
var o;
|
|
120
|
-
return (o =
|
|
121
|
-
}), this.algorithmControl = new
|
|
122
|
-
|
|
131
|
+
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
132
|
+
}), this.algorithmControl = new U(), this.localeControl = new w(), this.currencyControl = new E(), this.productCountControl = new D(), this.productLayoutControl = new v(), this.filtersControl = new L(), this.shuffleControl = new V(), this.pricePlacementControl = new A(), this.layoutOrientationControl = new F(), this.strategyControl = this.rrsEnabled ? new x() : null, this._subControls.forEach((t) => {
|
|
133
|
+
t && (t.api = this.api);
|
|
123
134
|
}), `
|
|
124
135
|
<div class="recommendation-controls-container">
|
|
125
|
-
${((
|
|
136
|
+
${((e = this.strategyControl) == null ? void 0 : e.getTemplate()) ?? ""}
|
|
126
137
|
${this.layoutOrientationControl.getTemplate()}
|
|
127
138
|
${this.productCountControl.getTemplate()}
|
|
128
139
|
${this.productLayoutControl.getTemplate()}
|
|
@@ -135,39 +146,39 @@ class at extends N {
|
|
|
135
146
|
</div>
|
|
136
147
|
`;
|
|
137
148
|
}
|
|
138
|
-
_showControlsForBlock(
|
|
149
|
+
_showControlsForBlock(e) {
|
|
139
150
|
var r;
|
|
140
|
-
const
|
|
141
|
-
if (!
|
|
151
|
+
const t = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
|
|
152
|
+
if (!t)
|
|
142
153
|
return;
|
|
143
|
-
const o = this._getRecommendationIdFromNode(
|
|
144
|
-
|
|
154
|
+
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) >= P), s = this.rrsEnabled && !!o && !n;
|
|
155
|
+
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", s);
|
|
145
156
|
}
|
|
146
157
|
async onRender() {
|
|
147
158
|
var o;
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
159
|
+
O(this.api);
|
|
160
|
+
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
161
|
+
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)) {
|
|
151
162
|
this._initializeSubControls();
|
|
152
163
|
return;
|
|
153
164
|
}
|
|
154
|
-
await this._fetchBlockData(
|
|
165
|
+
await this._fetchBlockData(t), this._initializeSubControls();
|
|
155
166
|
}
|
|
156
|
-
onTemplateNodeUpdated(
|
|
167
|
+
onTemplateNodeUpdated(e) {
|
|
157
168
|
var o;
|
|
158
|
-
super.onTemplateNodeUpdated(
|
|
159
|
-
const
|
|
160
|
-
|
|
169
|
+
super.onTemplateNodeUpdated(e);
|
|
170
|
+
const t = this._getRecommendationIdFromNode(e);
|
|
171
|
+
t !== null && t !== this.store.currentRecommendationId && this.store.setCurrentBlock(t), t !== null && this._syncNodeConfigIfChanged(t), this._showControlsForBlock(e), t !== null && !((o = this.store.blockStates[t]) != null && o.isInitialized) && this._fetchBlockData(t).then(() => {
|
|
161
172
|
this._initializeSubControls();
|
|
162
173
|
}), this._subControls.forEach((n) => {
|
|
163
174
|
var s;
|
|
164
|
-
n != null && n.api && (n.currentNode =
|
|
175
|
+
n != null && n.api && (n.currentNode = e, (s = n.onTemplateNodeUpdated) == null || s.call(n, e));
|
|
165
176
|
});
|
|
166
177
|
}
|
|
167
178
|
onDestroy() {
|
|
168
|
-
this.storeUnsubscription(), this.
|
|
169
|
-
var
|
|
170
|
-
return (
|
|
179
|
+
this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
|
|
180
|
+
var t;
|
|
181
|
+
return (t = e == null ? void 0 : e.onDestroy) == null ? void 0 : t.call(e);
|
|
171
182
|
});
|
|
172
183
|
}
|
|
173
184
|
/**
|
|
@@ -175,9 +186,9 @@ class at extends N {
|
|
|
175
186
|
* Each sub-control manages its own form values and event listeners
|
|
176
187
|
*/
|
|
177
188
|
_initializeSubControls() {
|
|
178
|
-
this._subControls.forEach((
|
|
179
|
-
var
|
|
180
|
-
|
|
189
|
+
this._subControls.forEach((e) => {
|
|
190
|
+
var t;
|
|
191
|
+
e && (e.api = this.api, e.currentNode = this.currentNode, (t = e.onRender) == null || t.call(e));
|
|
181
192
|
});
|
|
182
193
|
}
|
|
183
194
|
/**
|
|
@@ -204,35 +215,36 @@ class at extends N {
|
|
|
204
215
|
* that state and made a re-dropped saved module keep the defaults its wiped
|
|
205
216
|
* state was rebuilt with (SD-150347).
|
|
206
217
|
*/
|
|
207
|
-
_syncNodeConfigIfChanged(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
218
|
+
_syncNodeConfigIfChanged(e) {
|
|
219
|
+
var s;
|
|
220
|
+
this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== e && this._flushPendingNodeConfig();
|
|
221
|
+
const t = this.store.blockStates[e];
|
|
222
|
+
if (!t)
|
|
211
223
|
return;
|
|
212
|
-
const o = JSON.stringify(
|
|
213
|
-
|
|
224
|
+
const o = JSON.stringify(d.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
|
|
225
|
+
t.syncedConfigFingerprint = o, n !== o && ((s = this.pendingNodeConfigWrite) == null ? void 0 : s.blockId) !== e && this._syncNodeConfigToStore();
|
|
214
226
|
}
|
|
215
227
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
216
228
|
_isPendingStrategyIdChange() {
|
|
217
|
-
const
|
|
218
|
-
return
|
|
229
|
+
const e = this.pendingNodeConfigWrite;
|
|
230
|
+
return e ? d.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
|
|
219
231
|
}
|
|
220
232
|
_capturePendingNodeConfigWrite() {
|
|
221
|
-
const t = this.store.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
233
|
+
const e = this.store.currentRecommendationId, t = e === null ? void 0 : this.store.blockStates[e];
|
|
234
|
+
!this.currentNode || !this.api || e === null || !t || (this.pendingNodeConfigWrite = {
|
|
235
|
+
blockId: e,
|
|
236
|
+
updates: this._getNodeConfigUpdates(t.recommendationConfigs)
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
_getNodeConfigUpdates(e) {
|
|
240
|
+
const { filters: t, strategy: o, strategyId: n, size: s, nodeConfigVersion: r } = e, { partnerName: a } = g();
|
|
241
|
+
return {
|
|
242
|
+
filters: t,
|
|
243
|
+
strategy: o,
|
|
244
|
+
strategyId: n,
|
|
245
|
+
size: s,
|
|
246
|
+
configVersion: r,
|
|
247
|
+
...a.value ? { partnerName: a.value } : {}
|
|
236
248
|
};
|
|
237
249
|
}
|
|
238
250
|
/**
|
|
@@ -245,9 +257,9 @@ class at extends N {
|
|
|
245
257
|
* @param documentModifier - The batch to accumulate into
|
|
246
258
|
* @returns Whether anything was staged
|
|
247
259
|
*/
|
|
248
|
-
_stagePendingNodeConfig(
|
|
249
|
-
const
|
|
250
|
-
return !
|
|
260
|
+
_stagePendingNodeConfig(e) {
|
|
261
|
+
const t = this.pendingNodeConfigWrite;
|
|
262
|
+
return !t || !this.currentNode ? !1 : (d.stageConfig(e, this.currentNode, t.updates), !0);
|
|
251
263
|
}
|
|
252
264
|
/**
|
|
253
265
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -264,45 +276,57 @@ class at extends N {
|
|
|
264
276
|
}
|
|
265
277
|
/**
|
|
266
278
|
* Writes the deferred change standalone when the batch it was staged into never
|
|
267
|
-
* committed. Always targets
|
|
268
|
-
*
|
|
279
|
+
* committed. Always targets a LIVE node — a captured one is an immutable snapshot
|
|
280
|
+
* the intervening re-render staled, and saveConfig swallows that failure.
|
|
269
281
|
*/
|
|
270
282
|
_flushPendingNodeConfig() {
|
|
271
|
-
const
|
|
272
|
-
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
283
|
+
const e = this.pendingNodeConfigWrite;
|
|
284
|
+
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !(!e || !this.api)) {
|
|
285
|
+
if (e.blockId !== this.store.currentRecommendationId || !this.currentNode) {
|
|
286
|
+
const { blockId: t, updates: o } = e;
|
|
287
|
+
!m(t, o, f) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
this._isEditedConfigChange(e) && d.updateConfig(
|
|
291
|
+
this.api,
|
|
292
|
+
this.currentNode,
|
|
293
|
+
e.updates,
|
|
294
|
+
f
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
_isEditedConfigChange(e) {
|
|
299
|
+
return !e || !this.currentNode ? !1 : B(this.currentNode, e.updates);
|
|
276
300
|
}
|
|
277
301
|
_syncNodeConfigToStore() {
|
|
278
302
|
var n;
|
|
279
|
-
const
|
|
303
|
+
const e = d.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
280
304
|
this.store.patchCurrentBlockConfig({
|
|
281
|
-
strategy:
|
|
282
|
-
strategyId:
|
|
283
|
-
nodeConfigVersion:
|
|
284
|
-
language:
|
|
285
|
-
size:
|
|
286
|
-
productIds:
|
|
287
|
-
cardsInRow:
|
|
288
|
-
mobileCardsInRow:
|
|
289
|
-
mobileLayoutEnabled:
|
|
290
|
-
orientation:
|
|
305
|
+
strategy: e.strategy,
|
|
306
|
+
strategyId: e.strategyId,
|
|
307
|
+
nodeConfigVersion: e.configVersion,
|
|
308
|
+
language: e.language,
|
|
309
|
+
size: e.size,
|
|
310
|
+
productIds: e.productIds,
|
|
311
|
+
cardsInRow: e.cardsInRow,
|
|
312
|
+
mobileCardsInRow: e.mobileCardsInRow,
|
|
313
|
+
mobileLayoutEnabled: e.mobileLayoutEnabled,
|
|
314
|
+
orientation: e.layout,
|
|
291
315
|
// Only sync filters from node config during initial load.
|
|
292
316
|
// After initialization, the Pinia store is the source of truth
|
|
293
317
|
// for filters (edited via the filter drawer).
|
|
294
|
-
...o ? {} : { filters:
|
|
295
|
-
shuffleProducts:
|
|
296
|
-
priceMovedToNextLine:
|
|
297
|
-
priceHideIfSameAsDiscounted:
|
|
318
|
+
...o ? {} : { filters: e.filters },
|
|
319
|
+
shuffleProducts: e.shuffleProducts,
|
|
320
|
+
priceMovedToNextLine: e.priceMovedToNextLine,
|
|
321
|
+
priceHideIfSameAsDiscounted: e.priceHideIfSameAsDiscounted,
|
|
298
322
|
currencySettings: {
|
|
299
|
-
name:
|
|
300
|
-
value:
|
|
301
|
-
symbol:
|
|
302
|
-
alignment:
|
|
303
|
-
decimalCount:
|
|
304
|
-
decimalSeparator:
|
|
305
|
-
thousandSeparator:
|
|
323
|
+
name: e.currency.code,
|
|
324
|
+
value: e.currency.code,
|
|
325
|
+
symbol: e.currency.symbol,
|
|
326
|
+
alignment: e.currency.alignment === "before" ? "0" : "1",
|
|
327
|
+
decimalCount: e.currency.decimalCount.toString(),
|
|
328
|
+
decimalSeparator: e.currency.decimalSeparator,
|
|
329
|
+
thousandSeparator: e.currency.thousandSeparator
|
|
306
330
|
}
|
|
307
331
|
}, { triggerRefetch: !1 });
|
|
308
332
|
}
|
|
@@ -315,18 +339,27 @@ class at extends N {
|
|
|
315
339
|
* Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
|
|
316
340
|
* Marks the block as initialized to prevent redundant fetches on re-selection.
|
|
317
341
|
*/
|
|
318
|
-
async _fetchBlockData(
|
|
319
|
-
|
|
342
|
+
async _fetchBlockData(e) {
|
|
343
|
+
if (e !== null && this.store.markBlockInitialized(e), (await Promise.allSettled([
|
|
320
344
|
this.store.fetchRecommendationCreateData(),
|
|
321
345
|
this.store.fetchRecommendationFilters()
|
|
322
|
-
])).forEach((
|
|
323
|
-
|
|
324
|
-
}), this.
|
|
346
|
+
])).forEach((n, s) => {
|
|
347
|
+
n.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][s]} failed`, n.reason);
|
|
348
|
+
}), e !== null && this.store.currentRecommendationId !== e) {
|
|
349
|
+
this._refreshOutsidePanel(e, !0);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
this._applySmartDefaults();
|
|
353
|
+
const o = this._getBlockConfigVersion(e);
|
|
325
354
|
try {
|
|
326
355
|
await this.store.fetchRecommendationProducts();
|
|
327
|
-
} catch (
|
|
328
|
-
console.warn("Recommendation block: fetchRecommendationProducts failed",
|
|
356
|
+
} catch (n) {
|
|
357
|
+
console.warn("Recommendation block: fetchRecommendationProducts failed", n);
|
|
329
358
|
}
|
|
359
|
+
e !== null && !this._isPanelOn(e) && this._refreshOutsidePanel(e, this._getBlockConfigVersion(e) !== o);
|
|
360
|
+
}
|
|
361
|
+
_isPanelOn(e) {
|
|
362
|
+
return this.isPanelAlive && this.store.currentRecommendationId === e;
|
|
330
363
|
}
|
|
331
364
|
/**
|
|
332
365
|
* Applies smart defaults for newly dropped blocks.
|
|
@@ -341,49 +374,49 @@ class at extends N {
|
|
|
341
374
|
_applySmartDefaults() {
|
|
342
375
|
if (!this.currentNode || !this.api)
|
|
343
376
|
return;
|
|
344
|
-
const
|
|
377
|
+
const e = d.getConfig(this.currentNode), t = {};
|
|
345
378
|
let o = null, n = null, s = null;
|
|
346
|
-
if (
|
|
379
|
+
if (e.currency.code === l.currency.code) {
|
|
347
380
|
const { currencyList: r } = this.store;
|
|
348
381
|
r.length > 0 && (r.some(
|
|
349
|
-
(
|
|
350
|
-
) || (o = r[0].value.replace("price.", ""),
|
|
351
|
-
...
|
|
382
|
+
(u) => u.value === `price.${l.currency.code}`
|
|
383
|
+
) || (o = r[0].value.replace("price.", ""), t.currency = {
|
|
384
|
+
...l.currency,
|
|
352
385
|
code: o,
|
|
353
386
|
symbol: o
|
|
354
387
|
}));
|
|
355
388
|
}
|
|
356
|
-
if (
|
|
389
|
+
if (e.strategy === l.strategy) {
|
|
357
390
|
const r = this.store.getActivePredictiveAlgorithms;
|
|
358
391
|
r.length > 0 && (r.some(
|
|
359
|
-
(
|
|
360
|
-
) || (n = r[0].value,
|
|
392
|
+
(u) => u.value === l.strategy
|
|
393
|
+
) || (n = r[0].value, t.strategy = n));
|
|
361
394
|
}
|
|
362
|
-
if (
|
|
395
|
+
if (e.language === l.language) {
|
|
363
396
|
const r = this.store.getLanguages;
|
|
364
397
|
r.length > 0 && (r.some(
|
|
365
|
-
(
|
|
366
|
-
) || (s = r[0].value,
|
|
398
|
+
(u) => u.value === l.language
|
|
399
|
+
) || (s = r[0].value, t.language = s));
|
|
367
400
|
}
|
|
368
|
-
!o && !n && !s || (
|
|
401
|
+
!o && !n && !s || (d.updateConfig(
|
|
369
402
|
this.api,
|
|
370
403
|
this.currentNode,
|
|
371
|
-
|
|
404
|
+
t,
|
|
372
405
|
"Applied smart defaults"
|
|
373
|
-
), o &&
|
|
406
|
+
), o && t.currency && W({
|
|
374
407
|
currentNode: this.currentNode,
|
|
375
408
|
documentModifier: this.api.getDocumentModifier(),
|
|
376
|
-
currency:
|
|
409
|
+
currency: t.currency
|
|
377
410
|
}), this.store.patchCurrentBlockConfig({
|
|
378
411
|
...o ? {
|
|
379
412
|
currencySettings: {
|
|
380
413
|
name: o,
|
|
381
414
|
value: o,
|
|
382
415
|
symbol: o,
|
|
383
|
-
alignment:
|
|
384
|
-
decimalCount:
|
|
385
|
-
decimalSeparator:
|
|
386
|
-
thousandSeparator:
|
|
416
|
+
alignment: l.currency.alignment === "before" ? "0" : "1",
|
|
417
|
+
decimalCount: l.currency.decimalCount.toString(),
|
|
418
|
+
decimalSeparator: l.currency.decimalSeparator,
|
|
419
|
+
thousandSeparator: l.currency.thousandSeparator
|
|
387
420
|
}
|
|
388
421
|
} : {},
|
|
389
422
|
...n ? { strategy: n } : {},
|
|
@@ -393,20 +426,88 @@ class at extends N {
|
|
|
393
426
|
/**
|
|
394
427
|
* Reads the recommendation-id attribute from the block element within the node
|
|
395
428
|
*/
|
|
396
|
-
_getRecommendationIdFromNode(
|
|
397
|
-
const
|
|
398
|
-
if (!
|
|
429
|
+
_getRecommendationIdFromNode(e) {
|
|
430
|
+
const t = G(e);
|
|
431
|
+
if (!t || !("getAttribute" in t))
|
|
399
432
|
return null;
|
|
400
|
-
const o =
|
|
433
|
+
const o = t.getAttribute(k);
|
|
401
434
|
if (!o)
|
|
402
435
|
return null;
|
|
403
436
|
const n = parseInt(o);
|
|
404
437
|
return Number.isNaN(n) ? null : n;
|
|
405
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* Lands what the panel still owes its block before it stops watching it: the config now, the
|
|
441
|
+
* products through a block-scoped refresh. Never throws — it runs from Stripo's teardown.
|
|
442
|
+
*/
|
|
443
|
+
_finishBlockOutsidePanel(e = this._trackedBlockSnapshot()) {
|
|
444
|
+
const { blockId: t, fetchedConfigVersion: o, hasUnrenderedProducts: n, followUpAnchor: s } = e;
|
|
445
|
+
try {
|
|
446
|
+
this._flushPendingNodeConfig();
|
|
447
|
+
const r = t === null ? void 0 : this.store.blockStates[t];
|
|
448
|
+
if (t === null || !r)
|
|
449
|
+
return;
|
|
450
|
+
const a = o !== r.configVersion;
|
|
451
|
+
a && !m(
|
|
452
|
+
t,
|
|
453
|
+
this._getNodeConfigUpdates(r.recommendationConfigs),
|
|
454
|
+
f
|
|
455
|
+
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: t }), (a || n) && this._refreshOutsidePanel(t, a, a ? null : s);
|
|
456
|
+
} catch (r) {
|
|
457
|
+
console.error("[recommendation] finishing the block outside the panel failed", r);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
_trackedBlockSnapshot() {
|
|
461
|
+
return {
|
|
462
|
+
blockId: this.trackedBlockId,
|
|
463
|
+
fetchedConfigVersion: this.fetchedConfigVersion,
|
|
464
|
+
hasUnrenderedProducts: this.hasUnrenderedProducts,
|
|
465
|
+
followUpAnchor: this.followUpAnchor
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
_refreshOutsidePanel(e, t, o = null) {
|
|
469
|
+
I(e, {
|
|
470
|
+
pickUpdates: (n) => this._getNodeConfigUpdates(n),
|
|
471
|
+
description: "Update recommendation configuration",
|
|
472
|
+
fetch: t,
|
|
473
|
+
followUpAnchor: o
|
|
474
|
+
}).then((n) => {
|
|
475
|
+
!n && this.store.blockStates[e] && console.error("[recommendation] refresh outside the panel did not reach a node", { blockId: e });
|
|
476
|
+
}).catch((n) => {
|
|
477
|
+
console.error("[recommendation] refresh outside the panel failed", n);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
_getBlockConfigVersion(e) {
|
|
481
|
+
var t;
|
|
482
|
+
return e === null ? 0 : ((t = this.store.blockStates[e]) == null ? void 0 : t.configVersion) ?? 0;
|
|
483
|
+
}
|
|
484
|
+
/** Draws the current block's products into this panel's node. */
|
|
485
|
+
_regenerateWithProducts() {
|
|
486
|
+
if (!this.currentNode || !this.api)
|
|
487
|
+
return;
|
|
488
|
+
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = !this._isEditedConfigChange(this.pendingNodeConfigWrite) && b(this.followUpAnchor);
|
|
489
|
+
this.followUpAnchor = null;
|
|
490
|
+
const n = this._stagePendingNodeConfig(t);
|
|
491
|
+
if (M(this.currentNode)) {
|
|
492
|
+
n && (T(t, "Update recommendation configuration", o), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
z({
|
|
496
|
+
currentNode: this.currentNode,
|
|
497
|
+
documentModifier: t,
|
|
498
|
+
products: e,
|
|
499
|
+
hidden: o
|
|
500
|
+
}) || $({
|
|
501
|
+
currentNode: this.currentNode,
|
|
502
|
+
documentModifier: t,
|
|
503
|
+
products: e,
|
|
504
|
+
hidden: o
|
|
505
|
+
});
|
|
506
|
+
}
|
|
406
507
|
/**
|
|
407
508
|
* Listen to store changes that require product refresh or regeneration.
|
|
408
509
|
*
|
|
409
|
-
* Uses configVersion counter (
|
|
510
|
+
* Uses the block's configVersion counter (bumped by patchCurrentBlockConfig and legacy conversion)
|
|
410
511
|
* to distinguish user-initiated config changes from internal mutations
|
|
411
512
|
* (e.g., fetchRecommendationCreateData setting preferred currency).
|
|
412
513
|
*
|
|
@@ -417,55 +518,57 @@ class at extends N {
|
|
|
417
518
|
* We skip that tick and update tracking references instead.
|
|
418
519
|
*/
|
|
419
520
|
_listenStateUpdates() {
|
|
420
|
-
const { store:
|
|
421
|
-
let
|
|
422
|
-
this.storeUnsubscription =
|
|
423
|
-
const
|
|
424
|
-
if (
|
|
425
|
-
|
|
521
|
+
const { store: e } = this;
|
|
522
|
+
let t = e.recommendationProducts, o = this._getBlockConfigVersion(e.currentRecommendationId);
|
|
523
|
+
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.followUpAnchor = null, this.storeUnsubscription = e.$subscribe(() => {
|
|
524
|
+
const n = e.currentRecommendationId;
|
|
525
|
+
if (n !== this.trackedBlockId) {
|
|
526
|
+
const p = this._trackedBlockSnapshot();
|
|
527
|
+
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.followUpAnchor = null, this._finishBlockOutsidePanel(p);
|
|
426
528
|
return;
|
|
427
529
|
}
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
|
|
530
|
+
const s = this._getBlockConfigVersion(n);
|
|
531
|
+
s !== o && (o = s, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, this.panelGeneration));
|
|
532
|
+
const r = e.recommendationProducts, a = r !== t, u = Array.isArray(r) && r.length > 0;
|
|
533
|
+
a && u && (t = r, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
|
|
432
534
|
});
|
|
433
535
|
}
|
|
434
536
|
}
|
|
435
537
|
export {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
538
|
+
pe as ALGORITHM_CONTROL_ID,
|
|
539
|
+
U as AlgorithmControl,
|
|
540
|
+
H as CONTROL_BLOCK_ID,
|
|
541
|
+
ye as CURRENCY_CONTROL_ID,
|
|
542
|
+
E as CurrencyControl,
|
|
543
|
+
Pe as FILTERS_CONTROL_ID,
|
|
544
|
+
L as FiltersControl,
|
|
545
|
+
Re as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
546
|
+
Se as LOCALE_CONTROL_ID,
|
|
547
|
+
F as LayoutOrientationControl,
|
|
548
|
+
w as LocaleControl,
|
|
549
|
+
Te as PRICE_PLACEMENT_CONTROL_ID,
|
|
550
|
+
Be as PRODUCT_COUNT_CONTROL_ID,
|
|
551
|
+
Ee as PRODUCT_LAYOUT_CONTROL_ID,
|
|
552
|
+
A as PricePlacementControl,
|
|
553
|
+
D as ProductCountControl,
|
|
554
|
+
v as ProductLayoutControl,
|
|
555
|
+
ge as RecommendationBlockControl,
|
|
556
|
+
Fe as SHUFFLE_CONTROL_ID,
|
|
557
|
+
Ae as STRATEGY_CONTROL_ID,
|
|
558
|
+
V as ShuffleControl,
|
|
559
|
+
x as StrategyControl,
|
|
560
|
+
ve as adjustProductsToSize,
|
|
561
|
+
Ve as formatProductPrice,
|
|
562
|
+
G as getBlockElement,
|
|
563
|
+
xe as getCardComposition,
|
|
564
|
+
We as getCurrencyAttributesFromBlock,
|
|
565
|
+
Ge as getCurrentLayout,
|
|
566
|
+
Me as getMainContainerTbody,
|
|
567
|
+
M as isPartnerManagedBlock,
|
|
568
|
+
ze as regenerateMobileProductRows,
|
|
569
|
+
$ as regenerateProductRowsWithStyles,
|
|
570
|
+
W as setCurrencyAttributes,
|
|
571
|
+
$e as updatePricesInPlace,
|
|
572
|
+
z as updateProductContentInPlace,
|
|
573
|
+
He as updateSingleProductContent
|
|
471
574
|
};
|