@useinsider/guido 3.19.0-beta.e110e88 → 3.19.0-beta.e11b9a3
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 +1 -0
- package/dist/@types/config/schemas.js +102 -87
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +83 -75
- package/dist/components/organisms/AutoSaveController.vue2.js +10 -8
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
- package/dist/components/organisms/header/EditorActions.vue.js +5 -5
- package/dist/components/organisms/header/EditorActions.vue2.js +83 -46
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +50 -0
- package/dist/components/wrappers/WpDrawer.vue.js +9 -7
- package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +4 -3
- package/dist/composables/useAuthError.js +52 -0
- package/dist/composables/useAutoSave.js +44 -42
- package/dist/composables/useHtmlCompiler.js +37 -26
- package/dist/composables/useHtmlValidator.js +2 -0
- package/dist/composables/useHttp.js +64 -54
- package/dist/composables/useLegacyStrategyConversion.js +23 -19
- package/dist/composables/useSave.js +93 -45
- package/dist/composables/useSaveValidation.js +284 -0
- package/dist/composables/useSaveValidationRollout.js +20 -0
- package/dist/composables/useStripo.js +24 -20
- package/dist/composables/useToaster.js +17 -15
- package/dist/composables/validators/useCouponBlockValidator.js +24 -21
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/recommendationPartnerMigrator.js +50 -0
- package/dist/enums/extensions/recommendationBlock.js +30 -29
- package/dist/enums/save-validation.js +4 -0
- package/dist/extensions/Blocks/Recommendation/block.js +21 -22
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +97 -107
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +203 -209
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +67 -91
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +21 -26
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +16 -55
- package/dist/guido.css +1 -1
- package/dist/services/settingsApi.js +11 -0
- package/dist/src/@types/config/schemas.d.ts +20 -0
- package/dist/src/@types/save-validation.d.ts +19 -0
- package/dist/src/components/Guido.vue.d.ts +17 -1
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
- package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
- package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
- package/dist/src/composables/useAuthError.d.ts +12 -0
- package/dist/src/composables/useAutoSave.d.ts +4 -1
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useHtmlValidator.d.ts +21 -0
- package/dist/src/composables/useHttp.d.ts +2 -0
- package/dist/src/composables/useSave.d.ts +6 -1
- package/dist/src/composables/useSaveValidation.d.ts +6 -0
- package/dist/src/composables/useSaveValidationRollout.d.ts +4 -0
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
- package/dist/src/enums/save-validation.d.ts +27 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -13
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +1 -3
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +0 -7
- package/dist/src/services/settingsApi.d.ts +6 -0
- package/dist/src/stores/config.d.ts +52 -0
- package/dist/src/stores/save-validation.d.ts +22 -0
- package/dist/src/stores/setup-settings.d.ts +4 -0
- package/dist/src/utils/templatePreparation.d.ts +30 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
- package/dist/stores/config.js +84 -67
- package/dist/stores/save-validation.js +30 -0
- package/dist/stores/setup-settings.js +10 -0
- package/dist/utils/templatePreparation.js +39 -36
- package/package.json +1 -1
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (g,
|
|
4
|
-
import { useConfig as
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var p = (g, u, t) => u in g ? C(g, u, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[u] = t;
|
|
3
|
+
var i = (g, u, t) => p(g, typeof u != "symbol" ? u + "" : u, t);
|
|
4
|
+
import { useConfig as h } from "../../../../../composables/useConfig.js";
|
|
5
5
|
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { CommonControl as N } from "../../../common-control.js";
|
|
7
7
|
import { RRS_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
8
|
import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
9
|
-
import { RecommendationConfigService as
|
|
9
|
+
import { RecommendationConfigService as c } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
11
11
|
import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
12
|
-
import { AlgorithmControl as
|
|
13
|
-
import { ALGORITHM_CONTROL_ID as
|
|
14
|
-
import { CurrencyControl as
|
|
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
15
|
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
17
17
|
import { FILTERS_CONTROL_ID as ft } from "./filters.js";
|
|
18
18
|
import { LayoutOrientationControl as O } from "./layoutOrientation.js";
|
|
19
19
|
import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
|
|
20
|
-
import { LocaleControl as
|
|
20
|
+
import { LocaleControl as L } from "./locale.js";
|
|
21
21
|
import { LOCALE_CONTROL_ID as yt } from "./locale.js";
|
|
22
|
-
import { PricePlacementControl as
|
|
22
|
+
import { PricePlacementControl as k } from "./pricePlacement.js";
|
|
23
23
|
import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
|
|
24
24
|
import { ProductCountControl as E } from "./productCount.js";
|
|
25
25
|
import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
|
|
26
26
|
import { ProductLayoutControl as F } from "./productLayout.js";
|
|
27
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
27
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Tt } from "./productLayout.js";
|
|
28
28
|
import { ShuffleControl as D } from "./shuffle.js";
|
|
29
29
|
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
|
-
import { StrategyControl as
|
|
31
|
-
import { STRATEGY_CONTROL_ID as
|
|
32
|
-
import { setCurrencyAttributes as
|
|
33
|
-
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as
|
|
34
|
-
import { useDebounceFn as
|
|
30
|
+
import { StrategyControl as w } from "./strategy.js";
|
|
31
|
+
import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
|
|
32
|
+
import { setCurrencyAttributes as v, getBlockElement as A, isPartnerManagedBlock as B, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as vt, regenerateMobileProductRows as At, updatePricesInPlace as Bt, updateSingleProductContent as xt } from "./utils.js";
|
|
34
|
+
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
35
|
const W = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
37
37
|
constructor() {
|
|
@@ -58,7 +58,7 @@ class at extends N {
|
|
|
58
58
|
/**
|
|
59
59
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
60
60
|
*/
|
|
61
|
-
i(this, "_debouncedFetchProducts",
|
|
61
|
+
i(this, "_debouncedFetchProducts", f(async () => {
|
|
62
62
|
try {
|
|
63
63
|
await this.store.fetchRecommendationProducts();
|
|
64
64
|
} finally {
|
|
@@ -76,22 +76,24 @@ class at extends N {
|
|
|
76
76
|
* count. The store pads products to the configured size, so in-place only
|
|
77
77
|
* fails when the size actually changed.
|
|
78
78
|
*/
|
|
79
|
-
i(this, "_debouncedRegenerateWithProducts",
|
|
79
|
+
i(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
80
|
+
const t = this.store.recommendationProducts;
|
|
80
81
|
if (!this.currentNode || !this.api)
|
|
81
82
|
return;
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
this.
|
|
83
|
+
const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
84
|
+
if (B(this.currentNode)) {
|
|
85
|
+
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
this.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
x({
|
|
89
|
+
currentNode: this.currentNode,
|
|
90
|
+
documentModifier: e,
|
|
91
|
+
products: t
|
|
92
|
+
}) || U({
|
|
93
|
+
currentNode: this.currentNode,
|
|
94
|
+
documentModifier: e,
|
|
95
|
+
products: t
|
|
96
|
+
});
|
|
95
97
|
}, 100));
|
|
96
98
|
}
|
|
97
99
|
getId() {
|
|
@@ -113,10 +115,10 @@ class at extends N {
|
|
|
113
115
|
}
|
|
114
116
|
getTemplate() {
|
|
115
117
|
var t;
|
|
116
|
-
return this.rrsEnabled =
|
|
118
|
+
return this.rrsEnabled = h().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
|
|
117
119
|
var o;
|
|
118
120
|
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
119
|
-
}), this.algorithmControl = new
|
|
121
|
+
}), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new E(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new k(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
|
|
120
122
|
e && (e.api = this.api);
|
|
121
123
|
}), `
|
|
122
124
|
<div class="recommendation-controls-container">
|
|
@@ -134,12 +136,12 @@ class at extends N {
|
|
|
134
136
|
`;
|
|
135
137
|
}
|
|
136
138
|
_showControlsForBlock(t) {
|
|
137
|
-
var
|
|
138
|
-
const e = (
|
|
139
|
+
var r;
|
|
140
|
+
const e = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
|
|
139
141
|
if (!e)
|
|
140
142
|
return;
|
|
141
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null :
|
|
142
|
-
e.classList.toggle("strategy-block",
|
|
143
|
+
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;
|
|
144
|
+
e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
|
|
143
145
|
}
|
|
144
146
|
async onRender() {
|
|
145
147
|
var o;
|
|
@@ -157,9 +159,9 @@ class at extends N {
|
|
|
157
159
|
const e = this._getRecommendationIdFromNode(t);
|
|
158
160
|
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(() => {
|
|
159
161
|
this._initializeSubControls();
|
|
160
|
-
}), this._subControls.forEach((
|
|
162
|
+
}), this._subControls.forEach((n) => {
|
|
161
163
|
var s;
|
|
162
|
-
|
|
164
|
+
n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
|
|
163
165
|
});
|
|
164
166
|
}
|
|
165
167
|
onDestroy() {
|
|
@@ -207,23 +209,30 @@ class at extends N {
|
|
|
207
209
|
const e = this.store.blockStates[t];
|
|
208
210
|
if (!e)
|
|
209
211
|
return;
|
|
210
|
-
const o = JSON.stringify(
|
|
211
|
-
e.syncedConfigFingerprint = o,
|
|
212
|
+
const o = JSON.stringify(c.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
|
|
213
|
+
e.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
212
214
|
}
|
|
213
215
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
214
216
|
_isPendingStrategyIdChange() {
|
|
215
217
|
const t = this.pendingNodeConfigWrite;
|
|
216
|
-
return t ?
|
|
218
|
+
return t ? c.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
|
|
217
219
|
}
|
|
218
220
|
_capturePendingNodeConfigWrite() {
|
|
219
221
|
const t = this.store.currentRecommendationId;
|
|
220
222
|
if (!this.currentNode || !this.api || t === null)
|
|
221
223
|
return;
|
|
222
|
-
const { filters: e, strategy: o, strategyId:
|
|
224
|
+
const { filters: e, strategy: o, strategyId: n, size: s, nodeConfigVersion: r } = this.store.recommendationConfigs, { partnerName: l } = h();
|
|
223
225
|
this.pendingNodeConfigWrite = {
|
|
224
226
|
blockId: t,
|
|
225
227
|
node: this.currentNode,
|
|
226
|
-
updates: {
|
|
228
|
+
updates: {
|
|
229
|
+
filters: e,
|
|
230
|
+
strategy: o,
|
|
231
|
+
strategyId: n,
|
|
232
|
+
size: s,
|
|
233
|
+
configVersion: r,
|
|
234
|
+
...l.value ? { partnerName: l.value } : {}
|
|
235
|
+
}
|
|
227
236
|
};
|
|
228
237
|
}
|
|
229
238
|
/**
|
|
@@ -238,7 +247,7 @@ class at extends N {
|
|
|
238
247
|
*/
|
|
239
248
|
_stagePendingNodeConfig(t) {
|
|
240
249
|
const e = this.pendingNodeConfigWrite;
|
|
241
|
-
return !e || !this.currentNode ? !1 : (
|
|
250
|
+
return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
|
|
242
251
|
}
|
|
243
252
|
/**
|
|
244
253
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -262,12 +271,12 @@ class at extends N {
|
|
|
262
271
|
const t = this.pendingNodeConfigWrite;
|
|
263
272
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
264
273
|
return;
|
|
265
|
-
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o =
|
|
266
|
-
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size ||
|
|
274
|
+
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
|
|
275
|
+
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
267
276
|
}
|
|
268
277
|
_syncNodeConfigToStore() {
|
|
269
|
-
var
|
|
270
|
-
const t =
|
|
278
|
+
var n;
|
|
279
|
+
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
|
|
271
280
|
this.store.patchCurrentBlockConfig({
|
|
272
281
|
strategy: t.strategy,
|
|
273
282
|
strategyId: t.strategyId,
|
|
@@ -310,8 +319,8 @@ class at extends N {
|
|
|
310
319
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
311
320
|
this.store.fetchRecommendationCreateData(),
|
|
312
321
|
this.store.fetchRecommendationFilters()
|
|
313
|
-
])).forEach((o,
|
|
314
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
322
|
+
])).forEach((o, n) => {
|
|
323
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
|
|
315
324
|
}), this._applySmartDefaults();
|
|
316
325
|
try {
|
|
317
326
|
await this.store.fetchRecommendationProducts();
|
|
@@ -332,36 +341,36 @@ class at extends N {
|
|
|
332
341
|
_applySmartDefaults() {
|
|
333
342
|
if (!this.currentNode || !this.api)
|
|
334
343
|
return;
|
|
335
|
-
const t =
|
|
336
|
-
let o = null,
|
|
344
|
+
const t = c.getConfig(this.currentNode), e = {};
|
|
345
|
+
let o = null, n = null, s = null;
|
|
337
346
|
if (t.currency.code === a.currency.code) {
|
|
338
|
-
const { currencyList:
|
|
339
|
-
|
|
340
|
-
(
|
|
341
|
-
) || (o =
|
|
347
|
+
const { currencyList: r } = this.store;
|
|
348
|
+
r.length > 0 && (r.some(
|
|
349
|
+
(d) => d.value === `price.${a.currency.code}`
|
|
350
|
+
) || (o = r[0].value.replace("price.", ""), e.currency = {
|
|
342
351
|
...a.currency,
|
|
343
352
|
code: o,
|
|
344
353
|
symbol: o
|
|
345
354
|
}));
|
|
346
355
|
}
|
|
347
356
|
if (t.strategy === a.strategy) {
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
(
|
|
351
|
-
) || (
|
|
357
|
+
const r = this.store.getActivePredictiveAlgorithms;
|
|
358
|
+
r.length > 0 && (r.some(
|
|
359
|
+
(d) => d.value === a.strategy
|
|
360
|
+
) || (n = r[0].value, e.strategy = n));
|
|
352
361
|
}
|
|
353
362
|
if (t.language === a.language) {
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
(
|
|
357
|
-
) || (s =
|
|
363
|
+
const r = this.store.getLanguages;
|
|
364
|
+
r.length > 0 && (r.some(
|
|
365
|
+
(d) => d.value === a.language
|
|
366
|
+
) || (s = r[0].value, e.language = s));
|
|
358
367
|
}
|
|
359
|
-
!o && !
|
|
368
|
+
!o && !n && !s || (c.updateConfig(
|
|
360
369
|
this.api,
|
|
361
370
|
this.currentNode,
|
|
362
371
|
e,
|
|
363
372
|
"Applied smart defaults"
|
|
364
|
-
), o && e.currency &&
|
|
373
|
+
), o && e.currency && v({
|
|
365
374
|
currentNode: this.currentNode,
|
|
366
375
|
documentModifier: this.api.getDocumentModifier(),
|
|
367
376
|
currency: e.currency
|
|
@@ -377,7 +386,7 @@ class at extends N {
|
|
|
377
386
|
thousandSeparator: a.currency.thousandSeparator
|
|
378
387
|
}
|
|
379
388
|
} : {},
|
|
380
|
-
...
|
|
389
|
+
...n ? { strategy: n } : {},
|
|
381
390
|
...s ? { language: s } : {}
|
|
382
391
|
}, { triggerRefetch: !1 }));
|
|
383
392
|
}
|
|
@@ -391,27 +400,8 @@ class at extends N {
|
|
|
391
400
|
const o = e.getAttribute(I);
|
|
392
401
|
if (!o)
|
|
393
402
|
return null;
|
|
394
|
-
const
|
|
395
|
-
return Number.isNaN(
|
|
396
|
-
}
|
|
397
|
-
/** Draws the current block's products into this panel's node. */
|
|
398
|
-
_regenerateWithProducts() {
|
|
399
|
-
if (!this.currentNode || !this.api)
|
|
400
|
-
return;
|
|
401
|
-
const t = this.store.recommendationProducts, e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
402
|
-
if (v(this.currentNode)) {
|
|
403
|
-
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
x({
|
|
407
|
-
currentNode: this.currentNode,
|
|
408
|
-
documentModifier: e,
|
|
409
|
-
products: t
|
|
410
|
-
}) || U({
|
|
411
|
-
currentNode: this.currentNode,
|
|
412
|
-
documentModifier: e,
|
|
413
|
-
products: t
|
|
414
|
-
});
|
|
403
|
+
const n = parseInt(o);
|
|
404
|
+
return Number.isNaN(n) ? null : n;
|
|
415
405
|
}
|
|
416
406
|
/**
|
|
417
407
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -428,54 +418,54 @@ class at extends N {
|
|
|
428
418
|
*/
|
|
429
419
|
_listenStateUpdates() {
|
|
430
420
|
const { store: t } = this;
|
|
431
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
421
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
|
|
432
422
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
433
423
|
const s = t.currentRecommendationId;
|
|
434
|
-
if (s !==
|
|
435
|
-
|
|
424
|
+
if (s !== n) {
|
|
425
|
+
n = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
436
426
|
return;
|
|
437
427
|
}
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
const
|
|
441
|
-
|
|
428
|
+
const r = t.$state.configVersion;
|
|
429
|
+
r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
|
|
430
|
+
const l = t.recommendationProducts, d = l !== e, m = Array.isArray(l) && l.length > 0;
|
|
431
|
+
d && m && (e = l, this._debouncedRegenerateWithProducts());
|
|
442
432
|
});
|
|
443
433
|
}
|
|
444
434
|
}
|
|
445
435
|
export {
|
|
446
|
-
|
|
447
|
-
|
|
436
|
+
ut as ALGORITHM_CONTROL_ID,
|
|
437
|
+
T as AlgorithmControl,
|
|
448
438
|
W as CONTROL_BLOCK_ID,
|
|
449
439
|
gt as CURRENCY_CONTROL_ID,
|
|
450
|
-
|
|
440
|
+
P as CurrencyControl,
|
|
451
441
|
ft as FILTERS_CONTROL_ID,
|
|
452
442
|
S as FiltersControl,
|
|
453
443
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
454
444
|
yt as LOCALE_CONTROL_ID,
|
|
455
445
|
O as LayoutOrientationControl,
|
|
456
|
-
|
|
446
|
+
L as LocaleControl,
|
|
457
447
|
_t as PRICE_PLACEMENT_CONTROL_ID,
|
|
458
448
|
Rt as PRODUCT_COUNT_CONTROL_ID,
|
|
459
|
-
|
|
460
|
-
|
|
449
|
+
Tt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
450
|
+
k as PricePlacementControl,
|
|
461
451
|
E as ProductCountControl,
|
|
462
452
|
F as ProductLayoutControl,
|
|
463
453
|
at as RecommendationBlockControl,
|
|
464
454
|
St as SHUFFLE_CONTROL_ID,
|
|
465
|
-
|
|
455
|
+
Lt as STRATEGY_CONTROL_ID,
|
|
466
456
|
D as ShuffleControl,
|
|
467
|
-
|
|
457
|
+
w as StrategyControl,
|
|
468
458
|
Et as adjustProductsToSize,
|
|
469
459
|
Ft as formatProductPrice,
|
|
470
460
|
A as getBlockElement,
|
|
471
461
|
Dt as getCardComposition,
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
462
|
+
wt as getCurrentLayout,
|
|
463
|
+
vt as getMainContainerTbody,
|
|
464
|
+
B as isPartnerManagedBlock,
|
|
475
465
|
At as regenerateMobileProductRows,
|
|
476
466
|
U as regenerateProductRowsWithStyles,
|
|
477
|
-
|
|
478
|
-
|
|
467
|
+
v as setCurrencyAttributes,
|
|
468
|
+
Bt as updatePricesInPlace,
|
|
479
469
|
x as updateProductContentInPlace,
|
|
480
470
|
xt as updateSingleProductContent
|
|
481
471
|
};
|
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (
|
|
4
|
-
import { useLegacyStrategyConversion as
|
|
5
|
-
import { ACADEMY_LINKS as
|
|
6
|
-
import { useOnboardingStore as
|
|
7
|
-
import { CommonControl as
|
|
8
|
-
import { RRS_CONFIG_VERSION as
|
|
9
|
-
import { RecommendationConfigService as
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
const
|
|
12
|
-
class
|
|
1
|
+
var w = Object.defineProperty;
|
|
2
|
+
var N = (l, o, t) => o in l ? w(l, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[o] = t;
|
|
3
|
+
var i = (l, o, t) => N(l, typeof o != "symbol" ? o + "" : o, t);
|
|
4
|
+
import { useLegacyStrategyConversion as L } from "../../../../../composables/useLegacyStrategyConversion.js";
|
|
5
|
+
import { ACADEMY_LINKS as $ } from "../../../../../enums/academy.js";
|
|
6
|
+
import { useOnboardingStore as A } from "../../../../../stores/onboarding.js";
|
|
7
|
+
import { CommonControl as R } from "../../../common-control.js";
|
|
8
|
+
import { RRS_CONFIG_VERSION as E } from "../../constants/defaultConfig.js";
|
|
9
|
+
import { RecommendationConfigService as C } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as O } from "../../store/recommendation.js";
|
|
11
|
+
const I = "recommendation-strategy-control";
|
|
12
|
+
class P extends R {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
|
-
i(this, "store",
|
|
16
|
-
i(this, "onboardingStore",
|
|
17
|
-
i(this, "legacyConversion",
|
|
15
|
+
i(this, "store", O());
|
|
16
|
+
i(this, "onboardingStore", A());
|
|
17
|
+
i(this, "legacyConversion", L());
|
|
18
18
|
i(this, "storeUnsubscription", () => {
|
|
19
19
|
});
|
|
20
20
|
i(this, "listeners", []);
|
|
21
21
|
i(this, "lastPaintedState", null);
|
|
22
22
|
}
|
|
23
23
|
getId() {
|
|
24
|
-
return
|
|
24
|
+
return I;
|
|
25
25
|
}
|
|
26
26
|
getTemplate() {
|
|
27
27
|
const t = this.api.translate(
|
|
28
28
|
"You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
|
|
29
|
-
), e = this.api.translate("For more information, you can"),
|
|
29
|
+
), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy"), r = this.api.translate("Legacy Strategy"), s = this.api.translate(
|
|
30
30
|
"Note that this is an older version of the Recommendation Strategy. We recommend you update it to the new Recommendation Strategy for an improved experience."
|
|
31
|
+
), g = this.api.translate(
|
|
32
|
+
"The recommendation strategy used in the recommendation block is no longer available. You can assign a different strategy to it."
|
|
31
33
|
);
|
|
32
34
|
return `
|
|
33
35
|
<div class="strategy-control-container">
|
|
@@ -52,9 +54,9 @@ class M extends A {
|
|
|
52
54
|
${t}
|
|
53
55
|
${e}
|
|
54
56
|
<a
|
|
55
|
-
href="${
|
|
57
|
+
href="${$.EMAIL_RECOMMENDATION_BLOCK}"
|
|
56
58
|
target="_blank"
|
|
57
|
-
rel="noopener noreferrer">${
|
|
59
|
+
rel="noopener noreferrer">${a}</a>.
|
|
58
60
|
</p>
|
|
59
61
|
</div>
|
|
60
62
|
<div data-strategy-empty-state style="display: none;">
|
|
@@ -71,16 +73,37 @@ class M extends A {
|
|
|
71
73
|
id: "guido__btn-create-strategy",
|
|
72
74
|
className: "strategy-control-cta primary"
|
|
73
75
|
})
|
|
76
|
+
], "strategy-control-cta-row")}
|
|
77
|
+
</div>
|
|
78
|
+
<div data-strategy-unavailable-state style="display: none;">
|
|
79
|
+
<div class="strategy-control-notice-row">
|
|
80
|
+
<div class="strategy-control-notice strategy-control-notice--error" role="alert">
|
|
81
|
+
<p class="strategy-control-notice-text">${g}</p>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
${this._GuTwoColumns([
|
|
85
|
+
this._GuButton({
|
|
86
|
+
name: "assignUnavailableStrategy",
|
|
87
|
+
label: this.api.translate("Assign Strategy"),
|
|
88
|
+
id: "guido__btn-assign-unavailable-strategy",
|
|
89
|
+
className: "strategy-control-cta on"
|
|
90
|
+
}),
|
|
91
|
+
this._GuButton({
|
|
92
|
+
name: "createUnavailableStrategy",
|
|
93
|
+
label: this.api.translate("Create New Strategy"),
|
|
94
|
+
id: "guido__btn-create-unavailable-strategy",
|
|
95
|
+
className: "strategy-control-cta primary"
|
|
96
|
+
})
|
|
74
97
|
], "strategy-control-cta-row")}
|
|
75
98
|
</div>
|
|
76
99
|
<div data-strategy-legacy-state style="display: none;">
|
|
77
100
|
<div class="strategy-control-notice-row">
|
|
78
101
|
<div class="strategy-control-notice">
|
|
79
|
-
<p class="strategy-control-notice-text">${
|
|
102
|
+
<p class="strategy-control-notice-text">${s}</p>
|
|
80
103
|
</div>
|
|
81
104
|
</div>
|
|
82
105
|
<div class="strategy-control-name-band">
|
|
83
|
-
<span class="strategy-control-name">${
|
|
106
|
+
<span class="strategy-control-name">${r}</span>
|
|
84
107
|
${this._strategyAction({
|
|
85
108
|
id: "guido__btn-update-legacy-strategy",
|
|
86
109
|
label: this.api.translate("Update"),
|
|
@@ -123,12 +146,12 @@ class M extends A {
|
|
|
123
146
|
</div>
|
|
124
147
|
`;
|
|
125
148
|
}
|
|
126
|
-
_strategyAction({ id: t, label: e, modifier:
|
|
149
|
+
_strategyAction({ id: t, label: e, modifier: a }) {
|
|
127
150
|
return `
|
|
128
151
|
<button
|
|
129
152
|
id="${t}"
|
|
130
153
|
type="button"
|
|
131
|
-
class="strategy-control-action strategy-control-action--${
|
|
154
|
+
class="strategy-control-action strategy-control-action--${a}">
|
|
132
155
|
<span>${e}</span>
|
|
133
156
|
</button>
|
|
134
157
|
`;
|
|
@@ -136,8 +159,8 @@ class M extends A {
|
|
|
136
159
|
onRender() {
|
|
137
160
|
this._teardown(), this.store.strategyPanelOpen = !0, this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
|
|
138
161
|
this._renderState();
|
|
139
|
-
}), this.store.recommendationConfigs.strategyId && !this.store.
|
|
140
|
-
});
|
|
162
|
+
}), this.store.recommendationConfigs.strategyId && !this.store.strategiesLoading && (this.store.invalidateStrategies(), this.store.fetchStrategies().catch(() => {
|
|
163
|
+
}));
|
|
141
164
|
}
|
|
142
165
|
/**
|
|
143
166
|
* Whether the document itself says this block has no strategy.
|
|
@@ -147,10 +170,10 @@ class M extends A {
|
|
|
147
170
|
* strategyId) for an assigned block.
|
|
148
171
|
*/
|
|
149
172
|
_isNodeUnassigned() {
|
|
150
|
-
if (!
|
|
173
|
+
if (!C.hasConfig(this.currentNode))
|
|
151
174
|
return !1;
|
|
152
|
-
const t =
|
|
153
|
-
return !t.strategyId && (t.configVersion ?? 0) >=
|
|
175
|
+
const t = C.getConfig(this.currentNode);
|
|
176
|
+
return !t.strategyId && (t.configVersion ?? 0) >= E;
|
|
154
177
|
}
|
|
155
178
|
onDestroy() {
|
|
156
179
|
this._teardown();
|
|
@@ -163,37 +186,37 @@ class M extends A {
|
|
|
163
186
|
const t = this.getContainer();
|
|
164
187
|
if (!t)
|
|
165
188
|
return;
|
|
166
|
-
const e = (
|
|
167
|
-
const
|
|
168
|
-
|
|
189
|
+
const e = (a, r) => {
|
|
190
|
+
const s = t.querySelector(a);
|
|
191
|
+
s && (s.addEventListener("click", r), this.listeners.push({ element: s, handler: r }));
|
|
169
192
|
};
|
|
170
|
-
e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-strategy", () => this.store.openStrategyCreation()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-legacy-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-remove-legacy-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-update-legacy-strategy", () => {
|
|
193
|
+
e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-strategy", () => this.store.openStrategyCreation()), e("#guido__btn-assign-unavailable-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-unavailable-strategy", () => this.store.openStrategyCreation()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-legacy-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-remove-legacy-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-update-legacy-strategy", () => {
|
|
171
194
|
this.legacyConversion.convertLegacyStrategy();
|
|
172
195
|
});
|
|
173
196
|
}
|
|
174
197
|
_renderState() {
|
|
175
|
-
var
|
|
176
|
-
const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((
|
|
177
|
-
if (
|
|
198
|
+
var f;
|
|
199
|
+
const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((f = this.store.assignedStrategy) == null ? void 0 : f.name) ?? "" : "", a = !!t && !e && (this.store.strategiesLoading || !this.store.strategiesSettled), r = !!t && !e && !a && this.store.strategiesFetched, s = this.store.legacyConversionLoading, g = this.store.isLegacyStrategyBlock, p = [t, e, a, r, s, g].join("\0");
|
|
200
|
+
if (p === this.lastPaintedState)
|
|
178
201
|
return;
|
|
179
|
-
const
|
|
180
|
-
if (!
|
|
202
|
+
const n = this.getContainer();
|
|
203
|
+
if (!n)
|
|
181
204
|
return;
|
|
182
|
-
const
|
|
183
|
-
if (!
|
|
205
|
+
const y = n.querySelector("[data-strategy-empty-state]"), u = n.querySelector("[data-strategy-assigned-state]"), c = n.querySelector("[data-strategy-legacy-state]"), h = n.querySelector("[data-strategy-unavailable-state]"), v = n.querySelector("[data-strategy-loading-state]"), b = n.querySelector("[data-strategy-content]"), m = n.querySelector("[data-strategy-name]"), _ = n.querySelector("[data-strategy-name-skeleton]");
|
|
206
|
+
if (!y || !u || !c || !h)
|
|
184
207
|
return;
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
[
|
|
188
|
-
|
|
189
|
-
}),
|
|
190
|
-
|
|
191
|
-
}),
|
|
208
|
+
v && (v.style.display = "none"), b && (b.style.display = "");
|
|
209
|
+
const k = t ? r ? h : u : g ? c : y;
|
|
210
|
+
[y, u, c, h].forEach((d) => {
|
|
211
|
+
d.style.display = d === k ? "" : "none";
|
|
212
|
+
}), c.querySelectorAll("button").forEach((d) => {
|
|
213
|
+
d.disabled = s;
|
|
214
|
+
}), c.classList.toggle("is-converting", s), !t && this._isNodeUnassigned() && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding");
|
|
192
215
|
const S = this.store.currentRecommendationId;
|
|
193
|
-
|
|
216
|
+
g && S !== null && this.store.blockStates[S] && this.onboardingStore.startOnboarding("recommendationLegacyStrategyOnboarding"), m && (m.style.display = a ? "none" : "", t && !a && (m.textContent = e || `#${t}`)), _ && (_.style.display = a ? "block" : "none"), this.lastPaintedState = p;
|
|
194
217
|
}
|
|
195
218
|
}
|
|
196
219
|
export {
|
|
197
|
-
|
|
198
|
-
|
|
220
|
+
I as STRATEGY_CONTROL_ID,
|
|
221
|
+
P as StrategyControl
|
|
199
222
|
};
|