@useinsider/guido 3.19.0-beta.76f392b → 3.19.0-beta.7d287ab
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/@types/config/schemas.js +104 -91
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +79 -74
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +4 -3
- package/dist/composables/useAuthError.js +52 -0
- package/dist/composables/useAutoSave.js +11 -11
- package/dist/composables/useHttp.js +64 -54
- package/dist/composables/useLegacyStrategyConversion.js +23 -19
- package/dist/composables/useStripo.js +24 -20
- package/dist/composables/useToaster.js +17 -15
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/itemsBlockMigrator.js +248 -236
- package/dist/config/migrator/recommendationMigrator.js +28 -21
- package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
- package/dist/enums/extensions/recommendationBlock.js +30 -29
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +17 -18
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +105 -114
- package/dist/extensions/Blocks/Items/enums/productEnums.js +9 -14
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +9 -11
- package/dist/extensions/Blocks/Items/template.js +204 -219
- package/dist/extensions/Blocks/Recommendation/block.js +15 -14
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +233 -189
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +30 -29
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
- package/dist/src/composables/useAuthError.d.ts +12 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useGuidoActions.d.ts +2 -0
- package/dist/src/composables/useHttp.d.ts +2 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +0 -3
- package/dist/src/extensions/Blocks/Items/template.d.ts +0 -19
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/mock/cortexChatStore.d.ts +12 -0
- package/dist/src/stores/config.d.ts +20 -0
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/src/stores/recommendation.d.ts +5 -0
- package/dist/src/utils/dateUtil.d.ts +10 -0
- package/dist/src/utils/genericUtil.d.ts +3 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
- package/dist/stores/onboarding.js +4 -0
- package/dist/utils/pairProductVariables.js +71 -71
- package/package.json +1 -1
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +0 -20
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +0 -44
|
@@ -1,66 +1,72 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var C = (g,
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { ModificationDescription as
|
|
6
|
-
import { CommonControl as
|
|
7
|
-
import { RRS_CONFIG_VERSION as
|
|
8
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
9
|
-
import { RecommendationConfigService as
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
12
|
-
import { AlgorithmControl as
|
|
13
|
-
import { ALGORITHM_CONTROL_ID as
|
|
14
|
-
import { CurrencyControl as
|
|
15
|
-
import { CURRENCY_CONTROL_ID as
|
|
2
|
+
var C = (g, l, e) => l in g ? m(g, l, { enumerable: !0, configurable: !0, writable: !0, value: e }) : g[l] = e;
|
|
3
|
+
var r = (g, l, e) => C(g, typeof l != "symbol" ? l + "" : l, e);
|
|
4
|
+
import { useConfig as h } from "../../../../../composables/useConfig.js";
|
|
5
|
+
import { ModificationDescription as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
+
import { CommonControl as y } from "../../../common-control.js";
|
|
7
|
+
import { RRS_CONFIG_VERSION as N, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RECOMMENDATION_ID_ATTR as _ } from "../../constants/selectors.js";
|
|
9
|
+
import { RecommendationConfigService as c } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
|
|
11
|
+
import { registerNodeConfigWriter as R, commitBlockChangeOutsidePanel as b } from "../../utils/nodeConfigWriter.js";
|
|
12
|
+
import { AlgorithmControl as P } from "./algorithm.js";
|
|
13
|
+
import { ALGORITHM_CONTROL_ID as de } from "./algorithm.js";
|
|
14
|
+
import { CurrencyControl as T } from "./currency.js";
|
|
15
|
+
import { CURRENCY_CONTROL_ID as ge } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
17
|
-
import { FILTERS_CONTROL_ID as
|
|
17
|
+
import { FILTERS_CONTROL_ID as fe } from "./filters.js";
|
|
18
18
|
import { LayoutOrientationControl as O } from "./layoutOrientation.js";
|
|
19
|
-
import { LAYOUT_ORIENTATION_CONTROL_ID as
|
|
20
|
-
import { LocaleControl as
|
|
21
|
-
import { LOCALE_CONTROL_ID as
|
|
22
|
-
import { PricePlacementControl as
|
|
23
|
-
import { PRICE_PLACEMENT_CONTROL_ID as
|
|
19
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as Ce } from "./layoutOrientation.js";
|
|
20
|
+
import { LocaleControl as k } from "./locale.js";
|
|
21
|
+
import { LOCALE_CONTROL_ID as ye } from "./locale.js";
|
|
22
|
+
import { PricePlacementControl as L } from "./pricePlacement.js";
|
|
23
|
+
import { PRICE_PLACEMENT_CONTROL_ID as _e } from "./pricePlacement.js";
|
|
24
24
|
import { ProductCountControl as E } from "./productCount.js";
|
|
25
|
-
import { PRODUCT_COUNT_CONTROL_ID as
|
|
25
|
+
import { PRODUCT_COUNT_CONTROL_ID as Re } from "./productCount.js";
|
|
26
26
|
import { ProductLayoutControl as F } from "./productLayout.js";
|
|
27
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
27
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Pe } from "./productLayout.js";
|
|
28
28
|
import { ShuffleControl as D } from "./shuffle.js";
|
|
29
|
-
import { SHUFFLE_CONTROL_ID as
|
|
29
|
+
import { SHUFFLE_CONTROL_ID as Se } from "./shuffle.js";
|
|
30
30
|
import { StrategyControl as w } from "./strategy.js";
|
|
31
|
-
import { STRATEGY_CONTROL_ID as
|
|
32
|
-
import { setCurrencyAttributes as
|
|
33
|
-
import { adjustProductsToSize as
|
|
34
|
-
import { useDebounceFn as
|
|
35
|
-
const
|
|
36
|
-
class
|
|
31
|
+
import { STRATEGY_CONTROL_ID as ke } from "./strategy.js";
|
|
32
|
+
import { setCurrencyAttributes as U, getBlockElement as v, isPartnerManagedBlock as B, updateProductContentInPlace as A, regenerateProductRowsWithStyles as x } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as Ee, formatProductPrice as Fe, getCardComposition as De, getCurrentLayout as we, getMainContainerTbody as Ue, regenerateMobileProductRows as ve, updatePricesInPlace as Be, updateSingleProductContent as Ae } from "./utils.js";
|
|
34
|
+
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
|
+
const V = "ui-elements-recommendation-block";
|
|
36
|
+
class ae extends y {
|
|
37
37
|
constructor() {
|
|
38
38
|
super(...arguments);
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
r(this, "store", I());
|
|
40
|
+
r(this, "storeUnsubscription", () => {
|
|
41
41
|
});
|
|
42
42
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
43
43
|
// re-render's single apply() — one user action must cost one undo press.
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
r(this, "pendingNodeConfigWrite", null);
|
|
45
|
+
r(this, "pendingConfigFlushTimer", null);
|
|
46
|
+
// Last configVersion the subscription handled, and whether its products still
|
|
47
|
+
// have to reach the canvas — both read on destroy to finish that work.
|
|
48
|
+
r(this, "seenConfigVersion", 0);
|
|
49
|
+
r(this, "fetchedConfigVersion", 0);
|
|
50
|
+
r(this, "hasUnappliedConfigChange", !1);
|
|
46
51
|
// Sub-control instances for lifecycle management
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
r(this, "algorithmControl", null);
|
|
53
|
+
r(this, "localeControl", null);
|
|
54
|
+
r(this, "currencyControl", null);
|
|
55
|
+
r(this, "productCountControl", null);
|
|
56
|
+
r(this, "productLayoutControl", null);
|
|
57
|
+
r(this, "filtersControl", null);
|
|
58
|
+
r(this, "shuffleControl", null);
|
|
59
|
+
r(this, "pricePlacementControl", null);
|
|
60
|
+
r(this, "layoutOrientationControl", null);
|
|
61
|
+
r(this, "strategyControl", null);
|
|
62
|
+
r(this, "rrsEnabled", !1);
|
|
58
63
|
/**
|
|
59
64
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
60
65
|
*/
|
|
61
|
-
|
|
66
|
+
r(this, "_debouncedFetchProducts", f(async () => {
|
|
67
|
+
const { configVersion: e } = this.store.$state;
|
|
62
68
|
try {
|
|
63
|
-
await this.store.fetchRecommendationProducts();
|
|
69
|
+
await this.store.fetchRecommendationProducts(), this.fetchedConfigVersion = e;
|
|
64
70
|
} finally {
|
|
65
71
|
this._scheduleConfigFlush();
|
|
66
72
|
}
|
|
@@ -76,28 +82,29 @@ class at extends N {
|
|
|
76
82
|
* count. The store pads products to the configured size, so in-place only
|
|
77
83
|
* fails when the size actually changed.
|
|
78
84
|
*/
|
|
79
|
-
|
|
80
|
-
const
|
|
85
|
+
r(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
86
|
+
const e = this.store.recommendationProducts;
|
|
81
87
|
if (!this.currentNode || !this.api)
|
|
82
88
|
return;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
this.fetchedConfigVersion === this.seenConfigVersion && (this.hasUnappliedConfigChange = !1);
|
|
90
|
+
const t = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(t);
|
|
91
|
+
if (B(this.currentNode)) {
|
|
92
|
+
o && (t.apply(new p("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
86
93
|
return;
|
|
87
94
|
}
|
|
88
|
-
|
|
95
|
+
A({
|
|
89
96
|
currentNode: this.currentNode,
|
|
90
|
-
documentModifier:
|
|
91
|
-
products:
|
|
92
|
-
}) ||
|
|
97
|
+
documentModifier: t,
|
|
98
|
+
products: e
|
|
99
|
+
}) || x({
|
|
93
100
|
currentNode: this.currentNode,
|
|
94
|
-
documentModifier:
|
|
95
|
-
products:
|
|
101
|
+
documentModifier: t,
|
|
102
|
+
products: e
|
|
96
103
|
});
|
|
97
104
|
}, 100));
|
|
98
105
|
}
|
|
99
106
|
getId() {
|
|
100
|
-
return
|
|
107
|
+
return V;
|
|
101
108
|
}
|
|
102
109
|
get _subControls() {
|
|
103
110
|
return [
|
|
@@ -114,15 +121,15 @@ class at extends N {
|
|
|
114
121
|
];
|
|
115
122
|
}
|
|
116
123
|
getTemplate() {
|
|
117
|
-
var
|
|
118
|
-
return this.rrsEnabled =
|
|
124
|
+
var e;
|
|
125
|
+
return this.rrsEnabled = h().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
119
126
|
var o;
|
|
120
|
-
return (o =
|
|
121
|
-
}), this.algorithmControl = new
|
|
122
|
-
|
|
127
|
+
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
128
|
+
}), this.algorithmControl = new P(), this.localeControl = new k(), this.currencyControl = new T(), this.productCountControl = new E(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new L(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((t) => {
|
|
129
|
+
t && (t.api = this.api);
|
|
123
130
|
}), `
|
|
124
131
|
<div class="recommendation-controls-container">
|
|
125
|
-
${((
|
|
132
|
+
${((e = this.strategyControl) == null ? void 0 : e.getTemplate()) ?? ""}
|
|
126
133
|
${this.layoutOrientationControl.getTemplate()}
|
|
127
134
|
${this.productCountControl.getTemplate()}
|
|
128
135
|
${this.productLayoutControl.getTemplate()}
|
|
@@ -135,39 +142,40 @@ class at extends N {
|
|
|
135
142
|
</div>
|
|
136
143
|
`;
|
|
137
144
|
}
|
|
138
|
-
_showControlsForBlock(
|
|
139
|
-
var
|
|
140
|
-
const
|
|
141
|
-
if (!
|
|
145
|
+
_showControlsForBlock(e) {
|
|
146
|
+
var i;
|
|
147
|
+
const t = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
|
|
148
|
+
if (!t)
|
|
142
149
|
return;
|
|
143
|
-
const o = this._getRecommendationIdFromNode(
|
|
144
|
-
|
|
150
|
+
const o = this._getRecommendationIdFromNode(e) === null ? null : c.getConfig(e), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= N), s = this.rrsEnabled && !!o && !n;
|
|
151
|
+
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", s);
|
|
145
152
|
}
|
|
146
153
|
async onRender() {
|
|
147
154
|
var o;
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
155
|
+
R(this.api);
|
|
156
|
+
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
157
|
+
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
158
|
this._initializeSubControls();
|
|
152
159
|
return;
|
|
153
160
|
}
|
|
154
|
-
await this._fetchBlockData(
|
|
161
|
+
await this._fetchBlockData(t), this._initializeSubControls();
|
|
155
162
|
}
|
|
156
|
-
onTemplateNodeUpdated(
|
|
163
|
+
onTemplateNodeUpdated(e) {
|
|
157
164
|
var o;
|
|
158
|
-
super.onTemplateNodeUpdated(
|
|
159
|
-
const
|
|
160
|
-
|
|
165
|
+
super.onTemplateNodeUpdated(e);
|
|
166
|
+
const t = this._getRecommendationIdFromNode(e);
|
|
167
|
+
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
168
|
this._initializeSubControls();
|
|
162
169
|
}), this._subControls.forEach((n) => {
|
|
163
170
|
var s;
|
|
164
|
-
n != null && n.api && (n.currentNode =
|
|
171
|
+
n != null && n.api && (n.currentNode = e, (s = n.onTemplateNodeUpdated) == null || s.call(n, e));
|
|
165
172
|
});
|
|
166
173
|
}
|
|
167
174
|
onDestroy() {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
175
|
+
const e = this.hasUnappliedConfigChange || this.store.$state.configVersion !== this.seenConfigVersion;
|
|
176
|
+
this.storeUnsubscription(), e ? this._refreshProductsOutsidePanel() : this._flushPendingNodeConfig(), this._subControls.forEach((t) => {
|
|
177
|
+
var o;
|
|
178
|
+
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
171
179
|
});
|
|
172
180
|
}
|
|
173
181
|
/**
|
|
@@ -175,9 +183,9 @@ class at extends N {
|
|
|
175
183
|
* Each sub-control manages its own form values and event listeners
|
|
176
184
|
*/
|
|
177
185
|
_initializeSubControls() {
|
|
178
|
-
this._subControls.forEach((
|
|
179
|
-
var
|
|
180
|
-
|
|
186
|
+
this._subControls.forEach((e) => {
|
|
187
|
+
var t;
|
|
188
|
+
e && (e.api = this.api, e.currentNode = this.currentNode, (t = e.onRender) == null || t.call(e));
|
|
181
189
|
});
|
|
182
190
|
}
|
|
183
191
|
/**
|
|
@@ -204,28 +212,35 @@ class at extends N {
|
|
|
204
212
|
* that state and made a re-dropped saved module keep the defaults its wiped
|
|
205
213
|
* state was rebuilt with (SD-150347).
|
|
206
214
|
*/
|
|
207
|
-
_syncNodeConfigIfChanged(
|
|
208
|
-
this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !==
|
|
209
|
-
const
|
|
210
|
-
if (!
|
|
215
|
+
_syncNodeConfigIfChanged(e) {
|
|
216
|
+
this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== e && this._flushPendingNodeConfig();
|
|
217
|
+
const t = this.store.blockStates[e];
|
|
218
|
+
if (!t)
|
|
211
219
|
return;
|
|
212
|
-
const o = JSON.stringify(
|
|
213
|
-
|
|
220
|
+
const o = JSON.stringify(c.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
|
|
221
|
+
t.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
214
222
|
}
|
|
215
223
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
216
224
|
_isPendingStrategyIdChange() {
|
|
217
|
-
const
|
|
218
|
-
return
|
|
225
|
+
const e = this.pendingNodeConfigWrite;
|
|
226
|
+
return e ? c.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
|
|
219
227
|
}
|
|
220
228
|
_capturePendingNodeConfigWrite() {
|
|
221
|
-
const
|
|
222
|
-
if (!this.currentNode || !this.api ||
|
|
229
|
+
const e = this.store.currentRecommendationId;
|
|
230
|
+
if (!this.currentNode || !this.api || e === null)
|
|
223
231
|
return;
|
|
224
|
-
const { filters:
|
|
232
|
+
const { filters: t, strategy: o, strategyId: n, size: s, nodeConfigVersion: i } = this.store.recommendationConfigs, { partnerName: d } = h();
|
|
225
233
|
this.pendingNodeConfigWrite = {
|
|
226
|
-
blockId:
|
|
234
|
+
blockId: e,
|
|
227
235
|
node: this.currentNode,
|
|
228
|
-
updates: {
|
|
236
|
+
updates: {
|
|
237
|
+
filters: t,
|
|
238
|
+
strategy: o,
|
|
239
|
+
strategyId: n,
|
|
240
|
+
size: s,
|
|
241
|
+
configVersion: i,
|
|
242
|
+
...d.value ? { partnerName: d.value } : {}
|
|
243
|
+
}
|
|
229
244
|
};
|
|
230
245
|
}
|
|
231
246
|
/**
|
|
@@ -238,9 +253,9 @@ class at extends N {
|
|
|
238
253
|
* @param documentModifier - The batch to accumulate into
|
|
239
254
|
* @returns Whether anything was staged
|
|
240
255
|
*/
|
|
241
|
-
_stagePendingNodeConfig(
|
|
242
|
-
const
|
|
243
|
-
return !
|
|
256
|
+
_stagePendingNodeConfig(e) {
|
|
257
|
+
const t = this.pendingNodeConfigWrite;
|
|
258
|
+
return !t || !this.currentNode ? !1 : (c.stageConfig(e, this.currentNode, t.updates), !0);
|
|
244
259
|
}
|
|
245
260
|
/**
|
|
246
261
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -261,41 +276,41 @@ class at extends N {
|
|
|
261
276
|
* snapshot the intervening re-render staled, and saveConfig swallows that failure.
|
|
262
277
|
*/
|
|
263
278
|
_flushPendingNodeConfig() {
|
|
264
|
-
const
|
|
265
|
-
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !
|
|
279
|
+
const e = this.pendingNodeConfigWrite;
|
|
280
|
+
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !e || !this.api)
|
|
266
281
|
return;
|
|
267
|
-
const
|
|
268
|
-
JSON.stringify(o.filters) === JSON.stringify(
|
|
282
|
+
const t = e.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : e.node, o = c.getConfig(t);
|
|
283
|
+
JSON.stringify(o.filters) === JSON.stringify(e.updates.filters) && o.strategy === e.updates.strategy && o.strategyId === e.updates.strategyId && o.size === e.updates.size || c.updateConfig(this.api, t, e.updates, "Update recommendation filters");
|
|
269
284
|
}
|
|
270
285
|
_syncNodeConfigToStore() {
|
|
271
286
|
var n;
|
|
272
|
-
const
|
|
287
|
+
const e = c.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
273
288
|
this.store.patchCurrentBlockConfig({
|
|
274
|
-
strategy:
|
|
275
|
-
strategyId:
|
|
276
|
-
nodeConfigVersion:
|
|
277
|
-
language:
|
|
278
|
-
size:
|
|
279
|
-
productIds:
|
|
280
|
-
cardsInRow:
|
|
281
|
-
mobileCardsInRow:
|
|
282
|
-
mobileLayoutEnabled:
|
|
283
|
-
orientation:
|
|
289
|
+
strategy: e.strategy,
|
|
290
|
+
strategyId: e.strategyId,
|
|
291
|
+
nodeConfigVersion: e.configVersion,
|
|
292
|
+
language: e.language,
|
|
293
|
+
size: e.size,
|
|
294
|
+
productIds: e.productIds,
|
|
295
|
+
cardsInRow: e.cardsInRow,
|
|
296
|
+
mobileCardsInRow: e.mobileCardsInRow,
|
|
297
|
+
mobileLayoutEnabled: e.mobileLayoutEnabled,
|
|
298
|
+
orientation: e.layout,
|
|
284
299
|
// Only sync filters from node config during initial load.
|
|
285
300
|
// After initialization, the Pinia store is the source of truth
|
|
286
301
|
// for filters (edited via the filter drawer).
|
|
287
|
-
...o ? {} : { filters:
|
|
288
|
-
shuffleProducts:
|
|
289
|
-
priceMovedToNextLine:
|
|
290
|
-
priceHideIfSameAsDiscounted:
|
|
302
|
+
...o ? {} : { filters: e.filters },
|
|
303
|
+
shuffleProducts: e.shuffleProducts,
|
|
304
|
+
priceMovedToNextLine: e.priceMovedToNextLine,
|
|
305
|
+
priceHideIfSameAsDiscounted: e.priceHideIfSameAsDiscounted,
|
|
291
306
|
currencySettings: {
|
|
292
|
-
name:
|
|
293
|
-
value:
|
|
294
|
-
symbol:
|
|
295
|
-
alignment:
|
|
296
|
-
decimalCount:
|
|
297
|
-
decimalSeparator:
|
|
298
|
-
thousandSeparator:
|
|
307
|
+
name: e.currency.code,
|
|
308
|
+
value: e.currency.code,
|
|
309
|
+
symbol: e.currency.symbol,
|
|
310
|
+
alignment: e.currency.alignment === "before" ? "0" : "1",
|
|
311
|
+
decimalCount: e.currency.decimalCount.toString(),
|
|
312
|
+
decimalSeparator: e.currency.decimalSeparator,
|
|
313
|
+
thousandSeparator: e.currency.thousandSeparator
|
|
299
314
|
}
|
|
300
315
|
}, { triggerRefetch: !1 });
|
|
301
316
|
}
|
|
@@ -308,8 +323,8 @@ class at extends N {
|
|
|
308
323
|
* Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
|
|
309
324
|
* Marks the block as initialized to prevent redundant fetches on re-selection.
|
|
310
325
|
*/
|
|
311
|
-
async _fetchBlockData(
|
|
312
|
-
|
|
326
|
+
async _fetchBlockData(e) {
|
|
327
|
+
e !== null && this.store.markBlockInitialized(e), (await Promise.allSettled([
|
|
313
328
|
this.store.fetchRecommendationCreateData(),
|
|
314
329
|
this.store.fetchRecommendationFilters()
|
|
315
330
|
])).forEach((o, n) => {
|
|
@@ -334,39 +349,39 @@ class at extends N {
|
|
|
334
349
|
_applySmartDefaults() {
|
|
335
350
|
if (!this.currentNode || !this.api)
|
|
336
351
|
return;
|
|
337
|
-
const
|
|
352
|
+
const e = c.getConfig(this.currentNode), t = {};
|
|
338
353
|
let o = null, n = null, s = null;
|
|
339
|
-
if (
|
|
340
|
-
const { currencyList:
|
|
341
|
-
|
|
354
|
+
if (e.currency.code === a.currency.code) {
|
|
355
|
+
const { currencyList: i } = this.store;
|
|
356
|
+
i.length > 0 && (i.some(
|
|
342
357
|
(u) => u.value === `price.${a.currency.code}`
|
|
343
|
-
) || (o =
|
|
358
|
+
) || (o = i[0].value.replace("price.", ""), t.currency = {
|
|
344
359
|
...a.currency,
|
|
345
360
|
code: o,
|
|
346
361
|
symbol: o
|
|
347
362
|
}));
|
|
348
363
|
}
|
|
349
|
-
if (
|
|
350
|
-
const
|
|
351
|
-
|
|
364
|
+
if (e.strategy === a.strategy) {
|
|
365
|
+
const i = this.store.getActivePredictiveAlgorithms;
|
|
366
|
+
i.length > 0 && (i.some(
|
|
352
367
|
(u) => u.value === a.strategy
|
|
353
|
-
) || (n =
|
|
368
|
+
) || (n = i[0].value, t.strategy = n));
|
|
354
369
|
}
|
|
355
|
-
if (
|
|
356
|
-
const
|
|
357
|
-
|
|
370
|
+
if (e.language === a.language) {
|
|
371
|
+
const i = this.store.getLanguages;
|
|
372
|
+
i.length > 0 && (i.some(
|
|
358
373
|
(u) => u.value === a.language
|
|
359
|
-
) || (s =
|
|
374
|
+
) || (s = i[0].value, t.language = s));
|
|
360
375
|
}
|
|
361
|
-
!o && !n && !s || (
|
|
376
|
+
!o && !n && !s || (c.updateConfig(
|
|
362
377
|
this.api,
|
|
363
378
|
this.currentNode,
|
|
364
|
-
|
|
379
|
+
t,
|
|
365
380
|
"Applied smart defaults"
|
|
366
|
-
), o &&
|
|
381
|
+
), o && t.currency && U({
|
|
367
382
|
currentNode: this.currentNode,
|
|
368
383
|
documentModifier: this.api.getDocumentModifier(),
|
|
369
|
-
currency:
|
|
384
|
+
currency: t.currency
|
|
370
385
|
}), this.store.patchCurrentBlockConfig({
|
|
371
386
|
...o ? {
|
|
372
387
|
currencySettings: {
|
|
@@ -386,16 +401,45 @@ class at extends N {
|
|
|
386
401
|
/**
|
|
387
402
|
* Reads the recommendation-id attribute from the block element within the node
|
|
388
403
|
*/
|
|
389
|
-
_getRecommendationIdFromNode(
|
|
390
|
-
const
|
|
391
|
-
if (!
|
|
404
|
+
_getRecommendationIdFromNode(e) {
|
|
405
|
+
const t = v(e);
|
|
406
|
+
if (!t || !("getAttribute" in t))
|
|
392
407
|
return null;
|
|
393
|
-
const o =
|
|
408
|
+
const o = t.getAttribute(_);
|
|
394
409
|
if (!o)
|
|
395
410
|
return null;
|
|
396
411
|
const n = parseInt(o);
|
|
397
412
|
return Number.isNaN(n) ? null : n;
|
|
398
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Fetches and renders the block's products without the panel, carrying the
|
|
416
|
+
* deferred config write so both still land as one undo entry.
|
|
417
|
+
*/
|
|
418
|
+
async _refreshProductsOutsidePanel() {
|
|
419
|
+
const e = this.store.currentRecommendationId;
|
|
420
|
+
if (e === null)
|
|
421
|
+
return;
|
|
422
|
+
this.hasUnappliedConfigChange = !1, this.pendingNodeConfigWrite || this._capturePendingNodeConfigWrite();
|
|
423
|
+
const t = this.pendingNodeConfigWrite, o = (t == null ? void 0 : t.blockId) === e ? t.updates : {};
|
|
424
|
+
try {
|
|
425
|
+
await this.store.fetchRecommendationProducts();
|
|
426
|
+
} catch (s) {
|
|
427
|
+
console.warn("Recommendation block: fetchRecommendationProducts failed", s);
|
|
428
|
+
}
|
|
429
|
+
const n = this.store.blockStates[e];
|
|
430
|
+
if (n) {
|
|
431
|
+
if (b(
|
|
432
|
+
e,
|
|
433
|
+
o,
|
|
434
|
+
n.recommendationProducts,
|
|
435
|
+
"Update recommendation configuration"
|
|
436
|
+
)) {
|
|
437
|
+
this.pendingNodeConfigWrite = null, this._clearConfigFlush();
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
this._flushPendingNodeConfig();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
399
443
|
/**
|
|
400
444
|
* Listen to store changes that require product refresh or regeneration.
|
|
401
445
|
*
|
|
@@ -410,55 +454,55 @@ class at extends N {
|
|
|
410
454
|
* We skip that tick and update tracking references instead.
|
|
411
455
|
*/
|
|
412
456
|
_listenStateUpdates() {
|
|
413
|
-
const { store:
|
|
414
|
-
let
|
|
415
|
-
this.storeUnsubscription =
|
|
416
|
-
const
|
|
417
|
-
if (
|
|
418
|
-
|
|
457
|
+
const { store: e } = this;
|
|
458
|
+
let t = e.recommendationProducts, o = e.currentRecommendationId;
|
|
459
|
+
this.seenConfigVersion = e.$state.configVersion, this.hasUnappliedConfigChange = !1, this.storeUnsubscription = e.$subscribe(() => {
|
|
460
|
+
const n = e.currentRecommendationId;
|
|
461
|
+
if (n !== o) {
|
|
462
|
+
o = n, t = e.recommendationProducts, this.seenConfigVersion = e.$state.configVersion;
|
|
419
463
|
return;
|
|
420
464
|
}
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
const
|
|
424
|
-
|
|
465
|
+
const s = e.$state.configVersion;
|
|
466
|
+
s !== this.seenConfigVersion && (this.seenConfigVersion = s, this.hasUnappliedConfigChange = !0, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
|
|
467
|
+
const i = e.recommendationProducts, d = i !== t, u = Array.isArray(i) && i.length > 0;
|
|
468
|
+
d && u && (t = i, this._debouncedRegenerateWithProducts());
|
|
425
469
|
});
|
|
426
470
|
}
|
|
427
471
|
}
|
|
428
472
|
export {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
473
|
+
de as ALGORITHM_CONTROL_ID,
|
|
474
|
+
P as AlgorithmControl,
|
|
475
|
+
V as CONTROL_BLOCK_ID,
|
|
476
|
+
ge as CURRENCY_CONTROL_ID,
|
|
477
|
+
T as CurrencyControl,
|
|
478
|
+
fe as FILTERS_CONTROL_ID,
|
|
435
479
|
S as FiltersControl,
|
|
436
|
-
|
|
437
|
-
|
|
480
|
+
Ce as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
481
|
+
ye as LOCALE_CONTROL_ID,
|
|
438
482
|
O as LayoutOrientationControl,
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
483
|
+
k as LocaleControl,
|
|
484
|
+
_e as PRICE_PLACEMENT_CONTROL_ID,
|
|
485
|
+
Re as PRODUCT_COUNT_CONTROL_ID,
|
|
486
|
+
Pe as PRODUCT_LAYOUT_CONTROL_ID,
|
|
487
|
+
L as PricePlacementControl,
|
|
444
488
|
E as ProductCountControl,
|
|
445
489
|
F as ProductLayoutControl,
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
490
|
+
ae as RecommendationBlockControl,
|
|
491
|
+
Se as SHUFFLE_CONTROL_ID,
|
|
492
|
+
ke as STRATEGY_CONTROL_ID,
|
|
449
493
|
D as ShuffleControl,
|
|
450
494
|
w as StrategyControl,
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
495
|
+
Ee as adjustProductsToSize,
|
|
496
|
+
Fe as formatProductPrice,
|
|
497
|
+
v as getBlockElement,
|
|
498
|
+
De as getCardComposition,
|
|
499
|
+
we as getCurrentLayout,
|
|
500
|
+
Ue as getMainContainerTbody,
|
|
501
|
+
B as isPartnerManagedBlock,
|
|
502
|
+
ve as regenerateMobileProductRows,
|
|
503
|
+
x as regenerateProductRowsWithStyles,
|
|
504
|
+
U as setCurrencyAttributes,
|
|
505
|
+
Be as updatePricesInPlace,
|
|
506
|
+
A as updateProductContentInPlace,
|
|
507
|
+
Ae as updateSingleProductContent
|
|
464
508
|
};
|