@useinsider/guido 3.22.0-beta.d4e1d48 → 3.22.0-beta.e1b5da2
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/organisms/unsubscribe/UnsubscribePageSelection.vue.js +11 -11
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +9 -9
- 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/Recommendation/block.js +33 -24
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +20 -19
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +148 -163
- 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/guido.css +1 -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/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -8
- 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/stores/unsubscribe.d.ts +0 -10
- package/dist/stores/unsubscribe.js +29 -33
- package/package.json +1 -1
|
@@ -11,10 +11,11 @@ import { useRecommendationExtensionStore as ft } from "../../store/recommendatio
|
|
|
11
11
|
import { ATTRIBUTE_CELL_CLASS as bt, gridElementRenderer as yt, DEFAULT_CELL_PADDING as Tt, buildFillerCell as Ct } from "../../templates/grid/elementRenderer.js";
|
|
12
12
|
import { listElementRenderer as St } from "../../templates/list/elementRenderer.js";
|
|
13
13
|
import { buildTitleRows as At, DEFAULT_TITLE_PARAGRAPH as It, DEFAULT_TITLE_TEXT as $t } from "../../templates/titleRows.js";
|
|
14
|
-
import {
|
|
15
|
-
import { normalizeCompositionKeys as
|
|
16
|
-
import { getTableDisplayValue as
|
|
17
|
-
import { isPartnerManagedBlock as
|
|
14
|
+
import { toDisplayName as vt, toDisplayableAttributeValue as Nt, buildElementRenderer as J } from "../../templates/utils.js";
|
|
15
|
+
import { normalizeCompositionKeys as Et, normalizeCustomAttrValues as Rt, compositionKeyToProductAttr as k, resolveRowVisibilityKeys as Lt, filterToProductAttrValue as C, findAttributeRow as Ot, rewriteLegacyRowKeyHtml as Q, bareAttributeName as H, isDefaultProductAttr as Dt, productAttrToCompositionKey as M } from "../../utils/compositionKeys.js";
|
|
16
|
+
import { getTableDisplayValue as Ht } from "../../utils/tagName.js";
|
|
17
|
+
import { isPartnerManagedBlock as Pt, regenerateProductRowsWithStyles as wt, getMainContainerTbody as Bt, getCurrentLayout as kt } from "../main/utils.js";
|
|
18
|
+
import { resolveInlinePriceOrder as Mt } from "../../utils/inlinePriceOrder.js";
|
|
18
19
|
const Ut = "ui-elements-recommendation-card-composition", U = ".product-card-wrapper > tbody", Z = ".product-info-cell > table > tbody", tt = {
|
|
19
20
|
ADD_ATTRIBUTE: "addAttribute"
|
|
20
21
|
}, b = 5, P = "reorderIcon_", qt = '<svg width="14" height="10" viewBox="0 0 14 10" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2.5" r="1.2"/><circle cx="7" cy="2.5" r="1.2"/><circle cx="12" cy="2.5" r="1.2"/><circle cx="2" cy="7.5" r="1.2"/><circle cx="7" cy="7.5" r="1.2"/><circle cx="12" cy="7.5" r="1.2"/></svg>', m = [
|
|
@@ -26,7 +27,7 @@ const Ut = "ui-elements-recommendation-card-composition", U = ".product-card-wra
|
|
|
26
27
|
{ key: pt, label: "Omnibus Discount" },
|
|
27
28
|
{ key: F, label: "Product Button" }
|
|
28
29
|
], L = { key: $, label: "Title" }, Ft = new Set(m.map((_) => _.key)), A = "customAttr_", w = "deleteAttr_";
|
|
29
|
-
class
|
|
30
|
+
class oe extends ut {
|
|
30
31
|
constructor() {
|
|
31
32
|
super(...arguments);
|
|
32
33
|
v(this, "store", ft());
|
|
@@ -155,7 +156,7 @@ class se extends ut {
|
|
|
155
156
|
const t = (r = this.getContainer()) == null ? void 0 : r.querySelector("[data-card-composition-control]");
|
|
156
157
|
if (!t)
|
|
157
158
|
return;
|
|
158
|
-
const e =
|
|
159
|
+
const e = Pt(this.currentNode);
|
|
159
160
|
t.style.pointerEvents = e ? "none" : "", t.style.opacity = e ? "0.5" : "";
|
|
160
161
|
}
|
|
161
162
|
onTemplateNodeUpdated(t) {
|
|
@@ -198,7 +199,7 @@ class se extends ut {
|
|
|
198
199
|
}
|
|
199
200
|
/** Upgrades legacy bare-name custom keys to the canonical form. (SD-147101) */
|
|
200
201
|
_normalizeComposition(t) {
|
|
201
|
-
return
|
|
202
|
+
return Et(t, this.currentNode, this.store.filterList);
|
|
202
203
|
}
|
|
203
204
|
_readCustomAttributesFromNode() {
|
|
204
205
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
@@ -206,7 +207,7 @@ class se extends ut {
|
|
|
206
207
|
const t = this.currentNode.getAttribute(W);
|
|
207
208
|
if (t)
|
|
208
209
|
try {
|
|
209
|
-
return
|
|
210
|
+
return Rt(
|
|
210
211
|
JSON.parse(t).map((e) => String(e)),
|
|
211
212
|
this.currentNode,
|
|
212
213
|
this.store.filterList
|
|
@@ -241,7 +242,7 @@ class se extends ut {
|
|
|
241
242
|
if (!("getAttribute" in r))
|
|
242
243
|
return;
|
|
243
244
|
const i = r.getAttribute(D);
|
|
244
|
-
i !== null &&
|
|
245
|
+
i !== null && Lt(r).forEach((s) => {
|
|
245
246
|
e[s] = this._parseVisibilityValue(i);
|
|
246
247
|
});
|
|
247
248
|
}), e;
|
|
@@ -276,7 +277,7 @@ class se extends ut {
|
|
|
276
277
|
if (!(i.dataset.inlinePrices !== String(s)) && this._tryReorderInPlace(i, t))
|
|
277
278
|
return !1;
|
|
278
279
|
i.dataset.inlinePrices = String(s);
|
|
279
|
-
const n = new Set(e), l =
|
|
280
|
+
const n = new Set(e), l = Mt(t);
|
|
280
281
|
let a = 0, d = 0;
|
|
281
282
|
const c = t.map((u) => {
|
|
282
283
|
if (s && (u === p || u === I))
|
|
@@ -653,7 +654,7 @@ class se extends ut {
|
|
|
653
654
|
try {
|
|
654
655
|
this._updateBothAttributes(t, e);
|
|
655
656
|
const r = this._isInlinePrices();
|
|
656
|
-
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode &&
|
|
657
|
+
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode && wt({
|
|
657
658
|
currentNode: this.currentNode,
|
|
658
659
|
documentModifier: this.api.getDocumentModifier()
|
|
659
660
|
});
|
|
@@ -671,7 +672,7 @@ class se extends ut {
|
|
|
671
672
|
* DOM converge on the next composition change without writing on open.
|
|
672
673
|
*/
|
|
673
674
|
_getExistingRowHtml(t, e) {
|
|
674
|
-
const r =
|
|
675
|
+
const r = Ot(t, e);
|
|
675
676
|
if (r && "getOuterHTML" in r)
|
|
676
677
|
return Q(r.getOuterHTML(), e);
|
|
677
678
|
const i = t.querySelector(
|
|
@@ -815,7 +816,7 @@ class se extends ut {
|
|
|
815
816
|
return;
|
|
816
817
|
const o = e ? "1" : "0", n = e ? this.api.translate("visible") : this.api.translate("hidden"), l = `${this.api.translate("Set visibility")}: ${t} → ${n}`, a = this.api.getDocumentModifier();
|
|
817
818
|
s.forEach((c) => {
|
|
818
|
-
const u =
|
|
819
|
+
const u = Ht(c), h = e ? u : "none";
|
|
819
820
|
a.modifyHtml(c).setStyle("display", h).setAttribute(D, o);
|
|
820
821
|
});
|
|
821
822
|
const d = {
|
|
@@ -877,7 +878,7 @@ class se extends ut {
|
|
|
877
878
|
return "children" in t && t.children().some((e) => "hasClass" in e && e.hasClass(_t));
|
|
878
879
|
}
|
|
879
880
|
_findTitleContainerBody() {
|
|
880
|
-
return (this.currentNode ?
|
|
881
|
+
return (this.currentNode ? Bt(this.currentNode) : null) ?? void 0;
|
|
881
882
|
}
|
|
882
883
|
_readInnerHtml(t) {
|
|
883
884
|
return "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : null;
|
|
@@ -904,7 +905,7 @@ class se extends ut {
|
|
|
904
905
|
return -1;
|
|
905
906
|
}
|
|
906
907
|
_getCurrentLayout() {
|
|
907
|
-
return this.store.recommendationConfigs.orientation ||
|
|
908
|
+
return this.store.recommendationConfigs.orientation || kt(this.currentNode);
|
|
908
909
|
}
|
|
909
910
|
/**
|
|
910
911
|
* Extracts background color properties from existing card elements.
|
|
@@ -1000,7 +1001,7 @@ class se extends ut {
|
|
|
1000
1001
|
*/
|
|
1001
1002
|
_getDisplayNameForAttribute(t) {
|
|
1002
1003
|
const e = Object.values(this.store.filterList).find((r) => C(r) === t);
|
|
1003
|
-
return e ? e.displayName :
|
|
1004
|
+
return e ? e.displayName : vt(H(t));
|
|
1004
1005
|
}
|
|
1005
1006
|
/**
|
|
1006
1007
|
* Resolves the display content for a custom attribute cell.
|
|
@@ -1008,8 +1009,8 @@ class se extends ut {
|
|
|
1008
1009
|
*/
|
|
1009
1010
|
_resolveAttributeContent(t, e, r) {
|
|
1010
1011
|
var l;
|
|
1011
|
-
const s = this.store.recommendationProducts[r], o = H(t), n =
|
|
1012
|
-
return
|
|
1012
|
+
const s = this.store.recommendationProducts[r], o = H(t), n = Dt(t) ? s == null ? void 0 : s[o] : (l = s == null ? void 0 : s.product_attributes) == null ? void 0 : l[o];
|
|
1013
|
+
return Nt(n) ?? e;
|
|
1013
1014
|
}
|
|
1014
1015
|
_getGridCellHtml(t, e, r, i = "", s = "", o = "") {
|
|
1015
1016
|
const n = M(t), l = H(t), a = J(yt, [n], this.store.filterList), d = {
|
|
@@ -1032,5 +1033,5 @@ class se extends ut {
|
|
|
1032
1033
|
}
|
|
1033
1034
|
export {
|
|
1034
1035
|
Ut as COMPOSITION_CONTROL_BLOCK_ID,
|
|
1035
|
-
|
|
1036
|
+
oe as RecommendationCardCompositionControl
|
|
1036
1037
|
};
|
|
@@ -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, c, e) => c in u ? y(u, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[c] = e;
|
|
3
|
+
var r = (u, c, e) => P(u, typeof c != "symbol" ? c + "" : c, 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 k, DEFAULT_NODE_CONFIG as m } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RECOMMENDATION_ID_ATTR as S } from "../../constants/selectors.js";
|
|
9
|
+
import { RecommendationConfigService as d } 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 C } from "../../utils/legacyStrategyMap.js";
|
|
13
|
+
import { registerNodeConfigWriter as b, writeBlockConfigOutsidePanel as p, hasEditedConfigChange as B, pickConfigDescription as F, isProductIdsChange as D, PRODUCT_IDS_DESCRIPTION as L } 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 Se } from "./filters.js";
|
|
20
|
+
import { LayoutOrientationControl as w } from "./layoutOrientation.js";
|
|
21
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as Oe } 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 De } 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 Ae } 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 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, getCurrentLayout as $e, 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 A(), 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 w(), 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,16 +146,16 @@ 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 : d.getConfig(e), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= k), i = this.rrsEnabled && !!o && !n;
|
|
153
154
|
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", i);
|
|
154
155
|
}
|
|
155
156
|
async onRender() {
|
|
156
157
|
var o;
|
|
157
|
-
|
|
158
|
+
b(this.api);
|
|
158
159
|
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
159
160
|
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
161
|
this._initializeSubControls();
|
|
@@ -219,13 +220,13 @@ class me extends P {
|
|
|
219
220
|
const t = this.store.blockStates[e];
|
|
220
221
|
if (!t)
|
|
221
222
|
return;
|
|
222
|
-
const o = JSON.stringify(
|
|
223
|
+
const o = JSON.stringify(d.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
|
|
223
224
|
t.syncedConfigFingerprint = o, n !== o && ((i = this.pendingNodeConfigWrite) == null ? void 0 : i.blockId) !== e && this._syncNodeConfigToStore();
|
|
224
225
|
}
|
|
225
226
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
226
227
|
_isPendingStrategyIdChange() {
|
|
227
228
|
const e = this.pendingNodeConfigWrite;
|
|
228
|
-
return e ?
|
|
229
|
+
return e ? d.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
|
|
229
230
|
}
|
|
230
231
|
_capturePendingNodeConfigWrite() {
|
|
231
232
|
const e = this.store.currentRecommendationId, t = e === null ? void 0 : this.store.blockStates[e];
|
|
@@ -240,15 +241,15 @@ class me extends P {
|
|
|
240
241
|
return !e || t !== null && e.blockId !== t ? null : e;
|
|
241
242
|
}
|
|
242
243
|
_getNodeConfigUpdates(e) {
|
|
243
|
-
const { filters: t, strategy: o, strategyId: n, size: i, productIds:
|
|
244
|
+
const { filters: t, strategy: o, strategyId: n, size: i, productIds: s, nodeConfigVersion: l } = e, { partnerName: a } = f();
|
|
244
245
|
return {
|
|
245
246
|
filters: t,
|
|
246
247
|
strategy: o,
|
|
247
248
|
strategyId: n,
|
|
248
249
|
size: i,
|
|
249
|
-
productIds:
|
|
250
|
-
configVersion:
|
|
251
|
-
...
|
|
250
|
+
productIds: s,
|
|
251
|
+
configVersion: l,
|
|
252
|
+
...a.value ? { partnerName: a.value } : {}
|
|
252
253
|
};
|
|
253
254
|
}
|
|
254
255
|
/**
|
|
@@ -263,7 +264,7 @@ class me extends P {
|
|
|
263
264
|
*/
|
|
264
265
|
_stagePendingNodeConfig(e) {
|
|
265
266
|
const t = this._pendingWriteForNode();
|
|
266
|
-
return !t || !this.currentNode ? !1 : (
|
|
267
|
+
return !t || !this.currentNode ? !1 : (d.stageConfig(e, this.currentNode, t.updates), !0);
|
|
267
268
|
}
|
|
268
269
|
/**
|
|
269
270
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -288,14 +289,14 @@ class me extends P {
|
|
|
288
289
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !(!e || !this.api)) {
|
|
289
290
|
if (e.blockId !== this.store.currentRecommendationId || !this.currentNode) {
|
|
290
291
|
const { blockId: t, updates: o } = e;
|
|
291
|
-
!
|
|
292
|
+
!p(t, o, h) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
|
|
292
293
|
return;
|
|
293
294
|
}
|
|
294
|
-
|
|
295
|
+
B(this.currentNode, e.updates) && d.updateConfig(
|
|
295
296
|
this.api,
|
|
296
297
|
this.currentNode,
|
|
297
298
|
e.updates,
|
|
298
|
-
|
|
299
|
+
F(this.currentNode, e.updates, h)
|
|
299
300
|
);
|
|
300
301
|
}
|
|
301
302
|
}
|
|
@@ -306,14 +307,14 @@ class me extends P {
|
|
|
306
307
|
/** The Product Ids label when the pending write moves the node's ids; the caller's default otherwise. */
|
|
307
308
|
_pendingDescription() {
|
|
308
309
|
const e = this._pendingWriteForNode();
|
|
309
|
-
if (!(!e || !this.currentNode || !
|
|
310
|
-
return
|
|
310
|
+
if (!(!e || !this.currentNode || !D(this.currentNode, e.updates)))
|
|
311
|
+
return L;
|
|
311
312
|
}
|
|
312
313
|
_syncNodeConfigToStore() {
|
|
313
314
|
var n;
|
|
314
|
-
const e =
|
|
315
|
+
const e = d.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
315
316
|
this.store.patchCurrentBlockConfig({
|
|
316
|
-
strategy: e.strategy,
|
|
317
|
+
strategy: C(e.strategy) ?? e.strategy,
|
|
317
318
|
strategyId: e.strategyId,
|
|
318
319
|
nodeConfigVersion: e.configVersion,
|
|
319
320
|
language: e.language,
|
|
@@ -373,61 +374,45 @@ class me extends P {
|
|
|
373
374
|
return this.isPanelAlive && this.store.currentRecommendationId === e;
|
|
374
375
|
}
|
|
375
376
|
/**
|
|
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.
|
|
377
|
+
* Falls back to the first available option when the block's currency or locale is not offered (a new block on
|
|
378
|
+
* the hard-coded default, or a block copied from another account). Only the default strategy gets an algorithm.
|
|
384
379
|
*/
|
|
385
380
|
_applySmartDefaults() {
|
|
386
381
|
if (!this.currentNode || !this.api)
|
|
387
382
|
return;
|
|
388
|
-
const e =
|
|
383
|
+
const e = d.getConfig(this.currentNode), t = {};
|
|
389
384
|
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));
|
|
385
|
+
const { currencyList: s } = this.store;
|
|
386
|
+
if (s.length > 0 && !s.some((a) => a.value === `price.${e.currency.code}`) && (o = s[0].value.replace("price.", ""), t.currency = {
|
|
387
|
+
...e.currency,
|
|
388
|
+
code: o,
|
|
389
|
+
symbol: o
|
|
390
|
+
}), C(e.strategy) === m.strategy) {
|
|
391
|
+
const a = this.store.getActivePredictiveAlgorithms;
|
|
392
|
+
a.length > 0 && (a.some(
|
|
393
|
+
(N) => N.value === m.strategy
|
|
394
|
+
) || (n = a[0].value, t.strategy = n));
|
|
411
395
|
}
|
|
412
|
-
|
|
396
|
+
const l = this.store.getLanguages;
|
|
397
|
+
l.length > 0 && !l.some((a) => a.value === e.language) && (i = l[0].value, t.language = i), !(!o && !n && !i) && (d.updateConfig(
|
|
413
398
|
this.api,
|
|
414
399
|
this.currentNode,
|
|
415
400
|
t,
|
|
416
401
|
"Applied smart defaults"
|
|
417
|
-
), o && t.currency &&
|
|
402
|
+
), o && t.currency && z({
|
|
418
403
|
currentNode: this.currentNode,
|
|
419
404
|
documentModifier: this.api.getDocumentModifier(),
|
|
420
405
|
currency: t.currency
|
|
421
406
|
}), this.store.patchCurrentBlockConfig({
|
|
422
|
-
...o ? {
|
|
407
|
+
...o && t.currency ? {
|
|
423
408
|
currencySettings: {
|
|
424
409
|
name: o,
|
|
425
410
|
value: o,
|
|
426
411
|
symbol: o,
|
|
427
|
-
alignment:
|
|
428
|
-
decimalCount:
|
|
429
|
-
decimalSeparator:
|
|
430
|
-
thousandSeparator:
|
|
412
|
+
alignment: t.currency.alignment === "before" ? "0" : "1",
|
|
413
|
+
decimalCount: t.currency.decimalCount.toString(),
|
|
414
|
+
decimalSeparator: t.currency.decimalSeparator,
|
|
415
|
+
thousandSeparator: t.currency.thousandSeparator
|
|
431
416
|
}
|
|
432
417
|
} : {},
|
|
433
418
|
...n ? { strategy: n } : {},
|
|
@@ -438,10 +423,10 @@ class me extends P {
|
|
|
438
423
|
* Reads the recommendation-id attribute from the block element within the node
|
|
439
424
|
*/
|
|
440
425
|
_getRecommendationIdFromNode(e) {
|
|
441
|
-
const t =
|
|
426
|
+
const t = $(e);
|
|
442
427
|
if (!t || !("getAttribute" in t))
|
|
443
428
|
return null;
|
|
444
|
-
const o = t.getAttribute(
|
|
429
|
+
const o = t.getAttribute(S);
|
|
445
430
|
if (!o)
|
|
446
431
|
return null;
|
|
447
432
|
const n = parseInt(o);
|
|
@@ -458,10 +443,10 @@ class me extends P {
|
|
|
458
443
|
if (e === null || !n)
|
|
459
444
|
return;
|
|
460
445
|
const i = t !== n.configVersion;
|
|
461
|
-
i && !
|
|
446
|
+
i && !p(
|
|
462
447
|
e,
|
|
463
448
|
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
464
|
-
|
|
449
|
+
h
|
|
465
450
|
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i || o) && this._refreshOutsidePanel(e, i);
|
|
466
451
|
} catch (n) {
|
|
467
452
|
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
@@ -475,7 +460,7 @@ class me extends P {
|
|
|
475
460
|
};
|
|
476
461
|
}
|
|
477
462
|
_refreshOutsidePanel(e, t) {
|
|
478
|
-
|
|
463
|
+
O(e, {
|
|
479
464
|
pickUpdates: (o) => this._getNodeConfigUpdates(o),
|
|
480
465
|
description: "Update recommendation configuration",
|
|
481
466
|
fetch: t
|
|
@@ -498,19 +483,19 @@ class me extends P {
|
|
|
498
483
|
return;
|
|
499
484
|
}
|
|
500
485
|
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = this._pendingDescription(), n = this._stagePendingNodeConfig(t);
|
|
501
|
-
if (
|
|
486
|
+
if (H(this.currentNode)) {
|
|
502
487
|
n && (t.apply(
|
|
503
|
-
new
|
|
488
|
+
new R(o ?? "Update recommendation configuration")
|
|
504
489
|
), this._consumePendingNodeConfig());
|
|
505
490
|
return;
|
|
506
491
|
}
|
|
507
|
-
|
|
492
|
+
Y({
|
|
508
493
|
currentNode: this.currentNode,
|
|
509
494
|
documentModifier: t,
|
|
510
495
|
products: e,
|
|
511
496
|
description: o,
|
|
512
497
|
onApplied: n ? () => this._consumePendingNodeConfig() : void 0
|
|
513
|
-
}) ||
|
|
498
|
+
}) || j({
|
|
514
499
|
currentNode: this.currentNode,
|
|
515
500
|
documentModifier: t,
|
|
516
501
|
products: e,
|
|
@@ -541,51 +526,51 @@ class me extends P {
|
|
|
541
526
|
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
|
|
542
527
|
const n = e.currentRecommendationId;
|
|
543
528
|
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(
|
|
529
|
+
const g = this._trackedBlockSnapshot();
|
|
530
|
+
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(g);
|
|
546
531
|
return;
|
|
547
532
|
}
|
|
548
533
|
const i = this._getBlockConfigVersion(n);
|
|
549
534
|
i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, this.panelGeneration));
|
|
550
|
-
const
|
|
551
|
-
|
|
535
|
+
const s = e.recommendationProducts, l = s !== t, a = Array.isArray(s) && s.length > 0;
|
|
536
|
+
l && a && (t = s, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
|
|
552
537
|
});
|
|
553
538
|
}
|
|
554
539
|
}
|
|
555
540
|
export {
|
|
556
|
-
|
|
541
|
+
Pe as ALGORITHM_CONTROL_ID,
|
|
557
542
|
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
|
-
|
|
543
|
+
q as CONTROL_BLOCK_ID,
|
|
544
|
+
Ie as CURRENCY_CONTROL_ID,
|
|
545
|
+
U as CurrencyControl,
|
|
546
|
+
Se as FILTERS_CONTROL_ID,
|
|
547
|
+
v as FiltersControl,
|
|
548
|
+
Oe as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
549
|
+
Be as LOCALE_CONTROL_ID,
|
|
550
|
+
w as LayoutOrientationControl,
|
|
551
|
+
A as LocaleControl,
|
|
552
|
+
De as PRICE_PLACEMENT_CONTROL_ID,
|
|
553
|
+
Ee as PRODUCT_COUNT_CONTROL_ID,
|
|
554
|
+
ve as PRODUCT_LAYOUT_CONTROL_ID,
|
|
555
|
+
V as PricePlacementControl,
|
|
556
|
+
W as ProductCountControl,
|
|
557
|
+
x as ProductLayoutControl,
|
|
558
|
+
_e as RecommendationBlockControl,
|
|
559
|
+
Ae as SHUFFLE_CONTROL_ID,
|
|
560
|
+
We as STRATEGY_CONTROL_ID,
|
|
561
|
+
M as ShuffleControl,
|
|
562
|
+
G as StrategyControl,
|
|
563
|
+
Me as adjustProductsToSize,
|
|
564
|
+
Ge as formatProductPrice,
|
|
565
|
+
$ as getBlockElement,
|
|
566
|
+
ze as getCardComposition,
|
|
567
|
+
$e as getCurrentLayout,
|
|
568
|
+
He as getMainContainerTbody,
|
|
569
|
+
H as isPartnerManagedBlock,
|
|
570
|
+
Ye as regenerateMobileProductRows,
|
|
571
|
+
j as regenerateProductRowsWithStyles,
|
|
572
|
+
z as setCurrencyAttributes,
|
|
573
|
+
je as updatePricesInPlace,
|
|
574
|
+
Y as updateProductContentInPlace,
|
|
575
|
+
qe as updateSingleProductContent
|
|
591
576
|
};
|