@useinsider/guido 3.18.2-beta.45f708c → 3.18.2-beta.4d2b065
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 +21 -3
- package/dist/@types/config/schemas.js +59 -51
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +72 -70
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -9
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +51 -66
- 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.vue2.js +40 -24
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -26
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +3 -3
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +20 -21
- package/dist/composables/useCustomInterfaceAppearance.js +47 -53
- package/dist/composables/useHtmlValidator.js +79 -84
- package/dist/composables/useLegacyStrategyConversion.js +61 -0
- package/dist/composables/useRecommendation.js +35 -40
- package/dist/composables/useStripo.js +30 -30
- package/dist/enums/extensions/recommendationBlock.js +41 -39
- package/dist/extensions/Blocks/Recommendation/block.js +39 -43
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +20 -21
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +80 -84
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +94 -82
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +97 -96
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +144 -179
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +16 -26
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +12 -21
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +46 -37
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +5 -3
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +1 -8
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +6 -7
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +70 -76
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +0 -4
- package/dist/src/services/recommendationApi.d.ts +2 -1
- package/dist/src/stores/config.d.ts +322 -0
- package/dist/src/stores/onboarding.d.ts +421 -0
- package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
- package/dist/static/assets/icons/line-info.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +74 -39
- package/dist/stores/config.js +74 -60
- package/dist/stores/onboarding.js +6 -1
- package/dist/utils/templatePreparation.js +55 -55
- package/package.json +5 -5
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +0 -24
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +0 -14
- package/dist/static/styles/components/skeleton.css.js +0 -23
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var C = (g,
|
|
3
|
-
var
|
|
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
4
|
import { useConfig as p } 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
|
-
import {
|
|
7
|
+
import { CURRENT_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
12
|
import { AlgorithmControl as T } from "./algorithm.js";
|
|
@@ -14,7 +14,7 @@ import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
|
|
|
14
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
|
-
import { FILTERS_CONTROL_ID as
|
|
17
|
+
import { FILTERS_CONTROL_ID as ht } 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
20
|
import { LocaleControl as L } from "./locale.js";
|
|
@@ -29,36 +29,36 @@ import { ShuffleControl as D } from "./shuffle.js";
|
|
|
29
29
|
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
30
|
import { StrategyControl as w } from "./strategy.js";
|
|
31
31
|
import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
|
|
32
|
-
import { setCurrencyAttributes as A, getBlockElement as
|
|
33
|
-
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as
|
|
34
|
-
import { useDebounceFn as
|
|
35
|
-
const
|
|
32
|
+
import { setCurrencyAttributes as A, getBlockElement as B, isPartnerManagedBlock as v, 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 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
36
|
class at extends N {
|
|
37
37
|
constructor() {
|
|
38
38
|
super(...arguments);
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
r(this, "store", R());
|
|
40
|
+
r(this, "storeUnsubscription", () => {
|
|
41
41
|
});
|
|
42
42
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
43
43
|
// re-render's single apply() — one user action must cost one undo press.
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
r(this, "pendingNodeConfigWrite", null);
|
|
45
|
+
r(this, "pendingConfigFlushTimer", null);
|
|
46
46
|
// Sub-control instances for lifecycle management
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
r(this, "algorithmControl", null);
|
|
48
|
+
r(this, "localeControl", null);
|
|
49
|
+
r(this, "currencyControl", null);
|
|
50
|
+
r(this, "productCountControl", null);
|
|
51
|
+
r(this, "productLayoutControl", null);
|
|
52
|
+
r(this, "filtersControl", null);
|
|
53
|
+
r(this, "shuffleControl", null);
|
|
54
|
+
r(this, "pricePlacementControl", null);
|
|
55
|
+
r(this, "layoutOrientationControl", null);
|
|
56
|
+
r(this, "strategyControl", null);
|
|
57
|
+
r(this, "rrsEnabled", !1);
|
|
58
58
|
/**
|
|
59
59
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
60
60
|
*/
|
|
61
|
-
|
|
61
|
+
r(this, "_debouncedFetchProducts", f(async () => {
|
|
62
62
|
try {
|
|
63
63
|
await this.store.fetchRecommendationProducts();
|
|
64
64
|
} finally {
|
|
@@ -76,16 +76,16 @@ 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
|
-
|
|
79
|
+
r(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
80
80
|
const t = this.store.recommendationProducts;
|
|
81
81
|
if (!this.currentNode || !this.api)
|
|
82
82
|
return;
|
|
83
83
|
const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
84
|
-
if (
|
|
84
|
+
if (v(this.currentNode)) {
|
|
85
85
|
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
x({
|
|
89
89
|
currentNode: this.currentNode,
|
|
90
90
|
documentModifier: e,
|
|
91
91
|
products: t
|
|
@@ -97,7 +97,7 @@ class at extends N {
|
|
|
97
97
|
}, 100));
|
|
98
98
|
}
|
|
99
99
|
getId() {
|
|
100
|
-
return
|
|
100
|
+
return $;
|
|
101
101
|
}
|
|
102
102
|
get _subControls() {
|
|
103
103
|
return [
|
|
@@ -140,14 +140,14 @@ class at extends N {
|
|
|
140
140
|
const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
|
|
141
141
|
if (!e)
|
|
142
142
|
return;
|
|
143
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null :
|
|
144
|
-
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);
|
|
145
145
|
}
|
|
146
146
|
async onRender() {
|
|
147
147
|
var o;
|
|
148
148
|
b(this.api);
|
|
149
149
|
const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
|
|
150
|
-
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode),
|
|
150
|
+
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)) {
|
|
151
151
|
this._initializeSubControls();
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
@@ -159,9 +159,9 @@ class at extends N {
|
|
|
159
159
|
const e = this._getRecommendationIdFromNode(t);
|
|
160
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(() => {
|
|
161
161
|
this._initializeSubControls();
|
|
162
|
-
}), this._subControls.forEach((
|
|
163
|
-
var
|
|
164
|
-
|
|
162
|
+
}), this._subControls.forEach((n) => {
|
|
163
|
+
var s;
|
|
164
|
+
n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
onDestroy() {
|
|
@@ -209,23 +209,18 @@ class at extends N {
|
|
|
209
209
|
const e = this.store.blockStates[t];
|
|
210
210
|
if (!e)
|
|
211
211
|
return;
|
|
212
|
-
const o = JSON.stringify(
|
|
213
|
-
e.syncedConfigFingerprint = o,
|
|
214
|
-
}
|
|
215
|
-
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
216
|
-
_isPendingStrategyIdChange() {
|
|
217
|
-
const t = this.pendingNodeConfigWrite;
|
|
218
|
-
return t ? l.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
|
|
212
|
+
const o = JSON.stringify(c.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
|
|
213
|
+
e.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
219
214
|
}
|
|
220
215
|
_capturePendingNodeConfigWrite() {
|
|
221
216
|
const t = this.store.currentRecommendationId;
|
|
222
217
|
if (!this.currentNode || !this.api || t === null)
|
|
223
218
|
return;
|
|
224
|
-
const { filters: e,
|
|
219
|
+
const { filters: e, strategyId: o, size: n, nodeConfigVersion: s } = this.store.recommendationConfigs;
|
|
225
220
|
this.pendingNodeConfigWrite = {
|
|
226
221
|
blockId: t,
|
|
227
222
|
node: this.currentNode,
|
|
228
|
-
updates: { filters: e,
|
|
223
|
+
updates: { filters: e, strategyId: o, size: n, configVersion: s }
|
|
229
224
|
};
|
|
230
225
|
}
|
|
231
226
|
/**
|
|
@@ -240,7 +235,7 @@ class at extends N {
|
|
|
240
235
|
*/
|
|
241
236
|
_stagePendingNodeConfig(t) {
|
|
242
237
|
const e = this.pendingNodeConfigWrite;
|
|
243
|
-
return !e || !this.currentNode ? !1 : (
|
|
238
|
+
return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
|
|
244
239
|
}
|
|
245
240
|
/**
|
|
246
241
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -264,15 +259,16 @@ class at extends N {
|
|
|
264
259
|
const t = this.pendingNodeConfigWrite;
|
|
265
260
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
266
261
|
return;
|
|
267
|
-
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o =
|
|
268
|
-
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.
|
|
262
|
+
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
|
|
263
|
+
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");
|
|
269
264
|
}
|
|
270
265
|
_syncNodeConfigToStore() {
|
|
271
|
-
var
|
|
272
|
-
const t =
|
|
266
|
+
var n;
|
|
267
|
+
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
|
|
273
268
|
this.store.patchCurrentBlockConfig({
|
|
274
269
|
strategy: t.strategy,
|
|
275
270
|
strategyId: t.strategyId,
|
|
271
|
+
nodeConfigVersion: t.configVersion,
|
|
276
272
|
language: t.language,
|
|
277
273
|
size: t.size,
|
|
278
274
|
productIds: t.productIds,
|
|
@@ -311,8 +307,8 @@ class at extends N {
|
|
|
311
307
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
312
308
|
this.store.fetchRecommendationCreateData(),
|
|
313
309
|
this.store.fetchRecommendationFilters()
|
|
314
|
-
])).forEach((o,
|
|
315
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
310
|
+
])).forEach((o, n) => {
|
|
311
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
|
|
316
312
|
}), this._applySmartDefaults();
|
|
317
313
|
try {
|
|
318
314
|
await this.store.fetchRecommendationProducts();
|
|
@@ -333,31 +329,31 @@ class at extends N {
|
|
|
333
329
|
_applySmartDefaults() {
|
|
334
330
|
if (!this.currentNode || !this.api)
|
|
335
331
|
return;
|
|
336
|
-
const t =
|
|
337
|
-
let o = null,
|
|
332
|
+
const t = c.getConfig(this.currentNode), e = {};
|
|
333
|
+
let o = null, n = null, s = null;
|
|
338
334
|
if (t.currency.code === a.currency.code) {
|
|
339
|
-
const { currencyList:
|
|
340
|
-
|
|
335
|
+
const { currencyList: i } = this.store;
|
|
336
|
+
i.length > 0 && (i.some(
|
|
341
337
|
(d) => d.value === `price.${a.currency.code}`
|
|
342
|
-
) || (o =
|
|
338
|
+
) || (o = i[0].value.replace("price.", ""), e.currency = {
|
|
343
339
|
...a.currency,
|
|
344
340
|
code: o,
|
|
345
341
|
symbol: o
|
|
346
342
|
}));
|
|
347
343
|
}
|
|
348
344
|
if (t.strategy === a.strategy) {
|
|
349
|
-
const
|
|
350
|
-
|
|
345
|
+
const i = this.store.getActivePredictiveAlgorithms;
|
|
346
|
+
i.length > 0 && (i.some(
|
|
351
347
|
(d) => d.value === a.strategy
|
|
352
|
-
) || (
|
|
348
|
+
) || (n = i[0].value, e.strategy = n));
|
|
353
349
|
}
|
|
354
350
|
if (t.language === a.language) {
|
|
355
|
-
const
|
|
356
|
-
|
|
351
|
+
const i = this.store.getLanguages;
|
|
352
|
+
i.length > 0 && (i.some(
|
|
357
353
|
(d) => d.value === a.language
|
|
358
|
-
) || (
|
|
354
|
+
) || (s = i[0].value, e.language = s));
|
|
359
355
|
}
|
|
360
|
-
!o && !
|
|
356
|
+
!o && !n && !s || (c.updateConfig(
|
|
361
357
|
this.api,
|
|
362
358
|
this.currentNode,
|
|
363
359
|
e,
|
|
@@ -378,22 +374,22 @@ class at extends N {
|
|
|
378
374
|
thousandSeparator: a.currency.thousandSeparator
|
|
379
375
|
}
|
|
380
376
|
} : {},
|
|
381
|
-
...
|
|
382
|
-
...
|
|
377
|
+
...n ? { strategy: n } : {},
|
|
378
|
+
...s ? { language: s } : {}
|
|
383
379
|
}, { triggerRefetch: !1 }));
|
|
384
380
|
}
|
|
385
381
|
/**
|
|
386
382
|
* Reads the recommendation-id attribute from the block element within the node
|
|
387
383
|
*/
|
|
388
384
|
_getRecommendationIdFromNode(t) {
|
|
389
|
-
const e =
|
|
385
|
+
const e = B(t);
|
|
390
386
|
if (!e || !("getAttribute" in e))
|
|
391
387
|
return null;
|
|
392
388
|
const o = e.getAttribute(I);
|
|
393
389
|
if (!o)
|
|
394
390
|
return null;
|
|
395
|
-
const
|
|
396
|
-
return Number.isNaN(
|
|
391
|
+
const n = parseInt(o);
|
|
392
|
+
return Number.isNaN(n) ? null : n;
|
|
397
393
|
}
|
|
398
394
|
/**
|
|
399
395
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -410,27 +406,27 @@ class at extends N {
|
|
|
410
406
|
*/
|
|
411
407
|
_listenStateUpdates() {
|
|
412
408
|
const { store: t } = this;
|
|
413
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
409
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
|
|
414
410
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
415
|
-
const
|
|
416
|
-
if (
|
|
417
|
-
|
|
411
|
+
const s = t.currentRecommendationId;
|
|
412
|
+
if (s !== n) {
|
|
413
|
+
n = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
418
414
|
return;
|
|
419
415
|
}
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
const u = t.recommendationProducts, d = u !== e,
|
|
423
|
-
d &&
|
|
416
|
+
const i = t.$state.configVersion;
|
|
417
|
+
i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
|
|
418
|
+
const u = t.recommendationProducts, d = u !== e, h = Array.isArray(u) && u.length > 0;
|
|
419
|
+
d && h && (e = u, this._debouncedRegenerateWithProducts());
|
|
424
420
|
});
|
|
425
421
|
}
|
|
426
422
|
}
|
|
427
423
|
export {
|
|
428
424
|
ut as ALGORITHM_CONTROL_ID,
|
|
429
425
|
T as AlgorithmControl,
|
|
430
|
-
|
|
426
|
+
$ as CONTROL_BLOCK_ID,
|
|
431
427
|
gt as CURRENCY_CONTROL_ID,
|
|
432
428
|
P as CurrencyControl,
|
|
433
|
-
|
|
429
|
+
ht as FILTERS_CONTROL_ID,
|
|
434
430
|
S as FiltersControl,
|
|
435
431
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
436
432
|
yt as LOCALE_CONTROL_ID,
|
|
@@ -449,15 +445,15 @@ export {
|
|
|
449
445
|
w as StrategyControl,
|
|
450
446
|
Et as adjustProductsToSize,
|
|
451
447
|
Ft as formatProductPrice,
|
|
452
|
-
|
|
448
|
+
B as getBlockElement,
|
|
453
449
|
Dt as getCardComposition,
|
|
454
450
|
wt as getCurrentLayout,
|
|
455
451
|
At as getMainContainerTbody,
|
|
456
|
-
|
|
457
|
-
|
|
452
|
+
v as isPartnerManagedBlock,
|
|
453
|
+
Bt as regenerateMobileProductRows,
|
|
458
454
|
U as regenerateProductRowsWithStyles,
|
|
459
455
|
A as setCurrencyAttributes,
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
456
|
+
vt as updatePricesInPlace,
|
|
457
|
+
x as updateProductContentInPlace,
|
|
458
|
+
xt as updateSingleProductContent
|
|
463
459
|
};
|
|
@@ -1,60 +1,49 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var r = (
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class I extends v {
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var v = (i, s, t) => s in i ? p(i, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[s] = t;
|
|
3
|
+
var r = (i, s, t) => v(i, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
+
import { useLegacyStrategyConversion as _ } from "../../../../../composables/useLegacyStrategyConversion.js";
|
|
5
|
+
import { ACADEMY_LINKS as b } from "../../../../../enums/academy.js";
|
|
6
|
+
import { useOnboardingStore as S } from "../../../../../stores/onboarding.js";
|
|
7
|
+
import { CommonControl as f } from "../../../common-control.js";
|
|
8
|
+
import { useRecommendationExtensionStore as $ } from "../../store/recommendation.js";
|
|
9
|
+
const C = "recommendation-strategy-control";
|
|
10
|
+
class N extends f {
|
|
12
11
|
constructor() {
|
|
13
12
|
super(...arguments);
|
|
14
|
-
r(this, "store",
|
|
15
|
-
r(this, "onboardingStore",
|
|
13
|
+
r(this, "store", $());
|
|
14
|
+
r(this, "onboardingStore", S());
|
|
15
|
+
r(this, "legacyConversion", _());
|
|
16
16
|
r(this, "storeUnsubscription", () => {
|
|
17
17
|
});
|
|
18
18
|
r(this, "listeners", []);
|
|
19
19
|
r(this, "lastPaintedState", null);
|
|
20
20
|
}
|
|
21
21
|
getId() {
|
|
22
|
-
return
|
|
22
|
+
return C;
|
|
23
23
|
}
|
|
24
24
|
getTemplate() {
|
|
25
25
|
const t = this.api.translate(
|
|
26
26
|
"You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
|
|
27
|
-
), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy")
|
|
27
|
+
), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy"), o = this.api.translate("Legacy Strategy"), n = this.api.translate(
|
|
28
|
+
"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."
|
|
29
|
+
);
|
|
28
30
|
return `
|
|
29
31
|
<div class="strategy-control-container">
|
|
30
|
-
<div
|
|
31
|
-
<
|
|
32
|
-
<span class="guido-skeleton guido-skeleton--strategy-title"></span>
|
|
33
|
-
</div>
|
|
34
|
-
<div class="strategy-control-description-row">
|
|
35
|
-
<span class="guido-skeleton guido-skeleton--strategy-description"></span>
|
|
36
|
-
</div>
|
|
37
|
-
<div class="strategy-control-skeleton-row">
|
|
38
|
-
<span class="guido-skeleton guido-skeleton--strategy-cta"></span>
|
|
39
|
-
<span class="guido-skeleton guido-skeleton--strategy-cta"></span>
|
|
40
|
-
</div>
|
|
32
|
+
<div class="strategy-control-header">
|
|
33
|
+
<h3 class="strategy-control-title">${this.api.translate("Recommendation Strategy")}</h3>
|
|
41
34
|
</div>
|
|
42
|
-
<div
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
</p>
|
|
55
|
-
</div>
|
|
56
|
-
<div data-strategy-empty-state style="display: none;">
|
|
57
|
-
${this._GuTwoColumns([
|
|
35
|
+
<div class="strategy-control-description-row">
|
|
36
|
+
<p class="strategy-control-description">
|
|
37
|
+
${t}
|
|
38
|
+
${e}
|
|
39
|
+
<a
|
|
40
|
+
href="${b.EMAIL_RECOMMENDATION_BLOCK}"
|
|
41
|
+
target="_blank"
|
|
42
|
+
rel="noopener noreferrer">${a}</a>.
|
|
43
|
+
</p>
|
|
44
|
+
</div>
|
|
45
|
+
<div data-strategy-empty-state>
|
|
46
|
+
${this._GuTwoColumns([
|
|
58
47
|
this._GuButton({
|
|
59
48
|
name: "assignStrategy",
|
|
60
49
|
label: this.api.translate("Assign Strategy"),
|
|
@@ -65,28 +54,53 @@ class I extends v {
|
|
|
65
54
|
name: "createStrategy",
|
|
66
55
|
label: this.api.translate("Create New Strategy"),
|
|
67
56
|
id: "guido__btn-create-strategy",
|
|
68
|
-
className: "strategy-control-cta primary"
|
|
57
|
+
className: "strategy-control-cta primary",
|
|
58
|
+
disabled: !0
|
|
69
59
|
})
|
|
70
60
|
], "strategy-control-cta-row")}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
-
class="guido-skeleton guido-skeleton--strategy-name" data-strategy-name-skeleton></span>
|
|
61
|
+
</div>
|
|
62
|
+
<div data-strategy-legacy-state style="display: none;">
|
|
63
|
+
<div class="strategy-control-notice-row">
|
|
64
|
+
<div class="strategy-control-notice">
|
|
65
|
+
<p class="strategy-control-notice-text">${n}</p>
|
|
77
66
|
</div>
|
|
78
|
-
|
|
79
|
-
|
|
67
|
+
</div>
|
|
68
|
+
<div class="strategy-control-name-band">
|
|
69
|
+
<span class="strategy-control-name">${o}</span>
|
|
70
|
+
${this._strategyAction({
|
|
71
|
+
id: "guido__btn-update-legacy-strategy",
|
|
72
|
+
label: this.api.translate("Update"),
|
|
73
|
+
modifier: "update"
|
|
74
|
+
})}
|
|
75
|
+
</div>
|
|
76
|
+
<div class="strategy-control-actions">
|
|
77
|
+
${this._strategyAction({
|
|
78
|
+
id: "guido__btn-change-legacy-strategy",
|
|
79
|
+
label: this.api.translate("Change"),
|
|
80
|
+
modifier: "change"
|
|
81
|
+
})}
|
|
82
|
+
${this._strategyAction({
|
|
83
|
+
id: "guido__btn-remove-legacy-strategy",
|
|
84
|
+
label: this.api.translate("Remove"),
|
|
85
|
+
modifier: "remove"
|
|
86
|
+
})}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
<div data-strategy-assigned-state style="display: none;">
|
|
90
|
+
<div class="strategy-control-name-band">
|
|
91
|
+
<span class="strategy-control-name" data-strategy-name></span>
|
|
92
|
+
</div>
|
|
93
|
+
<div class="strategy-control-actions">
|
|
94
|
+
${this._strategyAction({
|
|
80
95
|
id: "guido__btn-change-strategy",
|
|
81
96
|
label: this.api.translate("Change"),
|
|
82
97
|
modifier: "change"
|
|
83
98
|
})}
|
|
84
|
-
|
|
99
|
+
${this._strategyAction({
|
|
85
100
|
id: "guido__btn-remove-strategy",
|
|
86
101
|
label: this.api.translate("Remove"),
|
|
87
102
|
modifier: "remove"
|
|
88
103
|
})}
|
|
89
|
-
</div>
|
|
90
104
|
</div>
|
|
91
105
|
</div>
|
|
92
106
|
</div>
|
|
@@ -103,54 +117,52 @@ class I extends v {
|
|
|
103
117
|
`;
|
|
104
118
|
}
|
|
105
119
|
onRender() {
|
|
106
|
-
this._teardown(), this.
|
|
120
|
+
this._teardown(), this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
|
|
107
121
|
this._renderState();
|
|
108
|
-
}), this.store.recommendationConfigs.strategyId && !this.store.
|
|
122
|
+
}), this.store.recommendationConfigs.strategyId && !this.store.strategies.length && this.store.fetchStrategies().catch(() => {
|
|
109
123
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
* Whether the document itself says this block has no strategy.
|
|
113
|
-
*
|
|
114
|
-
* Read the node, not the store: when the main control cannot resolve the block id off the
|
|
115
|
-
* node it never syncs the persisted config, so the store still holds defaults (empty
|
|
116
|
-
* strategyId) for an assigned block.
|
|
117
|
-
*/
|
|
118
|
-
_isNodeUnassigned() {
|
|
119
|
-
if (!h.hasConfig(this.currentNode))
|
|
120
|
-
return !1;
|
|
121
|
-
const t = h.getConfig(this.currentNode);
|
|
122
|
-
return !t.strategyId && (t.configVersion ?? 0) >= b;
|
|
124
|
+
const t = this.store.currentRecommendationId, e = t !== null && !!this.store.blockStates[t], a = this.store.isLegacyStrategyBlock;
|
|
125
|
+
e && !this.store.recommendationConfigs.strategyId && !a && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding"), e && a && this.onboardingStore.startOnboarding("recommendationLegacyStrategyOnboarding");
|
|
123
126
|
}
|
|
124
127
|
onDestroy() {
|
|
125
128
|
this._teardown();
|
|
126
129
|
}
|
|
127
130
|
_teardown() {
|
|
128
|
-
this.
|
|
131
|
+
this.storeUnsubscription(), this.storeUnsubscription = () => {
|
|
129
132
|
}, this.lastPaintedState = null, this.listeners.forEach(({ element: t, handler: e }) => t.removeEventListener("click", e)), this.listeners = [];
|
|
130
133
|
}
|
|
131
134
|
_setupButtonListeners() {
|
|
132
135
|
const t = this.getContainer();
|
|
133
136
|
if (!t)
|
|
134
137
|
return;
|
|
135
|
-
const e = (a,
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
+
const e = (a, o) => {
|
|
139
|
+
const n = t.querySelector(a);
|
|
140
|
+
n && (n.addEventListener("click", o), this.listeners.push({ element: n, handler: o }));
|
|
138
141
|
};
|
|
139
|
-
e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-
|
|
142
|
+
e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), 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", () => {
|
|
143
|
+
this.legacyConversion.convertLegacyStrategy();
|
|
144
|
+
});
|
|
140
145
|
}
|
|
141
146
|
_renderState() {
|
|
142
|
-
var
|
|
143
|
-
const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((
|
|
144
|
-
if (
|
|
147
|
+
var h;
|
|
148
|
+
const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((h = this.store.assignedStrategy) == null ? void 0 : h.name) ?? "" : "", a = this.store.legacyConversionLoading, o = this.store.isLegacyStrategyBlock, n = `${t}\0${e}\0${a}\0${o}`;
|
|
149
|
+
if (n === this.lastPaintedState)
|
|
150
|
+
return;
|
|
151
|
+
const c = this.getContainer();
|
|
152
|
+
if (!c)
|
|
145
153
|
return;
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
154
|
+
const d = c.querySelector("[data-strategy-empty-state]"), y = c.querySelector("[data-strategy-assigned-state]"), g = c.querySelector("[data-strategy-legacy-state]"), m = c.querySelector("[data-strategy-name]");
|
|
155
|
+
if (!d || !y || !g)
|
|
148
156
|
return;
|
|
149
|
-
const
|
|
150
|
-
|
|
157
|
+
const u = t ? y : o ? g : d;
|
|
158
|
+
[d, y, g].forEach((l) => {
|
|
159
|
+
l.style.display = l === u ? "" : "none";
|
|
160
|
+
}), g.querySelectorAll("button").forEach((l) => {
|
|
161
|
+
l.disabled = a;
|
|
162
|
+
}), g.classList.toggle("is-converting", a), m && t && (m.textContent = e || `#${t}`), this.lastPaintedState = n;
|
|
151
163
|
}
|
|
152
164
|
}
|
|
153
165
|
export {
|
|
154
|
-
|
|
155
|
-
|
|
166
|
+
C as STRATEGY_CONTROL_ID,
|
|
167
|
+
N as StrategyControl
|
|
156
168
|
};
|