@useinsider/guido 3.18.1 → 3.18.2-beta.32d291d
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 +55 -53
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -7
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +82 -57
- 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 +24 -22
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -24
- 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 +21 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +46 -0
- package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +34 -34
- package/dist/composables/useCustomInterfaceAppearance.js +46 -42
- package/dist/composables/useHttp.js +24 -22
- package/dist/composables/useLegacyStrategyConversion.js +61 -0
- package/dist/enums/extensions/recommendationBlock.js +40 -31
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +91 -84
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -28
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +45 -44
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +123 -58
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +7 -7
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +29 -28
- package/dist/package.json.js +1 -1
- package/dist/services/recommendationApi.js +46 -37
- package/dist/services/templateLibraryApi.js +17 -14
- 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/components/organisms/onboarding/RecommendationStrategyOnboarding.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 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +82 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
- 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 +808 -10
- package/dist/src/utils/genericUtil.d.ts +6 -0
- package/dist/src/utils/liquidDynamicContent.d.ts +20 -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 +70 -5
- package/dist/stores/config.js +74 -60
- package/dist/stores/onboarding.js +46 -36
- package/dist/utils/genericUtil.js +63 -54
- package/dist/utils/liquidDynamicContent.js +15 -0
- package/dist/utils/templatePreparation.js +54 -52
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var C = (
|
|
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";
|
|
@@ -12,55 +12,53 @@ import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
|
12
12
|
import { AlgorithmControl as T } from "./algorithm.js";
|
|
13
13
|
import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
|
|
14
14
|
import { CurrencyControl as P } from "./currency.js";
|
|
15
|
-
import { CURRENCY_CONTROL_ID as
|
|
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";
|
|
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
|
-
import { ProductCountControl as
|
|
24
|
+
import { ProductCountControl as E } from "./productCount.js";
|
|
25
25
|
import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
|
|
26
|
-
import { ProductLayoutControl as
|
|
26
|
+
import { ProductLayoutControl as F } from "./productLayout.js";
|
|
27
27
|
import { PRODUCT_LAYOUT_CONTROL_ID as Tt } from "./productLayout.js";
|
|
28
|
-
import { ShuffleControl as
|
|
28
|
+
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
|
|
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
34
|
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
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
|
-
// blockId -> fingerprint of the node config as it looked at the last sync.
|
|
43
|
-
n(this, "syncedConfigs", /* @__PURE__ */ new Map());
|
|
44
42
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
45
43
|
// re-render's single apply() — one user action must cost one undo press.
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
r(this, "pendingNodeConfigWrite", null);
|
|
45
|
+
r(this, "pendingConfigFlushTimer", null);
|
|
48
46
|
// Sub-control instances for lifecycle management
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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);
|
|
60
58
|
/**
|
|
61
59
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
62
60
|
*/
|
|
63
|
-
|
|
61
|
+
r(this, "_debouncedFetchProducts", f(async () => {
|
|
64
62
|
try {
|
|
65
63
|
await this.store.fetchRecommendationProducts();
|
|
66
64
|
} finally {
|
|
@@ -78,16 +76,16 @@ class at extends N {
|
|
|
78
76
|
* count. The store pads products to the configured size, so in-place only
|
|
79
77
|
* fails when the size actually changed.
|
|
80
78
|
*/
|
|
81
|
-
|
|
79
|
+
r(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
82
80
|
const t = this.store.recommendationProducts;
|
|
83
81
|
if (!this.currentNode || !this.api)
|
|
84
82
|
return;
|
|
85
83
|
const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
86
|
-
if (
|
|
84
|
+
if (v(this.currentNode)) {
|
|
87
85
|
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
88
86
|
return;
|
|
89
87
|
}
|
|
90
|
-
|
|
88
|
+
x({
|
|
91
89
|
currentNode: this.currentNode,
|
|
92
90
|
documentModifier: e,
|
|
93
91
|
products: t
|
|
@@ -120,7 +118,7 @@ class at extends N {
|
|
|
120
118
|
return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
|
|
121
119
|
var o;
|
|
122
120
|
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
|
|
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) => {
|
|
124
122
|
e && (e.api = this.api);
|
|
125
123
|
}), `
|
|
126
124
|
<div class="recommendation-controls-container">
|
|
@@ -142,8 +140,8 @@ class at extends N {
|
|
|
142
140
|
const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
|
|
143
141
|
if (!e)
|
|
144
142
|
return;
|
|
145
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t),
|
|
146
|
-
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);
|
|
147
145
|
}
|
|
148
146
|
async onRender() {
|
|
149
147
|
var o;
|
|
@@ -161,9 +159,9 @@ class at extends N {
|
|
|
161
159
|
const e = this._getRecommendationIdFromNode(t);
|
|
162
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(() => {
|
|
163
161
|
this._initializeSubControls();
|
|
164
|
-
}), this._subControls.forEach((
|
|
165
|
-
var
|
|
166
|
-
|
|
162
|
+
}), this._subControls.forEach((n) => {
|
|
163
|
+
var s;
|
|
164
|
+
n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
|
|
167
165
|
});
|
|
168
166
|
}
|
|
169
167
|
onDestroy() {
|
|
@@ -200,21 +198,29 @@ class at extends N {
|
|
|
200
198
|
* fingerprint diff on this hook is the only way to notice (SD-149105).
|
|
201
199
|
* An unchanged fingerprint means the move came from us, so runtime store
|
|
202
200
|
* edits are never clobbered (SD-141049).
|
|
201
|
+
*
|
|
202
|
+
* The fingerprint is kept on the block's own store state so deleting the
|
|
203
|
+
* block drops it with the state it describes. A control-owned memo outlived
|
|
204
|
+
* that state and made a re-dropped saved module keep the defaults its wiped
|
|
205
|
+
* state was rebuilt with (SD-150347).
|
|
203
206
|
*/
|
|
204
207
|
_syncNodeConfigIfChanged(t) {
|
|
205
208
|
this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== t && this._flushPendingNodeConfig();
|
|
206
|
-
const e =
|
|
207
|
-
|
|
209
|
+
const e = this.store.blockStates[t];
|
|
210
|
+
if (!e)
|
|
211
|
+
return;
|
|
212
|
+
const o = JSON.stringify(c.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
|
|
213
|
+
e.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
208
214
|
}
|
|
209
215
|
_capturePendingNodeConfigWrite() {
|
|
210
216
|
const t = this.store.currentRecommendationId;
|
|
211
217
|
if (!this.currentNode || !this.api || t === null)
|
|
212
218
|
return;
|
|
213
|
-
const { filters: e, strategyId: o, size:
|
|
219
|
+
const { filters: e, strategyId: o, size: n, nodeConfigVersion: s } = this.store.recommendationConfigs;
|
|
214
220
|
this.pendingNodeConfigWrite = {
|
|
215
221
|
blockId: t,
|
|
216
222
|
node: this.currentNode,
|
|
217
|
-
updates: { filters: e, strategyId: o, size:
|
|
223
|
+
updates: { filters: e, strategyId: o, size: n, configVersion: s }
|
|
218
224
|
};
|
|
219
225
|
}
|
|
220
226
|
/**
|
|
@@ -257,11 +263,12 @@ class at extends N {
|
|
|
257
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");
|
|
258
264
|
}
|
|
259
265
|
_syncNodeConfigToStore() {
|
|
260
|
-
var
|
|
261
|
-
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((
|
|
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);
|
|
262
268
|
this.store.patchCurrentBlockConfig({
|
|
263
269
|
strategy: t.strategy,
|
|
264
270
|
strategyId: t.strategyId,
|
|
271
|
+
nodeConfigVersion: t.configVersion,
|
|
265
272
|
language: t.language,
|
|
266
273
|
size: t.size,
|
|
267
274
|
productIds: t.productIds,
|
|
@@ -300,8 +307,8 @@ class at extends N {
|
|
|
300
307
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
301
308
|
this.store.fetchRecommendationCreateData(),
|
|
302
309
|
this.store.fetchRecommendationFilters()
|
|
303
|
-
])).forEach((o,
|
|
304
|
-
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);
|
|
305
312
|
}), this._applySmartDefaults();
|
|
306
313
|
try {
|
|
307
314
|
await this.store.fetchRecommendationProducts();
|
|
@@ -323,30 +330,30 @@ class at extends N {
|
|
|
323
330
|
if (!this.currentNode || !this.api)
|
|
324
331
|
return;
|
|
325
332
|
const t = c.getConfig(this.currentNode), e = {};
|
|
326
|
-
let o = null,
|
|
333
|
+
let o = null, n = null, s = null;
|
|
327
334
|
if (t.currency.code === a.currency.code) {
|
|
328
|
-
const { currencyList:
|
|
329
|
-
|
|
335
|
+
const { currencyList: i } = this.store;
|
|
336
|
+
i.length > 0 && (i.some(
|
|
330
337
|
(d) => d.value === `price.${a.currency.code}`
|
|
331
|
-
) || (o =
|
|
338
|
+
) || (o = i[0].value.replace("price.", ""), e.currency = {
|
|
332
339
|
...a.currency,
|
|
333
340
|
code: o,
|
|
334
341
|
symbol: o
|
|
335
342
|
}));
|
|
336
343
|
}
|
|
337
344
|
if (t.strategy === a.strategy) {
|
|
338
|
-
const
|
|
339
|
-
|
|
345
|
+
const i = this.store.getActivePredictiveAlgorithms;
|
|
346
|
+
i.length > 0 && (i.some(
|
|
340
347
|
(d) => d.value === a.strategy
|
|
341
|
-
) || (
|
|
348
|
+
) || (n = i[0].value, e.strategy = n));
|
|
342
349
|
}
|
|
343
350
|
if (t.language === a.language) {
|
|
344
|
-
const
|
|
345
|
-
|
|
351
|
+
const i = this.store.getLanguages;
|
|
352
|
+
i.length > 0 && (i.some(
|
|
346
353
|
(d) => d.value === a.language
|
|
347
|
-
) || (
|
|
354
|
+
) || (s = i[0].value, e.language = s));
|
|
348
355
|
}
|
|
349
|
-
!o && !
|
|
356
|
+
!o && !n && !s || (c.updateConfig(
|
|
350
357
|
this.api,
|
|
351
358
|
this.currentNode,
|
|
352
359
|
e,
|
|
@@ -367,22 +374,22 @@ class at extends N {
|
|
|
367
374
|
thousandSeparator: a.currency.thousandSeparator
|
|
368
375
|
}
|
|
369
376
|
} : {},
|
|
370
|
-
...
|
|
371
|
-
...
|
|
377
|
+
...n ? { strategy: n } : {},
|
|
378
|
+
...s ? { language: s } : {}
|
|
372
379
|
}, { triggerRefetch: !1 }));
|
|
373
380
|
}
|
|
374
381
|
/**
|
|
375
382
|
* Reads the recommendation-id attribute from the block element within the node
|
|
376
383
|
*/
|
|
377
384
|
_getRecommendationIdFromNode(t) {
|
|
378
|
-
const e =
|
|
385
|
+
const e = B(t);
|
|
379
386
|
if (!e || !("getAttribute" in e))
|
|
380
387
|
return null;
|
|
381
388
|
const o = e.getAttribute(I);
|
|
382
389
|
if (!o)
|
|
383
390
|
return null;
|
|
384
|
-
const
|
|
385
|
-
return Number.isNaN(
|
|
391
|
+
const n = parseInt(o);
|
|
392
|
+
return Number.isNaN(n) ? null : n;
|
|
386
393
|
}
|
|
387
394
|
/**
|
|
388
395
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -399,17 +406,17 @@ class at extends N {
|
|
|
399
406
|
*/
|
|
400
407
|
_listenStateUpdates() {
|
|
401
408
|
const { store: t } = this;
|
|
402
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
409
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
|
|
403
410
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
404
|
-
const
|
|
405
|
-
if (
|
|
406
|
-
|
|
411
|
+
const s = t.currentRecommendationId;
|
|
412
|
+
if (s !== n) {
|
|
413
|
+
n = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
407
414
|
return;
|
|
408
415
|
}
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
const u = t.recommendationProducts, d = u !== e,
|
|
412
|
-
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());
|
|
413
420
|
});
|
|
414
421
|
}
|
|
415
422
|
}
|
|
@@ -417,9 +424,9 @@ export {
|
|
|
417
424
|
ut as ALGORITHM_CONTROL_ID,
|
|
418
425
|
T as AlgorithmControl,
|
|
419
426
|
$ as CONTROL_BLOCK_ID,
|
|
420
|
-
|
|
427
|
+
gt as CURRENCY_CONTROL_ID,
|
|
421
428
|
P as CurrencyControl,
|
|
422
|
-
|
|
429
|
+
ht as FILTERS_CONTROL_ID,
|
|
423
430
|
S as FiltersControl,
|
|
424
431
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
425
432
|
yt as LOCALE_CONTROL_ID,
|
|
@@ -428,25 +435,25 @@ export {
|
|
|
428
435
|
_t as PRICE_PLACEMENT_CONTROL_ID,
|
|
429
436
|
Rt as PRODUCT_COUNT_CONTROL_ID,
|
|
430
437
|
Tt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
438
|
+
k as PricePlacementControl,
|
|
439
|
+
E as ProductCountControl,
|
|
440
|
+
F as ProductLayoutControl,
|
|
434
441
|
at as RecommendationBlockControl,
|
|
435
442
|
St as SHUFFLE_CONTROL_ID,
|
|
436
443
|
Lt as STRATEGY_CONTROL_ID,
|
|
437
|
-
|
|
444
|
+
D as ShuffleControl,
|
|
438
445
|
w as StrategyControl,
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
446
|
+
Et as adjustProductsToSize,
|
|
447
|
+
Ft as formatProductPrice,
|
|
448
|
+
B as getBlockElement,
|
|
449
|
+
Dt as getCardComposition,
|
|
443
450
|
wt as getCurrentLayout,
|
|
444
451
|
At as getMainContainerTbody,
|
|
445
|
-
|
|
446
|
-
|
|
452
|
+
v as isPartnerManagedBlock,
|
|
453
|
+
Bt as regenerateMobileProductRows,
|
|
447
454
|
U as regenerateProductRowsWithStyles,
|
|
448
455
|
A as setCurrencyAttributes,
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
456
|
+
vt as updatePricesInPlace,
|
|
457
|
+
x as updateProductContentInPlace,
|
|
458
|
+
xt as updateSingleProductContent
|
|
452
459
|
};
|
|
@@ -1,26 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
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 {
|
|
9
11
|
constructor() {
|
|
10
12
|
super(...arguments);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
r(this, "store", $());
|
|
14
|
+
r(this, "onboardingStore", S());
|
|
15
|
+
r(this, "legacyConversion", _());
|
|
16
|
+
r(this, "storeUnsubscription", () => {
|
|
13
17
|
});
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
r(this, "listeners", []);
|
|
19
|
+
r(this, "lastPaintedState", null);
|
|
16
20
|
}
|
|
17
21
|
getId() {
|
|
18
|
-
return
|
|
22
|
+
return C;
|
|
19
23
|
}
|
|
20
24
|
getTemplate() {
|
|
21
25
|
const t = this.api.translate(
|
|
22
26
|
"You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
|
|
23
|
-
), 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
|
+
);
|
|
24
30
|
return `
|
|
25
31
|
<div class="strategy-control-container">
|
|
26
32
|
<div class="strategy-control-header">
|
|
@@ -31,7 +37,7 @@ class f extends h {
|
|
|
31
37
|
${t}
|
|
32
38
|
${e}
|
|
33
39
|
<a
|
|
34
|
-
href="${
|
|
40
|
+
href="${b.EMAIL_RECOMMENDATION_BLOCK}"
|
|
35
41
|
target="_blank"
|
|
36
42
|
rel="noopener noreferrer">${a}</a>.
|
|
37
43
|
</p>
|
|
@@ -53,6 +59,33 @@ class f extends h {
|
|
|
53
59
|
})
|
|
54
60
|
], "strategy-control-cta-row")}
|
|
55
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>
|
|
66
|
+
</div>
|
|
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>
|
|
56
89
|
<div data-strategy-assigned-state style="display: none;">
|
|
57
90
|
<div class="strategy-control-name-band">
|
|
58
91
|
<span class="strategy-control-name" data-strategy-name></span>
|
|
@@ -88,6 +121,8 @@ class f extends h {
|
|
|
88
121
|
this._renderState();
|
|
89
122
|
}), this.store.recommendationConfigs.strategyId && !this.store.strategies.length && this.store.fetchStrategies().catch(() => {
|
|
90
123
|
});
|
|
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");
|
|
91
126
|
}
|
|
92
127
|
onDestroy() {
|
|
93
128
|
this._teardown();
|
|
@@ -100,25 +135,34 @@ class f extends h {
|
|
|
100
135
|
const t = this.getContainer();
|
|
101
136
|
if (!t)
|
|
102
137
|
return;
|
|
103
|
-
const e = (a,
|
|
104
|
-
const
|
|
105
|
-
|
|
138
|
+
const e = (a, o) => {
|
|
139
|
+
const n = t.querySelector(a);
|
|
140
|
+
n && (n.addEventListener("click", o), this.listeners.push({ element: n, handler: o }));
|
|
106
141
|
};
|
|
107
|
-
e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal())
|
|
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
|
+
});
|
|
108
145
|
}
|
|
109
146
|
_renderState() {
|
|
110
|
-
var
|
|
111
|
-
const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((
|
|
112
|
-
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)
|
|
113
153
|
return;
|
|
114
|
-
const
|
|
115
|
-
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)
|
|
116
156
|
return;
|
|
117
|
-
const
|
|
118
|
-
|
|
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;
|
|
119
163
|
}
|
|
120
164
|
}
|
|
121
165
|
export {
|
|
122
|
-
|
|
123
|
-
|
|
166
|
+
C as STRATEGY_CONTROL_ID,
|
|
167
|
+
N as StrategyControl
|
|
124
168
|
};
|