@useinsider/guido 3.20.2-beta.87fb8ae → 3.21.0-beta.0df5409
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/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +65 -64
- package/dist/components/organisms/AutoSaveController.vue2.js +10 -9
- package/dist/components/organisms/header/EditorActions.vue.js +4 -4
- package/dist/components/organisms/header/EditorActions.vue2.js +53 -51
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +23 -22
- package/dist/composables/useActionsApi.js +80 -63
- package/dist/composables/useAutoSave.js +46 -44
- package/dist/composables/useGuidoStateBridge.js +3 -3
- package/dist/composables/useSave.js +26 -23
- package/dist/composables/useSaveValidation.js +113 -114
- package/dist/composables/useSaveValidationRollout.js +17 -6
- package/dist/composables/useStripo.js +11 -10
- package/dist/extensions/Blocks/Items/block.js +43 -42
- package/dist/extensions/Blocks/Recommendation/block.js +33 -29
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +78 -83
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +1 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +2 -12
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +104 -86
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +222 -210
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +48 -50
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +16 -21
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +44 -40
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +14 -19
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +104 -102
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +18 -23
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +312 -286
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +24 -20
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +6 -7
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +113 -151
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +9 -5
- package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +20 -11
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/currencySettings.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +106 -50
- package/dist/extensions/Blocks/Unsubscribe/block.js +70 -75
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +271 -192
- package/dist/package.json.js +1 -1
- package/dist/services/settingsApi.js +11 -0
- package/dist/src/components/Guido.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
- package/dist/src/composables/useActionsApi.d.ts +5 -1
- package/dist/src/composables/useAutoSave.d.ts +4 -1
- package/dist/src/composables/useSaveValidationRollout.d.ts +1 -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/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 +1 -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 -6
- 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 +5 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -11
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +6 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +6 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +21 -9
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +19 -13
- 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 +10 -8
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +9 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/currencySettings.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +13 -13
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +1 -6
- 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/services/settingsApi.d.ts +6 -0
- package/dist/src/stores/editor.d.ts +3 -1
- package/dist/src/stores/setup-settings.d.ts +4 -0
- package/dist/static/styles/components/button.css.js +5 -0
- package/dist/stores/editor.js +5 -0
- package/dist/stores/setup-settings.js +10 -0
- package/package.json +4 -4
|
@@ -1,72 +1,75 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { ModificationDescription as
|
|
6
|
-
import { CommonControl as
|
|
7
|
-
import { RRS_CONFIG_VERSION as
|
|
8
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
9
|
-
import { RecommendationConfigService as
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
import { refreshBlockOutsidePanel as
|
|
12
|
-
import {
|
|
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
|
-
import {
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var I = (h, l, e) => l in h ? k(h, l, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[l] = e;
|
|
3
|
+
var s = (h, l, e) => I(h, typeof l != "symbol" ? l + "" : l, e);
|
|
4
|
+
import { useConfig as m } from "../../../../../composables/useConfig.js";
|
|
5
|
+
import { ModificationDescription as C } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
+
import { CommonControl as R } from "../../../common-control.js";
|
|
7
|
+
import { RRS_CONFIG_VERSION as b, DEFAULT_NODE_CONFIG as u } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RECOMMENDATION_ID_ATTR as O } from "../../constants/selectors.js";
|
|
9
|
+
import { RecommendationConfigService as d } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as S } from "../../store/recommendation.js";
|
|
11
|
+
import { refreshBlockOutsidePanel as T } from "../../utils/blockRefresh.js";
|
|
12
|
+
import { toCurrencyConfig as B, toCurrencySettings as p } from "../../utils/currencySettings.js";
|
|
13
|
+
import { registerNodeConfigWriter as F, registerPendingConfigFlush as L, stageConfigChange as _, describeConfigChange as N, writeBlockConfigOutsidePanel as U } from "../../utils/nodeConfigWriter.js";
|
|
14
|
+
import { AlgorithmControl as E } from "./algorithm.js";
|
|
15
|
+
import { ALGORITHM_CONTROL_ID as Pe } from "./algorithm.js";
|
|
16
|
+
import { CurrencyControl as D } from "./currency.js";
|
|
17
|
+
import { CURRENCY_CONTROL_ID as Ie } from "./currency.js";
|
|
18
|
+
import { FiltersControl as v } from "./filters.js";
|
|
19
|
+
import { FILTERS_CONTROL_ID as be } from "./filters.js";
|
|
20
|
+
import { LayoutOrientationControl as w } from "./layoutOrientation.js";
|
|
21
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as Se } from "./layoutOrientation.js";
|
|
22
|
+
import { LocaleControl as A } from "./locale.js";
|
|
23
|
+
import { LOCALE_CONTROL_ID as Be } from "./locale.js";
|
|
24
|
+
import { PricePlacementControl as V } from "./pricePlacement.js";
|
|
25
|
+
import { PRICE_PLACEMENT_CONTROL_ID as Le } from "./pricePlacement.js";
|
|
26
|
+
import { ProductCountControl as x } from "./productCount.js";
|
|
27
|
+
import { PRODUCT_COUNT_CONTROL_ID as Ee } from "./productCount.js";
|
|
28
|
+
import { ProductLayoutControl as W } from "./productLayout.js";
|
|
29
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as ve } from "./productLayout.js";
|
|
30
|
+
import { ShuffleControl as M } from "./shuffle.js";
|
|
31
|
+
import { SHUFFLE_CONTROL_ID as Ae } from "./shuffle.js";
|
|
32
|
+
import { StrategyControl as G } from "./strategy.js";
|
|
33
|
+
import { STRATEGY_CONTROL_ID as xe } from "./strategy.js";
|
|
34
|
+
import { setCurrencyAttributes as z, getBlockElement as $, isPartnerManagedBlock as H, updateProductContentInPlace as Y, regenerateProductRowsWithStyles as j } from "./utils.js";
|
|
35
|
+
import { adjustProductsToSize as Me, formatProductPrice as Ge, getCardComposition as ze, getCurrencyAttributesFromBlock as $e, getCurrentLayout as He, getMainContainerTbody as Ye, regenerateMobileProductRows as je, updatePricesInPlace as qe, updateSingleProductContent as Je } from "./utils.js";
|
|
36
|
+
import { useDebounceFn as y } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
37
|
+
const q = "ui-elements-recommendation-block";
|
|
38
|
+
class _e extends R {
|
|
38
39
|
constructor() {
|
|
39
40
|
super(...arguments);
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
s(this, "store", S());
|
|
42
|
+
s(this, "storeUnsubscription", () => {
|
|
43
|
+
});
|
|
44
|
+
s(this, "unregisterConfigFlush", () => {
|
|
42
45
|
});
|
|
43
46
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
44
47
|
// re-render's single apply() — one user action must cost one undo press.
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
s(this, "pendingNodeConfigWrite", null);
|
|
49
|
+
s(this, "pendingConfigFlushTimer", null);
|
|
47
50
|
// What the panel still owes the block it watches — finished outside the panel on teardown
|
|
48
51
|
// and block switch. A new generation tells debounced work queued for the old one to stand down.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
s(this, "trackedBlockId", null);
|
|
53
|
+
s(this, "fetchedConfigVersion", 0);
|
|
54
|
+
s(this, "hasUnrenderedProducts", !1);
|
|
55
|
+
s(this, "panelGeneration", 0);
|
|
56
|
+
s(this, "isPanelAlive", !0);
|
|
54
57
|
// Sub-control instances for lifecycle management
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
s(this, "algorithmControl", null);
|
|
59
|
+
s(this, "localeControl", null);
|
|
60
|
+
s(this, "currencyControl", null);
|
|
61
|
+
s(this, "productCountControl", null);
|
|
62
|
+
s(this, "productLayoutControl", null);
|
|
63
|
+
s(this, "filtersControl", null);
|
|
64
|
+
s(this, "shuffleControl", null);
|
|
65
|
+
s(this, "pricePlacementControl", null);
|
|
66
|
+
s(this, "layoutOrientationControl", null);
|
|
67
|
+
s(this, "strategyControl", null);
|
|
68
|
+
s(this, "rrsEnabled", !1);
|
|
66
69
|
/**
|
|
67
70
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
68
71
|
*/
|
|
69
|
-
|
|
72
|
+
s(this, "_debouncedFetchProducts", y(async (e, t) => {
|
|
70
73
|
if (t !== this.panelGeneration)
|
|
71
74
|
return;
|
|
72
75
|
const o = this._getBlockConfigVersion(e);
|
|
@@ -87,7 +90,7 @@ class he extends P {
|
|
|
87
90
|
* count. The store pads products to the configured size, so in-place only
|
|
88
91
|
* fails when the size actually changed.
|
|
89
92
|
*/
|
|
90
|
-
|
|
93
|
+
s(this, "_debouncedRegenerateWithProducts", y((e) => {
|
|
91
94
|
if (e !== this.panelGeneration || !this.currentNode || !this.api)
|
|
92
95
|
return;
|
|
93
96
|
const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
|
|
@@ -106,7 +109,7 @@ class he extends P {
|
|
|
106
109
|
}, 100));
|
|
107
110
|
}
|
|
108
111
|
getId() {
|
|
109
|
-
return
|
|
112
|
+
return q;
|
|
110
113
|
}
|
|
111
114
|
get _subControls() {
|
|
112
115
|
return [
|
|
@@ -124,10 +127,10 @@ class he extends P {
|
|
|
124
127
|
}
|
|
125
128
|
getTemplate() {
|
|
126
129
|
var e;
|
|
127
|
-
return this.rrsEnabled =
|
|
130
|
+
return this.rrsEnabled = m().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
128
131
|
var o;
|
|
129
132
|
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
130
|
-
}), this.algorithmControl = new
|
|
133
|
+
}), this.algorithmControl = new E(), this.localeControl = new A(), this.currencyControl = new D(), this.productCountControl = new x(), this.productLayoutControl = new W(), this.filtersControl = new v(), this.shuffleControl = new M(), this.pricePlacementControl = new V(), this.layoutOrientationControl = new w(), this.strategyControl = this.rrsEnabled ? new G() : null, this._subControls.forEach((t) => {
|
|
131
134
|
t && (t.api = this.api);
|
|
132
135
|
}), `
|
|
133
136
|
<div class="recommendation-controls-container">
|
|
@@ -145,16 +148,16 @@ class he extends P {
|
|
|
145
148
|
`;
|
|
146
149
|
}
|
|
147
150
|
_showControlsForBlock(e) {
|
|
148
|
-
var
|
|
149
|
-
const t = (
|
|
151
|
+
var i;
|
|
152
|
+
const t = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
|
|
150
153
|
if (!t)
|
|
151
154
|
return;
|
|
152
|
-
const o = this._getRecommendationIdFromNode(e) === null ? null :
|
|
155
|
+
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) >= b), r = this.rrsEnabled && !!o && !n;
|
|
153
156
|
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", r);
|
|
154
157
|
}
|
|
155
158
|
async onRender() {
|
|
156
159
|
var o;
|
|
157
|
-
|
|
160
|
+
F(this.api), this.unregisterConfigFlush(), this.unregisterConfigFlush = L(() => this._flushPendingNodeConfig());
|
|
158
161
|
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
159
162
|
if (t !== null && this.store.setCurrentBlock(t), e !== null && this._syncNodeConfigIfChanged(e), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), t !== null && ((o = this.store.blockStates[t]) != null && o.isInitialized)) {
|
|
160
163
|
this._initializeSubControls();
|
|
@@ -174,7 +177,7 @@ class he extends P {
|
|
|
174
177
|
});
|
|
175
178
|
}
|
|
176
179
|
onDestroy() {
|
|
177
|
-
this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
|
|
180
|
+
this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this.unregisterConfigFlush(), this._subControls.forEach((e) => {
|
|
178
181
|
var t;
|
|
179
182
|
return (t = e == null ? void 0 : e.onDestroy) == null ? void 0 : t.call(e);
|
|
180
183
|
});
|
|
@@ -219,45 +222,66 @@ class he extends P {
|
|
|
219
222
|
const t = this.store.blockStates[e];
|
|
220
223
|
if (!t)
|
|
221
224
|
return;
|
|
222
|
-
const o = JSON.stringify(
|
|
225
|
+
const o = JSON.stringify(d.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
|
|
223
226
|
t.syncedConfigFingerprint = o, n !== o && ((r = this.pendingNodeConfigWrite) == null ? void 0 : r.blockId) !== e && this._syncNodeConfigToStore();
|
|
224
227
|
}
|
|
225
228
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
226
229
|
_isPendingStrategyIdChange() {
|
|
227
|
-
const e = this.
|
|
228
|
-
return e
|
|
230
|
+
const e = this._pendingUpdates();
|
|
231
|
+
return e !== null && d.getConfig(this.currentNode).strategyId !== e.strategyId;
|
|
229
232
|
}
|
|
230
233
|
_capturePendingNodeConfigWrite() {
|
|
231
|
-
const e = this.store.currentRecommendationId
|
|
232
|
-
!this.currentNode || !this.api || e === null || !
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
const e = this.store.currentRecommendationId;
|
|
235
|
+
!this.currentNode || !this.api || e === null || !this.store.blockStates[e] || (this.pendingNodeConfigWrite = { blockId: e });
|
|
236
|
+
}
|
|
237
|
+
// Read at write time, not at capture: a display-only edit (currency symbol) patches the store
|
|
238
|
+
// without a version bump while the write waits, and a snapshot would stage the older value over it.
|
|
239
|
+
_pendingUpdates() {
|
|
240
|
+
const e = this.pendingNodeConfigWrite, t = e ? this.store.blockStates[e.blockId] : void 0;
|
|
241
|
+
return t ? this._getNodeConfigUpdates(t.recommendationConfigs) : null;
|
|
242
|
+
}
|
|
243
|
+
// Another block's pending write must never be staged on, or drive the redraw of, the panel node.
|
|
244
|
+
_pendingUpdatesForCurrentNode() {
|
|
245
|
+
var e;
|
|
246
|
+
return !this.currentNode || ((e = this.pendingNodeConfigWrite) == null ? void 0 : e.blockId) !== this._getRecommendationIdFromNode(this.currentNode) ? null : this._pendingUpdates();
|
|
236
247
|
}
|
|
237
248
|
_getNodeConfigUpdates(e) {
|
|
238
|
-
const {
|
|
249
|
+
const {
|
|
250
|
+
filters: t,
|
|
251
|
+
strategy: o,
|
|
252
|
+
strategyId: n,
|
|
253
|
+
size: r,
|
|
254
|
+
productIds: i,
|
|
255
|
+
language: a,
|
|
256
|
+
shuffleProducts: c,
|
|
257
|
+
currencySettings: g,
|
|
258
|
+
nodeConfigVersion: P
|
|
259
|
+
} = e, { partnerName: f } = m();
|
|
239
260
|
return {
|
|
240
261
|
filters: t,
|
|
241
262
|
strategy: o,
|
|
242
263
|
strategyId: n,
|
|
243
264
|
size: r,
|
|
244
|
-
|
|
245
|
-
|
|
265
|
+
productIds: i,
|
|
266
|
+
language: a,
|
|
267
|
+
shuffleProducts: c,
|
|
268
|
+
currency: B(g),
|
|
269
|
+
configVersion: P,
|
|
270
|
+
...f.value ? { partnerName: f.value } : {}
|
|
246
271
|
};
|
|
247
272
|
}
|
|
248
273
|
/**
|
|
249
274
|
* Accumulates the pending write into `documentModifier` without applying, so the
|
|
250
275
|
* caller's apply() commits config and re-render as ONE undo entry.
|
|
251
|
-
*
|
|
252
|
-
* Deliberately does not consume the pending record: the product helpers call
|
|
253
|
-
* apply() only when they actually changed something, so this batch may never be
|
|
254
|
-
* committed and the flush has to stay able to write it standalone.
|
|
255
|
-
* @param documentModifier - The batch to accumulate into
|
|
256
|
-
* @returns Whether anything was staged
|
|
276
|
+
* @returns the undo label, null when only stamps moved; undefined when nothing was staged
|
|
257
277
|
*/
|
|
258
278
|
_stagePendingNodeConfig(e) {
|
|
259
|
-
const t = this.
|
|
260
|
-
|
|
279
|
+
const t = this._pendingUpdatesForCurrentNode();
|
|
280
|
+
if (!(!t || !this.currentNode))
|
|
281
|
+
return _(e, this.currentNode, t), N(d.getConfig(this.currentNode), t);
|
|
282
|
+
}
|
|
283
|
+
_consumePendingNodeConfig() {
|
|
284
|
+
this.pendingNodeConfigWrite = null, this._clearConfigFlush();
|
|
261
285
|
}
|
|
262
286
|
/**
|
|
263
287
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -272,30 +296,25 @@ class he extends P {
|
|
|
272
296
|
_clearConfigFlush() {
|
|
273
297
|
this.pendingConfigFlushTimer !== null && (clearTimeout(this.pendingConfigFlushTimer), this.pendingConfigFlushTimer = null);
|
|
274
298
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
* committed. Always targets a LIVE node — a captured one is an immutable snapshot
|
|
278
|
-
* the intervening re-render staled, and saveConfig swallows that failure.
|
|
279
|
-
*/
|
|
299
|
+
// Writes the deferred change standalone when its batch never committed. Targets a LIVE node:
|
|
300
|
+
// a captured one is a snapshot the intervening re-render staled, and saveConfig swallows that.
|
|
280
301
|
_flushPendingNodeConfig() {
|
|
281
|
-
const e = this.pendingNodeConfigWrite;
|
|
282
|
-
if (this.
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
b(this.currentNode, e.updates) && l.updateConfig(
|
|
289
|
-
this.api,
|
|
290
|
-
this.currentNode,
|
|
291
|
-
e.updates,
|
|
292
|
-
f
|
|
293
|
-
);
|
|
302
|
+
const e = this.pendingNodeConfigWrite, t = this._pendingUpdates();
|
|
303
|
+
if (this._consumePendingNodeConfig(), !e || !t || !this.api)
|
|
304
|
+
return !1;
|
|
305
|
+
if (!(e.blockId === this.store.currentRecommendationId && e.blockId === this._getRecommendationIdFromNode(this.currentNode)) || !this.currentNode) {
|
|
306
|
+
const { blockId: i } = e, a = U(i, t);
|
|
307
|
+
return a === "missing" && this.store.blockStates[i] && console.error("[recommendation] pending config write did not reach a node", { blockId: i }), a === "applied";
|
|
294
308
|
}
|
|
309
|
+
const n = N(d.getConfig(this.currentNode), t);
|
|
310
|
+
if (n === null)
|
|
311
|
+
return !1;
|
|
312
|
+
const r = this.api.getDocumentModifier();
|
|
313
|
+
return _(r, this.currentNode, t), r.apply(new C(n)), !0;
|
|
295
314
|
}
|
|
296
315
|
_syncNodeConfigToStore() {
|
|
297
316
|
var n;
|
|
298
|
-
const e =
|
|
317
|
+
const e = d.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
299
318
|
this.store.patchCurrentBlockConfig({
|
|
300
319
|
strategy: e.strategy,
|
|
301
320
|
strategyId: e.strategyId,
|
|
@@ -314,15 +333,7 @@ class he extends P {
|
|
|
314
333
|
shuffleProducts: e.shuffleProducts,
|
|
315
334
|
priceMovedToNextLine: e.priceMovedToNextLine,
|
|
316
335
|
priceHideIfSameAsDiscounted: e.priceHideIfSameAsDiscounted,
|
|
317
|
-
currencySettings:
|
|
318
|
-
name: e.currency.code,
|
|
319
|
-
value: e.currency.code,
|
|
320
|
-
symbol: e.currency.symbol,
|
|
321
|
-
alignment: e.currency.alignment === "before" ? "0" : "1",
|
|
322
|
-
decimalCount: e.currency.decimalCount.toString(),
|
|
323
|
-
decimalSeparator: e.currency.decimalSeparator,
|
|
324
|
-
thousandSeparator: e.currency.thousandSeparator
|
|
325
|
-
}
|
|
336
|
+
currencySettings: p(e.currency)
|
|
326
337
|
}, { triggerRefetch: !1 });
|
|
327
338
|
}
|
|
328
339
|
/**
|
|
@@ -369,51 +380,41 @@ class he extends P {
|
|
|
369
380
|
_applySmartDefaults() {
|
|
370
381
|
if (!this.currentNode || !this.api)
|
|
371
382
|
return;
|
|
372
|
-
const e =
|
|
383
|
+
const e = d.getConfig(this.currentNode), t = {};
|
|
373
384
|
let o = null, n = null, r = null;
|
|
374
|
-
if (e.currency.code ===
|
|
375
|
-
const { currencyList:
|
|
376
|
-
|
|
377
|
-
(
|
|
378
|
-
) || (o =
|
|
379
|
-
...
|
|
385
|
+
if (e.currency.code === u.currency.code) {
|
|
386
|
+
const { currencyList: i } = this.store;
|
|
387
|
+
i.length > 0 && (i.some(
|
|
388
|
+
(c) => c.value === `price.${u.currency.code}`
|
|
389
|
+
) || (o = i[0].value.replace("price.", ""), t.currency = {
|
|
390
|
+
...u.currency,
|
|
380
391
|
code: o,
|
|
381
392
|
symbol: o
|
|
382
393
|
}));
|
|
383
394
|
}
|
|
384
|
-
if (e.strategy ===
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
(
|
|
388
|
-
) || (n =
|
|
395
|
+
if (e.strategy === u.strategy) {
|
|
396
|
+
const i = this.store.getActivePredictiveAlgorithms;
|
|
397
|
+
i.length > 0 && (i.some(
|
|
398
|
+
(c) => c.value === u.strategy
|
|
399
|
+
) || (n = i[0].value, t.strategy = n));
|
|
389
400
|
}
|
|
390
|
-
if (e.language ===
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
(
|
|
394
|
-
) || (r =
|
|
401
|
+
if (e.language === u.language) {
|
|
402
|
+
const i = this.store.getLanguages;
|
|
403
|
+
i.length > 0 && (i.some(
|
|
404
|
+
(c) => c.value === u.language
|
|
405
|
+
) || (r = i[0].value, t.language = r));
|
|
395
406
|
}
|
|
396
|
-
!o && !n && !r || (
|
|
407
|
+
!o && !n && !r || (d.updateConfig(
|
|
397
408
|
this.api,
|
|
398
409
|
this.currentNode,
|
|
399
410
|
t,
|
|
400
411
|
"Applied smart defaults"
|
|
401
|
-
), o && t.currency &&
|
|
412
|
+
), o && t.currency && z({
|
|
402
413
|
currentNode: this.currentNode,
|
|
403
414
|
documentModifier: this.api.getDocumentModifier(),
|
|
404
415
|
currency: t.currency
|
|
405
416
|
}), this.store.patchCurrentBlockConfig({
|
|
406
|
-
...o ? {
|
|
407
|
-
currencySettings: {
|
|
408
|
-
name: o,
|
|
409
|
-
value: o,
|
|
410
|
-
symbol: o,
|
|
411
|
-
alignment: a.currency.alignment === "before" ? "0" : "1",
|
|
412
|
-
decimalCount: a.currency.decimalCount.toString(),
|
|
413
|
-
decimalSeparator: a.currency.decimalSeparator,
|
|
414
|
-
thousandSeparator: a.currency.thousandSeparator
|
|
415
|
-
}
|
|
416
|
-
} : {},
|
|
417
|
+
...o && t.currency ? { currencySettings: p(t.currency) } : {},
|
|
417
418
|
...n ? { strategy: n } : {},
|
|
418
419
|
...r ? { language: r } : {}
|
|
419
420
|
}, { triggerRefetch: !1 }));
|
|
@@ -422,10 +423,10 @@ class he extends P {
|
|
|
422
423
|
* Reads the recommendation-id attribute from the block element within the node
|
|
423
424
|
*/
|
|
424
425
|
_getRecommendationIdFromNode(e) {
|
|
425
|
-
const t =
|
|
426
|
+
const t = $(e);
|
|
426
427
|
if (!t || !("getAttribute" in t))
|
|
427
428
|
return null;
|
|
428
|
-
const o = t.getAttribute(
|
|
429
|
+
const o = t.getAttribute(O);
|
|
429
430
|
if (!o)
|
|
430
431
|
return null;
|
|
431
432
|
const n = parseInt(o);
|
|
@@ -435,20 +436,18 @@ class he extends P {
|
|
|
435
436
|
* Lands what the panel still owes its block before it stops watching it: the config now, the
|
|
436
437
|
* products through a block-scoped refresh. Never throws — it runs from Stripo's teardown.
|
|
437
438
|
*/
|
|
438
|
-
_finishBlockOutsidePanel(
|
|
439
|
+
_finishBlockOutsidePanel(e = this._trackedBlockSnapshot()) {
|
|
440
|
+
var r;
|
|
441
|
+
const { blockId: t, fetchedConfigVersion: o, hasUnrenderedProducts: n } = e;
|
|
439
442
|
try {
|
|
440
|
-
this.
|
|
441
|
-
|
|
442
|
-
|
|
443
|
+
const i = t === null ? void 0 : this.store.blockStates[t], a = i !== void 0 && o !== i.configVersion;
|
|
444
|
+
if (t !== null && i && (a || n)) {
|
|
445
|
+
((r = this.pendingNodeConfigWrite) == null ? void 0 : r.blockId) === t && this._consumePendingNodeConfig(), this._flushPendingNodeConfig(), this._refreshOutsidePanel(t, a);
|
|
443
446
|
return;
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
f
|
|
449
|
-
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (r || o) && this._refreshOutsidePanel(e, r);
|
|
450
|
-
} catch (n) {
|
|
451
|
-
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
447
|
+
}
|
|
448
|
+
this._flushPendingNodeConfig();
|
|
449
|
+
} catch (i) {
|
|
450
|
+
console.error("[recommendation] finishing the block outside the panel failed", i);
|
|
452
451
|
}
|
|
453
452
|
}
|
|
454
453
|
_trackedBlockSnapshot() {
|
|
@@ -459,7 +458,7 @@ class he extends P {
|
|
|
459
458
|
};
|
|
460
459
|
}
|
|
461
460
|
_refreshOutsidePanel(e, t) {
|
|
462
|
-
|
|
461
|
+
T(e, {
|
|
463
462
|
pickUpdates: (o) => this._getNodeConfigUpdates(o),
|
|
464
463
|
description: "Update recommendation configuration",
|
|
465
464
|
fetch: t
|
|
@@ -477,20 +476,32 @@ class he extends P {
|
|
|
477
476
|
_regenerateWithProducts() {
|
|
478
477
|
if (!this.currentNode || !this.api)
|
|
479
478
|
return;
|
|
480
|
-
const e = this.store.recommendationProducts,
|
|
481
|
-
|
|
482
|
-
|
|
479
|
+
const { currentNode: e } = this, t = this.store.recommendationProducts, o = this.api.getDocumentModifier(), n = this._pendingUpdatesForCurrentNode() ?? void 0, r = this._stagePendingNodeConfig(o), i = (g) => {
|
|
480
|
+
(r || g) && o.apply(
|
|
481
|
+
new C(r ?? "Updated recommendation products")
|
|
482
|
+
), r !== void 0 && this._consumePendingNodeConfig();
|
|
483
|
+
};
|
|
484
|
+
if (H(e)) {
|
|
485
|
+
i(!1);
|
|
483
486
|
return;
|
|
484
487
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
488
|
+
let a = !1;
|
|
489
|
+
Y({
|
|
490
|
+
currentNode: e,
|
|
491
|
+
documentModifier: o,
|
|
492
|
+
products: t,
|
|
493
|
+
stageOnly: !0,
|
|
494
|
+
configOverrides: n,
|
|
495
|
+
onChanged: () => {
|
|
496
|
+
a = !0;
|
|
497
|
+
}
|
|
498
|
+
}) || (a = j({
|
|
499
|
+
currentNode: e,
|
|
500
|
+
documentModifier: o,
|
|
501
|
+
products: t,
|
|
502
|
+
stageOnly: !0,
|
|
503
|
+
configOverrides: n
|
|
504
|
+
})), i(a);
|
|
494
505
|
}
|
|
495
506
|
/**
|
|
496
507
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -511,51 +522,52 @@ class he extends P {
|
|
|
511
522
|
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
|
|
512
523
|
const n = e.currentRecommendationId;
|
|
513
524
|
if (n !== this.trackedBlockId) {
|
|
514
|
-
const
|
|
515
|
-
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(
|
|
525
|
+
const g = this._trackedBlockSnapshot();
|
|
526
|
+
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(g);
|
|
516
527
|
return;
|
|
517
528
|
}
|
|
518
529
|
const r = this._getBlockConfigVersion(n);
|
|
519
530
|
r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, this.panelGeneration));
|
|
520
|
-
const
|
|
521
|
-
|
|
531
|
+
const i = e.recommendationProducts, a = i !== t, c = Array.isArray(i) && i.length > 0;
|
|
532
|
+
a && c && (t = i, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
|
|
522
533
|
});
|
|
523
534
|
}
|
|
524
535
|
}
|
|
525
536
|
export {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
537
|
+
Pe as ALGORITHM_CONTROL_ID,
|
|
538
|
+
E as AlgorithmControl,
|
|
539
|
+
q as CONTROL_BLOCK_ID,
|
|
540
|
+
Ie as CURRENCY_CONTROL_ID,
|
|
541
|
+
D as CurrencyControl,
|
|
542
|
+
be as FILTERS_CONTROL_ID,
|
|
543
|
+
v as FiltersControl,
|
|
544
|
+
Se as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
545
|
+
Be as LOCALE_CONTROL_ID,
|
|
546
|
+
w as LayoutOrientationControl,
|
|
547
|
+
A as LocaleControl,
|
|
548
|
+
Le as PRICE_PLACEMENT_CONTROL_ID,
|
|
549
|
+
Ee as PRODUCT_COUNT_CONTROL_ID,
|
|
550
|
+
ve as PRODUCT_LAYOUT_CONTROL_ID,
|
|
551
|
+
V as PricePlacementControl,
|
|
552
|
+
x as ProductCountControl,
|
|
553
|
+
W as ProductLayoutControl,
|
|
554
|
+
_e as RecommendationBlockControl,
|
|
555
|
+
Ae as SHUFFLE_CONTROL_ID,
|
|
556
|
+
xe as STRATEGY_CONTROL_ID,
|
|
557
|
+
M as ShuffleControl,
|
|
558
|
+
G as StrategyControl,
|
|
559
|
+
Me as adjustProductsToSize,
|
|
560
|
+
Ge as formatProductPrice,
|
|
561
|
+
$ as getBlockElement,
|
|
562
|
+
ze as getCardComposition,
|
|
563
|
+
$e as getCurrencyAttributesFromBlock,
|
|
564
|
+
He as getCurrentLayout,
|
|
565
|
+
Ye as getMainContainerTbody,
|
|
566
|
+
H as isPartnerManagedBlock,
|
|
567
|
+
je as regenerateMobileProductRows,
|
|
568
|
+
j as regenerateProductRowsWithStyles,
|
|
569
|
+
z as setCurrencyAttributes,
|
|
570
|
+
qe as updatePricesInPlace,
|
|
571
|
+
Y as updateProductContentInPlace,
|
|
572
|
+
Je as updateSingleProductContent
|
|
561
573
|
};
|