@useinsider/guido 3.21.2-beta.45bb425 → 3.21.2-beta.4b0fed7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composables/useSave.js +68 -75
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -22
- package/dist/config/migrator/recommendation/compositionMapper.js +56 -49
- package/dist/config/migrator/recommendation/extractors.js +68 -29
- package/dist/config/migrator/recommendation/htmlBuilder.js +283 -200
- package/dist/config/migrator/recommendation/settingsMapper.js +35 -32
- package/dist/config/migrator/recommendationMigrator.js +32 -29
- package/dist/extensions/Blocks/Recommendation/block.js +33 -24
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +146 -162
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +1 -2
- package/dist/services/templateLibraryApi.js +31 -36
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/extractors.d.ts +20 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -8
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +3 -2
- package/dist/src/utils/templatePreparation.d.ts +1 -2
- package/dist/utils/templatePreparation.js +30 -30
- package/package.json +1 -1
- package/dist/composables/validators/useHtmlDocumentCountValidator.js +0 -22
- package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +0 -3
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var N = Object.defineProperty;
|
|
2
|
+
var y = (u, c, e) => c in u ? N(u, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[c] = e;
|
|
3
|
+
var r = (u, c, e) => y(u, typeof c != "symbol" ? c + "" : c, e);
|
|
4
4
|
import { useConfig as g } from "../../../../../composables/useConfig.js";
|
|
5
|
-
import { ModificationDescription as
|
|
6
|
-
import { CommonControl as
|
|
7
|
-
import { RRS_CONFIG_VERSION as
|
|
8
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
9
|
-
import { RecommendationConfigService as
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
import { refreshBlockOutsidePanel as
|
|
12
|
-
import { registerNodeConfigWriter as
|
|
13
|
-
import { AlgorithmControl as
|
|
14
|
-
import { ALGORITHM_CONTROL_ID as
|
|
15
|
-
import { CurrencyControl as
|
|
16
|
-
import { CURRENCY_CONTROL_ID as
|
|
17
|
-
import { FiltersControl as
|
|
18
|
-
import { FILTERS_CONTROL_ID as
|
|
19
|
-
import { LayoutOrientationControl as
|
|
20
|
-
import { LAYOUT_ORIENTATION_CONTROL_ID as
|
|
21
|
-
import { LocaleControl as
|
|
22
|
-
import { LOCALE_CONTROL_ID as
|
|
23
|
-
import { PricePlacementControl as
|
|
24
|
-
import { PRICE_PLACEMENT_CONTROL_ID as
|
|
25
|
-
import { ProductCountControl as
|
|
26
|
-
import { PRODUCT_COUNT_CONTROL_ID as
|
|
27
|
-
import { ProductLayoutControl as
|
|
28
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
29
|
-
import { ShuffleControl as
|
|
30
|
-
import { SHUFFLE_CONTROL_ID as
|
|
31
|
-
import { StrategyControl as
|
|
32
|
-
import { STRATEGY_CONTROL_ID as
|
|
33
|
-
import { setCurrencyAttributes as
|
|
34
|
-
import { adjustProductsToSize as
|
|
35
|
-
import { useDebounceFn as
|
|
36
|
-
const
|
|
37
|
-
class
|
|
5
|
+
import { ModificationDescription as P } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
+
import { CommonControl as R } from "../../../common-control.js";
|
|
7
|
+
import { RRS_CONFIG_VERSION as I, DEFAULT_NODE_CONFIG as m } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RECOMMENDATION_ID_ATTR as k } from "../../constants/selectors.js";
|
|
9
|
+
import { RecommendationConfigService as d } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as S } from "../../store/recommendation.js";
|
|
11
|
+
import { refreshBlockOutsidePanel as T } from "../../utils/blockRefresh.js";
|
|
12
|
+
import { registerNodeConfigWriter as O, writeBlockConfigOutsidePanel as C, hasEditedConfigChange as b, pickConfigDescription as B, isProductIdsChange as F, PRODUCT_IDS_DESCRIPTION as D } from "../../utils/nodeConfigWriter.js";
|
|
13
|
+
import { AlgorithmControl as L } from "./algorithm.js";
|
|
14
|
+
import { ALGORITHM_CONTROL_ID as Ne } from "./algorithm.js";
|
|
15
|
+
import { CurrencyControl as E } from "./currency.js";
|
|
16
|
+
import { CURRENCY_CONTROL_ID as Pe } from "./currency.js";
|
|
17
|
+
import { FiltersControl as U } from "./filters.js";
|
|
18
|
+
import { FILTERS_CONTROL_ID as Ie } from "./filters.js";
|
|
19
|
+
import { LayoutOrientationControl as v } from "./layoutOrientation.js";
|
|
20
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as Se } from "./layoutOrientation.js";
|
|
21
|
+
import { LocaleControl as w } from "./locale.js";
|
|
22
|
+
import { LOCALE_CONTROL_ID as Oe } from "./locale.js";
|
|
23
|
+
import { PricePlacementControl as A } from "./pricePlacement.js";
|
|
24
|
+
import { PRICE_PLACEMENT_CONTROL_ID as Be } from "./pricePlacement.js";
|
|
25
|
+
import { ProductCountControl as V } from "./productCount.js";
|
|
26
|
+
import { PRODUCT_COUNT_CONTROL_ID as De } from "./productCount.js";
|
|
27
|
+
import { ProductLayoutControl as W } from "./productLayout.js";
|
|
28
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Ee } from "./productLayout.js";
|
|
29
|
+
import { ShuffleControl as x } from "./shuffle.js";
|
|
30
|
+
import { SHUFFLE_CONTROL_ID as ve } from "./shuffle.js";
|
|
31
|
+
import { StrategyControl as M } from "./strategy.js";
|
|
32
|
+
import { STRATEGY_CONTROL_ID as Ae } from "./strategy.js";
|
|
33
|
+
import { setCurrencyAttributes as G, getBlockElement as z, isPartnerManagedBlock as $, updateProductContentInPlace as H, regenerateProductRowsWithStyles as Y } from "./utils.js";
|
|
34
|
+
import { adjustProductsToSize as We, formatProductPrice as xe, getCardComposition as Me, getCurrentLayout as Ge, getMainContainerTbody as ze, regenerateMobileProductRows as $e, updatePricesInPlace as He, updateSingleProductContent as Ye } from "./utils.js";
|
|
35
|
+
import { useDebounceFn as p } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
36
|
+
const h = "Update recommendation filters", j = "ui-elements-recommendation-block";
|
|
37
|
+
class Ce extends R {
|
|
38
38
|
constructor() {
|
|
39
39
|
super(...arguments);
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
r(this, "store", S());
|
|
41
|
+
r(this, "storeUnsubscription", () => {
|
|
42
42
|
});
|
|
43
43
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
44
44
|
// re-render's single apply() — one user action must cost one undo press.
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
r(this, "pendingNodeConfigWrite", null);
|
|
46
|
+
r(this, "pendingConfigFlushTimer", null);
|
|
47
47
|
// What the panel still owes the block it watches — finished outside the panel on teardown
|
|
48
48
|
// and block switch. A new generation tells debounced work queued for the old one to stand down.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
r(this, "trackedBlockId", null);
|
|
50
|
+
r(this, "fetchedConfigVersion", 0);
|
|
51
|
+
r(this, "hasUnrenderedProducts", !1);
|
|
52
|
+
r(this, "panelGeneration", 0);
|
|
53
|
+
r(this, "isPanelAlive", !0);
|
|
54
54
|
// Sub-control instances for lifecycle management
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
r(this, "algorithmControl", null);
|
|
56
|
+
r(this, "localeControl", null);
|
|
57
|
+
r(this, "currencyControl", null);
|
|
58
|
+
r(this, "productCountControl", null);
|
|
59
|
+
r(this, "productLayoutControl", null);
|
|
60
|
+
r(this, "filtersControl", null);
|
|
61
|
+
r(this, "shuffleControl", null);
|
|
62
|
+
r(this, "pricePlacementControl", null);
|
|
63
|
+
r(this, "layoutOrientationControl", null);
|
|
64
|
+
r(this, "strategyControl", null);
|
|
65
|
+
r(this, "rrsEnabled", !1);
|
|
66
66
|
/**
|
|
67
67
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
r(this, "_debouncedFetchProducts", p(async (e, t) => {
|
|
70
70
|
if (t !== this.panelGeneration)
|
|
71
71
|
return;
|
|
72
72
|
const o = this._getBlockConfigVersion(e);
|
|
@@ -87,7 +87,7 @@ class me extends P {
|
|
|
87
87
|
* count. The store pads products to the configured size, so in-place only
|
|
88
88
|
* fails when the size actually changed.
|
|
89
89
|
*/
|
|
90
|
-
|
|
90
|
+
r(this, "_debouncedRegenerateWithProducts", p((e) => {
|
|
91
91
|
if (e !== this.panelGeneration || !this.currentNode || !this.api)
|
|
92
92
|
return;
|
|
93
93
|
const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
|
|
@@ -106,7 +106,7 @@ class me extends P {
|
|
|
106
106
|
}, 100));
|
|
107
107
|
}
|
|
108
108
|
getId() {
|
|
109
|
-
return
|
|
109
|
+
return j;
|
|
110
110
|
}
|
|
111
111
|
get _subControls() {
|
|
112
112
|
return [
|
|
@@ -127,7 +127,7 @@ class me extends P {
|
|
|
127
127
|
return this.rrsEnabled = g().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
128
128
|
var o;
|
|
129
129
|
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
130
|
-
}), this.algorithmControl = new
|
|
130
|
+
}), this.algorithmControl = new L(), this.localeControl = new w(), this.currencyControl = new E(), this.productCountControl = new V(), this.productLayoutControl = new W(), this.filtersControl = new U(), this.shuffleControl = new x(), this.pricePlacementControl = new A(), this.layoutOrientationControl = new v(), this.strategyControl = this.rrsEnabled ? new M() : null, this._subControls.forEach((t) => {
|
|
131
131
|
t && (t.api = this.api);
|
|
132
132
|
}), `
|
|
133
133
|
<div class="recommendation-controls-container">
|
|
@@ -145,16 +145,16 @@ class me extends P {
|
|
|
145
145
|
`;
|
|
146
146
|
}
|
|
147
147
|
_showControlsForBlock(e) {
|
|
148
|
-
var
|
|
149
|
-
const t = (
|
|
148
|
+
var s;
|
|
149
|
+
const t = (s = this.getContainer()) == null ? void 0 : s.querySelector(".recommendation-controls-container");
|
|
150
150
|
if (!t)
|
|
151
151
|
return;
|
|
152
|
-
const o = this._getRecommendationIdFromNode(e) === null ? null :
|
|
152
|
+
const o = this._getRecommendationIdFromNode(e) === null ? null : d.getConfig(e), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= I), i = this.rrsEnabled && !!o && !n;
|
|
153
153
|
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", i);
|
|
154
154
|
}
|
|
155
155
|
async onRender() {
|
|
156
156
|
var o;
|
|
157
|
-
|
|
157
|
+
O(this.api);
|
|
158
158
|
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
159
159
|
if (t !== null && this.store.setCurrentBlock(t), e !== null && this._syncNodeConfigIfChanged(e), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), t !== null && ((o = this.store.blockStates[t]) != null && o.isInitialized)) {
|
|
160
160
|
this._initializeSubControls();
|
|
@@ -219,13 +219,13 @@ class me extends P {
|
|
|
219
219
|
const t = this.store.blockStates[e];
|
|
220
220
|
if (!t)
|
|
221
221
|
return;
|
|
222
|
-
const o = JSON.stringify(
|
|
222
|
+
const o = JSON.stringify(d.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
|
|
223
223
|
t.syncedConfigFingerprint = o, n !== o && ((i = this.pendingNodeConfigWrite) == null ? void 0 : i.blockId) !== e && this._syncNodeConfigToStore();
|
|
224
224
|
}
|
|
225
225
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
226
226
|
_isPendingStrategyIdChange() {
|
|
227
227
|
const e = this.pendingNodeConfigWrite;
|
|
228
|
-
return e ?
|
|
228
|
+
return e ? d.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
|
|
229
229
|
}
|
|
230
230
|
_capturePendingNodeConfigWrite() {
|
|
231
231
|
const e = this.store.currentRecommendationId, t = e === null ? void 0 : this.store.blockStates[e];
|
|
@@ -240,15 +240,15 @@ class me extends P {
|
|
|
240
240
|
return !e || t !== null && e.blockId !== t ? null : e;
|
|
241
241
|
}
|
|
242
242
|
_getNodeConfigUpdates(e) {
|
|
243
|
-
const { filters: t, strategy: o, strategyId: n, size: i, productIds:
|
|
243
|
+
const { filters: t, strategy: o, strategyId: n, size: i, productIds: s, nodeConfigVersion: l } = e, { partnerName: a } = g();
|
|
244
244
|
return {
|
|
245
245
|
filters: t,
|
|
246
246
|
strategy: o,
|
|
247
247
|
strategyId: n,
|
|
248
248
|
size: i,
|
|
249
|
-
productIds:
|
|
250
|
-
configVersion:
|
|
251
|
-
...
|
|
249
|
+
productIds: s,
|
|
250
|
+
configVersion: l,
|
|
251
|
+
...a.value ? { partnerName: a.value } : {}
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
254
|
/**
|
|
@@ -263,7 +263,7 @@ class me extends P {
|
|
|
263
263
|
*/
|
|
264
264
|
_stagePendingNodeConfig(e) {
|
|
265
265
|
const t = this._pendingWriteForNode();
|
|
266
|
-
return !t || !this.currentNode ? !1 : (
|
|
266
|
+
return !t || !this.currentNode ? !1 : (d.stageConfig(e, this.currentNode, t.updates), !0);
|
|
267
267
|
}
|
|
268
268
|
/**
|
|
269
269
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -288,14 +288,14 @@ class me extends P {
|
|
|
288
288
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !(!e || !this.api)) {
|
|
289
289
|
if (e.blockId !== this.store.currentRecommendationId || !this.currentNode) {
|
|
290
290
|
const { blockId: t, updates: o } = e;
|
|
291
|
-
!
|
|
291
|
+
!C(t, o, h) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
|
|
292
292
|
return;
|
|
293
293
|
}
|
|
294
|
-
|
|
294
|
+
b(this.currentNode, e.updates) && d.updateConfig(
|
|
295
295
|
this.api,
|
|
296
296
|
this.currentNode,
|
|
297
297
|
e.updates,
|
|
298
|
-
|
|
298
|
+
B(this.currentNode, e.updates, h)
|
|
299
299
|
);
|
|
300
300
|
}
|
|
301
301
|
}
|
|
@@ -306,12 +306,12 @@ class me extends P {
|
|
|
306
306
|
/** The Product Ids label when the pending write moves the node's ids; the caller's default otherwise. */
|
|
307
307
|
_pendingDescription() {
|
|
308
308
|
const e = this._pendingWriteForNode();
|
|
309
|
-
if (!(!e || !this.currentNode || !
|
|
310
|
-
return
|
|
309
|
+
if (!(!e || !this.currentNode || !F(this.currentNode, e.updates)))
|
|
310
|
+
return D;
|
|
311
311
|
}
|
|
312
312
|
_syncNodeConfigToStore() {
|
|
313
313
|
var n;
|
|
314
|
-
const e =
|
|
314
|
+
const e = d.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
315
315
|
this.store.patchCurrentBlockConfig({
|
|
316
316
|
strategy: e.strategy,
|
|
317
317
|
strategyId: e.strategyId,
|
|
@@ -373,61 +373,45 @@ class me extends P {
|
|
|
373
373
|
return this.isPanelAlive && this.store.currentRecommendationId === e;
|
|
374
374
|
}
|
|
375
375
|
/**
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
* For new blocks (config still matches hardcoded defaults), validates that
|
|
379
|
-
* the default currency and algorithm are available from the API response.
|
|
380
|
-
* If not, falls back to the first available option.
|
|
381
|
-
*
|
|
382
|
-
* Saved templates with user-customized config are left unchanged because
|
|
383
|
-
* their values won't match the hardcoded defaults.
|
|
376
|
+
* Falls back to the first available option when the block's currency or locale is not offered (a new block on
|
|
377
|
+
* the hard-coded default, or a block copied from another account). The algorithm falls back only on new blocks.
|
|
384
378
|
*/
|
|
385
379
|
_applySmartDefaults() {
|
|
386
380
|
if (!this.currentNode || !this.api)
|
|
387
381
|
return;
|
|
388
|
-
const e =
|
|
382
|
+
const e = d.getConfig(this.currentNode), t = {};
|
|
389
383
|
let o = null, n = null, i = null;
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
if (e.strategy === a.strategy) {
|
|
401
|
-
const r = this.store.getActivePredictiveAlgorithms;
|
|
402
|
-
r.length > 0 && (r.some(
|
|
403
|
-
(c) => c.value === a.strategy
|
|
404
|
-
) || (n = r[0].value, t.strategy = n));
|
|
405
|
-
}
|
|
406
|
-
if (e.language === a.language) {
|
|
407
|
-
const r = this.store.getLanguages;
|
|
408
|
-
r.length > 0 && (r.some(
|
|
409
|
-
(c) => c.value === a.language
|
|
410
|
-
) || (i = r[0].value, t.language = i));
|
|
384
|
+
const { currencyList: s } = this.store;
|
|
385
|
+
if (s.length > 0 && !s.some((a) => a.value === `price.${e.currency.code}`) && (o = s[0].value.replace("price.", ""), t.currency = {
|
|
386
|
+
...e.currency,
|
|
387
|
+
code: o,
|
|
388
|
+
symbol: o
|
|
389
|
+
}), e.strategy === m.strategy) {
|
|
390
|
+
const a = this.store.getActivePredictiveAlgorithms;
|
|
391
|
+
a.length > 0 && (a.some(
|
|
392
|
+
(_) => _.value === m.strategy
|
|
393
|
+
) || (n = a[0].value, t.strategy = n));
|
|
411
394
|
}
|
|
412
|
-
|
|
395
|
+
const l = this.store.getLanguages;
|
|
396
|
+
l.length > 0 && !l.some((a) => a.value === e.language) && (i = l[0].value, t.language = i), !(!o && !n && !i) && (d.updateConfig(
|
|
413
397
|
this.api,
|
|
414
398
|
this.currentNode,
|
|
415
399
|
t,
|
|
416
400
|
"Applied smart defaults"
|
|
417
|
-
), o && t.currency &&
|
|
401
|
+
), o && t.currency && G({
|
|
418
402
|
currentNode: this.currentNode,
|
|
419
403
|
documentModifier: this.api.getDocumentModifier(),
|
|
420
404
|
currency: t.currency
|
|
421
405
|
}), this.store.patchCurrentBlockConfig({
|
|
422
|
-
...o ? {
|
|
406
|
+
...o && t.currency ? {
|
|
423
407
|
currencySettings: {
|
|
424
408
|
name: o,
|
|
425
409
|
value: o,
|
|
426
410
|
symbol: o,
|
|
427
|
-
alignment:
|
|
428
|
-
decimalCount:
|
|
429
|
-
decimalSeparator:
|
|
430
|
-
thousandSeparator:
|
|
411
|
+
alignment: t.currency.alignment === "before" ? "0" : "1",
|
|
412
|
+
decimalCount: t.currency.decimalCount.toString(),
|
|
413
|
+
decimalSeparator: t.currency.decimalSeparator,
|
|
414
|
+
thousandSeparator: t.currency.thousandSeparator
|
|
431
415
|
}
|
|
432
416
|
} : {},
|
|
433
417
|
...n ? { strategy: n } : {},
|
|
@@ -438,10 +422,10 @@ class me extends P {
|
|
|
438
422
|
* Reads the recommendation-id attribute from the block element within the node
|
|
439
423
|
*/
|
|
440
424
|
_getRecommendationIdFromNode(e) {
|
|
441
|
-
const t =
|
|
425
|
+
const t = z(e);
|
|
442
426
|
if (!t || !("getAttribute" in t))
|
|
443
427
|
return null;
|
|
444
|
-
const o = t.getAttribute(
|
|
428
|
+
const o = t.getAttribute(k);
|
|
445
429
|
if (!o)
|
|
446
430
|
return null;
|
|
447
431
|
const n = parseInt(o);
|
|
@@ -458,10 +442,10 @@ class me extends P {
|
|
|
458
442
|
if (e === null || !n)
|
|
459
443
|
return;
|
|
460
444
|
const i = t !== n.configVersion;
|
|
461
|
-
i && !
|
|
445
|
+
i && !C(
|
|
462
446
|
e,
|
|
463
447
|
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
464
|
-
|
|
448
|
+
h
|
|
465
449
|
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i || o) && this._refreshOutsidePanel(e, i);
|
|
466
450
|
} catch (n) {
|
|
467
451
|
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
@@ -475,7 +459,7 @@ class me extends P {
|
|
|
475
459
|
};
|
|
476
460
|
}
|
|
477
461
|
_refreshOutsidePanel(e, t) {
|
|
478
|
-
|
|
462
|
+
T(e, {
|
|
479
463
|
pickUpdates: (o) => this._getNodeConfigUpdates(o),
|
|
480
464
|
description: "Update recommendation configuration",
|
|
481
465
|
fetch: t
|
|
@@ -498,19 +482,19 @@ class me extends P {
|
|
|
498
482
|
return;
|
|
499
483
|
}
|
|
500
484
|
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = this._pendingDescription(), n = this._stagePendingNodeConfig(t);
|
|
501
|
-
if (
|
|
485
|
+
if ($(this.currentNode)) {
|
|
502
486
|
n && (t.apply(
|
|
503
|
-
new
|
|
487
|
+
new P(o ?? "Update recommendation configuration")
|
|
504
488
|
), this._consumePendingNodeConfig());
|
|
505
489
|
return;
|
|
506
490
|
}
|
|
507
|
-
|
|
491
|
+
H({
|
|
508
492
|
currentNode: this.currentNode,
|
|
509
493
|
documentModifier: t,
|
|
510
494
|
products: e,
|
|
511
495
|
description: o,
|
|
512
496
|
onApplied: n ? () => this._consumePendingNodeConfig() : void 0
|
|
513
|
-
}) ||
|
|
497
|
+
}) || Y({
|
|
514
498
|
currentNode: this.currentNode,
|
|
515
499
|
documentModifier: t,
|
|
516
500
|
products: e,
|
|
@@ -541,51 +525,51 @@ class me extends P {
|
|
|
541
525
|
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
|
|
542
526
|
const n = e.currentRecommendationId;
|
|
543
527
|
if (n !== this.trackedBlockId) {
|
|
544
|
-
const
|
|
545
|
-
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(
|
|
528
|
+
const f = this._trackedBlockSnapshot();
|
|
529
|
+
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(f);
|
|
546
530
|
return;
|
|
547
531
|
}
|
|
548
532
|
const i = this._getBlockConfigVersion(n);
|
|
549
533
|
i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, this.panelGeneration));
|
|
550
|
-
const
|
|
551
|
-
|
|
534
|
+
const s = e.recommendationProducts, l = s !== t, a = Array.isArray(s) && s.length > 0;
|
|
535
|
+
l && a && (t = s, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
|
|
552
536
|
});
|
|
553
537
|
}
|
|
554
538
|
}
|
|
555
539
|
export {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
540
|
+
Ne as ALGORITHM_CONTROL_ID,
|
|
541
|
+
L as AlgorithmControl,
|
|
542
|
+
j as CONTROL_BLOCK_ID,
|
|
543
|
+
Pe as CURRENCY_CONTROL_ID,
|
|
544
|
+
E as CurrencyControl,
|
|
545
|
+
Ie as FILTERS_CONTROL_ID,
|
|
546
|
+
U as FiltersControl,
|
|
547
|
+
Se as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
548
|
+
Oe as LOCALE_CONTROL_ID,
|
|
549
|
+
v as LayoutOrientationControl,
|
|
550
|
+
w as LocaleControl,
|
|
551
|
+
Be as PRICE_PLACEMENT_CONTROL_ID,
|
|
552
|
+
De as PRODUCT_COUNT_CONTROL_ID,
|
|
553
|
+
Ee as PRODUCT_LAYOUT_CONTROL_ID,
|
|
554
|
+
A as PricePlacementControl,
|
|
555
|
+
V as ProductCountControl,
|
|
556
|
+
W as ProductLayoutControl,
|
|
557
|
+
Ce as RecommendationBlockControl,
|
|
558
|
+
ve as SHUFFLE_CONTROL_ID,
|
|
559
|
+
Ae as STRATEGY_CONTROL_ID,
|
|
560
|
+
x as ShuffleControl,
|
|
561
|
+
M as StrategyControl,
|
|
562
|
+
We as adjustProductsToSize,
|
|
563
|
+
xe as formatProductPrice,
|
|
564
|
+
z as getBlockElement,
|
|
565
|
+
Me as getCardComposition,
|
|
566
|
+
Ge as getCurrentLayout,
|
|
567
|
+
ze as getMainContainerTbody,
|
|
568
|
+
$ as isPartnerManagedBlock,
|
|
569
|
+
$e as regenerateMobileProductRows,
|
|
570
|
+
Y as regenerateProductRowsWithStyles,
|
|
571
|
+
G as setCurrencyAttributes,
|
|
572
|
+
He as updatePricesInPlace,
|
|
573
|
+
H as updateProductContentInPlace,
|
|
574
|
+
Ye as updateSingleProductContent
|
|
591
575
|
};
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { useRecommendationExtensionStore as D } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
11
|
-
import { useSaveAsTemplateStore as L } from "../stores/save-as-template.js";
|
|
1
|
+
import { useConfig as w } from "../composables/useConfig.js";
|
|
2
|
+
import { useHttp as b } from "../composables/useHttp.js";
|
|
3
|
+
import { useToaster as C } from "../composables/useToaster.js";
|
|
4
|
+
import { useTranslations as h } from "../composables/useTranslations.js";
|
|
5
|
+
import { useLiquidValidator as S } from "../composables/validators/useLiquidValidator.js";
|
|
6
|
+
import { EditorType as v } from "../enums/defaults.js";
|
|
7
|
+
import { ToasterTypeOptions as x } from "../enums/toaster.js";
|
|
8
|
+
import { useRecommendationExtensionStore as E } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
9
|
+
import { useSaveAsTemplateStore as N } from "../stores/save-as-template.js";
|
|
12
10
|
import { base64EncodeWithSpecialChars as r } from "../utils/base64.js";
|
|
13
|
-
import { isPlainObject as
|
|
14
|
-
import { useTemplatePreparation as
|
|
15
|
-
const
|
|
16
|
-
const { get: n, post: m } =
|
|
11
|
+
import { isPlainObject as P } from "../utils/genericUtil.js";
|
|
12
|
+
import { useTemplatePreparation as A } from "../utils/templatePreparation.js";
|
|
13
|
+
const B = () => {
|
|
14
|
+
const { get: n, post: m } = b(), { handleError: o, showToaster: l } = C(), { config: c, isFeatureEnabled: p } = w(), { validateLiquidSyntax: f } = S(), u = h();
|
|
17
15
|
return {
|
|
18
16
|
getCategories: async () => {
|
|
19
17
|
try {
|
|
20
18
|
const { data: e = [] } = await n("/newsletter/template-library/get-template-categories");
|
|
21
19
|
return e;
|
|
22
20
|
} catch (e) {
|
|
23
|
-
return
|
|
21
|
+
return o(e, "Failed to fetch template categories"), [];
|
|
24
22
|
}
|
|
25
23
|
},
|
|
26
24
|
checkTemplateNameAvailability: async (e) => {
|
|
@@ -37,30 +35,27 @@ const Z = () => {
|
|
|
37
35
|
);
|
|
38
36
|
return t.toString();
|
|
39
37
|
} catch (t) {
|
|
40
|
-
return
|
|
38
|
+
return o(t, "Failed to create category"), "";
|
|
41
39
|
}
|
|
42
40
|
},
|
|
43
41
|
createTemplate: async () => {
|
|
44
42
|
var e, t, d, y;
|
|
45
43
|
try {
|
|
46
|
-
const { prepareTemplateDetails: i } =
|
|
47
|
-
if (!
|
|
44
|
+
const { prepareTemplateDetails: i } = A(), s = N(), a = await i();
|
|
45
|
+
if (p("liquidSyntax") && !await f(a.compiledHtml))
|
|
48
46
|
return !1;
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const C = {
|
|
53
|
-
name: o.getTemplateName,
|
|
54
|
-
categories: o.getSelectedCategoryIds,
|
|
47
|
+
const T = {
|
|
48
|
+
name: s.getTemplateName,
|
|
49
|
+
categories: s.getSelectedCategoryIds,
|
|
55
50
|
productId: ((t = (e = c.value) == null ? void 0 : e.partner) == null ? void 0 : t.productType) || 0,
|
|
56
|
-
editorType:
|
|
51
|
+
editorType: v,
|
|
57
52
|
messageType: ((y = (d = c.value) == null ? void 0 : d.partner) == null ? void 0 : y.messageType) || 0,
|
|
58
53
|
content: r(a.compiledHtml),
|
|
59
54
|
css: r(a.css),
|
|
60
55
|
unsubscriptionPreferencePageStatus: !1,
|
|
61
56
|
unsubscriptionPreferencePages: [],
|
|
62
57
|
recommendationCampaignUrls: r(
|
|
63
|
-
|
|
58
|
+
E().recommendationCampaignUrls
|
|
64
59
|
),
|
|
65
60
|
recommendationConfigs: r({}),
|
|
66
61
|
isGuido: !0,
|
|
@@ -72,31 +67,31 @@ const Z = () => {
|
|
|
72
67
|
css: a.css,
|
|
73
68
|
dynamicContentList: a.dynamicContentList
|
|
74
69
|
})
|
|
75
|
-
}, { data:
|
|
70
|
+
}, { data: g } = await m(
|
|
76
71
|
"/newsletter/template-library/create-template",
|
|
77
|
-
|
|
72
|
+
T
|
|
78
73
|
);
|
|
79
|
-
if (!
|
|
74
|
+
if (!P(g))
|
|
80
75
|
throw new Error("Unexpected create-template response");
|
|
81
|
-
return
|
|
76
|
+
return g.type === "alert" ? (l({
|
|
82
77
|
message: u(
|
|
83
78
|
"newsletter.template-library-save-alert",
|
|
84
|
-
{ templateName:
|
|
79
|
+
{ templateName: s.getTemplateName }
|
|
85
80
|
),
|
|
86
|
-
type:
|
|
81
|
+
type: x.Error
|
|
87
82
|
}), !1) : (l({
|
|
88
83
|
message: u(
|
|
89
84
|
"newsletter.template-library-save-success",
|
|
90
|
-
{ templateName:
|
|
85
|
+
{ templateName: s.getTemplateName }
|
|
91
86
|
),
|
|
92
87
|
type: "success"
|
|
93
88
|
}), !0);
|
|
94
89
|
} catch (i) {
|
|
95
|
-
return
|
|
90
|
+
return o(i, "Failed to create template"), !1;
|
|
96
91
|
}
|
|
97
92
|
}
|
|
98
93
|
};
|
|
99
94
|
};
|
|
100
95
|
export {
|
|
101
|
-
|
|
96
|
+
B as useTemplateLibraryApi
|
|
102
97
|
};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { type LegacyVariable, type MappedComposition } from './types';
|
|
2
|
-
export declare function mapComposition(variables: LegacyVariable[] | undefined
|
|
2
|
+
export declare function mapComposition(variables: LegacyVariable[] | undefined, { oldPriceFirst }?: {
|
|
3
|
+
oldPriceFirst?: boolean;
|
|
4
|
+
}): MappedComposition;
|