@useinsider/guido 3.17.0-beta.ddd4dde → 3.17.0-beta.e23d5cd
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 +1 -0
- package/dist/@types/config/schemas.js +7 -6
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +77 -73
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +106 -0
- package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
- package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +63 -0
- package/dist/composables/useCustomInterfaceAppearance.js +52 -38
- package/dist/composables/useRecommendation.js +41 -34
- package/dist/config/migrator/recommendation/settingsMapper.js +17 -17
- package/dist/config/migrator/recommendationMigrator.js +5 -4
- package/dist/enums/academy.js +2 -1
- package/dist/enums/date.js +5 -3
- package/dist/enums/extensions/recommendationBlock.js +3 -1
- package/dist/extensions/Blocks/Items/block.js +49 -98
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +24 -25
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +11 -12
- package/dist/extensions/Blocks/Items/template.js +152 -153
- package/dist/extensions/Blocks/Recommendation/block.js +26 -21
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +34 -34
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +96 -95
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +238 -185
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +124 -0
- package/dist/extensions/Blocks/Recommendation/services/configService.js +54 -36
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +165 -79
- package/dist/extensions/Blocks/common-control.js +22 -19
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +69 -30
- package/dist/src/@types/config/schemas.d.ts +2 -0
- package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
- package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +15 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useRecommendation.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/date.d.ts +1 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +0 -21
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +2 -6
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +44 -8
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +16 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +12 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +150 -10
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
- package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
- package/dist/src/services/recommendationApi.d.ts +4 -1
- package/dist/src/stores/config.d.ts +18 -0
- package/dist/src/stores/save-as-template.d.ts +4 -3
- package/dist/src/utils/genericUtil.d.ts +5 -0
- package/dist/static/assets/icons/line-change.svg.js +5 -0
- package/dist/static/assets/icons/line-delete.svg.js +5 -0
- package/dist/static/assets/icons/line-plus.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +155 -0
- package/dist/utils/dateUtil.js +23 -10
- package/dist/utils/genericUtil.js +28 -27
- package/dist/utils/pairProductVariables.js +59 -60
- package/dist/utils/templatePreparation.js +35 -34
- package/package.json +2 -1
- package/dist/extensions/Blocks/Items/constants/currency.js +0 -11
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +0 -19
|
@@ -1,53 +1,64 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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
|
-
|
|
30
|
-
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var C = (h, l, t) => l in h ? m(h, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[l] = t;
|
|
3
|
+
var r = (h, l, t) => C(h, typeof l != "symbol" ? l + "" : l, t);
|
|
4
|
+
import { useConfig as p } from "../../../../../composables/useConfig.js";
|
|
5
|
+
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
+
import { CommonControl as N } from "../../../common-control.js";
|
|
7
|
+
import { CURRENT_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RecommendationConfigService as c } from "../../services/configService.js";
|
|
9
|
+
import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
|
|
10
|
+
import { AlgorithmControl as R } from "./algorithm.js";
|
|
11
|
+
import { ALGORITHM_CONTROL_ID as at } from "./algorithm.js";
|
|
12
|
+
import { CurrencyControl as b } from "./currency.js";
|
|
13
|
+
import { CURRENCY_CONTROL_ID as ct } from "./currency.js";
|
|
14
|
+
import { FiltersControl as T } from "./filters.js";
|
|
15
|
+
import { FILTERS_CONTROL_ID as dt } from "./filters.js";
|
|
16
|
+
import { LayoutOrientationControl as P } from "./layoutOrientation.js";
|
|
17
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as ft } from "./layoutOrientation.js";
|
|
18
|
+
import { LocaleControl as S } from "./locale.js";
|
|
19
|
+
import { LOCALE_CONTROL_ID as mt } from "./locale.js";
|
|
20
|
+
import { PricePlacementControl as O } from "./pricePlacement.js";
|
|
21
|
+
import { PRICE_PLACEMENT_CONTROL_ID as pt } from "./pricePlacement.js";
|
|
22
|
+
import { ProductCountControl as L } from "./productCount.js";
|
|
23
|
+
import { PRODUCT_COUNT_CONTROL_ID as Nt } from "./productCount.js";
|
|
24
|
+
import { ProductLayoutControl as E } from "./productLayout.js";
|
|
25
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as It } from "./productLayout.js";
|
|
26
|
+
import { ShuffleControl as k } from "./shuffle.js";
|
|
27
|
+
import { SHUFFLE_CONTROL_ID as bt } from "./shuffle.js";
|
|
28
|
+
import { StrategyControl as D } from "./strategy.js";
|
|
29
|
+
import { STRATEGY_CONTROL_ID as Pt } from "./strategy.js";
|
|
30
|
+
import { setCurrencyAttributes as F, getBlockElement as w, isPartnerManagedBlock as A, updateProductContentInPlace as v, regenerateProductRowsWithStyles as x } from "./utils.js";
|
|
31
|
+
import { adjustProductsToSize as Ot, formatProductPrice as Lt, getCardComposition as Et, getCurrentLayout as kt, regenerateMobileProductRows as Dt, updatePricesInPlace as Ft, updateSingleProductContent as wt } from "./utils.js";
|
|
32
|
+
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
33
|
+
const B = "recommendation-id", U = "ui-elements-recommendation-block";
|
|
34
|
+
class rt extends N {
|
|
31
35
|
constructor() {
|
|
32
36
|
super(...arguments);
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
r(this, "store", I());
|
|
38
|
+
r(this, "storeUnsubscription", () => {
|
|
35
39
|
});
|
|
36
|
-
|
|
40
|
+
// blockId -> fingerprint of the node config as it looked at the last sync.
|
|
41
|
+
r(this, "syncedConfigs", /* @__PURE__ */ new Map());
|
|
42
|
+
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
43
|
+
// re-render's single apply() — one user action must cost one undo press.
|
|
44
|
+
r(this, "pendingNodeConfigWrite", null);
|
|
45
|
+
r(this, "pendingConfigFlushTimer", null);
|
|
37
46
|
// Sub-control instances for lifecycle management
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
r(this, "algorithmControl", null);
|
|
48
|
+
r(this, "localeControl", null);
|
|
49
|
+
r(this, "currencyControl", null);
|
|
50
|
+
r(this, "productCountControl", null);
|
|
51
|
+
r(this, "productLayoutControl", null);
|
|
52
|
+
r(this, "filtersControl", null);
|
|
53
|
+
r(this, "shuffleControl", null);
|
|
54
|
+
r(this, "pricePlacementControl", null);
|
|
55
|
+
r(this, "layoutOrientationControl", null);
|
|
56
|
+
r(this, "strategyControl", null);
|
|
57
|
+
r(this, "rrsEnabled", !1);
|
|
47
58
|
/**
|
|
48
59
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
49
60
|
*/
|
|
50
|
-
|
|
61
|
+
r(this, "_debouncedFetchProducts", f(() => {
|
|
51
62
|
this.store.fetchRecommendationProducts();
|
|
52
63
|
}, 500));
|
|
53
64
|
/**
|
|
@@ -61,16 +72,20 @@ class Q extends g {
|
|
|
61
72
|
* count. The store pads products to the configured size, so in-place only
|
|
62
73
|
* fails when the size actually changed.
|
|
63
74
|
*/
|
|
64
|
-
|
|
75
|
+
r(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
65
76
|
const t = this.store.recommendationProducts;
|
|
66
|
-
if (!this.currentNode || !this.api
|
|
77
|
+
if (!this.currentNode || !this.api)
|
|
67
78
|
return;
|
|
68
|
-
const e = this.api.getDocumentModifier();
|
|
69
|
-
|
|
79
|
+
const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
80
|
+
if (A(this.currentNode)) {
|
|
81
|
+
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
v({
|
|
70
85
|
currentNode: this.currentNode,
|
|
71
86
|
documentModifier: e,
|
|
72
87
|
products: t
|
|
73
|
-
}) ||
|
|
88
|
+
}) || x({
|
|
74
89
|
currentNode: this.currentNode,
|
|
75
90
|
documentModifier: e,
|
|
76
91
|
products: t
|
|
@@ -78,23 +93,32 @@ class Q extends g {
|
|
|
78
93
|
}, 100));
|
|
79
94
|
}
|
|
80
95
|
getId() {
|
|
81
|
-
return
|
|
96
|
+
return U;
|
|
82
97
|
}
|
|
83
|
-
|
|
84
|
-
return
|
|
98
|
+
get _subControls() {
|
|
99
|
+
return [
|
|
100
|
+
this.layoutOrientationControl,
|
|
101
|
+
this.productCountControl,
|
|
85
102
|
this.algorithmControl,
|
|
86
103
|
this.localeControl,
|
|
87
104
|
this.currencyControl,
|
|
88
|
-
this.productCountControl,
|
|
89
105
|
this.productLayoutControl,
|
|
90
106
|
this.filtersControl,
|
|
91
107
|
this.shuffleControl,
|
|
92
108
|
this.pricePlacementControl,
|
|
93
|
-
this.
|
|
94
|
-
]
|
|
95
|
-
|
|
109
|
+
this.strategyControl
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
getTemplate() {
|
|
113
|
+
var t;
|
|
114
|
+
return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
|
|
115
|
+
var o;
|
|
116
|
+
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
117
|
+
}), this.algorithmControl = new R(), this.localeControl = new S(), this.currencyControl = new b(), this.productCountControl = new L(), this.productLayoutControl = new E(), this.filtersControl = new T(), this.shuffleControl = new k(), this.pricePlacementControl = new O(), this.layoutOrientationControl = new P(), this.strategyControl = this.rrsEnabled ? new D() : null, this._subControls.forEach((e) => {
|
|
118
|
+
e && (e.api = this.api);
|
|
96
119
|
}), `
|
|
97
120
|
<div class="recommendation-controls-container">
|
|
121
|
+
${((t = this.strategyControl) == null ? void 0 : t.getTemplate()) ?? ""}
|
|
98
122
|
${this.layoutOrientationControl.getTemplate()}
|
|
99
123
|
${this.productCountControl.getTemplate()}
|
|
100
124
|
${this.productLayoutControl.getTemplate()}
|
|
@@ -107,50 +131,38 @@ class Q extends g {
|
|
|
107
131
|
</div>
|
|
108
132
|
`;
|
|
109
133
|
}
|
|
134
|
+
_showControlsForBlock(t) {
|
|
135
|
+
var i;
|
|
136
|
+
const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
|
|
137
|
+
if (!e)
|
|
138
|
+
return;
|
|
139
|
+
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _);
|
|
140
|
+
e.classList.toggle("strategy-block", n);
|
|
141
|
+
}
|
|
110
142
|
async onRender() {
|
|
111
143
|
var o;
|
|
112
144
|
const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
|
|
113
|
-
if (e !== null && this.store.setCurrentBlock(e), t !== null &&
|
|
145
|
+
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
|
|
114
146
|
this._initializeSubControls();
|
|
115
147
|
return;
|
|
116
148
|
}
|
|
117
149
|
await this._fetchBlockData(e), this._initializeSubControls();
|
|
118
150
|
}
|
|
119
151
|
onTemplateNodeUpdated(t) {
|
|
120
|
-
var
|
|
152
|
+
var o;
|
|
121
153
|
super.onTemplateNodeUpdated(t);
|
|
122
154
|
const e = this._getRecommendationIdFromNode(t);
|
|
123
|
-
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null &&
|
|
155
|
+
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigIfChanged(e), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
|
|
124
156
|
this._initializeSubControls();
|
|
125
|
-
}),
|
|
126
|
-
this.layoutOrientationControl,
|
|
127
|
-
this.productCountControl,
|
|
128
|
-
this.algorithmControl,
|
|
129
|
-
this.localeControl,
|
|
130
|
-
this.currencyControl,
|
|
131
|
-
this.productLayoutControl,
|
|
132
|
-
this.filtersControl,
|
|
133
|
-
this.shuffleControl,
|
|
134
|
-
this.pricePlacementControl
|
|
135
|
-
].forEach((n) => {
|
|
157
|
+
}), this._subControls.forEach((n) => {
|
|
136
158
|
var i;
|
|
137
159
|
n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
|
|
138
160
|
});
|
|
139
161
|
}
|
|
140
162
|
onDestroy() {
|
|
141
|
-
this.storeUnsubscription(),
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.algorithmControl,
|
|
145
|
-
this.localeControl,
|
|
146
|
-
this.currencyControl,
|
|
147
|
-
this.productLayoutControl,
|
|
148
|
-
this.filtersControl,
|
|
149
|
-
this.shuffleControl,
|
|
150
|
-
this.pricePlacementControl
|
|
151
|
-
].forEach((e) => {
|
|
152
|
-
var o;
|
|
153
|
-
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
163
|
+
this.storeUnsubscription(), this._flushPendingNodeConfig(), this._subControls.forEach((t) => {
|
|
164
|
+
var e;
|
|
165
|
+
return (e = t == null ? void 0 : t.onDestroy) == null ? void 0 : e.call(t);
|
|
154
166
|
});
|
|
155
167
|
}
|
|
156
168
|
/**
|
|
@@ -158,25 +170,14 @@ class Q extends g {
|
|
|
158
170
|
* Each sub-control manages its own form values and event listeners
|
|
159
171
|
*/
|
|
160
172
|
_initializeSubControls() {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.
|
|
164
|
-
this.algorithmControl,
|
|
165
|
-
this.localeControl,
|
|
166
|
-
this.currencyControl,
|
|
167
|
-
this.productLayoutControl,
|
|
168
|
-
this.filtersControl,
|
|
169
|
-
this.shuffleControl,
|
|
170
|
-
this.pricePlacementControl
|
|
171
|
-
].forEach((e) => {
|
|
172
|
-
var o;
|
|
173
|
-
e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
|
|
173
|
+
this._subControls.forEach((t) => {
|
|
174
|
+
var e;
|
|
175
|
+
t && (t.api = this.api, t.currentNode = this.currentNode, (e = t.onRender) == null || e.call(t));
|
|
174
176
|
});
|
|
175
177
|
}
|
|
176
178
|
/**
|
|
177
179
|
* Syncs persisted node config into the Pinia store's block state.
|
|
178
180
|
*
|
|
179
|
-
* setCurrentBlock() creates a default entry (USD, en_US, mostPopular).
|
|
180
181
|
* For saved templates, the real config lives in the node (e.g., TRY, tr_TR).
|
|
181
182
|
* This method reads it and patches the store so fetchRecommendationProducts()
|
|
182
183
|
* uses the correct values.
|
|
@@ -184,11 +185,76 @@ class Q extends g {
|
|
|
184
185
|
* Uses triggerRefetch: false because the fetch hasn't happened yet —
|
|
185
186
|
* values are being prepared for the upcoming initial fetch.
|
|
186
187
|
*/
|
|
188
|
+
/**
|
|
189
|
+
* Re-syncs the store when the node config moved since we last read it.
|
|
190
|
+
*
|
|
191
|
+
* Undo/redo, the code editor and version-history restore rewrite the node
|
|
192
|
+
* config behind the store's back — Stripo exposes no undo signal, so a
|
|
193
|
+
* fingerprint diff on this hook is the only way to notice (SD-149105).
|
|
194
|
+
* An unchanged fingerprint means the move came from us, so runtime store
|
|
195
|
+
* edits are never clobbered (SD-141049).
|
|
196
|
+
*/
|
|
197
|
+
_syncNodeConfigIfChanged(t) {
|
|
198
|
+
this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== t && this._flushPendingNodeConfig();
|
|
199
|
+
const e = JSON.stringify(c.getConfig(this.currentNode)), o = this.syncedConfigs.get(t);
|
|
200
|
+
this.syncedConfigs.set(t, e), o !== e && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
201
|
+
}
|
|
202
|
+
_capturePendingNodeConfigWrite() {
|
|
203
|
+
const t = this.store.currentRecommendationId;
|
|
204
|
+
if (!this.currentNode || !this.api || t === null)
|
|
205
|
+
return;
|
|
206
|
+
const { filters: e, strategyId: o, size: n } = this.store.recommendationConfigs;
|
|
207
|
+
this.pendingNodeConfigWrite = {
|
|
208
|
+
blockId: t,
|
|
209
|
+
node: this.currentNode,
|
|
210
|
+
updates: { filters: e, strategyId: o, size: n }
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Accumulates the pending write into `documentModifier` without applying, so the
|
|
215
|
+
* caller's apply() commits config and re-render as ONE undo entry.
|
|
216
|
+
*
|
|
217
|
+
* Deliberately does not consume the pending record: the product helpers call
|
|
218
|
+
* apply() only when they actually changed something, so this batch may never be
|
|
219
|
+
* committed and the flush has to stay able to write it standalone.
|
|
220
|
+
* @param documentModifier - The batch to accumulate into
|
|
221
|
+
* @returns Whether anything was staged
|
|
222
|
+
*/
|
|
223
|
+
_stagePendingNodeConfig(t) {
|
|
224
|
+
const e = this.pendingNodeConfigWrite;
|
|
225
|
+
return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Arms the guaranteed fallback write. The delay has to outlast the product fetch
|
|
229
|
+
* and the re-render debounce it triggers — firing earlier writes the config on
|
|
230
|
+
* its own and the undo entry splits in two again.
|
|
231
|
+
*/
|
|
232
|
+
_scheduleConfigFlush() {
|
|
233
|
+
this._clearConfigFlush(), this.pendingConfigFlushTimer = setTimeout(() => {
|
|
234
|
+
this.pendingConfigFlushTimer = null, this._flushPendingNodeConfig();
|
|
235
|
+
}, 800);
|
|
236
|
+
}
|
|
237
|
+
_clearConfigFlush() {
|
|
238
|
+
this.pendingConfigFlushTimer !== null && (clearTimeout(this.pendingConfigFlushTimer), this.pendingConfigFlushTimer = null);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Writes the deferred change standalone when the batch it was staged into never
|
|
242
|
+
* committed. Always targets the LIVE node — the captured one is an immutable
|
|
243
|
+
* snapshot the intervening re-render staled, and saveConfig swallows that failure.
|
|
244
|
+
*/
|
|
245
|
+
_flushPendingNodeConfig() {
|
|
246
|
+
const t = this.pendingNodeConfigWrite;
|
|
247
|
+
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
248
|
+
return;
|
|
249
|
+
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
|
|
250
|
+
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
251
|
+
}
|
|
187
252
|
_syncNodeConfigToStore() {
|
|
188
|
-
var
|
|
189
|
-
const t =
|
|
253
|
+
var n;
|
|
254
|
+
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
|
|
190
255
|
this.store.patchCurrentBlockConfig({
|
|
191
256
|
strategy: t.strategy,
|
|
257
|
+
strategyId: t.strategyId,
|
|
192
258
|
language: t.language,
|
|
193
259
|
size: t.size,
|
|
194
260
|
productIds: t.productIds,
|
|
@@ -227,8 +293,8 @@ class Q extends g {
|
|
|
227
293
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
228
294
|
this.store.fetchRecommendationCreateData(),
|
|
229
295
|
this.store.fetchRecommendationFilters()
|
|
230
|
-
])).forEach((o,
|
|
231
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
296
|
+
])).forEach((o, n) => {
|
|
297
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
|
|
232
298
|
}), this._applySmartDefaults();
|
|
233
299
|
try {
|
|
234
300
|
await this.store.fetchRecommendationProducts();
|
|
@@ -249,36 +315,36 @@ class Q extends g {
|
|
|
249
315
|
_applySmartDefaults() {
|
|
250
316
|
if (!this.currentNode || !this.api)
|
|
251
317
|
return;
|
|
252
|
-
const t =
|
|
253
|
-
let o = null,
|
|
254
|
-
if (t.currency.code ===
|
|
255
|
-
const { currencyList:
|
|
256
|
-
|
|
257
|
-
(
|
|
258
|
-
) || (o =
|
|
259
|
-
...
|
|
318
|
+
const t = c.getConfig(this.currentNode), e = {};
|
|
319
|
+
let o = null, n = null, i = null;
|
|
320
|
+
if (t.currency.code === a.currency.code) {
|
|
321
|
+
const { currencyList: s } = this.store;
|
|
322
|
+
s.length > 0 && (s.some(
|
|
323
|
+
(d) => d.value === `price.${a.currency.code}`
|
|
324
|
+
) || (o = s[0].value.replace("price.", ""), e.currency = {
|
|
325
|
+
...a.currency,
|
|
260
326
|
code: o,
|
|
261
327
|
symbol: o
|
|
262
328
|
}));
|
|
263
329
|
}
|
|
264
|
-
if (t.strategy ===
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
(
|
|
268
|
-
) || (
|
|
330
|
+
if (t.strategy === a.strategy) {
|
|
331
|
+
const s = this.store.getActivePredictiveAlgorithms;
|
|
332
|
+
s.length > 0 && (s.some(
|
|
333
|
+
(d) => d.value === a.strategy
|
|
334
|
+
) || (n = s[0].value, e.strategy = n));
|
|
269
335
|
}
|
|
270
|
-
if (t.language ===
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
(
|
|
274
|
-
) || (
|
|
336
|
+
if (t.language === a.language) {
|
|
337
|
+
const s = this.store.getLanguages;
|
|
338
|
+
s.length > 0 && (s.some(
|
|
339
|
+
(d) => d.value === a.language
|
|
340
|
+
) || (i = s[0].value, e.language = i));
|
|
275
341
|
}
|
|
276
|
-
!o && !
|
|
342
|
+
!o && !n && !i || (c.updateConfig(
|
|
277
343
|
this.api,
|
|
278
344
|
this.currentNode,
|
|
279
345
|
e,
|
|
280
346
|
"Applied smart defaults"
|
|
281
|
-
), o && e.currency &&
|
|
347
|
+
), o && e.currency && F({
|
|
282
348
|
currentNode: this.currentNode,
|
|
283
349
|
documentModifier: this.api.getDocumentModifier(),
|
|
284
350
|
currency: e.currency
|
|
@@ -288,28 +354,28 @@ class Q extends g {
|
|
|
288
354
|
name: o,
|
|
289
355
|
value: o,
|
|
290
356
|
symbol: o,
|
|
291
|
-
alignment:
|
|
292
|
-
decimalCount:
|
|
293
|
-
decimalSeparator:
|
|
294
|
-
thousandSeparator:
|
|
357
|
+
alignment: a.currency.alignment === "before" ? "0" : "1",
|
|
358
|
+
decimalCount: a.currency.decimalCount.toString(),
|
|
359
|
+
decimalSeparator: a.currency.decimalSeparator,
|
|
360
|
+
thousandSeparator: a.currency.thousandSeparator
|
|
295
361
|
}
|
|
296
362
|
} : {},
|
|
297
|
-
...
|
|
298
|
-
...
|
|
363
|
+
...n ? { strategy: n } : {},
|
|
364
|
+
...i ? { language: i } : {}
|
|
299
365
|
}, { triggerRefetch: !1 }));
|
|
300
366
|
}
|
|
301
367
|
/**
|
|
302
368
|
* Reads the recommendation-id attribute from the block element within the node
|
|
303
369
|
*/
|
|
304
370
|
_getRecommendationIdFromNode(t) {
|
|
305
|
-
const e =
|
|
371
|
+
const e = w(t);
|
|
306
372
|
if (!e || !("getAttribute" in e))
|
|
307
373
|
return null;
|
|
308
|
-
const o = e.getAttribute(
|
|
374
|
+
const o = e.getAttribute(B);
|
|
309
375
|
if (!o)
|
|
310
376
|
return null;
|
|
311
|
-
const
|
|
312
|
-
return Number.isNaN(
|
|
377
|
+
const n = parseInt(o);
|
|
378
|
+
return Number.isNaN(n) ? null : n;
|
|
313
379
|
}
|
|
314
380
|
/**
|
|
315
381
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -326,66 +392,53 @@ class Q extends g {
|
|
|
326
392
|
*/
|
|
327
393
|
_listenStateUpdates() {
|
|
328
394
|
const { store: t } = this;
|
|
329
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
395
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
|
|
330
396
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
333
|
-
|
|
397
|
+
const i = t.currentRecommendationId;
|
|
398
|
+
if (i !== n) {
|
|
399
|
+
n = i, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
334
400
|
return;
|
|
335
401
|
}
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
const
|
|
339
|
-
|
|
402
|
+
const s = t.$state.configVersion;
|
|
403
|
+
s !== o && (o = s, this._capturePendingNodeConfigWrite(), this._scheduleConfigFlush(), this._debouncedFetchProducts());
|
|
404
|
+
const u = t.recommendationProducts, d = u !== e, g = Array.isArray(u) && u.length > 0;
|
|
405
|
+
d && g && (e = u, this._debouncedRegenerateWithProducts());
|
|
340
406
|
});
|
|
341
407
|
}
|
|
342
|
-
/**
|
|
343
|
-
* Persists the current filter state from Pinia store to the Stripo node config.
|
|
344
|
-
* This ensures filters survive template save/reload cycles.
|
|
345
|
-
*/
|
|
346
|
-
_persistFiltersToNodeConfig() {
|
|
347
|
-
if (!this.currentNode || !this.api)
|
|
348
|
-
return;
|
|
349
|
-
const { filters: t } = this.store.recommendationConfigs, e = h.getConfig(this.currentNode).filters;
|
|
350
|
-
JSON.stringify(e) !== JSON.stringify(t) && h.updateConfig(
|
|
351
|
-
this.api,
|
|
352
|
-
this.currentNode,
|
|
353
|
-
{ filters: t },
|
|
354
|
-
"Update recommendation filters"
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
408
|
}
|
|
358
409
|
export {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
A as
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
410
|
+
at as ALGORITHM_CONTROL_ID,
|
|
411
|
+
R as AlgorithmControl,
|
|
412
|
+
U as CONTROL_BLOCK_ID,
|
|
413
|
+
ct as CURRENCY_CONTROL_ID,
|
|
414
|
+
b as CurrencyControl,
|
|
415
|
+
dt as FILTERS_CONTROL_ID,
|
|
416
|
+
T as FiltersControl,
|
|
417
|
+
ft as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
418
|
+
mt as LOCALE_CONTROL_ID,
|
|
419
|
+
P as LayoutOrientationControl,
|
|
420
|
+
S as LocaleControl,
|
|
421
|
+
pt as PRICE_PLACEMENT_CONTROL_ID,
|
|
422
|
+
Nt as PRODUCT_COUNT_CONTROL_ID,
|
|
423
|
+
It as PRODUCT_LAYOUT_CONTROL_ID,
|
|
424
|
+
O as PricePlacementControl,
|
|
425
|
+
L as ProductCountControl,
|
|
426
|
+
E as ProductLayoutControl,
|
|
427
|
+
rt as RecommendationBlockControl,
|
|
428
|
+
bt as SHUFFLE_CONTROL_ID,
|
|
429
|
+
Pt as STRATEGY_CONTROL_ID,
|
|
430
|
+
k as ShuffleControl,
|
|
431
|
+
D as StrategyControl,
|
|
432
|
+
Ot as adjustProductsToSize,
|
|
433
|
+
Lt as formatProductPrice,
|
|
434
|
+
w as getBlockElement,
|
|
435
|
+
Et as getCardComposition,
|
|
436
|
+
kt as getCurrentLayout,
|
|
437
|
+
A as isPartnerManagedBlock,
|
|
438
|
+
Dt as regenerateMobileProductRows,
|
|
439
|
+
x as regenerateProductRowsWithStyles,
|
|
440
|
+
F as setCurrencyAttributes,
|
|
441
|
+
Ft as updatePricesInPlace,
|
|
442
|
+
v as updateProductContentInPlace,
|
|
443
|
+
wt as updateSingleProductContent
|
|
391
444
|
};
|