@useinsider/guido 3.17.0 → 3.18.0-beta.41e529d
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 +6 -5
- package/dist/@types/config/schemas.js +10 -7
- package/dist/components/Guido.vue.js +10 -10
- package/dist/components/Guido.vue2.js +86 -78
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +131 -0
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.js +17 -0
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +57 -0
- package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
- package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +63 -0
- package/dist/composables/useCustomInterfaceAppearance.js +56 -38
- package/dist/composables/useLegacyStrategyConversion.js +52 -0
- package/dist/composables/useModuleRepair.js +33 -0
- package/dist/composables/useRecommendation.js +41 -34
- package/dist/composables/useSave.js +30 -29
- package/dist/composables/useStripo.js +15 -15
- package/dist/composables/useSyncModuleExtractor.js +15 -13
- package/dist/composables/validators/useSyncModuleBlockValidator.js +24 -0
- package/dist/config/i18n/en/labels.json.js +1 -1
- package/dist/config/migrator/index.js +9 -8
- package/dist/config/migrator/recommendation/compositionMapper.js +20 -20
- package/dist/config/migrator/recommendation/extractors.js +29 -24
- package/dist/config/migrator/recommendation/htmlBuilder.js +116 -130
- package/dist/config/migrator/recommendation/settingsMapper.js +17 -17
- package/dist/config/migrator/recommendationMigrator.js +31 -25
- package/dist/config/migrator/recommendationTitleMigrator.js +119 -0
- package/dist/enums/academy.js +2 -1
- package/dist/enums/date.js +5 -3
- package/dist/enums/extensions/recommendationBlock.js +4 -1
- package/dist/extensions/Blocks/Items/block.js +118 -49
- package/dist/extensions/Blocks/Items/constants/currency.js +25 -0
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -11
- package/dist/extensions/Blocks/Items/template.js +153 -152
- package/dist/extensions/Blocks/Items/utils/constants.js +4 -0
- package/dist/extensions/Blocks/Recommendation/block.js +35 -29
- package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +29 -27
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +35 -28
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +309 -236
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +242 -180
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +159 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +1 -0
- package/dist/extensions/Blocks/Recommendation/controls/title/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/extension.js +31 -29
- package/dist/extensions/Blocks/Recommendation/services/configService.js +54 -36
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +23 -4
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +217 -80
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
- package/dist/extensions/Blocks/Recommendation/templates/titleRows.js +33 -0
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +85 -107
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +58 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +22 -0
- package/dist/extensions/Blocks/Recommendation/utils/recommendationBlockCount.js +10 -6
- package/dist/extensions/Blocks/common-control.js +22 -19
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +81 -33
- package/dist/src/@types/config/schemas.d.ts +6 -0
- package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
- package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +15 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
- package/dist/src/composables/useModuleRepair.d.ts +18 -0
- package/dist/src/composables/useRecommendation.d.ts +1 -0
- package/dist/src/composables/useSyncModuleExtractor.d.ts +2 -0
- package/dist/src/composables/validators/useSyncModuleBlockValidator.d.ts +3 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +8 -0
- package/dist/src/config/migrator/recommendationTitleMigrator.d.ts +5 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/date.d.ts +1 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +35 -0
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +43 -0
- package/dist/src/extensions/Blocks/Items/utils/constants.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +2 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +3 -6
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +12 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +11 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +44 -8
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +17 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +86 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +12 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +229 -10
- package/dist/src/extensions/Blocks/Recommendation/templates/titleRows.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +39 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +31 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/recommendationBlockCount.d.ts +6 -2
- package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
- package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
- package/dist/src/services/recommendationApi.d.ts +5 -1
- package/dist/src/stores/config.d.ts +178 -0
- package/dist/src/stores/save-as-template.d.ts +4 -3
- package/dist/src/utils/genericUtil.d.ts +5 -0
- package/dist/src/utils/itemsCurrencyRepair.d.ts +17 -0
- package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
- package/dist/static/assets/icons/line-change.svg.js +5 -0
- package/dist/static/assets/icons/line-delete.svg.js +5 -0
- package/dist/static/assets/icons/line-info.svg.js +5 -0
- package/dist/static/assets/icons/line-plus.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +220 -0
- package/dist/static/styles/customEditorStyle.css.js +3 -1
- package/dist/stores/config.js +66 -59
- package/dist/utils/dateUtil.js +23 -10
- package/dist/utils/genericUtil.js +28 -27
- package/dist/utils/itemsCurrencyRepair.js +39 -0
- package/dist/utils/pairProductVariables.js +58 -58
- package/dist/utils/templatePreparation.js +35 -34
- package/package.json +3 -2
- package/dist/composables/useModuleDynamicContentRepair.js +0 -37
- package/dist/src/composables/useModuleDynamicContentRepair.d.ts +0 -13
|
@@ -1,54 +1,71 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var C = (g, l, t) => l in g ? m(g, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[l] = t;
|
|
3
|
+
var r = (g, l, t) => C(g, typeof l != "symbol" ? l + "" : l, t);
|
|
4
|
+
import { useConfig as p } from "../../../../../composables/useConfig.js";
|
|
5
|
+
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
+
import { CommonControl as N } from "../../../common-control.js";
|
|
7
|
+
import { CURRENT_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
9
|
+
import { RecommendationConfigService as c } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
11
|
+
import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
12
|
+
import { AlgorithmControl as T } from "./algorithm.js";
|
|
13
|
+
import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
|
|
14
|
+
import { CurrencyControl as P } from "./currency.js";
|
|
15
|
+
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
|
+
import { FiltersControl as S } from "./filters.js";
|
|
17
|
+
import { FILTERS_CONTROL_ID as ht } from "./filters.js";
|
|
18
|
+
import { LayoutOrientationControl as O } from "./layoutOrientation.js";
|
|
19
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
|
|
20
|
+
import { LocaleControl as L } from "./locale.js";
|
|
21
|
+
import { LOCALE_CONTROL_ID as yt } from "./locale.js";
|
|
22
|
+
import { PricePlacementControl as E } from "./pricePlacement.js";
|
|
23
|
+
import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
|
|
24
|
+
import { ProductCountControl as k } from "./productCount.js";
|
|
25
|
+
import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
|
|
26
|
+
import { ProductLayoutControl as D } from "./productLayout.js";
|
|
27
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Tt } from "./productLayout.js";
|
|
28
|
+
import { ShuffleControl as F } from "./shuffle.js";
|
|
29
|
+
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
|
+
import { StrategyControl as w } from "./strategy.js";
|
|
31
|
+
import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
|
|
32
|
+
import { setCurrencyAttributes as A, getBlockElement as B, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as kt, formatProductPrice as Dt, getCardComposition as Ft, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as Bt, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
|
|
34
|
+
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
|
+
const $ = "ui-elements-recommendation-block";
|
|
36
|
+
class at extends N {
|
|
31
37
|
constructor() {
|
|
32
38
|
super(...arguments);
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
r(this, "store", R());
|
|
40
|
+
r(this, "storeUnsubscription", () => {
|
|
35
41
|
});
|
|
36
|
-
|
|
42
|
+
// blockId -> fingerprint of the node config as it looked at the last sync.
|
|
43
|
+
r(this, "syncedConfigs", /* @__PURE__ */ new Map());
|
|
44
|
+
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
45
|
+
// re-render's single apply() — one user action must cost one undo press.
|
|
46
|
+
r(this, "pendingNodeConfigWrite", null);
|
|
47
|
+
r(this, "pendingConfigFlushTimer", null);
|
|
37
48
|
// Sub-control instances for lifecycle management
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
r(this, "algorithmControl", null);
|
|
50
|
+
r(this, "localeControl", null);
|
|
51
|
+
r(this, "currencyControl", null);
|
|
52
|
+
r(this, "productCountControl", null);
|
|
53
|
+
r(this, "productLayoutControl", null);
|
|
54
|
+
r(this, "filtersControl", null);
|
|
55
|
+
r(this, "shuffleControl", null);
|
|
56
|
+
r(this, "pricePlacementControl", null);
|
|
57
|
+
r(this, "layoutOrientationControl", null);
|
|
58
|
+
r(this, "strategyControl", null);
|
|
59
|
+
r(this, "rrsEnabled", !1);
|
|
47
60
|
/**
|
|
48
61
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
49
62
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
r(this, "_debouncedFetchProducts", f(async () => {
|
|
64
|
+
try {
|
|
65
|
+
await this.store.fetchRecommendationProducts();
|
|
66
|
+
} finally {
|
|
67
|
+
this._scheduleConfigFlush();
|
|
68
|
+
}
|
|
52
69
|
}, 500));
|
|
53
70
|
/**
|
|
54
71
|
* Debounced content update when products arrive from API.
|
|
@@ -61,16 +78,20 @@ class Q extends g {
|
|
|
61
78
|
* count. The store pads products to the configured size, so in-place only
|
|
62
79
|
* fails when the size actually changed.
|
|
63
80
|
*/
|
|
64
|
-
|
|
81
|
+
r(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
65
82
|
const t = this.store.recommendationProducts;
|
|
66
|
-
if (!this.currentNode || !this.api
|
|
83
|
+
if (!this.currentNode || !this.api)
|
|
84
|
+
return;
|
|
85
|
+
const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
86
|
+
if (v(this.currentNode)) {
|
|
87
|
+
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
67
88
|
return;
|
|
68
|
-
|
|
69
|
-
|
|
89
|
+
}
|
|
90
|
+
x({
|
|
70
91
|
currentNode: this.currentNode,
|
|
71
92
|
documentModifier: e,
|
|
72
93
|
products: t
|
|
73
|
-
}) ||
|
|
94
|
+
}) || U({
|
|
74
95
|
currentNode: this.currentNode,
|
|
75
96
|
documentModifier: e,
|
|
76
97
|
products: t
|
|
@@ -78,23 +99,32 @@ class Q extends g {
|
|
|
78
99
|
}, 100));
|
|
79
100
|
}
|
|
80
101
|
getId() {
|
|
81
|
-
return
|
|
102
|
+
return $;
|
|
82
103
|
}
|
|
83
|
-
|
|
84
|
-
return
|
|
104
|
+
get _subControls() {
|
|
105
|
+
return [
|
|
106
|
+
this.layoutOrientationControl,
|
|
107
|
+
this.productCountControl,
|
|
85
108
|
this.algorithmControl,
|
|
86
109
|
this.localeControl,
|
|
87
110
|
this.currencyControl,
|
|
88
|
-
this.productCountControl,
|
|
89
111
|
this.productLayoutControl,
|
|
90
112
|
this.filtersControl,
|
|
91
113
|
this.shuffleControl,
|
|
92
114
|
this.pricePlacementControl,
|
|
93
|
-
this.
|
|
94
|
-
]
|
|
95
|
-
|
|
115
|
+
this.strategyControl
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
getTemplate() {
|
|
119
|
+
var t;
|
|
120
|
+
return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
|
|
121
|
+
var o;
|
|
122
|
+
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
123
|
+
}), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new k(), this.productLayoutControl = new D(), this.filtersControl = new S(), this.shuffleControl = new F(), this.pricePlacementControl = new E(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
|
|
124
|
+
e && (e.api = this.api);
|
|
96
125
|
}), `
|
|
97
126
|
<div class="recommendation-controls-container">
|
|
127
|
+
${((t = this.strategyControl) == null ? void 0 : t.getTemplate()) ?? ""}
|
|
98
128
|
${this.layoutOrientationControl.getTemplate()}
|
|
99
129
|
${this.productCountControl.getTemplate()}
|
|
100
130
|
${this.productLayoutControl.getTemplate()}
|
|
@@ -107,50 +137,39 @@ class Q extends g {
|
|
|
107
137
|
</div>
|
|
108
138
|
`;
|
|
109
139
|
}
|
|
140
|
+
_showControlsForBlock(t) {
|
|
141
|
+
var i;
|
|
142
|
+
const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
|
|
143
|
+
if (!e)
|
|
144
|
+
return;
|
|
145
|
+
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !n;
|
|
146
|
+
e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
|
|
147
|
+
}
|
|
110
148
|
async onRender() {
|
|
111
149
|
var o;
|
|
150
|
+
b(this.api);
|
|
112
151
|
const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
|
|
113
|
-
if (e !== null && this.store.setCurrentBlock(e), t !== null &&
|
|
152
|
+
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
|
|
114
153
|
this._initializeSubControls();
|
|
115
154
|
return;
|
|
116
155
|
}
|
|
117
156
|
await this._fetchBlockData(e), this._initializeSubControls();
|
|
118
157
|
}
|
|
119
158
|
onTemplateNodeUpdated(t) {
|
|
120
|
-
var
|
|
159
|
+
var o;
|
|
121
160
|
super.onTemplateNodeUpdated(t);
|
|
122
161
|
const e = this._getRecommendationIdFromNode(t);
|
|
123
|
-
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null &&
|
|
162
|
+
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigIfChanged(e), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
|
|
124
163
|
this._initializeSubControls();
|
|
125
|
-
}),
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.algorithmControl,
|
|
129
|
-
this.localeControl,
|
|
130
|
-
this.currencyControl,
|
|
131
|
-
this.productLayoutControl,
|
|
132
|
-
this.filtersControl,
|
|
133
|
-
this.shuffleControl,
|
|
134
|
-
this.pricePlacementControl
|
|
135
|
-
].forEach((n) => {
|
|
136
|
-
var i;
|
|
137
|
-
n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
|
|
164
|
+
}), this._subControls.forEach((n) => {
|
|
165
|
+
var s;
|
|
166
|
+
n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
|
|
138
167
|
});
|
|
139
168
|
}
|
|
140
169
|
onDestroy() {
|
|
141
|
-
this.storeUnsubscription(),
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.algorithmControl,
|
|
145
|
-
this.localeControl,
|
|
146
|
-
this.currencyControl,
|
|
147
|
-
this.productLayoutControl,
|
|
148
|
-
this.filtersControl,
|
|
149
|
-
this.shuffleControl,
|
|
150
|
-
this.pricePlacementControl
|
|
151
|
-
].forEach((e) => {
|
|
152
|
-
var o;
|
|
153
|
-
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
170
|
+
this.storeUnsubscription(), this._flushPendingNodeConfig(), this._subControls.forEach((t) => {
|
|
171
|
+
var e;
|
|
172
|
+
return (e = t == null ? void 0 : t.onDestroy) == null ? void 0 : e.call(t);
|
|
154
173
|
});
|
|
155
174
|
}
|
|
156
175
|
/**
|
|
@@ -158,25 +177,14 @@ class Q extends g {
|
|
|
158
177
|
* Each sub-control manages its own form values and event listeners
|
|
159
178
|
*/
|
|
160
179
|
_initializeSubControls() {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.
|
|
164
|
-
this.algorithmControl,
|
|
165
|
-
this.localeControl,
|
|
166
|
-
this.currencyControl,
|
|
167
|
-
this.productLayoutControl,
|
|
168
|
-
this.filtersControl,
|
|
169
|
-
this.shuffleControl,
|
|
170
|
-
this.pricePlacementControl
|
|
171
|
-
].forEach((e) => {
|
|
172
|
-
var o;
|
|
173
|
-
e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
|
|
180
|
+
this._subControls.forEach((t) => {
|
|
181
|
+
var e;
|
|
182
|
+
t && (t.api = this.api, t.currentNode = this.currentNode, (e = t.onRender) == null || e.call(t));
|
|
174
183
|
});
|
|
175
184
|
}
|
|
176
185
|
/**
|
|
177
186
|
* Syncs persisted node config into the Pinia store's block state.
|
|
178
187
|
*
|
|
179
|
-
* setCurrentBlock() creates a default entry (USD, en_US, mostPopular).
|
|
180
188
|
* For saved templates, the real config lives in the node (e.g., TRY, tr_TR).
|
|
181
189
|
* This method reads it and patches the store so fetchRecommendationProducts()
|
|
182
190
|
* uses the correct values.
|
|
@@ -184,11 +192,77 @@ class Q extends g {
|
|
|
184
192
|
* Uses triggerRefetch: false because the fetch hasn't happened yet —
|
|
185
193
|
* values are being prepared for the upcoming initial fetch.
|
|
186
194
|
*/
|
|
195
|
+
/**
|
|
196
|
+
* Re-syncs the store when the node config moved since we last read it.
|
|
197
|
+
*
|
|
198
|
+
* Undo/redo, the code editor and version-history restore rewrite the node
|
|
199
|
+
* config behind the store's back — Stripo exposes no undo signal, so a
|
|
200
|
+
* fingerprint diff on this hook is the only way to notice (SD-149105).
|
|
201
|
+
* An unchanged fingerprint means the move came from us, so runtime store
|
|
202
|
+
* edits are never clobbered (SD-141049).
|
|
203
|
+
*/
|
|
204
|
+
_syncNodeConfigIfChanged(t) {
|
|
205
|
+
this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== t && this._flushPendingNodeConfig();
|
|
206
|
+
const e = JSON.stringify(c.getConfig(this.currentNode)), o = this.syncedConfigs.get(t);
|
|
207
|
+
this.syncedConfigs.set(t, e), o !== e && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
208
|
+
}
|
|
209
|
+
_capturePendingNodeConfigWrite() {
|
|
210
|
+
const t = this.store.currentRecommendationId;
|
|
211
|
+
if (!this.currentNode || !this.api || t === null)
|
|
212
|
+
return;
|
|
213
|
+
const { filters: e, strategyId: o, size: n, nodeConfigVersion: s } = this.store.recommendationConfigs;
|
|
214
|
+
this.pendingNodeConfigWrite = {
|
|
215
|
+
blockId: t,
|
|
216
|
+
node: this.currentNode,
|
|
217
|
+
updates: { filters: e, strategyId: o, size: n, configVersion: s }
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Accumulates the pending write into `documentModifier` without applying, so the
|
|
222
|
+
* caller's apply() commits config and re-render as ONE undo entry.
|
|
223
|
+
*
|
|
224
|
+
* Deliberately does not consume the pending record: the product helpers call
|
|
225
|
+
* apply() only when they actually changed something, so this batch may never be
|
|
226
|
+
* committed and the flush has to stay able to write it standalone.
|
|
227
|
+
* @param documentModifier - The batch to accumulate into
|
|
228
|
+
* @returns Whether anything was staged
|
|
229
|
+
*/
|
|
230
|
+
_stagePendingNodeConfig(t) {
|
|
231
|
+
const e = this.pendingNodeConfigWrite;
|
|
232
|
+
return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
236
|
+
* delay only has to outlast the re-render debounce that fetch triggers — firing
|
|
237
|
+
* earlier writes the config on its own and the undo entry splits in two again.
|
|
238
|
+
*/
|
|
239
|
+
_scheduleConfigFlush() {
|
|
240
|
+
this._clearConfigFlush(), this.pendingConfigFlushTimer = setTimeout(() => {
|
|
241
|
+
this.pendingConfigFlushTimer = null, this._flushPendingNodeConfig();
|
|
242
|
+
}, 800);
|
|
243
|
+
}
|
|
244
|
+
_clearConfigFlush() {
|
|
245
|
+
this.pendingConfigFlushTimer !== null && (clearTimeout(this.pendingConfigFlushTimer), this.pendingConfigFlushTimer = null);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Writes the deferred change standalone when the batch it was staged into never
|
|
249
|
+
* committed. Always targets the LIVE node — the captured one is an immutable
|
|
250
|
+
* snapshot the intervening re-render staled, and saveConfig swallows that failure.
|
|
251
|
+
*/
|
|
252
|
+
_flushPendingNodeConfig() {
|
|
253
|
+
const t = this.pendingNodeConfigWrite;
|
|
254
|
+
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
255
|
+
return;
|
|
256
|
+
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
|
|
257
|
+
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
258
|
+
}
|
|
187
259
|
_syncNodeConfigToStore() {
|
|
188
|
-
var
|
|
189
|
-
const t =
|
|
260
|
+
var n;
|
|
261
|
+
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
|
|
190
262
|
this.store.patchCurrentBlockConfig({
|
|
191
263
|
strategy: t.strategy,
|
|
264
|
+
strategyId: t.strategyId,
|
|
265
|
+
nodeConfigVersion: t.configVersion,
|
|
192
266
|
language: t.language,
|
|
193
267
|
size: t.size,
|
|
194
268
|
productIds: t.productIds,
|
|
@@ -227,8 +301,8 @@ class Q extends g {
|
|
|
227
301
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
228
302
|
this.store.fetchRecommendationCreateData(),
|
|
229
303
|
this.store.fetchRecommendationFilters()
|
|
230
|
-
])).forEach((o,
|
|
231
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
304
|
+
])).forEach((o, n) => {
|
|
305
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
|
|
232
306
|
}), this._applySmartDefaults();
|
|
233
307
|
try {
|
|
234
308
|
await this.store.fetchRecommendationProducts();
|
|
@@ -249,36 +323,36 @@ class Q extends g {
|
|
|
249
323
|
_applySmartDefaults() {
|
|
250
324
|
if (!this.currentNode || !this.api)
|
|
251
325
|
return;
|
|
252
|
-
const t =
|
|
253
|
-
let o = null,
|
|
254
|
-
if (t.currency.code ===
|
|
326
|
+
const t = c.getConfig(this.currentNode), e = {};
|
|
327
|
+
let o = null, n = null, s = null;
|
|
328
|
+
if (t.currency.code === a.currency.code) {
|
|
255
329
|
const { currencyList: i } = this.store;
|
|
256
330
|
i.length > 0 && (i.some(
|
|
257
|
-
(
|
|
331
|
+
(d) => d.value === `price.${a.currency.code}`
|
|
258
332
|
) || (o = i[0].value.replace("price.", ""), e.currency = {
|
|
259
|
-
...
|
|
333
|
+
...a.currency,
|
|
260
334
|
code: o,
|
|
261
335
|
symbol: o
|
|
262
336
|
}));
|
|
263
337
|
}
|
|
264
|
-
if (t.strategy ===
|
|
338
|
+
if (t.strategy === a.strategy) {
|
|
265
339
|
const i = this.store.getActivePredictiveAlgorithms;
|
|
266
340
|
i.length > 0 && (i.some(
|
|
267
|
-
(
|
|
268
|
-
) || (
|
|
341
|
+
(d) => d.value === a.strategy
|
|
342
|
+
) || (n = i[0].value, e.strategy = n));
|
|
269
343
|
}
|
|
270
|
-
if (t.language ===
|
|
344
|
+
if (t.language === a.language) {
|
|
271
345
|
const i = this.store.getLanguages;
|
|
272
346
|
i.length > 0 && (i.some(
|
|
273
|
-
(
|
|
274
|
-
) || (
|
|
347
|
+
(d) => d.value === a.language
|
|
348
|
+
) || (s = i[0].value, e.language = s));
|
|
275
349
|
}
|
|
276
|
-
!o && !
|
|
350
|
+
!o && !n && !s || (c.updateConfig(
|
|
277
351
|
this.api,
|
|
278
352
|
this.currentNode,
|
|
279
353
|
e,
|
|
280
354
|
"Applied smart defaults"
|
|
281
|
-
), o && e.currency &&
|
|
355
|
+
), o && e.currency && A({
|
|
282
356
|
currentNode: this.currentNode,
|
|
283
357
|
documentModifier: this.api.getDocumentModifier(),
|
|
284
358
|
currency: e.currency
|
|
@@ -288,28 +362,28 @@ class Q extends g {
|
|
|
288
362
|
name: o,
|
|
289
363
|
value: o,
|
|
290
364
|
symbol: o,
|
|
291
|
-
alignment:
|
|
292
|
-
decimalCount:
|
|
293
|
-
decimalSeparator:
|
|
294
|
-
thousandSeparator:
|
|
365
|
+
alignment: a.currency.alignment === "before" ? "0" : "1",
|
|
366
|
+
decimalCount: a.currency.decimalCount.toString(),
|
|
367
|
+
decimalSeparator: a.currency.decimalSeparator,
|
|
368
|
+
thousandSeparator: a.currency.thousandSeparator
|
|
295
369
|
}
|
|
296
370
|
} : {},
|
|
297
|
-
...
|
|
298
|
-
...
|
|
371
|
+
...n ? { strategy: n } : {},
|
|
372
|
+
...s ? { language: s } : {}
|
|
299
373
|
}, { triggerRefetch: !1 }));
|
|
300
374
|
}
|
|
301
375
|
/**
|
|
302
376
|
* Reads the recommendation-id attribute from the block element within the node
|
|
303
377
|
*/
|
|
304
378
|
_getRecommendationIdFromNode(t) {
|
|
305
|
-
const e =
|
|
379
|
+
const e = B(t);
|
|
306
380
|
if (!e || !("getAttribute" in e))
|
|
307
381
|
return null;
|
|
308
|
-
const o = e.getAttribute(
|
|
382
|
+
const o = e.getAttribute(I);
|
|
309
383
|
if (!o)
|
|
310
384
|
return null;
|
|
311
|
-
const
|
|
312
|
-
return Number.isNaN(
|
|
385
|
+
const n = parseInt(o);
|
|
386
|
+
return Number.isNaN(n) ? null : n;
|
|
313
387
|
}
|
|
314
388
|
/**
|
|
315
389
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -326,66 +400,54 @@ class Q extends g {
|
|
|
326
400
|
*/
|
|
327
401
|
_listenStateUpdates() {
|
|
328
402
|
const { store: t } = this;
|
|
329
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
403
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
|
|
330
404
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
333
|
-
|
|
405
|
+
const s = t.currentRecommendationId;
|
|
406
|
+
if (s !== n) {
|
|
407
|
+
n = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
334
408
|
return;
|
|
335
409
|
}
|
|
336
410
|
const i = t.$state.configVersion;
|
|
337
|
-
i !== o && (o = i, this.
|
|
338
|
-
const
|
|
339
|
-
|
|
411
|
+
i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
|
|
412
|
+
const u = t.recommendationProducts, d = u !== e, h = Array.isArray(u) && u.length > 0;
|
|
413
|
+
d && h && (e = u, this._debouncedRegenerateWithProducts());
|
|
340
414
|
});
|
|
341
415
|
}
|
|
342
|
-
/**
|
|
343
|
-
* Persists the current filter state from Pinia store to the Stripo node config.
|
|
344
|
-
* This ensures filters survive template save/reload cycles.
|
|
345
|
-
*/
|
|
346
|
-
_persistFiltersToNodeConfig() {
|
|
347
|
-
if (!this.currentNode || !this.api)
|
|
348
|
-
return;
|
|
349
|
-
const { filters: t } = this.store.recommendationConfigs, e = h.getConfig(this.currentNode).filters;
|
|
350
|
-
JSON.stringify(e) !== JSON.stringify(t) && h.updateConfig(
|
|
351
|
-
this.api,
|
|
352
|
-
this.currentNode,
|
|
353
|
-
{ filters: t },
|
|
354
|
-
"Update recommendation filters"
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
416
|
}
|
|
358
417
|
export {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
418
|
+
ut as ALGORITHM_CONTROL_ID,
|
|
419
|
+
T as AlgorithmControl,
|
|
420
|
+
$ as CONTROL_BLOCK_ID,
|
|
421
|
+
gt as CURRENCY_CONTROL_ID,
|
|
422
|
+
P as CurrencyControl,
|
|
423
|
+
ht as FILTERS_CONTROL_ID,
|
|
424
|
+
S as FiltersControl,
|
|
425
|
+
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
426
|
+
yt as LOCALE_CONTROL_ID,
|
|
427
|
+
O as LayoutOrientationControl,
|
|
428
|
+
L as LocaleControl,
|
|
429
|
+
_t as PRICE_PLACEMENT_CONTROL_ID,
|
|
430
|
+
Rt as PRODUCT_COUNT_CONTROL_ID,
|
|
431
|
+
Tt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
432
|
+
E as PricePlacementControl,
|
|
433
|
+
k as ProductCountControl,
|
|
434
|
+
D as ProductLayoutControl,
|
|
435
|
+
at as RecommendationBlockControl,
|
|
436
|
+
St as SHUFFLE_CONTROL_ID,
|
|
437
|
+
Lt as STRATEGY_CONTROL_ID,
|
|
438
|
+
F as ShuffleControl,
|
|
439
|
+
w as StrategyControl,
|
|
440
|
+
kt as adjustProductsToSize,
|
|
441
|
+
Dt as formatProductPrice,
|
|
442
|
+
B as getBlockElement,
|
|
443
|
+
Ft as getCardComposition,
|
|
444
|
+
wt as getCurrentLayout,
|
|
445
|
+
At as getMainContainerTbody,
|
|
446
|
+
v as isPartnerManagedBlock,
|
|
447
|
+
Bt as regenerateMobileProductRows,
|
|
448
|
+
U as regenerateProductRowsWithStyles,
|
|
449
|
+
A as setCurrencyAttributes,
|
|
450
|
+
vt as updatePricesInPlace,
|
|
451
|
+
x as updateProductContentInPlace,
|
|
452
|
+
xt as updateSingleProductContent
|
|
391
453
|
};
|