@useinsider/guido 3.22.0 → 3.23.0
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 +35 -4
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +118 -108
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +11 -11
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +9 -9
- package/dist/composables/useEditorOpenMetrics.js +167 -0
- package/dist/composables/useStripo.js +93 -82
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -22
- package/dist/config/migrator/recommendation/compositionMapper.js +56 -49
- package/dist/config/migrator/recommendation/extractors.js +100 -40
- package/dist/config/migrator/recommendation/htmlBuilder.js +285 -207
- package/dist/config/migrator/recommendation/settingsMapper.js +37 -36
- package/dist/config/migrator/recommendation/themeMapper.js +53 -41
- package/dist/config/migrator/recommendationMigrator.js +68 -61
- package/dist/extensions/Blocks/Items/controls/button/link.js +14 -17
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +14 -17
- package/dist/extensions/Blocks/Items/controls/image/link.js +14 -17
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +9 -10
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +24 -25
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -13
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +29 -30
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -16
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +25 -26
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +27 -28
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +75 -80
- package/dist/extensions/Blocks/Recommendation/block.js +33 -24
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +27 -26
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +13 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +165 -175
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +15 -15
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +10 -10
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +1 -1
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +23 -22
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +19 -18
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +82 -91
- package/dist/extensions/Blocks/Recommendation/utils/inlinePriceOrder.js +12 -0
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +3 -2
- package/dist/extensions/Blocks/common-control.js +62 -55
- package/dist/guido.css +1 -1
- package/dist/library.js +12 -10
- package/dist/package.json.js +6 -4
- package/dist/public/prefetchRuntime.js +4 -0
- package/dist/src/composables/useEditorOpenMetrics.d.ts +27 -0
- package/dist/src/composables/useStripo.d.ts +2 -1
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/extractors.d.ts +35 -6
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/types.d.ts +11 -1
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -10
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -13
- package/dist/src/extensions/Blocks/Recommendation/utils/inlinePriceOrder.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +2 -19
- package/dist/src/extensions/Blocks/common-control.d.ts +2 -0
- package/dist/src/library.d.ts +1 -0
- package/dist/src/public/prefetchRuntime.d.ts +1 -0
- package/dist/src/stores/unsubscribe.d.ts +10 -0
- package/dist/src/utils/runtimePrefetch.d.ts +4 -0
- package/dist/src/utils/stripoRuntime.d.ts +3 -0
- package/dist/static/stripo-runtime-manifest.json.js +9 -0
- package/dist/stores/unsubscribe.js +33 -29
- package/dist/utils/runtimePrefetch.js +26 -0
- package/dist/utils/stripoRuntime.js +13 -0
- package/package.json +7 -2
|
@@ -1,72 +1,73 @@
|
|
|
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 {
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var P = (u, d, e) => d in u ? y(u, d, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[d] = e;
|
|
3
|
+
var r = (u, d, e) => P(u, typeof d != "symbol" ? d + "" : d, e);
|
|
4
|
+
import { useConfig as f } from "../../../../../composables/useConfig.js";
|
|
5
|
+
import { ModificationDescription as R } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
+
import { CommonControl as I } from "../../../common-control.js";
|
|
7
|
+
import { RRS_CONFIG_VERSION as S, DEFAULT_NODE_CONFIG as m } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RECOMMENDATION_ID_ATTR as k } from "../../constants/selectors.js";
|
|
9
|
+
import { RecommendationConfigService as c } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as T } from "../../store/recommendation.js";
|
|
11
|
+
import { refreshBlockOutsidePanel as O } from "../../utils/blockRefresh.js";
|
|
12
|
+
import { mapLegacyStrategy as p } from "../../utils/legacyStrategyMap.js";
|
|
13
|
+
import { registerNodeConfigWriter as b, writeBlockConfigOutsidePanel as C, hasEditedConfigChange as B, pickConfigDescription as F, isProductIdsChange as L, PRODUCT_IDS_DESCRIPTION as D } from "../../utils/nodeConfigWriter.js";
|
|
13
14
|
import { AlgorithmControl as E } from "./algorithm.js";
|
|
14
|
-
import { ALGORITHM_CONTROL_ID as
|
|
15
|
-
import { CurrencyControl as
|
|
16
|
-
import { CURRENCY_CONTROL_ID as
|
|
17
|
-
import { FiltersControl as
|
|
18
|
-
import { FILTERS_CONTROL_ID as
|
|
19
|
-
import { LayoutOrientationControl as
|
|
20
|
-
import { LAYOUT_ORIENTATION_CONTROL_ID as
|
|
21
|
-
import { LocaleControl as
|
|
22
|
-
import { LOCALE_CONTROL_ID as
|
|
23
|
-
import { PricePlacementControl as
|
|
24
|
-
import { PRICE_PLACEMENT_CONTROL_ID as
|
|
25
|
-
import { ProductCountControl as
|
|
26
|
-
import { PRODUCT_COUNT_CONTROL_ID as
|
|
27
|
-
import { ProductLayoutControl as
|
|
28
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
29
|
-
import { ShuffleControl as
|
|
30
|
-
import { SHUFFLE_CONTROL_ID as
|
|
31
|
-
import { StrategyControl as
|
|
32
|
-
import { STRATEGY_CONTROL_ID as
|
|
33
|
-
import { setCurrencyAttributes as
|
|
34
|
-
import { adjustProductsToSize as
|
|
35
|
-
import { useDebounceFn as
|
|
36
|
-
const
|
|
37
|
-
class
|
|
15
|
+
import { ALGORITHM_CONTROL_ID as Pe } from "./algorithm.js";
|
|
16
|
+
import { CurrencyControl as U } 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 ke } from "./filters.js";
|
|
20
|
+
import { LayoutOrientationControl as A } from "./layoutOrientation.js";
|
|
21
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as Oe } from "./layoutOrientation.js";
|
|
22
|
+
import { LocaleControl as w } 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 W } from "./productCount.js";
|
|
27
|
+
import { PRODUCT_COUNT_CONTROL_ID as Ee } from "./productCount.js";
|
|
28
|
+
import { ProductLayoutControl as x } 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 we } from "./shuffle.js";
|
|
32
|
+
import { StrategyControl as G } from "./strategy.js";
|
|
33
|
+
import { STRATEGY_CONTROL_ID as We } from "./strategy.js";
|
|
34
|
+
import { setCurrencyAttributes as $, getBlockElement as z, isPartnerManagedBlock as H, updateProductContentInPlace as Y, regenerateProductRowsWithStyles as j } from "./utils.js";
|
|
35
|
+
import { adjustProductsToSize as Me, formatProductPrice as Ge, getCardComposition as $e, getCurrentLayout as ze, getMainContainerTbody as He, regenerateMobileProductRows as Ye, updatePricesInPlace as je, updateSingleProductContent as qe } from "./utils.js";
|
|
36
|
+
import { useDebounceFn as _ } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
37
|
+
const h = "Update recommendation filters", q = "ui-elements-recommendation-block";
|
|
38
|
+
class _e extends I {
|
|
38
39
|
constructor() {
|
|
39
40
|
super(...arguments);
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
r(this, "store", T());
|
|
42
|
+
r(this, "storeUnsubscription", () => {
|
|
42
43
|
});
|
|
43
44
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
44
45
|
// re-render's single apply() — one user action must cost one undo press.
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
r(this, "pendingNodeConfigWrite", null);
|
|
47
|
+
r(this, "pendingConfigFlushTimer", null);
|
|
47
48
|
// What the panel still owes the block it watches — finished outside the panel on teardown
|
|
48
49
|
// and block switch. A new generation tells debounced work queued for the old one to stand down.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
r(this, "trackedBlockId", null);
|
|
51
|
+
r(this, "fetchedConfigVersion", 0);
|
|
52
|
+
r(this, "hasUnrenderedProducts", !1);
|
|
53
|
+
r(this, "panelGeneration", 0);
|
|
54
|
+
r(this, "isPanelAlive", !0);
|
|
54
55
|
// Sub-control instances for lifecycle management
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
r(this, "algorithmControl", null);
|
|
57
|
+
r(this, "localeControl", null);
|
|
58
|
+
r(this, "currencyControl", null);
|
|
59
|
+
r(this, "productCountControl", null);
|
|
60
|
+
r(this, "productLayoutControl", null);
|
|
61
|
+
r(this, "filtersControl", null);
|
|
62
|
+
r(this, "shuffleControl", null);
|
|
63
|
+
r(this, "pricePlacementControl", null);
|
|
64
|
+
r(this, "layoutOrientationControl", null);
|
|
65
|
+
r(this, "strategyControl", null);
|
|
66
|
+
r(this, "rrsEnabled", !1);
|
|
66
67
|
/**
|
|
67
68
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
68
69
|
*/
|
|
69
|
-
|
|
70
|
+
r(this, "_debouncedFetchProducts", _(async (e, t) => {
|
|
70
71
|
if (t !== this.panelGeneration)
|
|
71
72
|
return;
|
|
72
73
|
const o = this._getBlockConfigVersion(e);
|
|
@@ -87,7 +88,7 @@ class me extends P {
|
|
|
87
88
|
* count. The store pads products to the configured size, so in-place only
|
|
88
89
|
* fails when the size actually changed.
|
|
89
90
|
*/
|
|
90
|
-
|
|
91
|
+
r(this, "_debouncedRegenerateWithProducts", _((e) => {
|
|
91
92
|
if (e !== this.panelGeneration || !this.currentNode || !this.api)
|
|
92
93
|
return;
|
|
93
94
|
const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
|
|
@@ -106,7 +107,7 @@ class me extends P {
|
|
|
106
107
|
}, 100));
|
|
107
108
|
}
|
|
108
109
|
getId() {
|
|
109
|
-
return
|
|
110
|
+
return q;
|
|
110
111
|
}
|
|
111
112
|
get _subControls() {
|
|
112
113
|
return [
|
|
@@ -124,10 +125,10 @@ class me extends P {
|
|
|
124
125
|
}
|
|
125
126
|
getTemplate() {
|
|
126
127
|
var e;
|
|
127
|
-
return this.rrsEnabled =
|
|
128
|
+
return this.rrsEnabled = f().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
128
129
|
var o;
|
|
129
130
|
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
130
|
-
}), this.algorithmControl = new E(), this.localeControl = new
|
|
131
|
+
}), this.algorithmControl = new E(), this.localeControl = new w(), this.currencyControl = new U(), this.productCountControl = new W(), this.productLayoutControl = new x(), this.filtersControl = new v(), this.shuffleControl = new M(), this.pricePlacementControl = new V(), this.layoutOrientationControl = new A(), this.strategyControl = this.rrsEnabled ? new G() : null, this._subControls.forEach((t) => {
|
|
131
132
|
t && (t.api = this.api);
|
|
132
133
|
}), `
|
|
133
134
|
<div class="recommendation-controls-container">
|
|
@@ -145,28 +146,21 @@ class me extends P {
|
|
|
145
146
|
`;
|
|
146
147
|
}
|
|
147
148
|
_showControlsForBlock(e) {
|
|
148
|
-
var
|
|
149
|
-
const t = (
|
|
149
|
+
var s;
|
|
150
|
+
const t = (s = this.getContainer()) == null ? void 0 : s.querySelector(".recommendation-controls-container");
|
|
150
151
|
if (!t)
|
|
151
152
|
return;
|
|
152
|
-
const o = this._getRecommendationIdFromNode(e) === null ? null :
|
|
153
|
+
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) >= S), i = this.rrsEnabled && !!o && !n;
|
|
153
154
|
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", i);
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
T(this.api);
|
|
158
|
-
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
159
|
-
if (t !== null && this.store.setCurrentBlock(t), e !== null && this._syncNodeConfigIfChanged(e), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), t !== null && ((o = this.store.blockStates[t]) != null && o.isInitialized)) {
|
|
160
|
-
this._initializeSubControls();
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
await this._fetchBlockData(t), this._initializeSubControls();
|
|
156
|
+
onRender() {
|
|
157
|
+
b(this.api), this.forgetLastPanelNode(), this._listenStateUpdates();
|
|
164
158
|
}
|
|
165
159
|
onTemplateNodeUpdated(e) {
|
|
166
160
|
var o;
|
|
167
161
|
super.onTemplateNodeUpdated(e);
|
|
168
162
|
const t = this._getRecommendationIdFromNode(e);
|
|
169
|
-
t !== null && t !== this.store.currentRecommendationId && this.store.setCurrentBlock(t), t !== null && this._syncNodeConfigIfChanged(t), this._showControlsForBlock(e), t !== null && !((o = this.store.blockStates[t]) != null && o.isInitialized) && this._fetchBlockData(t).then(() => {
|
|
163
|
+
t !== null && t !== this.store.currentRecommendationId && this.store.setCurrentBlock(t), t !== null && this._syncNodeConfigIfChanged(t), this._showControlsForBlock(e), this._renderWithPanelNode(t), t !== null && !((o = this.store.blockStates[t]) != null && o.isInitialized) && this._fetchBlockData(t).then(() => {
|
|
170
164
|
this._initializeSubControls();
|
|
171
165
|
}), this._subControls.forEach((n) => {
|
|
172
166
|
var i;
|
|
@@ -174,7 +168,7 @@ class me extends P {
|
|
|
174
168
|
});
|
|
175
169
|
}
|
|
176
170
|
onDestroy() {
|
|
177
|
-
this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
|
|
171
|
+
this.panelGeneration++, this.isPanelAlive = !1, this.isAwaitingPanelNode = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
|
|
178
172
|
var t;
|
|
179
173
|
return (t = e == null ? void 0 : e.onDestroy) == null ? void 0 : t.call(e);
|
|
180
174
|
});
|
|
@@ -184,11 +178,23 @@ class me extends P {
|
|
|
184
178
|
* Each sub-control manages its own form values and event listeners
|
|
185
179
|
*/
|
|
186
180
|
_initializeSubControls() {
|
|
187
|
-
this._subControls.forEach((e) => {
|
|
181
|
+
this.currentNode && this._subControls.forEach((e) => {
|
|
188
182
|
var t;
|
|
189
183
|
e && (e.api = this.api, e.currentNode = this.currentNode, (t = e.onRender) == null || t.call(e));
|
|
190
184
|
});
|
|
191
185
|
}
|
|
186
|
+
// The panel's own node, not the store's last focused block, decides what to render; the caller
|
|
187
|
+
// fetches an uninitialized block once its config is synced.
|
|
188
|
+
_renderWithPanelNode(e) {
|
|
189
|
+
var t;
|
|
190
|
+
if (!(!this.isAwaitingPanelNode || e === null)) {
|
|
191
|
+
if (this.isAwaitingPanelNode = !1, (t = this.store.blockStates[e]) != null && t.isInitialized) {
|
|
192
|
+
this._initializeSubControls();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender());
|
|
196
|
+
}
|
|
197
|
+
}
|
|
192
198
|
/**
|
|
193
199
|
* Syncs persisted node config into the Pinia store's block state.
|
|
194
200
|
*
|
|
@@ -219,13 +225,13 @@ class me extends P {
|
|
|
219
225
|
const t = this.store.blockStates[e];
|
|
220
226
|
if (!t)
|
|
221
227
|
return;
|
|
222
|
-
const o = JSON.stringify(
|
|
228
|
+
const o = JSON.stringify(c.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
|
|
223
229
|
t.syncedConfigFingerprint = o, n !== o && ((i = this.pendingNodeConfigWrite) == null ? void 0 : i.blockId) !== e && this._syncNodeConfigToStore();
|
|
224
230
|
}
|
|
225
231
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
226
232
|
_isPendingStrategyIdChange() {
|
|
227
233
|
const e = this.pendingNodeConfigWrite;
|
|
228
|
-
return e ?
|
|
234
|
+
return e ? c.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
|
|
229
235
|
}
|
|
230
236
|
_capturePendingNodeConfigWrite() {
|
|
231
237
|
const e = this.store.currentRecommendationId, t = e === null ? void 0 : this.store.blockStates[e];
|
|
@@ -240,15 +246,15 @@ class me extends P {
|
|
|
240
246
|
return !e || t !== null && e.blockId !== t ? null : e;
|
|
241
247
|
}
|
|
242
248
|
_getNodeConfigUpdates(e) {
|
|
243
|
-
const { filters: t, strategy: o, strategyId: n, size: i, productIds:
|
|
249
|
+
const { filters: t, strategy: o, strategyId: n, size: i, productIds: s, nodeConfigVersion: l } = e, { partnerName: a } = f();
|
|
244
250
|
return {
|
|
245
251
|
filters: t,
|
|
246
252
|
strategy: o,
|
|
247
253
|
strategyId: n,
|
|
248
254
|
size: i,
|
|
249
|
-
productIds:
|
|
250
|
-
configVersion:
|
|
251
|
-
...
|
|
255
|
+
productIds: s,
|
|
256
|
+
configVersion: l,
|
|
257
|
+
...a.value ? { partnerName: a.value } : {}
|
|
252
258
|
};
|
|
253
259
|
}
|
|
254
260
|
/**
|
|
@@ -263,7 +269,7 @@ class me extends P {
|
|
|
263
269
|
*/
|
|
264
270
|
_stagePendingNodeConfig(e) {
|
|
265
271
|
const t = this._pendingWriteForNode();
|
|
266
|
-
return !t || !this.currentNode ? !1 : (
|
|
272
|
+
return !t || !this.currentNode ? !1 : (c.stageConfig(e, this.currentNode, t.updates), !0);
|
|
267
273
|
}
|
|
268
274
|
/**
|
|
269
275
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -288,14 +294,14 @@ class me extends P {
|
|
|
288
294
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !(!e || !this.api)) {
|
|
289
295
|
if (e.blockId !== this.store.currentRecommendationId || !this.currentNode) {
|
|
290
296
|
const { blockId: t, updates: o } = e;
|
|
291
|
-
!
|
|
297
|
+
!C(t, o, h) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
|
|
292
298
|
return;
|
|
293
299
|
}
|
|
294
|
-
|
|
300
|
+
B(this.currentNode, e.updates) && c.updateConfig(
|
|
295
301
|
this.api,
|
|
296
302
|
this.currentNode,
|
|
297
303
|
e.updates,
|
|
298
|
-
|
|
304
|
+
F(this.currentNode, e.updates, h)
|
|
299
305
|
);
|
|
300
306
|
}
|
|
301
307
|
}
|
|
@@ -306,14 +312,14 @@ class me extends P {
|
|
|
306
312
|
/** The Product Ids label when the pending write moves the node's ids; the caller's default otherwise. */
|
|
307
313
|
_pendingDescription() {
|
|
308
314
|
const e = this._pendingWriteForNode();
|
|
309
|
-
if (!(!e || !this.currentNode || !
|
|
310
|
-
return
|
|
315
|
+
if (!(!e || !this.currentNode || !L(this.currentNode, e.updates)))
|
|
316
|
+
return D;
|
|
311
317
|
}
|
|
312
318
|
_syncNodeConfigToStore() {
|
|
313
319
|
var n;
|
|
314
|
-
const e =
|
|
320
|
+
const e = c.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
315
321
|
this.store.patchCurrentBlockConfig({
|
|
316
|
-
strategy: e.strategy,
|
|
322
|
+
strategy: p(e.strategy) ?? e.strategy,
|
|
317
323
|
strategyId: e.strategyId,
|
|
318
324
|
nodeConfigVersion: e.configVersion,
|
|
319
325
|
language: e.language,
|
|
@@ -347,7 +353,7 @@ class me extends P {
|
|
|
347
353
|
* 2. Smart defaults for new blocks (currency, algorithm) — sequential
|
|
348
354
|
* 3. Product data with correct defaults — sequential
|
|
349
355
|
*
|
|
350
|
-
*
|
|
356
|
+
* Called from onTemplateNodeUpdated() once the node config is synced.
|
|
351
357
|
* Marks the block as initialized to prevent redundant fetches on re-selection.
|
|
352
358
|
*/
|
|
353
359
|
async _fetchBlockData(e) {
|
|
@@ -373,61 +379,45 @@ class me extends P {
|
|
|
373
379
|
return this.isPanelAlive && this.store.currentRecommendationId === e;
|
|
374
380
|
}
|
|
375
381
|
/**
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
* For new blocks (config still matches hardcoded defaults), validates that
|
|
379
|
-
* the default currency and algorithm are available from the API response.
|
|
380
|
-
* If not, falls back to the first available option.
|
|
381
|
-
*
|
|
382
|
-
* Saved templates with user-customized config are left unchanged because
|
|
383
|
-
* their values won't match the hardcoded defaults.
|
|
382
|
+
* Falls back to the first available option when the block's currency or locale is not offered (a new block on
|
|
383
|
+
* the hard-coded default, or a block copied from another account). Only the default strategy gets an algorithm.
|
|
384
384
|
*/
|
|
385
385
|
_applySmartDefaults() {
|
|
386
386
|
if (!this.currentNode || !this.api)
|
|
387
387
|
return;
|
|
388
|
-
const e =
|
|
388
|
+
const e = c.getConfig(this.currentNode), t = {};
|
|
389
389
|
let o = null, n = null, i = null;
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
if (e.strategy === a.strategy) {
|
|
401
|
-
const r = this.store.getActivePredictiveAlgorithms;
|
|
402
|
-
r.length > 0 && (r.some(
|
|
403
|
-
(c) => c.value === a.strategy
|
|
404
|
-
) || (n = r[0].value, t.strategy = n));
|
|
405
|
-
}
|
|
406
|
-
if (e.language === a.language) {
|
|
407
|
-
const r = this.store.getLanguages;
|
|
408
|
-
r.length > 0 && (r.some(
|
|
409
|
-
(c) => c.value === a.language
|
|
410
|
-
) || (i = r[0].value, t.language = i));
|
|
390
|
+
const { currencyList: s } = this.store;
|
|
391
|
+
if (s.length > 0 && !s.some((a) => a.value === `price.${e.currency.code}`) && (o = s[0].value.replace("price.", ""), t.currency = {
|
|
392
|
+
...e.currency,
|
|
393
|
+
code: o,
|
|
394
|
+
symbol: o
|
|
395
|
+
}), p(e.strategy) === m.strategy) {
|
|
396
|
+
const a = this.store.getActivePredictiveAlgorithms;
|
|
397
|
+
a.length > 0 && (a.some(
|
|
398
|
+
(N) => N.value === m.strategy
|
|
399
|
+
) || (n = a[0].value, t.strategy = n));
|
|
411
400
|
}
|
|
412
|
-
|
|
401
|
+
const l = this.store.getLanguages;
|
|
402
|
+
l.length > 0 && !l.some((a) => a.value === e.language) && (i = l[0].value, t.language = i), !(!o && !n && !i) && (c.updateConfig(
|
|
413
403
|
this.api,
|
|
414
404
|
this.currentNode,
|
|
415
405
|
t,
|
|
416
406
|
"Applied smart defaults"
|
|
417
|
-
), o && t.currency &&
|
|
407
|
+
), o && t.currency && $({
|
|
418
408
|
currentNode: this.currentNode,
|
|
419
409
|
documentModifier: this.api.getDocumentModifier(),
|
|
420
410
|
currency: t.currency
|
|
421
411
|
}), this.store.patchCurrentBlockConfig({
|
|
422
|
-
...o ? {
|
|
412
|
+
...o && t.currency ? {
|
|
423
413
|
currencySettings: {
|
|
424
414
|
name: o,
|
|
425
415
|
value: o,
|
|
426
416
|
symbol: o,
|
|
427
|
-
alignment:
|
|
428
|
-
decimalCount:
|
|
429
|
-
decimalSeparator:
|
|
430
|
-
thousandSeparator:
|
|
417
|
+
alignment: t.currency.alignment === "before" ? "0" : "1",
|
|
418
|
+
decimalCount: t.currency.decimalCount.toString(),
|
|
419
|
+
decimalSeparator: t.currency.decimalSeparator,
|
|
420
|
+
thousandSeparator: t.currency.thousandSeparator
|
|
431
421
|
}
|
|
432
422
|
} : {},
|
|
433
423
|
...n ? { strategy: n } : {},
|
|
@@ -438,10 +428,10 @@ class me extends P {
|
|
|
438
428
|
* Reads the recommendation-id attribute from the block element within the node
|
|
439
429
|
*/
|
|
440
430
|
_getRecommendationIdFromNode(e) {
|
|
441
|
-
const t =
|
|
431
|
+
const t = z(e);
|
|
442
432
|
if (!t || !("getAttribute" in t))
|
|
443
433
|
return null;
|
|
444
|
-
const o = t.getAttribute(
|
|
434
|
+
const o = t.getAttribute(k);
|
|
445
435
|
if (!o)
|
|
446
436
|
return null;
|
|
447
437
|
const n = parseInt(o);
|
|
@@ -458,10 +448,10 @@ class me extends P {
|
|
|
458
448
|
if (e === null || !n)
|
|
459
449
|
return;
|
|
460
450
|
const i = t !== n.configVersion;
|
|
461
|
-
i && !
|
|
451
|
+
i && !C(
|
|
462
452
|
e,
|
|
463
453
|
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
464
|
-
|
|
454
|
+
h
|
|
465
455
|
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i || o) && this._refreshOutsidePanel(e, i);
|
|
466
456
|
} catch (n) {
|
|
467
457
|
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
@@ -475,7 +465,7 @@ class me extends P {
|
|
|
475
465
|
};
|
|
476
466
|
}
|
|
477
467
|
_refreshOutsidePanel(e, t) {
|
|
478
|
-
|
|
468
|
+
O(e, {
|
|
479
469
|
pickUpdates: (o) => this._getNodeConfigUpdates(o),
|
|
480
470
|
description: "Update recommendation configuration",
|
|
481
471
|
fetch: t
|
|
@@ -498,19 +488,19 @@ class me extends P {
|
|
|
498
488
|
return;
|
|
499
489
|
}
|
|
500
490
|
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = this._pendingDescription(), n = this._stagePendingNodeConfig(t);
|
|
501
|
-
if (
|
|
491
|
+
if (H(this.currentNode)) {
|
|
502
492
|
n && (t.apply(
|
|
503
|
-
new
|
|
493
|
+
new R(o ?? "Update recommendation configuration")
|
|
504
494
|
), this._consumePendingNodeConfig());
|
|
505
495
|
return;
|
|
506
496
|
}
|
|
507
|
-
|
|
497
|
+
Y({
|
|
508
498
|
currentNode: this.currentNode,
|
|
509
499
|
documentModifier: t,
|
|
510
500
|
products: e,
|
|
511
501
|
description: o,
|
|
512
502
|
onApplied: n ? () => this._consumePendingNodeConfig() : void 0
|
|
513
|
-
}) ||
|
|
503
|
+
}) || j({
|
|
514
504
|
currentNode: this.currentNode,
|
|
515
505
|
documentModifier: t,
|
|
516
506
|
products: e,
|
|
@@ -541,51 +531,51 @@ class me extends P {
|
|
|
541
531
|
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
|
|
542
532
|
const n = e.currentRecommendationId;
|
|
543
533
|
if (n !== this.trackedBlockId) {
|
|
544
|
-
const
|
|
545
|
-
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(
|
|
534
|
+
const g = this._trackedBlockSnapshot();
|
|
535
|
+
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(g);
|
|
546
536
|
return;
|
|
547
537
|
}
|
|
548
538
|
const i = this._getBlockConfigVersion(n);
|
|
549
539
|
i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, this.panelGeneration));
|
|
550
|
-
const
|
|
551
|
-
|
|
540
|
+
const s = e.recommendationProducts, l = s !== t, a = Array.isArray(s) && s.length > 0;
|
|
541
|
+
l && a && (t = s, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
|
|
552
542
|
});
|
|
553
543
|
}
|
|
554
544
|
}
|
|
555
545
|
export {
|
|
556
|
-
|
|
546
|
+
Pe as ALGORITHM_CONTROL_ID,
|
|
557
547
|
E as AlgorithmControl,
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
548
|
+
q as CONTROL_BLOCK_ID,
|
|
549
|
+
Ie as CURRENCY_CONTROL_ID,
|
|
550
|
+
U as CurrencyControl,
|
|
551
|
+
ke as FILTERS_CONTROL_ID,
|
|
552
|
+
v as FiltersControl,
|
|
553
|
+
Oe as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
554
|
+
Be as LOCALE_CONTROL_ID,
|
|
555
|
+
A as LayoutOrientationControl,
|
|
556
|
+
w as LocaleControl,
|
|
557
|
+
Le as PRICE_PLACEMENT_CONTROL_ID,
|
|
558
|
+
Ee as PRODUCT_COUNT_CONTROL_ID,
|
|
559
|
+
ve as PRODUCT_LAYOUT_CONTROL_ID,
|
|
560
|
+
V as PricePlacementControl,
|
|
561
|
+
W as ProductCountControl,
|
|
562
|
+
x as ProductLayoutControl,
|
|
563
|
+
_e as RecommendationBlockControl,
|
|
564
|
+
we as SHUFFLE_CONTROL_ID,
|
|
565
|
+
We as STRATEGY_CONTROL_ID,
|
|
566
|
+
M as ShuffleControl,
|
|
567
|
+
G as StrategyControl,
|
|
568
|
+
Me as adjustProductsToSize,
|
|
569
|
+
Ge as formatProductPrice,
|
|
570
|
+
z as getBlockElement,
|
|
571
|
+
$e as getCardComposition,
|
|
572
|
+
ze as getCurrentLayout,
|
|
573
|
+
He as getMainContainerTbody,
|
|
574
|
+
H as isPartnerManagedBlock,
|
|
575
|
+
Ye as regenerateMobileProductRows,
|
|
576
|
+
j as regenerateProductRowsWithStyles,
|
|
577
|
+
$ as setCurrencyAttributes,
|
|
578
|
+
je as updatePricesInPlace,
|
|
579
|
+
Y as updateProductContentInPlace,
|
|
580
|
+
qe as updateSingleProductContent
|
|
591
581
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ModificationDescription as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
import { CommonControl as
|
|
2
|
+
import { CommonControl as d } from "../../../common-control.js";
|
|
3
3
|
import { RecommendationBlockId as a } from "../../constants/blockIds.js";
|
|
4
|
-
import { RecommendationControlId as
|
|
4
|
+
import { RecommendationControlId as u } from "../../constants/controlIds.js";
|
|
5
5
|
import { BLOCK_ROOT_SELECTOR as m } from "../../constants/selectors.js";
|
|
6
6
|
import { CSS_CLASS_TEXT_TRIM as r, ensureTextTrimCssRulesExist as T } from "../shared/textTrimCssRules.js";
|
|
7
7
|
const s = {
|
|
8
8
|
TEXT_TRIM_ENABLED: "textTrimEnabled"
|
|
9
9
|
};
|
|
10
|
-
class N extends
|
|
10
|
+
class N extends d {
|
|
11
11
|
getId() {
|
|
12
|
-
return
|
|
12
|
+
return u.NAME_TEXT_TRIM;
|
|
13
13
|
}
|
|
14
14
|
getTemplate() {
|
|
15
15
|
return `
|
|
@@ -23,7 +23,7 @@ class N extends u {
|
|
|
23
23
|
`;
|
|
24
24
|
}
|
|
25
25
|
onRender() {
|
|
26
|
-
this.
|
|
26
|
+
this.forgetLastPanelNode(), this._listenToFormUpdates();
|
|
27
27
|
}
|
|
28
28
|
onTemplateNodeUpdated(e) {
|
|
29
29
|
super.onTemplateNodeUpdated(e), this._setFormValues();
|
|
@@ -4,8 +4,8 @@ import { CommonControl as l } from "../../../common-control.js";
|
|
|
4
4
|
import { RecommendationBlockId as d } from "../../constants/blockIds.js";
|
|
5
5
|
import { RecommendationControlId as T } from "../../constants/controlIds.js";
|
|
6
6
|
import { BLOCK_ROOT_SELECTOR as f } from "../../constants/selectors.js";
|
|
7
|
-
const
|
|
8
|
-
class
|
|
7
|
+
const s = "data-text-after", u = "", p = ".omnibus-text-after";
|
|
8
|
+
class N extends l {
|
|
9
9
|
getId() {
|
|
10
10
|
return T.OMNIBUS_DISCOUNT_TEXT_AFTER;
|
|
11
11
|
}
|
|
@@ -24,7 +24,7 @@ class g extends l {
|
|
|
24
24
|
`;
|
|
25
25
|
}
|
|
26
26
|
onRender() {
|
|
27
|
-
this.
|
|
27
|
+
this.forgetLastPanelNode(), this._listenToFormUpdates();
|
|
28
28
|
}
|
|
29
29
|
onTemplateNodeUpdated(t) {
|
|
30
30
|
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
@@ -38,7 +38,7 @@ class g extends l {
|
|
|
38
38
|
_getCurrentText() {
|
|
39
39
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
40
40
|
return u;
|
|
41
|
-
const t = this.currentNode.getAttribute(
|
|
41
|
+
const t = this.currentNode.getAttribute(s);
|
|
42
42
|
return t === null ? u : t;
|
|
43
43
|
}
|
|
44
44
|
_onTextChange(t) {
|
|
@@ -53,9 +53,9 @@ class g extends l {
|
|
|
53
53
|
if (!n.length)
|
|
54
54
|
return;
|
|
55
55
|
const o = this.api.getDocumentModifier();
|
|
56
|
-
n.forEach((
|
|
57
|
-
o.modifyHtml(
|
|
58
|
-
const r =
|
|
56
|
+
n.forEach((i) => {
|
|
57
|
+
o.modifyHtml(i).setAttribute(s, t);
|
|
58
|
+
const r = i.querySelector(p);
|
|
59
59
|
if (r) {
|
|
60
60
|
const a = m(r, t);
|
|
61
61
|
o.modifyHtml(r).setInnerHtml(a);
|
|
@@ -69,5 +69,5 @@ class g extends l {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
export {
|
|
72
|
-
|
|
72
|
+
N as OmnibusDiscountTextAfterControl
|
|
73
73
|
};
|