@useinsider/guido 3.21.2-beta.4b0fed7 → 3.21.2-beta.5a809f7
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 +75 -68
- package/dist/composables/validators/useHtmlDocumentCountValidator.js +22 -0
- package/dist/config/migrator/recommendation/extractors.js +36 -27
- package/dist/config/migrator/recommendation/htmlBuilder.js +99 -105
- package/dist/config/migrator/recommendation/settingsMapper.js +13 -15
- package/dist/config/migrator/recommendationMigrator.js +62 -59
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +20 -19
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +101 -100
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +23 -22
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +19 -18
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +82 -91
- package/dist/extensions/Blocks/Recommendation/utils/inlinePriceOrder.js +12 -0
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +2 -0
- package/dist/services/templateLibraryApi.js +36 -31
- package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +3 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -13
- package/dist/src/extensions/Blocks/Recommendation/utils/inlinePriceOrder.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +2 -20
- package/dist/src/utils/templatePreparation.d.ts +2 -1
- package/dist/utils/pairProductVariables.js +98 -90
- package/dist/utils/templatePreparation.js +30 -30
- package/package.json +1 -1
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var r = (u, c, e) =>
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { ModificationDescription as
|
|
6
|
-
import { CommonControl as
|
|
7
|
-
import { RRS_CONFIG_VERSION as
|
|
8
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var P = (u, c, e) => c in u ? y(u, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[c] = e;
|
|
3
|
+
var r = (u, c, e) => P(u, typeof c != "symbol" ? c + "" : c, e);
|
|
4
|
+
import { useConfig as f } from "../../../../../composables/useConfig.js";
|
|
5
|
+
import { ModificationDescription as R } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
+
import { CommonControl as I } from "../../../common-control.js";
|
|
7
|
+
import { RRS_CONFIG_VERSION as k, DEFAULT_NODE_CONFIG as m } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RECOMMENDATION_ID_ATTR as S } from "../../constants/selectors.js";
|
|
9
9
|
import { RecommendationConfigService as d } from "../../services/configService.js";
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
import { refreshBlockOutsidePanel as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
|
|
37
|
-
|
|
10
|
+
import { useRecommendationExtensionStore as T } from "../../store/recommendation.js";
|
|
11
|
+
import { refreshBlockOutsidePanel as O } from "../../utils/blockRefresh.js";
|
|
12
|
+
import { mapLegacyStrategy as C } from "../../utils/legacyStrategyMap.js";
|
|
13
|
+
import { registerNodeConfigWriter as b, writeBlockConfigOutsidePanel as p, hasEditedConfigChange as B, pickConfigDescription as F, isProductIdsChange as D, PRODUCT_IDS_DESCRIPTION as L } from "../../utils/nodeConfigWriter.js";
|
|
14
|
+
import { AlgorithmControl as E } from "./algorithm.js";
|
|
15
|
+
import { ALGORITHM_CONTROL_ID as Pe } from "./algorithm.js";
|
|
16
|
+
import { CurrencyControl as U } from "./currency.js";
|
|
17
|
+
import { CURRENCY_CONTROL_ID as Ie } from "./currency.js";
|
|
18
|
+
import { FiltersControl as v } from "./filters.js";
|
|
19
|
+
import { FILTERS_CONTROL_ID as Se } from "./filters.js";
|
|
20
|
+
import { LayoutOrientationControl as w } from "./layoutOrientation.js";
|
|
21
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as Oe } from "./layoutOrientation.js";
|
|
22
|
+
import { LocaleControl as A } from "./locale.js";
|
|
23
|
+
import { LOCALE_CONTROL_ID as Be } from "./locale.js";
|
|
24
|
+
import { PricePlacementControl as V } from "./pricePlacement.js";
|
|
25
|
+
import { PRICE_PLACEMENT_CONTROL_ID as De } from "./pricePlacement.js";
|
|
26
|
+
import { ProductCountControl as W } from "./productCount.js";
|
|
27
|
+
import { PRODUCT_COUNT_CONTROL_ID as Ee } from "./productCount.js";
|
|
28
|
+
import { ProductLayoutControl as x } from "./productLayout.js";
|
|
29
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as ve } from "./productLayout.js";
|
|
30
|
+
import { ShuffleControl as M } from "./shuffle.js";
|
|
31
|
+
import { SHUFFLE_CONTROL_ID as Ae } from "./shuffle.js";
|
|
32
|
+
import { StrategyControl as G } from "./strategy.js";
|
|
33
|
+
import { STRATEGY_CONTROL_ID as We } from "./strategy.js";
|
|
34
|
+
import { setCurrencyAttributes as z, getBlockElement as $, isPartnerManagedBlock as H, updateProductContentInPlace as Y, regenerateProductRowsWithStyles as j } from "./utils.js";
|
|
35
|
+
import { adjustProductsToSize as Me, formatProductPrice as Ge, getCardComposition as ze, getCurrentLayout as $e, getMainContainerTbody as He, regenerateMobileProductRows as Ye, updatePricesInPlace as je, updateSingleProductContent as qe } from "./utils.js";
|
|
36
|
+
import { useDebounceFn as _ } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
37
|
+
const h = "Update recommendation filters", q = "ui-elements-recommendation-block";
|
|
38
|
+
class _e extends I {
|
|
38
39
|
constructor() {
|
|
39
40
|
super(...arguments);
|
|
40
|
-
r(this, "store",
|
|
41
|
+
r(this, "store", T());
|
|
41
42
|
r(this, "storeUnsubscription", () => {
|
|
42
43
|
});
|
|
43
44
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
@@ -66,7 +67,7 @@ class Ce extends R {
|
|
|
66
67
|
/**
|
|
67
68
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
68
69
|
*/
|
|
69
|
-
r(this, "_debouncedFetchProducts",
|
|
70
|
+
r(this, "_debouncedFetchProducts", _(async (e, t) => {
|
|
70
71
|
if (t !== this.panelGeneration)
|
|
71
72
|
return;
|
|
72
73
|
const o = this._getBlockConfigVersion(e);
|
|
@@ -87,7 +88,7 @@ class Ce extends R {
|
|
|
87
88
|
* count. The store pads products to the configured size, so in-place only
|
|
88
89
|
* fails when the size actually changed.
|
|
89
90
|
*/
|
|
90
|
-
r(this, "_debouncedRegenerateWithProducts",
|
|
91
|
+
r(this, "_debouncedRegenerateWithProducts", _((e) => {
|
|
91
92
|
if (e !== this.panelGeneration || !this.currentNode || !this.api)
|
|
92
93
|
return;
|
|
93
94
|
const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
|
|
@@ -106,7 +107,7 @@ class Ce extends R {
|
|
|
106
107
|
}, 100));
|
|
107
108
|
}
|
|
108
109
|
getId() {
|
|
109
|
-
return
|
|
110
|
+
return q;
|
|
110
111
|
}
|
|
111
112
|
get _subControls() {
|
|
112
113
|
return [
|
|
@@ -124,10 +125,10 @@ class Ce extends R {
|
|
|
124
125
|
}
|
|
125
126
|
getTemplate() {
|
|
126
127
|
var e;
|
|
127
|
-
return this.rrsEnabled =
|
|
128
|
+
return this.rrsEnabled = f().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
128
129
|
var o;
|
|
129
130
|
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
130
|
-
}), this.algorithmControl = new
|
|
131
|
+
}), this.algorithmControl = new E(), this.localeControl = new A(), this.currencyControl = new U(), this.productCountControl = new W(), this.productLayoutControl = new x(), this.filtersControl = new v(), this.shuffleControl = new M(), this.pricePlacementControl = new V(), this.layoutOrientationControl = new w(), this.strategyControl = this.rrsEnabled ? new G() : null, this._subControls.forEach((t) => {
|
|
131
132
|
t && (t.api = this.api);
|
|
132
133
|
}), `
|
|
133
134
|
<div class="recommendation-controls-container">
|
|
@@ -149,12 +150,12 @@ class Ce extends R {
|
|
|
149
150
|
const t = (s = this.getContainer()) == null ? void 0 : s.querySelector(".recommendation-controls-container");
|
|
150
151
|
if (!t)
|
|
151
152
|
return;
|
|
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) >=
|
|
153
|
+
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) >= k), i = this.rrsEnabled && !!o && !n;
|
|
153
154
|
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", i);
|
|
154
155
|
}
|
|
155
156
|
async onRender() {
|
|
156
157
|
var o;
|
|
157
|
-
|
|
158
|
+
b(this.api);
|
|
158
159
|
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
159
160
|
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
161
|
this._initializeSubControls();
|
|
@@ -240,7 +241,7 @@ class Ce extends R {
|
|
|
240
241
|
return !e || t !== null && e.blockId !== t ? null : e;
|
|
241
242
|
}
|
|
242
243
|
_getNodeConfigUpdates(e) {
|
|
243
|
-
const { filters: t, strategy: o, strategyId: n, size: i, productIds: s, nodeConfigVersion: l } = e, { partnerName: a } =
|
|
244
|
+
const { filters: t, strategy: o, strategyId: n, size: i, productIds: s, nodeConfigVersion: l } = e, { partnerName: a } = f();
|
|
244
245
|
return {
|
|
245
246
|
filters: t,
|
|
246
247
|
strategy: o,
|
|
@@ -288,14 +289,14 @@ class Ce extends R {
|
|
|
288
289
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !(!e || !this.api)) {
|
|
289
290
|
if (e.blockId !== this.store.currentRecommendationId || !this.currentNode) {
|
|
290
291
|
const { blockId: t, updates: o } = e;
|
|
291
|
-
!
|
|
292
|
+
!p(t, o, h) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
|
|
292
293
|
return;
|
|
293
294
|
}
|
|
294
|
-
|
|
295
|
+
B(this.currentNode, e.updates) && d.updateConfig(
|
|
295
296
|
this.api,
|
|
296
297
|
this.currentNode,
|
|
297
298
|
e.updates,
|
|
298
|
-
|
|
299
|
+
F(this.currentNode, e.updates, h)
|
|
299
300
|
);
|
|
300
301
|
}
|
|
301
302
|
}
|
|
@@ -306,14 +307,14 @@ class Ce extends R {
|
|
|
306
307
|
/** The Product Ids label when the pending write moves the node's ids; the caller's default otherwise. */
|
|
307
308
|
_pendingDescription() {
|
|
308
309
|
const e = this._pendingWriteForNode();
|
|
309
|
-
if (!(!e || !this.currentNode || !
|
|
310
|
-
return
|
|
310
|
+
if (!(!e || !this.currentNode || !D(this.currentNode, e.updates)))
|
|
311
|
+
return L;
|
|
311
312
|
}
|
|
312
313
|
_syncNodeConfigToStore() {
|
|
313
314
|
var n;
|
|
314
315
|
const e = d.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
315
316
|
this.store.patchCurrentBlockConfig({
|
|
316
|
-
strategy: e.strategy,
|
|
317
|
+
strategy: C(e.strategy) ?? e.strategy,
|
|
317
318
|
strategyId: e.strategyId,
|
|
318
319
|
nodeConfigVersion: e.configVersion,
|
|
319
320
|
language: e.language,
|
|
@@ -374,7 +375,7 @@ class Ce extends R {
|
|
|
374
375
|
}
|
|
375
376
|
/**
|
|
376
377
|
* 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).
|
|
378
|
+
* the hard-coded default, or a block copied from another account). Only the default strategy gets an algorithm.
|
|
378
379
|
*/
|
|
379
380
|
_applySmartDefaults() {
|
|
380
381
|
if (!this.currentNode || !this.api)
|
|
@@ -386,10 +387,10 @@ class Ce extends R {
|
|
|
386
387
|
...e.currency,
|
|
387
388
|
code: o,
|
|
388
389
|
symbol: o
|
|
389
|
-
}), e.strategy === m.strategy) {
|
|
390
|
+
}), C(e.strategy) === m.strategy) {
|
|
390
391
|
const a = this.store.getActivePredictiveAlgorithms;
|
|
391
392
|
a.length > 0 && (a.some(
|
|
392
|
-
(
|
|
393
|
+
(N) => N.value === m.strategy
|
|
393
394
|
) || (n = a[0].value, t.strategy = n));
|
|
394
395
|
}
|
|
395
396
|
const l = this.store.getLanguages;
|
|
@@ -398,7 +399,7 @@ class Ce extends R {
|
|
|
398
399
|
this.currentNode,
|
|
399
400
|
t,
|
|
400
401
|
"Applied smart defaults"
|
|
401
|
-
), o && t.currency &&
|
|
402
|
+
), o && t.currency && z({
|
|
402
403
|
currentNode: this.currentNode,
|
|
403
404
|
documentModifier: this.api.getDocumentModifier(),
|
|
404
405
|
currency: t.currency
|
|
@@ -422,10 +423,10 @@ class Ce extends R {
|
|
|
422
423
|
* Reads the recommendation-id attribute from the block element within the node
|
|
423
424
|
*/
|
|
424
425
|
_getRecommendationIdFromNode(e) {
|
|
425
|
-
const t =
|
|
426
|
+
const t = $(e);
|
|
426
427
|
if (!t || !("getAttribute" in t))
|
|
427
428
|
return null;
|
|
428
|
-
const o = t.getAttribute(
|
|
429
|
+
const o = t.getAttribute(S);
|
|
429
430
|
if (!o)
|
|
430
431
|
return null;
|
|
431
432
|
const n = parseInt(o);
|
|
@@ -442,7 +443,7 @@ class Ce extends R {
|
|
|
442
443
|
if (e === null || !n)
|
|
443
444
|
return;
|
|
444
445
|
const i = t !== n.configVersion;
|
|
445
|
-
i && !
|
|
446
|
+
i && !p(
|
|
446
447
|
e,
|
|
447
448
|
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
448
449
|
h
|
|
@@ -459,7 +460,7 @@ class Ce extends R {
|
|
|
459
460
|
};
|
|
460
461
|
}
|
|
461
462
|
_refreshOutsidePanel(e, t) {
|
|
462
|
-
|
|
463
|
+
O(e, {
|
|
463
464
|
pickUpdates: (o) => this._getNodeConfigUpdates(o),
|
|
464
465
|
description: "Update recommendation configuration",
|
|
465
466
|
fetch: t
|
|
@@ -482,19 +483,19 @@ class Ce extends R {
|
|
|
482
483
|
return;
|
|
483
484
|
}
|
|
484
485
|
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = this._pendingDescription(), n = this._stagePendingNodeConfig(t);
|
|
485
|
-
if (
|
|
486
|
+
if (H(this.currentNode)) {
|
|
486
487
|
n && (t.apply(
|
|
487
|
-
new
|
|
488
|
+
new R(o ?? "Update recommendation configuration")
|
|
488
489
|
), this._consumePendingNodeConfig());
|
|
489
490
|
return;
|
|
490
491
|
}
|
|
491
|
-
|
|
492
|
+
Y({
|
|
492
493
|
currentNode: this.currentNode,
|
|
493
494
|
documentModifier: t,
|
|
494
495
|
products: e,
|
|
495
496
|
description: o,
|
|
496
497
|
onApplied: n ? () => this._consumePendingNodeConfig() : void 0
|
|
497
|
-
}) ||
|
|
498
|
+
}) || j({
|
|
498
499
|
currentNode: this.currentNode,
|
|
499
500
|
documentModifier: t,
|
|
500
501
|
products: e,
|
|
@@ -525,8 +526,8 @@ class Ce extends R {
|
|
|
525
526
|
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
|
|
526
527
|
const n = e.currentRecommendationId;
|
|
527
528
|
if (n !== this.trackedBlockId) {
|
|
528
|
-
const
|
|
529
|
-
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(
|
|
529
|
+
const g = this._trackedBlockSnapshot();
|
|
530
|
+
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(g);
|
|
530
531
|
return;
|
|
531
532
|
}
|
|
532
533
|
const i = this._getBlockConfigVersion(n);
|
|
@@ -537,39 +538,39 @@ class Ce extends R {
|
|
|
537
538
|
}
|
|
538
539
|
}
|
|
539
540
|
export {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
541
|
+
Pe as ALGORITHM_CONTROL_ID,
|
|
542
|
+
E as AlgorithmControl,
|
|
543
|
+
q as CONTROL_BLOCK_ID,
|
|
544
|
+
Ie as CURRENCY_CONTROL_ID,
|
|
545
|
+
U as CurrencyControl,
|
|
546
|
+
Se as FILTERS_CONTROL_ID,
|
|
547
|
+
v as FiltersControl,
|
|
548
|
+
Oe as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
549
|
+
Be as LOCALE_CONTROL_ID,
|
|
550
|
+
w as LayoutOrientationControl,
|
|
551
|
+
A as LocaleControl,
|
|
552
|
+
De as PRICE_PLACEMENT_CONTROL_ID,
|
|
553
|
+
Ee as PRODUCT_COUNT_CONTROL_ID,
|
|
554
|
+
ve as PRODUCT_LAYOUT_CONTROL_ID,
|
|
555
|
+
V as PricePlacementControl,
|
|
556
|
+
W as ProductCountControl,
|
|
557
|
+
x as ProductLayoutControl,
|
|
558
|
+
_e as RecommendationBlockControl,
|
|
559
|
+
Ae as SHUFFLE_CONTROL_ID,
|
|
560
|
+
We as STRATEGY_CONTROL_ID,
|
|
561
|
+
M as ShuffleControl,
|
|
562
|
+
G as StrategyControl,
|
|
563
|
+
Me as adjustProductsToSize,
|
|
564
|
+
Ge as formatProductPrice,
|
|
565
|
+
$ as getBlockElement,
|
|
566
|
+
ze as getCardComposition,
|
|
567
|
+
$e as getCurrentLayout,
|
|
568
|
+
He as getMainContainerTbody,
|
|
569
|
+
H as isPartnerManagedBlock,
|
|
570
|
+
Ye as regenerateMobileProductRows,
|
|
571
|
+
j as regenerateProductRowsWithStyles,
|
|
572
|
+
z as setCurrencyAttributes,
|
|
573
|
+
je as updatePricesInPlace,
|
|
574
|
+
Y as updateProductContentInPlace,
|
|
575
|
+
qe as updateSingleProductContent
|
|
575
576
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ATTR_PRODUCT_PRICE as
|
|
1
|
+
import { ATTR_PRODUCT_PRICE as D, ATTR_PRODUCT_OLD_PRICE as O } from "../../constants/selectors.js";
|
|
2
2
|
import { DEFAULT_PRODUCTS_PER_ROW as w } from "../../constants/layout.js";
|
|
3
|
-
import { createBlockTemplate as A, getDefaultProducts as g, DEFAULTS as U, buildSpacer as h, DEFAULT_CARD_COMPOSITION as Y, buildElementRenderer as B,
|
|
4
|
-
import { DEFAULT_CELL_PADDING as
|
|
3
|
+
import { createBlockTemplate as A, getDefaultProducts as g, DEFAULTS as U, buildSpacer as h, DEFAULT_CARD_COMPOSITION as Y, buildElementRenderer as B, buildCellOptions as m, DEFAULT_CARD_VISIBILITY as F } from "../utils.js";
|
|
4
|
+
import { DEFAULT_CELL_PADDING as W, renderInlineGridPriceCell as k, buildFillerCell as H, gridElementRenderer as x } from "./elementRenderer.js";
|
|
5
|
+
import { resolveInlinePriceOrder as y } from "../../utils/inlinePriceOrder.js";
|
|
5
6
|
const G = `
|
|
6
7
|
<tr class="recommendation-product-row">
|
|
7
8
|
<td>
|
|
@@ -28,29 +29,29 @@ const G = `
|
|
|
28
29
|
{-{-CELLS-}-}
|
|
29
30
|
</tr>
|
|
30
31
|
`;
|
|
31
|
-
function j(t, r,
|
|
32
|
-
const { cellPadding: s =
|
|
33
|
-
return L.filter((l) =>
|
|
34
|
-
const _ = (a == null ? void 0 : a[l]) ??
|
|
32
|
+
function j(t, r, n, e = Y, c = {}, i = {}) {
|
|
33
|
+
const { cellPadding: s = W, cardBackgroundColor: u, visibility: a, priceInline: o = !1 } = i, d = (100 / r).toFixed(2), p = r - t.length, T = p > 0 ? H(d, s).repeat(p) : "", I = B(n, e, c), R = y(e), L = o ? e.filter((l) => l !== R.skip) : e, C = m(D, i), P = m(O, i);
|
|
34
|
+
return L.filter((l) => I[l]).map((l) => {
|
|
35
|
+
const _ = (a == null ? void 0 : a[l]) ?? F[l] ?? !0, b = _ ? "" : 'style="display: none;"', S = m(l, i, e), f = t.map((E) => (o && l === R.anchor ? k(
|
|
35
36
|
E,
|
|
36
37
|
R.originalFirst,
|
|
37
38
|
C,
|
|
38
39
|
P,
|
|
39
40
|
u
|
|
40
|
-
) :
|
|
41
|
-
return V.replace("{-{-ATTR_TYPE-}-}", l).replace("{-{-VISIBILITY-}-}", _ ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", b).replace("{-{-CELLS-}-}",
|
|
41
|
+
) : I[l](E, S)).replace("<td", `<td width="${d}%"`)).join("");
|
|
42
|
+
return V.replace("{-{-ATTR_TYPE-}-}", l).replace("{-{-VISIBILITY-}-}", _ ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", b).replace("{-{-CELLS-}-}", f + T);
|
|
42
43
|
}).join("");
|
|
43
44
|
}
|
|
44
|
-
function v(t, r,
|
|
45
|
+
function v(t, r, n, e, c = {}, i = {}) {
|
|
45
46
|
const s = [];
|
|
46
|
-
for (let
|
|
47
|
-
s.push(t.slice(
|
|
47
|
+
for (let o = 0; o < t.length; o += r)
|
|
48
|
+
s.push(t.slice(o, o + r));
|
|
48
49
|
const u = h(i.rowSpacingPx);
|
|
49
|
-
return s.map((
|
|
50
|
+
return s.map((o, d) => {
|
|
50
51
|
const p = j(
|
|
51
|
-
n,
|
|
52
|
-
r,
|
|
53
52
|
o,
|
|
53
|
+
r,
|
|
54
|
+
n,
|
|
54
55
|
e,
|
|
55
56
|
c,
|
|
56
57
|
i
|
|
@@ -58,22 +59,22 @@ function v(t, r, o, e, c = {}, i = {}) {
|
|
|
58
59
|
return d > 0 ? u + T : T;
|
|
59
60
|
}).join("");
|
|
60
61
|
}
|
|
61
|
-
function M(t, r,
|
|
62
|
+
function M(t, r, n, e = {}, c = {}) {
|
|
62
63
|
return v(
|
|
63
64
|
t,
|
|
64
65
|
r,
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
x,
|
|
67
|
+
n,
|
|
67
68
|
e,
|
|
68
69
|
c
|
|
69
70
|
);
|
|
70
71
|
}
|
|
71
|
-
function
|
|
72
|
-
const r = t ? `ins-recommendation-v3-block-${t}` : void 0,
|
|
73
|
-
return
|
|
72
|
+
function X(t) {
|
|
73
|
+
const r = t ? `ins-recommendation-v3-block-${t}` : void 0, n = A("grid", r), e = g(), c = M(e, w);
|
|
74
|
+
return n.replace("{-{-TITLE-}-}", U.TITLE).replace("{-{-PRODUCT_ROWS-}-}", c).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
|
|
74
75
|
}
|
|
75
76
|
export {
|
|
76
|
-
|
|
77
|
+
X as getDefaultTemplate,
|
|
77
78
|
j as prepareGridAttributeRows,
|
|
78
79
|
v as prepareGridProductRows,
|
|
79
80
|
M as prepareProductRows
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ATTR_PRODUCT_IMAGE as p, ATTR_PRODUCT_BUTTON as C, ATTR_PRODUCT_OLD_PRICE as A, ATTR_PRODUCT_PRICE as
|
|
2
|
-
import { buildSpacer as
|
|
3
|
-
import { listElementRenderer as
|
|
1
|
+
import { ATTR_PRODUCT_IMAGE as p, ATTR_PRODUCT_BUTTON as C, ATTR_PRODUCT_OLD_PRICE as A, ATTR_PRODUCT_PRICE as m } from "../../constants/selectors.js";
|
|
2
|
+
import { buildSpacer as I, DEFAULT_CARD_COMPOSITION as g, buildElementRenderer as E, buildCellOptions as i, DEFAULT_CARD_VISIBILITY as w } from "../utils.js";
|
|
3
|
+
import { listElementRenderer as y, renderInlineListPriceRow as L } from "./elementRenderer.js";
|
|
4
|
+
import { resolveInlinePriceOrder as O } from "../../utils/inlinePriceOrder.js";
|
|
4
5
|
const S = "0 5px";
|
|
5
6
|
function U(l, r, n) {
|
|
6
|
-
const
|
|
7
|
+
const e = n ? "" : ' style="display: none;"', o = l.replace(/<tr>/, "").replace(/<\/tr>/, "");
|
|
7
8
|
return `<tr
|
|
8
9
|
class="recommendation-attribute-row"
|
|
9
10
|
data-attribute-type="${r}"
|
|
10
|
-
data-visibility="${n ? "1" : "0"}"${
|
|
11
|
+
data-visibility="${n ? "1" : "0"}"${e}>${o}</tr>`;
|
|
11
12
|
}
|
|
12
13
|
const N = `
|
|
13
14
|
<tr class="recommendation-product-row">
|
|
@@ -27,40 +28,40 @@ const N = `
|
|
|
27
28
|
</td>
|
|
28
29
|
</tr>
|
|
29
30
|
`;
|
|
30
|
-
function x(l, r = g, n = {},
|
|
31
|
+
function x(l, r = g, n = {}, e = {}) {
|
|
31
32
|
const {
|
|
32
33
|
cellPadding: o = S,
|
|
33
34
|
cardBackgroundColor: d,
|
|
34
35
|
visibility: c,
|
|
35
36
|
priceInline: a = !1
|
|
36
|
-
} =
|
|
37
|
+
} = e, u = d ? ` style="table-layout: fixed; background-color: ${d};"` : ' style="table-layout: fixed;"', s = E(y, r, n), P = s[p](l, i(p, e)), R = O(r), T = `
|
|
37
38
|
<td class="product-info-cell" valign="middle" style="padding: 15px;">
|
|
38
39
|
<table cellpadding="0" cellspacing="0" role="presentation" width="100%" style="table-layout: fixed;">
|
|
39
40
|
<tbody>
|
|
40
|
-
${r.filter((
|
|
41
|
-
const b = (c == null ? void 0 : c[
|
|
41
|
+
${r.filter((t) => t !== p && t !== C).filter((t) => !(a && t === R.skip)).filter((t) => s[t]).map((t) => {
|
|
42
|
+
const b = (c == null ? void 0 : c[t]) ?? w[t] ?? !0, f = a && t === R.anchor ? L(
|
|
42
43
|
l,
|
|
43
44
|
R.originalFirst,
|
|
44
|
-
i(
|
|
45
|
-
i(A,
|
|
46
|
-
) : s[
|
|
47
|
-
return U(f,
|
|
45
|
+
i(m, e),
|
|
46
|
+
i(A, e)
|
|
47
|
+
) : s[t](l, i(t, e, r));
|
|
48
|
+
return U(f, t, b);
|
|
48
49
|
}).join(`
|
|
49
50
|
`)}
|
|
50
51
|
</tbody>
|
|
51
52
|
</table>
|
|
52
53
|
</td>
|
|
53
|
-
`, _ = s[C](l, i(C,
|
|
54
|
+
`, _ = s[C](l, i(C, e)), D = P + T + _;
|
|
54
55
|
return N.replace("{-{-CARD_PADDING-}-}", o).replace("{-{-WRAPPER_STYLE-}-}", u).replace("{-{-PRODUCT_CONTENT-}-}", D);
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
-
const o =
|
|
57
|
+
function k(l, r, n = {}, e = {}) {
|
|
58
|
+
const o = I(e.rowSpacingPx);
|
|
58
59
|
return l.map((d, c) => {
|
|
59
|
-
const a = x(d, r, n,
|
|
60
|
+
const a = x(d, r, n, e);
|
|
60
61
|
return c > 0 ? o + a : a;
|
|
61
62
|
}).join("");
|
|
62
63
|
}
|
|
63
64
|
export {
|
|
64
65
|
x as getListProductCard,
|
|
65
|
-
|
|
66
|
+
k as prepareProductRows
|
|
66
67
|
};
|