@useinsider/guido 3.21.0-beta.450394b → 3.21.0-beta.647fb59
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/extensions/Blocks/Recommendation/controls/main/algorithm.js +23 -18
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +141 -171
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +97 -98
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +45 -62
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -4
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +0 -4
- package/package.json +1 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UEAttr as
|
|
5
|
-
import { CommonControl as
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var h = (r, s, t) => s in r ? d(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
|
|
3
|
+
var c = (r, s, t) => h(r, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
+
import { UEAttr as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as g } from "../../../common-control.js";
|
|
6
6
|
import { RecommendationConfigService as n } from "../../services/configService.js";
|
|
7
|
-
import { useRecommendationExtensionStore as
|
|
8
|
-
import { mapLegacyStrategy as
|
|
9
|
-
const
|
|
7
|
+
import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
|
|
8
|
+
import { mapLegacyStrategy as u } from "../../utils/legacyStrategyMap.js";
|
|
9
|
+
const p = "recommendation-algorithm-control", i = {
|
|
10
10
|
ALGORITHM: "strategy",
|
|
11
11
|
PRODUCT_IDS: "productIds"
|
|
12
12
|
};
|
|
13
|
-
class
|
|
13
|
+
class R extends g {
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...arguments);
|
|
16
16
|
// Store is used ONLY for API-fetched data (algorithms list), not for config
|
|
17
|
-
|
|
17
|
+
c(this, "store", m());
|
|
18
18
|
}
|
|
19
19
|
getId() {
|
|
20
|
-
return
|
|
20
|
+
return p;
|
|
21
21
|
}
|
|
22
22
|
getTemplate() {
|
|
23
23
|
return `
|
|
@@ -46,10 +46,10 @@ class S extends m {
|
|
|
46
46
|
super.onTemplateNodeUpdated(t), this._initializeSelectItems(), this._setFormValues();
|
|
47
47
|
}
|
|
48
48
|
_setFormValues() {
|
|
49
|
-
const t = n.getConfig(this.currentNode), e =
|
|
49
|
+
const t = n.getConfig(this.currentNode), e = u(t.strategy) ?? t.strategy;
|
|
50
50
|
this._setProductIdsVisibility(e);
|
|
51
|
-
const o = { [i.ALGORITHM]: e }, a = t.productIds.join(",")
|
|
52
|
-
|
|
51
|
+
const o = { [i.ALGORITHM]: e }, a = t.productIds.join(",");
|
|
52
|
+
this.api.getValues()[i.PRODUCT_IDS] !== a && (o[i.PRODUCT_IDS] = a), this.api.updateValues(o);
|
|
53
53
|
}
|
|
54
54
|
_initializeSelectItems() {
|
|
55
55
|
var e;
|
|
@@ -58,7 +58,7 @@ class S extends m {
|
|
|
58
58
|
try {
|
|
59
59
|
this.api.setUIEAttribute(
|
|
60
60
|
i.ALGORITHM,
|
|
61
|
-
|
|
61
|
+
l.SELECTPICKER.items,
|
|
62
62
|
t
|
|
63
63
|
);
|
|
64
64
|
} catch (o) {
|
|
@@ -93,7 +93,12 @@ class S extends m {
|
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
95
|
const o = t === "" ? [] : t.split(",");
|
|
96
|
-
|
|
96
|
+
n.updateConfig(
|
|
97
|
+
this.api,
|
|
98
|
+
this.currentNode,
|
|
99
|
+
{ productIds: o },
|
|
100
|
+
"Updated product IDs"
|
|
101
|
+
), this.store.patchCurrentBlockConfig({ productIds: o });
|
|
97
102
|
}
|
|
98
103
|
_listenToFormUpdates() {
|
|
99
104
|
this.api.onValueChanged(i.ALGORITHM, (t) => {
|
|
@@ -104,6 +109,6 @@ class S extends m {
|
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
111
|
export {
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
p as ALGORITHM_CONTROL_ID,
|
|
113
|
+
R as AlgorithmControl
|
|
109
114
|
};
|
|
@@ -1,79 +1,79 @@
|
|
|
1
1
|
var _ = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
2
|
+
var y = (h, c, e) => c in h ? _(h, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[c] = e;
|
|
3
|
+
var i = (h, c, e) => y(h, typeof c != "symbol" ? c + "" : c, e);
|
|
4
4
|
import { useConfig as g } from "../../../../../composables/useConfig.js";
|
|
5
|
-
import { ModificationDescription as
|
|
5
|
+
import { ModificationDescription as N } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { CommonControl as P } from "../../../common-control.js";
|
|
7
7
|
import { RRS_CONFIG_VERSION as R, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
8
|
+
import { RECOMMENDATION_ID_ATTR as k } from "../../constants/selectors.js";
|
|
9
9
|
import { RecommendationConfigService as l } from "../../services/configService.js";
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
10
|
+
import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
|
|
11
11
|
import { refreshBlockOutsidePanel as S } from "../../utils/blockRefresh.js";
|
|
12
|
-
import { registerNodeConfigWriter as T, writeBlockConfigOutsidePanel as m, hasEditedConfigChange as
|
|
13
|
-
import { AlgorithmControl as
|
|
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
|
|
12
|
+
import { registerNodeConfigWriter as T, writeBlockConfigOutsidePanel as m, hasEditedConfigChange as b } from "../../utils/nodeConfigWriter.js";
|
|
13
|
+
import { AlgorithmControl as O } from "./algorithm.js";
|
|
14
|
+
import { ALGORITHM_CONTROL_ID as me } from "./algorithm.js";
|
|
15
|
+
import { CurrencyControl as B } from "./currency.js";
|
|
16
|
+
import { CURRENCY_CONTROL_ID as pe } from "./currency.js";
|
|
17
|
+
import { FiltersControl as L } from "./filters.js";
|
|
18
|
+
import { FILTERS_CONTROL_ID as ye } from "./filters.js";
|
|
19
|
+
import { LayoutOrientationControl as E } from "./layoutOrientation.js";
|
|
20
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as Pe } from "./layoutOrientation.js";
|
|
21
|
+
import { LocaleControl as F } from "./locale.js";
|
|
22
|
+
import { LOCALE_CONTROL_ID as ke } from "./locale.js";
|
|
23
|
+
import { PricePlacementControl as D } from "./pricePlacement.js";
|
|
24
|
+
import { PRICE_PLACEMENT_CONTROL_ID as Se } from "./pricePlacement.js";
|
|
25
|
+
import { ProductCountControl as U } from "./productCount.js";
|
|
26
|
+
import { PRODUCT_COUNT_CONTROL_ID as be } from "./productCount.js";
|
|
27
|
+
import { ProductLayoutControl as v } from "./productLayout.js";
|
|
28
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Be } from "./productLayout.js";
|
|
29
|
+
import { ShuffleControl as w } from "./shuffle.js";
|
|
30
|
+
import { SHUFFLE_CONTROL_ID as Ee } from "./shuffle.js";
|
|
31
|
+
import { StrategyControl as A } from "./strategy.js";
|
|
32
|
+
import { STRATEGY_CONTROL_ID as De } from "./strategy.js";
|
|
33
|
+
import { setCurrencyAttributes as V, getBlockElement as x, isPartnerManagedBlock as W, updateProductContentInPlace as M, regenerateProductRowsWithStyles as G } from "./utils.js";
|
|
34
|
+
import { adjustProductsToSize as ve, formatProductPrice as we, getCardComposition as Ae, getCurrentLayout as Ve, getMainContainerTbody as xe, regenerateMobileProductRows as We, updatePricesInPlace as Me, updateSingleProductContent as Ge } from "./utils.js";
|
|
35
35
|
import { useDebounceFn as C } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
36
|
-
const f = "Update recommendation filters",
|
|
37
|
-
class
|
|
36
|
+
const f = "Update recommendation filters", z = "ui-elements-recommendation-block";
|
|
37
|
+
class he extends P {
|
|
38
38
|
constructor() {
|
|
39
39
|
super(...arguments);
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
i(this, "store", I());
|
|
41
|
+
i(this, "storeUnsubscription", () => {
|
|
42
42
|
});
|
|
43
43
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
44
44
|
// re-render's single apply() — one user action must cost one undo press.
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
i(this, "pendingNodeConfigWrite", null);
|
|
46
|
+
i(this, "pendingConfigFlushTimer", null);
|
|
47
47
|
// What the panel still owes the block it watches — finished outside the panel on teardown
|
|
48
48
|
// and block switch. A new generation tells debounced work queued for the old one to stand down.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
i(this, "trackedBlockId", null);
|
|
50
|
+
i(this, "fetchedConfigVersion", 0);
|
|
51
|
+
i(this, "hasUnrenderedProducts", !1);
|
|
52
|
+
i(this, "panelGeneration", 0);
|
|
53
|
+
i(this, "isPanelAlive", !0);
|
|
54
54
|
// Sub-control instances for lifecycle management
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
i(this, "algorithmControl", null);
|
|
56
|
+
i(this, "localeControl", null);
|
|
57
|
+
i(this, "currencyControl", null);
|
|
58
|
+
i(this, "productCountControl", null);
|
|
59
|
+
i(this, "productLayoutControl", null);
|
|
60
|
+
i(this, "filtersControl", null);
|
|
61
|
+
i(this, "shuffleControl", null);
|
|
62
|
+
i(this, "pricePlacementControl", null);
|
|
63
|
+
i(this, "layoutOrientationControl", null);
|
|
64
|
+
i(this, "strategyControl", null);
|
|
65
|
+
i(this, "rrsEnabled", !1);
|
|
66
66
|
/**
|
|
67
67
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
i(this, "_debouncedFetchProducts", C(async (e, t) => {
|
|
70
70
|
if (t !== this.panelGeneration)
|
|
71
71
|
return;
|
|
72
72
|
const o = this._getBlockConfigVersion(e);
|
|
73
73
|
try {
|
|
74
74
|
await (e === null ? this.store.fetchRecommendationProducts() : this.store.fetchRecommendationProductsForBlock(e)), t === this.panelGeneration && (this.fetchedConfigVersion = Math.max(this.fetchedConfigVersion, o));
|
|
75
75
|
} finally {
|
|
76
|
-
t === this.panelGeneration &&
|
|
76
|
+
t === this.panelGeneration && this._scheduleConfigFlush();
|
|
77
77
|
}
|
|
78
78
|
}, 500));
|
|
79
79
|
/**
|
|
@@ -87,7 +87,7 @@ class me extends P {
|
|
|
87
87
|
* count. The store pads products to the configured size, so in-place only
|
|
88
88
|
* fails when the size actually changed.
|
|
89
89
|
*/
|
|
90
|
-
|
|
90
|
+
i(this, "_debouncedRegenerateWithProducts", C((e) => {
|
|
91
91
|
if (e !== this.panelGeneration || !this.currentNode || !this.api)
|
|
92
92
|
return;
|
|
93
93
|
const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
|
|
@@ -106,7 +106,7 @@ class me extends P {
|
|
|
106
106
|
}, 100));
|
|
107
107
|
}
|
|
108
108
|
getId() {
|
|
109
|
-
return
|
|
109
|
+
return z;
|
|
110
110
|
}
|
|
111
111
|
get _subControls() {
|
|
112
112
|
return [
|
|
@@ -127,7 +127,7 @@ class me extends P {
|
|
|
127
127
|
return this.rrsEnabled = g().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
128
128
|
var o;
|
|
129
129
|
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
130
|
-
}), this.algorithmControl = new
|
|
130
|
+
}), this.algorithmControl = new O(), this.localeControl = new F(), this.currencyControl = new B(), this.productCountControl = new U(), this.productLayoutControl = new v(), this.filtersControl = new L(), this.shuffleControl = new w(), this.pricePlacementControl = new D(), this.layoutOrientationControl = new E(), this.strategyControl = this.rrsEnabled ? new A() : null, this._subControls.forEach((t) => {
|
|
131
131
|
t && (t.api = this.api);
|
|
132
132
|
}), `
|
|
133
133
|
<div class="recommendation-controls-container">
|
|
@@ -145,12 +145,12 @@ class me extends P {
|
|
|
145
145
|
`;
|
|
146
146
|
}
|
|
147
147
|
_showControlsForBlock(e) {
|
|
148
|
-
var
|
|
149
|
-
const t = (
|
|
148
|
+
var s;
|
|
149
|
+
const t = (s = this.getContainer()) == null ? void 0 : s.querySelector(".recommendation-controls-container");
|
|
150
150
|
if (!t)
|
|
151
151
|
return;
|
|
152
|
-
const o = this._getRecommendationIdFromNode(e) === null ? null : l.getConfig(e), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= R),
|
|
153
|
-
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block",
|
|
152
|
+
const o = this._getRecommendationIdFromNode(e) === null ? null : l.getConfig(e), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= R), r = this.rrsEnabled && !!o && !n;
|
|
153
|
+
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", r);
|
|
154
154
|
}
|
|
155
155
|
async onRender() {
|
|
156
156
|
var o;
|
|
@@ -169,8 +169,8 @@ class me extends P {
|
|
|
169
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(() => {
|
|
170
170
|
this._initializeSubControls();
|
|
171
171
|
}), this._subControls.forEach((n) => {
|
|
172
|
-
var
|
|
173
|
-
n != null && n.api && (n.currentNode = e, (
|
|
172
|
+
var r;
|
|
173
|
+
n != null && n.api && (n.currentNode = e, (r = n.onTemplateNodeUpdated) == null || r.call(n, e));
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
onDestroy() {
|
|
@@ -214,13 +214,13 @@ class me extends P {
|
|
|
214
214
|
* state was rebuilt with (SD-150347).
|
|
215
215
|
*/
|
|
216
216
|
_syncNodeConfigIfChanged(e) {
|
|
217
|
-
var
|
|
217
|
+
var r;
|
|
218
218
|
this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== e && this._flushPendingNodeConfig();
|
|
219
219
|
const t = this.store.blockStates[e];
|
|
220
220
|
if (!t)
|
|
221
221
|
return;
|
|
222
222
|
const o = JSON.stringify(l.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
|
|
223
|
-
t.syncedConfigFingerprint = o, n !== o && ((
|
|
223
|
+
t.syncedConfigFingerprint = o, n !== o && ((r = this.pendingNodeConfigWrite) == null ? void 0 : r.blockId) !== e && this._syncNodeConfigToStore();
|
|
224
224
|
}
|
|
225
225
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
226
226
|
_isPendingStrategyIdChange() {
|
|
@@ -229,26 +229,20 @@ class me extends P {
|
|
|
229
229
|
}
|
|
230
230
|
_capturePendingNodeConfigWrite() {
|
|
231
231
|
const e = this.store.currentRecommendationId, t = e === null ? void 0 : this.store.blockStates[e];
|
|
232
|
-
!this.currentNode || !this.api || e === null || !t || (this.
|
|
232
|
+
!this.currentNode || !this.api || e === null || !t || (this.pendingNodeConfigWrite = {
|
|
233
233
|
blockId: e,
|
|
234
234
|
updates: this._getNodeConfigUpdates(t.recommendationConfigs)
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
|
-
/** The pending write only when it belongs to the node this panel draws: a duplicate focuses the copy. */
|
|
238
|
-
_pendingWriteForNode() {
|
|
239
|
-
const e = this.pendingNodeConfigWrite, t = this._getRecommendationIdFromNode(this.currentNode);
|
|
240
|
-
return !e || t !== null && e.blockId !== t ? null : e;
|
|
241
|
-
}
|
|
242
237
|
_getNodeConfigUpdates(e) {
|
|
243
|
-
const { filters: t, strategy: o, strategyId: n, size:
|
|
238
|
+
const { filters: t, strategy: o, strategyId: n, size: r, nodeConfigVersion: s } = e, { partnerName: d } = g();
|
|
244
239
|
return {
|
|
245
240
|
filters: t,
|
|
246
241
|
strategy: o,
|
|
247
242
|
strategyId: n,
|
|
248
|
-
size:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
...c.value ? { partnerName: c.value } : {}
|
|
243
|
+
size: r,
|
|
244
|
+
configVersion: s,
|
|
245
|
+
...d.value ? { partnerName: d.value } : {}
|
|
252
246
|
};
|
|
253
247
|
}
|
|
254
248
|
/**
|
|
@@ -262,7 +256,7 @@ class me extends P {
|
|
|
262
256
|
* @returns Whether anything was staged
|
|
263
257
|
*/
|
|
264
258
|
_stagePendingNodeConfig(e) {
|
|
265
|
-
const t = this.
|
|
259
|
+
const t = this.pendingNodeConfigWrite;
|
|
266
260
|
return !t || !this.currentNode ? !1 : (l.stageConfig(e, this.currentNode, t.updates), !0);
|
|
267
261
|
}
|
|
268
262
|
/**
|
|
@@ -291,24 +285,14 @@ class me extends P {
|
|
|
291
285
|
!m(t, o, f) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
|
|
292
286
|
return;
|
|
293
287
|
}
|
|
294
|
-
|
|
288
|
+
b(this.currentNode, e.updates) && l.updateConfig(
|
|
295
289
|
this.api,
|
|
296
290
|
this.currentNode,
|
|
297
291
|
e.updates,
|
|
298
|
-
|
|
292
|
+
f
|
|
299
293
|
);
|
|
300
294
|
}
|
|
301
295
|
}
|
|
302
|
-
_cardsPredatePendingWrite() {
|
|
303
|
-
const e = this._pendingWriteForNode();
|
|
304
|
-
return e !== null && this.fetchedConfigVersion < this._getBlockConfigVersion(e.blockId);
|
|
305
|
-
}
|
|
306
|
-
/** The Product Ids label when the pending write moves the node's ids; the caller's default otherwise. */
|
|
307
|
-
_pendingDescription() {
|
|
308
|
-
const e = this._pendingWriteForNode();
|
|
309
|
-
if (!(!e || !this.currentNode || !B(this.currentNode, e.updates)))
|
|
310
|
-
return F;
|
|
311
|
-
}
|
|
312
296
|
_syncNodeConfigToStore() {
|
|
313
297
|
var n;
|
|
314
298
|
const e = l.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
@@ -354,8 +338,8 @@ class me extends P {
|
|
|
354
338
|
if (e !== null && this.store.markBlockInitialized(e), (await Promise.allSettled([
|
|
355
339
|
this.store.fetchRecommendationCreateData(),
|
|
356
340
|
this.store.fetchRecommendationFilters()
|
|
357
|
-
])).forEach((n,
|
|
358
|
-
n.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
341
|
+
])).forEach((n, r) => {
|
|
342
|
+
n.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, n.reason);
|
|
359
343
|
}), e !== null && this.store.currentRecommendationId !== e) {
|
|
360
344
|
this._refreshOutsidePanel(e, !0);
|
|
361
345
|
return;
|
|
@@ -386,35 +370,35 @@ class me extends P {
|
|
|
386
370
|
if (!this.currentNode || !this.api)
|
|
387
371
|
return;
|
|
388
372
|
const e = l.getConfig(this.currentNode), t = {};
|
|
389
|
-
let o = null, n = null,
|
|
373
|
+
let o = null, n = null, r = null;
|
|
390
374
|
if (e.currency.code === a.currency.code) {
|
|
391
|
-
const { currencyList:
|
|
392
|
-
|
|
393
|
-
(
|
|
394
|
-
) || (o =
|
|
375
|
+
const { currencyList: s } = this.store;
|
|
376
|
+
s.length > 0 && (s.some(
|
|
377
|
+
(u) => u.value === `price.${a.currency.code}`
|
|
378
|
+
) || (o = s[0].value.replace("price.", ""), t.currency = {
|
|
395
379
|
...a.currency,
|
|
396
380
|
code: o,
|
|
397
381
|
symbol: o
|
|
398
382
|
}));
|
|
399
383
|
}
|
|
400
384
|
if (e.strategy === a.strategy) {
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
(
|
|
404
|
-
) || (n =
|
|
385
|
+
const s = this.store.getActivePredictiveAlgorithms;
|
|
386
|
+
s.length > 0 && (s.some(
|
|
387
|
+
(u) => u.value === a.strategy
|
|
388
|
+
) || (n = s[0].value, t.strategy = n));
|
|
405
389
|
}
|
|
406
390
|
if (e.language === a.language) {
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
(
|
|
410
|
-
) || (
|
|
391
|
+
const s = this.store.getLanguages;
|
|
392
|
+
s.length > 0 && (s.some(
|
|
393
|
+
(u) => u.value === a.language
|
|
394
|
+
) || (r = s[0].value, t.language = r));
|
|
411
395
|
}
|
|
412
|
-
!o && !n && !
|
|
396
|
+
!o && !n && !r || (l.updateConfig(
|
|
413
397
|
this.api,
|
|
414
398
|
this.currentNode,
|
|
415
399
|
t,
|
|
416
400
|
"Applied smart defaults"
|
|
417
|
-
), o && t.currency &&
|
|
401
|
+
), o && t.currency && V({
|
|
418
402
|
currentNode: this.currentNode,
|
|
419
403
|
documentModifier: this.api.getDocumentModifier(),
|
|
420
404
|
currency: t.currency
|
|
@@ -431,17 +415,17 @@ class me extends P {
|
|
|
431
415
|
}
|
|
432
416
|
} : {},
|
|
433
417
|
...n ? { strategy: n } : {},
|
|
434
|
-
...
|
|
418
|
+
...r ? { language: r } : {}
|
|
435
419
|
}, { triggerRefetch: !1 }));
|
|
436
420
|
}
|
|
437
421
|
/**
|
|
438
422
|
* Reads the recommendation-id attribute from the block element within the node
|
|
439
423
|
*/
|
|
440
424
|
_getRecommendationIdFromNode(e) {
|
|
441
|
-
const t =
|
|
425
|
+
const t = x(e);
|
|
442
426
|
if (!t || !("getAttribute" in t))
|
|
443
427
|
return null;
|
|
444
|
-
const o = t.getAttribute(
|
|
428
|
+
const o = t.getAttribute(k);
|
|
445
429
|
if (!o)
|
|
446
430
|
return null;
|
|
447
431
|
const n = parseInt(o);
|
|
@@ -457,12 +441,12 @@ class me extends P {
|
|
|
457
441
|
const n = e === null ? void 0 : this.store.blockStates[e];
|
|
458
442
|
if (e === null || !n)
|
|
459
443
|
return;
|
|
460
|
-
const
|
|
461
|
-
|
|
444
|
+
const r = t !== n.configVersion;
|
|
445
|
+
r && !m(
|
|
462
446
|
e,
|
|
463
447
|
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
464
448
|
f
|
|
465
|
-
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (
|
|
449
|
+
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (r || o) && this._refreshOutsidePanel(e, r);
|
|
466
450
|
} catch (n) {
|
|
467
451
|
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
468
452
|
}
|
|
@@ -493,34 +477,20 @@ class me extends P {
|
|
|
493
477
|
_regenerateWithProducts() {
|
|
494
478
|
if (!this.currentNode || !this.api)
|
|
495
479
|
return;
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}
|
|
500
|
-
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = this._pendingDescription(), n = this._stagePendingNodeConfig(t);
|
|
501
|
-
if (z(this.currentNode)) {
|
|
502
|
-
n && (t.apply(
|
|
503
|
-
new y(o ?? "Update recommendation configuration")
|
|
504
|
-
), this._consumePendingNodeConfig());
|
|
480
|
+
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(t);
|
|
481
|
+
if (W(this.currentNode)) {
|
|
482
|
+
o && (t.apply(new N("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
505
483
|
return;
|
|
506
484
|
}
|
|
507
|
-
|
|
485
|
+
M({
|
|
508
486
|
currentNode: this.currentNode,
|
|
509
487
|
documentModifier: t,
|
|
510
|
-
products: e
|
|
511
|
-
|
|
512
|
-
onApplied: n ? () => this._consumePendingNodeConfig() : void 0
|
|
513
|
-
}) || H({
|
|
488
|
+
products: e
|
|
489
|
+
}) || G({
|
|
514
490
|
currentNode: this.currentNode,
|
|
515
491
|
documentModifier: t,
|
|
516
|
-
products: e
|
|
517
|
-
|
|
518
|
-
}) && n && this._consumePendingNodeConfig();
|
|
519
|
-
}
|
|
520
|
-
// Spent only once it landed with the cards (never when another block's write stayed unstaged):
|
|
521
|
-
// kept alive, it blocks the store resync an Undo needs and the flush writes the undone ids back.
|
|
522
|
-
_consumePendingNodeConfig() {
|
|
523
|
-
this.pendingNodeConfigWrite = null, this._clearConfigFlush();
|
|
492
|
+
products: e
|
|
493
|
+
});
|
|
524
494
|
}
|
|
525
495
|
/**
|
|
526
496
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -545,47 +515,47 @@ class me extends P {
|
|
|
545
515
|
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(p);
|
|
546
516
|
return;
|
|
547
517
|
}
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
const
|
|
551
|
-
|
|
518
|
+
const r = this._getBlockConfigVersion(n);
|
|
519
|
+
r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, this.panelGeneration));
|
|
520
|
+
const s = e.recommendationProducts, d = s !== t, u = Array.isArray(s) && s.length > 0;
|
|
521
|
+
d && u && (t = s, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
|
|
552
522
|
});
|
|
553
523
|
}
|
|
554
524
|
}
|
|
555
525
|
export {
|
|
556
|
-
|
|
557
|
-
|
|
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
|
-
|
|
526
|
+
me as ALGORITHM_CONTROL_ID,
|
|
527
|
+
O as AlgorithmControl,
|
|
528
|
+
z as CONTROL_BLOCK_ID,
|
|
529
|
+
pe as CURRENCY_CONTROL_ID,
|
|
530
|
+
B as CurrencyControl,
|
|
531
|
+
ye as FILTERS_CONTROL_ID,
|
|
532
|
+
L as FiltersControl,
|
|
533
|
+
Pe as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
534
|
+
ke as LOCALE_CONTROL_ID,
|
|
535
|
+
E as LayoutOrientationControl,
|
|
536
|
+
F as LocaleControl,
|
|
537
|
+
Se as PRICE_PLACEMENT_CONTROL_ID,
|
|
538
|
+
be as PRODUCT_COUNT_CONTROL_ID,
|
|
539
|
+
Be as PRODUCT_LAYOUT_CONTROL_ID,
|
|
540
|
+
D as PricePlacementControl,
|
|
541
|
+
U as ProductCountControl,
|
|
542
|
+
v as ProductLayoutControl,
|
|
543
|
+
he as RecommendationBlockControl,
|
|
544
|
+
Ee as SHUFFLE_CONTROL_ID,
|
|
545
|
+
De as STRATEGY_CONTROL_ID,
|
|
546
|
+
w as ShuffleControl,
|
|
547
|
+
A as StrategyControl,
|
|
548
|
+
ve as adjustProductsToSize,
|
|
549
|
+
we as formatProductPrice,
|
|
550
|
+
x as getBlockElement,
|
|
551
|
+
Ae as getCardComposition,
|
|
552
|
+
Ve as getCurrentLayout,
|
|
553
|
+
xe as getMainContainerTbody,
|
|
554
|
+
W as isPartnerManagedBlock,
|
|
555
|
+
We as regenerateMobileProductRows,
|
|
556
|
+
G as regenerateProductRowsWithStyles,
|
|
557
|
+
V as setCurrencyAttributes,
|
|
558
|
+
Me as updatePricesInPlace,
|
|
559
|
+
M as updateProductContentInPlace,
|
|
560
|
+
Ge as updateSingleProductContent
|
|
591
561
|
};
|
|
@@ -90,21 +90,21 @@ function F(t, e = {}) {
|
|
|
90
90
|
documentModifier: o,
|
|
91
91
|
products: r,
|
|
92
92
|
layout: s,
|
|
93
|
-
composition:
|
|
93
|
+
composition: l
|
|
94
94
|
} = t;
|
|
95
95
|
if (!n || !("querySelector" in n))
|
|
96
96
|
return !1;
|
|
97
|
-
const u = s ?? T(n),
|
|
98
|
-
if (u === "list" || !
|
|
97
|
+
const u = s ?? T(n), i = g.getConfig(n);
|
|
98
|
+
if (u === "list" || !i.mobileLayoutEnabled)
|
|
99
99
|
return ne({ currentNode: n, documentModifier: o });
|
|
100
|
-
const c = E(),
|
|
101
|
-
productsPerRow:
|
|
102
|
-
composition:
|
|
100
|
+
const c = E(), a = v(r, c.recommendationProducts), f = l ?? B(n, c.filterList), p = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${x(a, u, {
|
|
101
|
+
productsPerRow: i.mobileCardsInRow,
|
|
102
|
+
composition: f,
|
|
103
103
|
filterList: c.filterList,
|
|
104
|
-
priceInline: !
|
|
104
|
+
priceInline: !i.priceMovedToNextLine,
|
|
105
105
|
// Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
|
|
106
|
-
cellPadding: j(
|
|
107
|
-
rowSpacingPx:
|
|
106
|
+
cellPadding: j(i.mobileColumnSpacing),
|
|
107
|
+
rowSpacingPx: i.mobileRowSpacing,
|
|
108
108
|
...e
|
|
109
109
|
})}</table></td>`, y = n.querySelector(k);
|
|
110
110
|
return y ? (o.modifyHtml(y).setInnerHtml(p), !0) : (ie(n, o, p), !1);
|
|
@@ -118,17 +118,17 @@ function le(t, e = {}) {
|
|
|
118
118
|
documentModifier: o,
|
|
119
119
|
products: r,
|
|
120
120
|
layout: s,
|
|
121
|
-
composition:
|
|
121
|
+
composition: l
|
|
122
122
|
} = t;
|
|
123
123
|
if (!n || !("querySelector" in n))
|
|
124
124
|
return !1;
|
|
125
125
|
const u = n.querySelector(w) ?? n.querySelector(Y);
|
|
126
126
|
if (!u)
|
|
127
127
|
return !1;
|
|
128
|
-
const
|
|
129
|
-
productsPerRow:
|
|
130
|
-
composition:
|
|
131
|
-
filterList:
|
|
128
|
+
const i = E(), c = v(r, i.recommendationProducts), { cardsInRow: a } = g.getConfig(n), f = l ?? B(n, i.filterList), d = s ?? T(n), p = g.getConfig(n), y = x(c, d, {
|
|
129
|
+
productsPerRow: a,
|
|
130
|
+
composition: f,
|
|
131
|
+
filterList: i.filterList,
|
|
132
132
|
priceInline: !p.priceMovedToNextLine,
|
|
133
133
|
// Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
|
|
134
134
|
cellPadding: j(p.columnSpacing),
|
|
@@ -154,14 +154,14 @@ function ue(t, e, n) {
|
|
|
154
154
|
const r = o.getAttribute(q);
|
|
155
155
|
if (!r)
|
|
156
156
|
return !1;
|
|
157
|
-
const s = E(),
|
|
158
|
-
c &&
|
|
159
|
-
const
|
|
157
|
+
const s = E(), l = r.split(",").filter(Boolean), u = H(l, o, s.filterList), i = [], c = u.join(",") !== l.join(",");
|
|
158
|
+
c && i.push([q, u.join(",")]);
|
|
159
|
+
const a = ce(
|
|
160
160
|
o.getAttribute(h)
|
|
161
|
-
),
|
|
162
|
-
if (
|
|
161
|
+
), f = a && J(a, o, s.filterList);
|
|
162
|
+
if (a && f && f.join(",") !== a.join(",") && i.push([h, JSON.stringify(f)]), i.length === 0)
|
|
163
163
|
return !1;
|
|
164
|
-
if (
|
|
164
|
+
if (i.forEach(([d, p]) => {
|
|
165
165
|
e.modifyHtml(o).setAttribute(d, p);
|
|
166
166
|
}), c && g.hasConfig(t)) {
|
|
167
167
|
const d = {
|
|
@@ -179,21 +179,20 @@ function Re(t) {
|
|
|
179
179
|
afterRegenerate: o,
|
|
180
180
|
products: r,
|
|
181
181
|
layout: s,
|
|
182
|
-
composition:
|
|
183
|
-
skipStylePreservation: u
|
|
184
|
-
description: l
|
|
182
|
+
composition: l,
|
|
183
|
+
skipStylePreservation: u
|
|
185
184
|
} = t;
|
|
186
185
|
if (!e)
|
|
187
186
|
return !1;
|
|
188
|
-
const
|
|
187
|
+
const i = u ? {} : D(e), c = {
|
|
189
188
|
currentNode: e,
|
|
190
189
|
documentModifier: n,
|
|
191
190
|
products: r,
|
|
192
191
|
layout: s,
|
|
193
|
-
composition:
|
|
192
|
+
composition: l
|
|
194
193
|
};
|
|
195
|
-
let a = le(
|
|
196
|
-
return a = F(
|
|
194
|
+
let a = le(c, i);
|
|
195
|
+
return a = F(c, i) || a, a && (ue(e, n, l), n.apply(new C("Regenerate products with styles"))), o == null || o(), a;
|
|
197
196
|
}
|
|
198
197
|
function qe(t, e) {
|
|
199
198
|
return t.length === e ? t : t.length > e ? t.slice(0, e) : [...t, ...U(e - t.length)];
|
|
@@ -217,28 +216,28 @@ function R(t, e = "price") {
|
|
|
217
216
|
});
|
|
218
217
|
}
|
|
219
218
|
function se(t) {
|
|
220
|
-
var s,
|
|
221
|
-
const e = K(), n = ((s = t.original_price) == null ? void 0 : s[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, o = ((
|
|
219
|
+
var s, l;
|
|
220
|
+
const e = K(), n = ((s = t.original_price) == null ? void 0 : s[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, o = ((l = t.price) == null ? void 0 : l[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, r = n > 0 ? Math.round((n - o) / n * 100) : 0;
|
|
222
221
|
return r > 0 ? `-${r}%` : "0%";
|
|
223
222
|
}
|
|
224
223
|
function V(t) {
|
|
225
|
-
const { documentModifier: e, product: n, priceEl: o, oldPriceEl: r, omnibusPriceEl: s, omnibusDiscountEl:
|
|
224
|
+
const { documentModifier: e, product: n, priceEl: o, oldPriceEl: r, omnibusPriceEl: s, omnibusDiscountEl: l } = t;
|
|
226
225
|
let u = !1;
|
|
227
226
|
if (o && "querySelector" in o) {
|
|
228
|
-
const
|
|
229
|
-
S(e,
|
|
227
|
+
const i = o.querySelector("strong") ?? o.querySelector("p"), c = R(n, "price");
|
|
228
|
+
S(e, i ?? null, c) && (u = !0);
|
|
230
229
|
}
|
|
231
230
|
if (r && "querySelector" in r) {
|
|
232
|
-
const
|
|
233
|
-
S(e,
|
|
231
|
+
const i = r.querySelector("strong") ?? r.querySelector("p"), c = R(n, "original_price");
|
|
232
|
+
S(e, i ?? null, c) && (u = !0), A(e, r, "data-same-price", String(Z(n))) && (u = !0);
|
|
234
233
|
}
|
|
235
234
|
if (s && "querySelector" in s) {
|
|
236
|
-
const
|
|
237
|
-
S(e,
|
|
235
|
+
const i = s.querySelector(".omnibus-price-value") ?? null, c = R(n, "original_price");
|
|
236
|
+
S(e, i, c) && (u = !0);
|
|
238
237
|
}
|
|
239
|
-
if (
|
|
240
|
-
const
|
|
241
|
-
S(e,
|
|
238
|
+
if (l && "querySelector" in l) {
|
|
239
|
+
const i = l.querySelector(".omnibus-discount-value") ?? null, c = se(n);
|
|
240
|
+
S(e, i, c) && (u = !0);
|
|
242
241
|
}
|
|
243
242
|
return u;
|
|
244
243
|
}
|
|
@@ -249,37 +248,37 @@ function ae(t) {
|
|
|
249
248
|
imageEl: o,
|
|
250
249
|
nameEl: r,
|
|
251
250
|
priceEl: s,
|
|
252
|
-
oldPriceEl:
|
|
251
|
+
oldPriceEl: l,
|
|
253
252
|
omnibusPriceEl: u,
|
|
254
|
-
omnibusDiscountEl:
|
|
253
|
+
omnibusDiscountEl: i,
|
|
255
254
|
buttonEl: c
|
|
256
255
|
} = t;
|
|
257
|
-
let
|
|
256
|
+
let a = !1;
|
|
258
257
|
if (o && "querySelector" in o) {
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
261
|
-
const p = A(e,
|
|
262
|
-
|
|
258
|
+
const f = o.querySelector("img");
|
|
259
|
+
if (f) {
|
|
260
|
+
const p = A(e, f, "src", Q(n.image_url)), y = A(e, f, "alt", n.name);
|
|
261
|
+
a = a || p || y;
|
|
263
262
|
}
|
|
264
263
|
const d = o.querySelector("a");
|
|
265
|
-
d && A(e, d, "href", n.url) && (
|
|
264
|
+
d && A(e, d, "href", n.url) && (a = !0);
|
|
266
265
|
}
|
|
267
266
|
if (r && "querySelector" in r) {
|
|
268
|
-
const
|
|
269
|
-
S(e,
|
|
267
|
+
const f = r.querySelector("strong") ?? r.querySelector("p");
|
|
268
|
+
S(e, f ?? null, n.name) && (a = !0);
|
|
270
269
|
}
|
|
271
270
|
if (V({
|
|
272
271
|
documentModifier: e,
|
|
273
272
|
product: n,
|
|
274
273
|
priceEl: s,
|
|
275
|
-
oldPriceEl:
|
|
274
|
+
oldPriceEl: l,
|
|
276
275
|
omnibusPriceEl: u,
|
|
277
|
-
omnibusDiscountEl:
|
|
278
|
-
}) && (
|
|
279
|
-
const
|
|
280
|
-
|
|
276
|
+
omnibusDiscountEl: i
|
|
277
|
+
}) && (a = !0), c && "querySelector" in c) {
|
|
278
|
+
const f = c.querySelector("a.es-button") || c.querySelector("a");
|
|
279
|
+
f && A(e, f, "href", n.url) && (a = !0);
|
|
281
280
|
}
|
|
282
|
-
return
|
|
281
|
+
return a;
|
|
283
282
|
}
|
|
284
283
|
function G(t) {
|
|
285
284
|
return "querySelector" in t ? t.querySelector(w) ?? t : t;
|
|
@@ -303,26 +302,26 @@ function de(t, e, n) {
|
|
|
303
302
|
if (o.length === 0)
|
|
304
303
|
return !1;
|
|
305
304
|
const r = /* @__PURE__ */ new Map();
|
|
306
|
-
o.forEach((
|
|
307
|
-
if (!("getAttribute" in
|
|
305
|
+
o.forEach((l) => {
|
|
306
|
+
if (!("getAttribute" in l))
|
|
308
307
|
return;
|
|
309
|
-
const u =
|
|
308
|
+
const u = l.getAttribute(z);
|
|
310
309
|
if (!u)
|
|
311
310
|
return;
|
|
312
|
-
const
|
|
313
|
-
|
|
311
|
+
const i = r.get(u) ?? [];
|
|
312
|
+
i.push(l), r.set(u, i);
|
|
314
313
|
});
|
|
315
314
|
let s = !1;
|
|
316
|
-
return r.forEach((
|
|
317
|
-
const
|
|
318
|
-
|
|
315
|
+
return r.forEach((l, u) => {
|
|
316
|
+
const i = Math.min(l.length, n.length);
|
|
317
|
+
l.slice(0, i).forEach((c, a) => {
|
|
319
318
|
if (!("querySelector" in c))
|
|
320
319
|
return;
|
|
321
|
-
const
|
|
322
|
-
if (
|
|
320
|
+
const f = fe(u, n[a]);
|
|
321
|
+
if (f === null)
|
|
323
322
|
return;
|
|
324
323
|
const d = c.querySelector("p") ?? null;
|
|
325
|
-
S(e, d,
|
|
324
|
+
S(e, d, f) && (s = !0);
|
|
326
325
|
});
|
|
327
326
|
}), s;
|
|
328
327
|
}
|
|
@@ -335,55 +334,55 @@ function _(t, e, n) {
|
|
|
335
334
|
`[esd-extension-block-id="${m.NAME}"]`
|
|
336
335
|
), s = t.querySelectorAll(
|
|
337
336
|
`[esd-extension-block-id="${m.PRICE}"]`
|
|
338
|
-
),
|
|
337
|
+
), l = t.querySelectorAll(
|
|
339
338
|
`[esd-extension-block-id="${m.OLD_PRICE}"]`
|
|
340
339
|
), u = t.querySelectorAll(
|
|
341
340
|
`[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
|
|
342
|
-
),
|
|
341
|
+
), i = t.querySelectorAll(
|
|
343
342
|
`[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
|
|
344
343
|
), c = t.querySelectorAll(
|
|
345
344
|
`[esd-extension-block-id="${m.BUTTON}"]`
|
|
346
|
-
),
|
|
347
|
-
let
|
|
348
|
-
for (let d = 0; d <
|
|
345
|
+
), a = Math.min(o.length, n.length);
|
|
346
|
+
let f = !1;
|
|
347
|
+
for (let d = 0; d < a; d++) {
|
|
349
348
|
const p = ae({
|
|
350
349
|
documentModifier: e,
|
|
351
350
|
product: n[d],
|
|
352
351
|
imageEl: o[d] ?? null,
|
|
353
352
|
nameEl: r[d] ?? null,
|
|
354
353
|
priceEl: s[d] ?? null,
|
|
355
|
-
oldPriceEl:
|
|
354
|
+
oldPriceEl: l[d] ?? null,
|
|
356
355
|
omnibusPriceEl: u[d] ?? null,
|
|
357
|
-
omnibusDiscountEl:
|
|
356
|
+
omnibusDiscountEl: i[d] ?? null,
|
|
358
357
|
buttonEl: c[d] ?? null
|
|
359
358
|
});
|
|
360
|
-
|
|
359
|
+
f = f || p;
|
|
361
360
|
}
|
|
362
|
-
return de(t, e, n) && (
|
|
361
|
+
return de(t, e, n) && (f = !0), f;
|
|
363
362
|
}
|
|
364
363
|
function he(t) {
|
|
365
|
-
const { currentNode: e, documentModifier: n, products: o, onApplied: r
|
|
364
|
+
const { currentNode: e, documentModifier: n, products: o, onApplied: r } = t;
|
|
366
365
|
if (!e || !("querySelectorAll" in e))
|
|
367
366
|
return !1;
|
|
368
|
-
const
|
|
369
|
-
if (!("querySelectorAll" in
|
|
367
|
+
const s = G(e);
|
|
368
|
+
if (!("querySelectorAll" in s) || s.querySelectorAll(
|
|
370
369
|
`[esd-extension-block-id="${m.IMAGE}"]`
|
|
371
370
|
).length !== o.length)
|
|
372
371
|
return !1;
|
|
373
|
-
let
|
|
374
|
-
const
|
|
375
|
-
if (
|
|
372
|
+
let u = _(s, n, o);
|
|
373
|
+
const i = T(e), c = g.getConfig(e);
|
|
374
|
+
if (i !== "list" && c.mobileLayoutEnabled && "querySelector" in e) {
|
|
376
375
|
const a = e.querySelector(L);
|
|
377
376
|
if (a) {
|
|
378
|
-
const
|
|
377
|
+
const f = _(
|
|
379
378
|
a,
|
|
380
379
|
n,
|
|
381
380
|
o
|
|
382
381
|
);
|
|
383
|
-
|
|
382
|
+
u = u || f;
|
|
384
383
|
}
|
|
385
384
|
}
|
|
386
|
-
return
|
|
385
|
+
return u && (n.apply(new C("Updated product content in-place")), r == null || r()), !0;
|
|
387
386
|
}
|
|
388
387
|
function N(t, e, n) {
|
|
389
388
|
if (!("querySelectorAll" in t))
|
|
@@ -394,10 +393,10 @@ function N(t, e, n) {
|
|
|
394
393
|
`[esd-extension-block-id="${m.OLD_PRICE}"]`
|
|
395
394
|
), s = t.querySelectorAll(
|
|
396
395
|
`[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
|
|
397
|
-
),
|
|
396
|
+
), l = t.querySelectorAll(
|
|
398
397
|
`[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
|
|
399
398
|
), u = Math.min(o.length, n.length);
|
|
400
|
-
let
|
|
399
|
+
let i = !1;
|
|
401
400
|
for (let c = 0; c < u; c++)
|
|
402
401
|
V({
|
|
403
402
|
documentModifier: e,
|
|
@@ -405,9 +404,9 @@ function N(t, e, n) {
|
|
|
405
404
|
priceEl: o[c] ?? null,
|
|
406
405
|
oldPriceEl: r[c] ?? null,
|
|
407
406
|
omnibusPriceEl: s[c] ?? null,
|
|
408
|
-
omnibusDiscountEl:
|
|
409
|
-
}) && (
|
|
410
|
-
return
|
|
407
|
+
omnibusDiscountEl: l[c] ?? null
|
|
408
|
+
}) && (i = !0);
|
|
409
|
+
return i;
|
|
411
410
|
}
|
|
412
411
|
function Me(t) {
|
|
413
412
|
const { currentNode: e, documentModifier: n } = t;
|
|
@@ -419,25 +418,25 @@ function Me(t) {
|
|
|
419
418
|
if (r.length === 0)
|
|
420
419
|
return !1;
|
|
421
420
|
const s = G(e);
|
|
422
|
-
let
|
|
423
|
-
const u = T(e),
|
|
424
|
-
if (u !== "list" &&
|
|
421
|
+
let l = N(s, n, r);
|
|
422
|
+
const u = T(e), i = g.getConfig(e);
|
|
423
|
+
if (u !== "list" && i.mobileLayoutEnabled && "querySelector" in e) {
|
|
425
424
|
const c = e.querySelector(L);
|
|
426
425
|
if (c) {
|
|
427
|
-
const
|
|
428
|
-
|
|
426
|
+
const a = N(c, n, r);
|
|
427
|
+
l = l || a;
|
|
429
428
|
}
|
|
430
429
|
}
|
|
431
|
-
return
|
|
430
|
+
return l && n.apply(new C("Updated price formatting in-place")), l;
|
|
432
431
|
}
|
|
433
432
|
function Ie(t) {
|
|
434
433
|
const { currentNode: e, documentModifier: n, currency: o } = t, r = P(e);
|
|
435
434
|
if (!r)
|
|
436
435
|
return;
|
|
437
|
-
const s = o.alignment === "before" ? "0" : "1",
|
|
438
|
-
n.modifyHtml(r).setAttribute(u,
|
|
436
|
+
const s = o.alignment === "before" ? "0" : "1", l = (u, i) => {
|
|
437
|
+
n.modifyHtml(r).setAttribute(u, i);
|
|
439
438
|
};
|
|
440
|
-
|
|
439
|
+
l(b.CURRENCY, o.code), l(b.SYMBOL, o.symbol), l(b.ALIGNMENT, s), l(b.THOUSAND_SEPARATOR, o.thousandSeparator), l(b.DECIMAL_SEPARATOR, o.decimalSeparator), l(b.DECIMAL_COUNT, o.decimalCount.toString()), n.apply(new C("Update currency attributes"));
|
|
441
440
|
}
|
|
442
441
|
export {
|
|
443
442
|
qe as adjustProductsToSize,
|
|
@@ -1,85 +1,68 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
3
|
-
import { isPartnerManagedBlock as
|
|
1
|
+
import { ModificationDescription as g } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { RECOMMENDATION_ID_ATTR as l } from "../constants/selectors.js";
|
|
3
|
+
import { isPartnerManagedBlock as m, updateProductContentInPlace as d, regenerateProductRowsWithStyles as C } from "../controls/main/utils.js";
|
|
4
4
|
import { RecommendationConfigService as c } from "../services/configService.js";
|
|
5
|
-
import { useRecommendationExtensionStore as
|
|
5
|
+
import { useRecommendationExtensionStore as y } from "../store/recommendation.js";
|
|
6
6
|
let r = null;
|
|
7
|
-
function
|
|
8
|
-
r =
|
|
7
|
+
function M(n) {
|
|
8
|
+
r = n;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
return !
|
|
10
|
+
function a(n) {
|
|
11
|
+
const e = r == null ? void 0 : r.getDocumentRootHtmlNode();
|
|
12
|
+
return !e || !("querySelector" in e) ? null : e.querySelector(`[${l}="${n}"]`) ?? null;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const o = c.getConfig(
|
|
16
|
-
return Object.keys(
|
|
14
|
+
function N(n, e) {
|
|
15
|
+
const o = c.getConfig(n);
|
|
16
|
+
return Object.keys(e).some((t) => JSON.stringify(o[t]) !== JSON.stringify(e[t]));
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
const o = c.getConfig(
|
|
20
|
-
return ["filters", "strategy", "strategyId", "size"
|
|
18
|
+
function S(n, e) {
|
|
19
|
+
const o = c.getConfig(n);
|
|
20
|
+
return ["filters", "strategy", "strategyId", "size"].some((t) => t in e && JSON.stringify(o[t]) !== JSON.stringify(e[t]));
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return !1;
|
|
26
|
-
const o = c.getConfig(t);
|
|
27
|
-
return JSON.stringify(o.productIds) !== JSON.stringify(n.productIds);
|
|
28
|
-
}
|
|
29
|
-
function h(t, n, o) {
|
|
30
|
-
return S(t, n) ? p : o;
|
|
31
|
-
}
|
|
32
|
-
function k(t, n, o) {
|
|
33
|
-
const e = C(t);
|
|
34
|
-
if (!r || !e)
|
|
35
|
-
return !1;
|
|
36
|
-
if (R(e, n)) {
|
|
37
|
-
const i = h(e, n, o);
|
|
38
|
-
c.updateConfig(r, e, n, i);
|
|
39
|
-
}
|
|
40
|
-
return !0;
|
|
22
|
+
function P(n, e, o) {
|
|
23
|
+
const t = a(n);
|
|
24
|
+
return !r || !t ? !1 : (S(t, e) && c.updateConfig(r, t, e, o), !0);
|
|
41
25
|
}
|
|
42
|
-
function
|
|
43
|
-
const o =
|
|
44
|
-
if (
|
|
45
|
-
|
|
26
|
+
function p(n, e) {
|
|
27
|
+
const o = y(), t = o.currentRecommendationId;
|
|
28
|
+
if (t === n || !o.blockStates[n]) {
|
|
29
|
+
e();
|
|
46
30
|
return;
|
|
47
31
|
}
|
|
48
|
-
o.setCurrentBlock(
|
|
32
|
+
o.setCurrentBlock(n);
|
|
49
33
|
try {
|
|
50
|
-
|
|
34
|
+
e();
|
|
51
35
|
} finally {
|
|
52
|
-
o.$patch({ currentRecommendationId:
|
|
36
|
+
o.$patch({ currentRecommendationId: t });
|
|
53
37
|
}
|
|
54
38
|
}
|
|
55
|
-
function
|
|
56
|
-
const
|
|
57
|
-
return !
|
|
39
|
+
function I(n) {
|
|
40
|
+
const e = r == null ? void 0 : r.getDocumentRootHtmlNode();
|
|
41
|
+
return !e || !("querySelectorAll" in e) ? [] : e.querySelectorAll(`[${l}="${n}"]`).map((o) => c.getConfig(o));
|
|
58
42
|
}
|
|
59
|
-
function
|
|
60
|
-
const i =
|
|
43
|
+
function $(n, e, o, t) {
|
|
44
|
+
const i = a(n);
|
|
61
45
|
if (!r || !i)
|
|
62
46
|
return !1;
|
|
63
|
-
const f = r.getDocumentModifier(),
|
|
64
|
-
if (c.stageConfig(f, i,
|
|
65
|
-
return
|
|
47
|
+
const f = r.getDocumentModifier(), s = N(i, e);
|
|
48
|
+
if (c.stageConfig(f, i, e), m(i))
|
|
49
|
+
return s && f.apply(new g(t)), !0;
|
|
66
50
|
let u = !1;
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
51
|
+
return p(n, () => {
|
|
52
|
+
d({
|
|
53
|
+
currentNode: i,
|
|
54
|
+
documentModifier: f,
|
|
55
|
+
products: o,
|
|
70
56
|
onApplied: () => {
|
|
71
57
|
u = !0;
|
|
72
58
|
}
|
|
73
|
-
}) || (u =
|
|
74
|
-
}), !u &&
|
|
59
|
+
}) || (u = C({ currentNode: i, documentModifier: f, products: o }));
|
|
60
|
+
}), !u && s && f.apply(new g(t)), !0;
|
|
75
61
|
}
|
|
76
62
|
export {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
q as readBlockNodeConfigs,
|
|
83
|
-
$ as registerNodeConfigWriter,
|
|
84
|
-
k as writeBlockConfigOutsidePanel
|
|
63
|
+
$ as commitBlockChangeOutsidePanel,
|
|
64
|
+
S as hasEditedConfigChange,
|
|
65
|
+
I as readBlockNodeConfigs,
|
|
66
|
+
M as registerNodeConfigWriter,
|
|
67
|
+
P as writeBlockConfigOutsidePanel
|
|
85
68
|
};
|
|
@@ -78,8 +78,6 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
78
78
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
79
79
|
private _isPendingStrategyIdChange;
|
|
80
80
|
private _capturePendingNodeConfigWrite;
|
|
81
|
-
/** The pending write only when it belongs to the node this panel draws: a duplicate focuses the copy. */
|
|
82
|
-
private _pendingWriteForNode;
|
|
83
81
|
private _getNodeConfigUpdates;
|
|
84
82
|
/**
|
|
85
83
|
* Accumulates the pending write into `documentModifier` without applying, so the
|
|
@@ -105,9 +103,6 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
105
103
|
* the intervening re-render staled, and saveConfig swallows that failure.
|
|
106
104
|
*/
|
|
107
105
|
private _flushPendingNodeConfig;
|
|
108
|
-
private _cardsPredatePendingWrite;
|
|
109
|
-
/** The Product Ids label when the pending write moves the node's ids; the caller's default otherwise. */
|
|
110
|
-
private _pendingDescription;
|
|
111
106
|
private _syncNodeConfigToStore;
|
|
112
107
|
/**
|
|
113
108
|
* Fetches initial data for a block in three phases:
|
|
@@ -161,7 +156,6 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
161
156
|
private _debouncedRegenerateWithProducts;
|
|
162
157
|
/** Draws the current block's products into this panel's node. */
|
|
163
158
|
private _regenerateWithProducts;
|
|
164
|
-
private _consumePendingNodeConfig;
|
|
165
159
|
/**
|
|
166
160
|
* Listen to store changes that require product refresh or regeneration.
|
|
167
161
|
*
|
|
@@ -88,8 +88,6 @@ export interface RegenerateWithStylesOptions extends Omit<RegenerateProductRowsO
|
|
|
88
88
|
products?: RecommendationProduct[];
|
|
89
89
|
/** Optional: pass layout directly to avoid stale DOM reads after setAttribute */
|
|
90
90
|
layout?: Orientation;
|
|
91
|
-
/** Undo label for the apply; the caller sets it when a config change rides in the same batch */
|
|
92
|
-
description?: string;
|
|
93
91
|
}
|
|
94
92
|
/**
|
|
95
93
|
* Regenerates product rows while preserving user-applied styles, in a SINGLE commit.
|
|
@@ -158,8 +156,6 @@ export interface UpdateProductContentInPlaceOptions {
|
|
|
158
156
|
* leaves anything a caller staged into the same batch unwritten unless it applies itself.
|
|
159
157
|
*/
|
|
160
158
|
onApplied?: () => void;
|
|
161
|
-
/** Undo label for the apply; the caller sets it when a config change rides in the same batch */
|
|
162
|
-
description?: string;
|
|
163
159
|
}
|
|
164
160
|
/**
|
|
165
161
|
* Updates product content in-place without regenerating HTML structure.
|
|
@@ -14,10 +14,6 @@ interface ConfigWriterApi {
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function registerNodeConfigWriter(api: ConfigWriterApi): void;
|
|
16
16
|
export declare function hasEditedConfigChange(node: ImmutableHtmlNode, updates: PartialNodeConfig): boolean;
|
|
17
|
-
export declare const PRODUCT_IDS_DESCRIPTION = "Updated product IDs";
|
|
18
|
-
/** A deferred Product Ids edit keeps its own undo label wherever the write finally lands. */
|
|
19
|
-
export declare function isProductIdsChange(node: ImmutableHtmlNode, updates: PartialNodeConfig): boolean;
|
|
20
|
-
export declare function pickConfigDescription(node: ImmutableHtmlNode, updates: PartialNodeConfig, fallback: string): string;
|
|
21
17
|
/**
|
|
22
18
|
* Writes a config change to the block's node on its own, found by id — never through a
|
|
23
19
|
* panel-held node, which may already belong to the block the user switched to.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.21.0-beta.
|
|
3
|
+
"version": "3.21.0-beta.647fb59",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|