@useinsider/guido 3.7.2-beta.1e8f93e → 3.7.2-beta.2220fb0
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/@types/config/schemas.js +70 -66
- package/dist/composables/usePreviewMode.js +15 -14
- package/dist/composables/useRecommendationPreview.js +100 -0
- package/dist/config/compiler/recommendationCompilerRules.js +1 -1
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +90 -82
- package/dist/config/migrator/recommendation/htmlBuilder.js +59 -58
- package/dist/config/migrator/recommendation/settingsMapper.js +38 -33
- package/dist/extensions/Blocks/Items/block.js +29 -48
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +45 -62
- package/dist/extensions/Blocks/Recommendation/block.js +60 -41
- package/dist/extensions/Blocks/Recommendation/canvasPreview.css.js +16 -0
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +41 -32
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +369 -288
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +96 -84
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +133 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +83 -81
- package/dist/extensions/Blocks/Recommendation/extension.js +30 -29
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +21 -7
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +64 -4
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +7 -5
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +109 -78
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +31 -30
- package/dist/extensions/Blocks/Recommendation/templates/index.js +9 -7
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +78 -61
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +90 -55
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useRecommendationPreview.d.ts +10 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/block.d.ts +0 -8
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +29 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +59 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +16 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +39 -1
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +15 -0
- package/dist/src/stores/config.d.ts +36 -0
- package/package.json +1 -1
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
var
|
|
2
|
-
var p = (d,
|
|
3
|
-
var s = (d,
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var p = (d, l, t) => l in d ? f(d, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[l] = t;
|
|
3
|
+
var s = (d, l, t) => p(d, typeof l != "symbol" ? l + "" : l, t);
|
|
4
4
|
import { CommonControl as g } from "../../../common-control.js";
|
|
5
|
-
import { DEFAULT_NODE_CONFIG as
|
|
6
|
-
import { RecommendationConfigService as
|
|
5
|
+
import { DEFAULT_NODE_CONFIG as c } from "../../constants/defaultConfig.js";
|
|
6
|
+
import { RecommendationConfigService as m } from "../../services/configService.js";
|
|
7
7
|
import { useRecommendationExtensionStore as y } from "../../store/recommendation.js";
|
|
8
8
|
import { AlgorithmControl as R } from "./algorithm.js";
|
|
9
|
-
import { ALGORITHM_CONTROL_ID as
|
|
10
|
-
import { CurrencyControl as
|
|
11
|
-
import { CURRENCY_CONTROL_ID as
|
|
12
|
-
import { FiltersControl as
|
|
13
|
-
import { FILTERS_CONTROL_ID as
|
|
14
|
-
import { LayoutOrientationControl as
|
|
15
|
-
import { LAYOUT_ORIENTATION_CONTROL_ID as
|
|
16
|
-
import { LocaleControl as
|
|
17
|
-
import { LOCALE_CONTROL_ID as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
import { ALGORITHM_CONTROL_ID as Z } from "./algorithm.js";
|
|
10
|
+
import { CurrencyControl as N } from "./currency.js";
|
|
11
|
+
import { CURRENCY_CONTROL_ID as et } from "./currency.js";
|
|
12
|
+
import { FiltersControl as I } from "./filters.js";
|
|
13
|
+
import { FILTERS_CONTROL_ID as rt } from "./filters.js";
|
|
14
|
+
import { LayoutOrientationControl as _ } from "./layoutOrientation.js";
|
|
15
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as it } from "./layoutOrientation.js";
|
|
16
|
+
import { LocaleControl as b } from "./locale.js";
|
|
17
|
+
import { LOCALE_CONTROL_ID as ct } from "./locale.js";
|
|
18
|
+
import { PricePlacementControl as T } from "./pricePlacement.js";
|
|
19
|
+
import { PRICE_PLACEMENT_CONTROL_ID as at } from "./pricePlacement.js";
|
|
20
|
+
import { ProductCountControl as P } from "./productCount.js";
|
|
21
|
+
import { PRODUCT_COUNT_CONTROL_ID as dt } from "./productCount.js";
|
|
22
|
+
import { ProductLayoutControl as O } from "./productLayout.js";
|
|
23
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as ht } from "./productLayout.js";
|
|
24
|
+
import { ShuffleControl as L } from "./shuffle.js";
|
|
25
|
+
import { SHUFFLE_CONTROL_ID as ft } from "./shuffle.js";
|
|
26
|
+
import { setCurrencyAttributes as S, getBlockElement as k, updateProductContentInPlace as D, regenerateProductRowsWithStyles as E } from "./utils.js";
|
|
27
|
+
import { adjustProductsToSize as gt, formatProductPrice as yt, getCardComposition as Rt, getCurrentLayout as Nt, reapplySpacing as It, regenerateMobileProductRows as _t, regenerateProductRows as bt, updatePricesInPlace as Tt, updateSingleProductContent as Pt } from "./utils.js";
|
|
28
|
+
import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
29
|
+
const w = "recommendation-id", A = "ui-elements-recommendation-block";
|
|
30
|
+
class J extends g {
|
|
29
31
|
constructor() {
|
|
30
32
|
super(...arguments);
|
|
31
33
|
s(this, "store", y());
|
|
@@ -40,11 +42,12 @@ class K extends g {
|
|
|
40
42
|
s(this, "productLayoutControl", null);
|
|
41
43
|
s(this, "filtersControl", null);
|
|
42
44
|
s(this, "shuffleControl", null);
|
|
45
|
+
s(this, "pricePlacementControl", null);
|
|
43
46
|
s(this, "layoutOrientationControl", null);
|
|
44
47
|
/**
|
|
45
48
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
46
49
|
*/
|
|
47
|
-
s(this, "_debouncedFetchProducts",
|
|
50
|
+
s(this, "_debouncedFetchProducts", h(() => {
|
|
48
51
|
this.store.fetchRecommendationProducts();
|
|
49
52
|
}, 500));
|
|
50
53
|
/**
|
|
@@ -58,16 +61,16 @@ class K extends g {
|
|
|
58
61
|
* count. The store pads products to the configured size, so in-place only
|
|
59
62
|
* fails when the size actually changed.
|
|
60
63
|
*/
|
|
61
|
-
s(this, "_debouncedRegenerateWithProducts",
|
|
64
|
+
s(this, "_debouncedRegenerateWithProducts", h(() => {
|
|
62
65
|
const t = this.store.recommendationProducts;
|
|
63
66
|
if (!this.currentNode || !this.api)
|
|
64
67
|
return;
|
|
65
68
|
const e = this.api.getDocumentModifier();
|
|
66
|
-
|
|
69
|
+
D({
|
|
67
70
|
currentNode: this.currentNode,
|
|
68
71
|
documentModifier: e,
|
|
69
72
|
products: t
|
|
70
|
-
}) ||
|
|
73
|
+
}) || E({
|
|
71
74
|
currentNode: this.currentNode,
|
|
72
75
|
documentModifier: e,
|
|
73
76
|
products: t
|
|
@@ -75,10 +78,10 @@ class K extends g {
|
|
|
75
78
|
}, 100));
|
|
76
79
|
}
|
|
77
80
|
getId() {
|
|
78
|
-
return
|
|
81
|
+
return A;
|
|
79
82
|
}
|
|
80
83
|
getTemplate() {
|
|
81
|
-
return this.algorithmControl = new R(), this.localeControl = new
|
|
84
|
+
return this.algorithmControl = new R(), this.localeControl = new b(), this.currencyControl = new N(), this.productCountControl = new P(), this.productLayoutControl = new O(), this.filtersControl = new I(), this.shuffleControl = new L(), this.pricePlacementControl = new T(), this.layoutOrientationControl = new _(), [
|
|
82
85
|
this.algorithmControl,
|
|
83
86
|
this.localeControl,
|
|
84
87
|
this.currencyControl,
|
|
@@ -86,6 +89,7 @@ class K extends g {
|
|
|
86
89
|
this.productLayoutControl,
|
|
87
90
|
this.filtersControl,
|
|
88
91
|
this.shuffleControl,
|
|
92
|
+
this.pricePlacementControl,
|
|
89
93
|
this.layoutOrientationControl
|
|
90
94
|
].forEach((e) => {
|
|
91
95
|
e.api = this.api;
|
|
@@ -96,6 +100,7 @@ class K extends g {
|
|
|
96
100
|
${this.productLayoutControl.getTemplate()}
|
|
97
101
|
${this.algorithmControl.getTemplate()}
|
|
98
102
|
${this.localeControl.getTemplate()}
|
|
103
|
+
${this.pricePlacementControl.getTemplate()}
|
|
99
104
|
${this.currencyControl.getTemplate()}
|
|
100
105
|
${this.filtersControl.getTemplate()}
|
|
101
106
|
${this.shuffleControl.getTemplate()}
|
|
@@ -125,7 +130,8 @@ class K extends g {
|
|
|
125
130
|
this.currencyControl,
|
|
126
131
|
this.productLayoutControl,
|
|
127
132
|
this.filtersControl,
|
|
128
|
-
this.shuffleControl
|
|
133
|
+
this.shuffleControl,
|
|
134
|
+
this.pricePlacementControl
|
|
129
135
|
].forEach((n) => {
|
|
130
136
|
var i;
|
|
131
137
|
n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
|
|
@@ -140,7 +146,8 @@ class K extends g {
|
|
|
140
146
|
this.currencyControl,
|
|
141
147
|
this.productLayoutControl,
|
|
142
148
|
this.filtersControl,
|
|
143
|
-
this.shuffleControl
|
|
149
|
+
this.shuffleControl,
|
|
150
|
+
this.pricePlacementControl
|
|
144
151
|
].forEach((e) => {
|
|
145
152
|
var o;
|
|
146
153
|
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
@@ -159,7 +166,8 @@ class K extends g {
|
|
|
159
166
|
this.currencyControl,
|
|
160
167
|
this.productLayoutControl,
|
|
161
168
|
this.filtersControl,
|
|
162
|
-
this.shuffleControl
|
|
169
|
+
this.shuffleControl,
|
|
170
|
+
this.pricePlacementControl
|
|
163
171
|
].forEach((e) => {
|
|
164
172
|
var o;
|
|
165
173
|
e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
|
|
@@ -178,7 +186,7 @@ class K extends g {
|
|
|
178
186
|
*/
|
|
179
187
|
_syncNodeConfigToStore() {
|
|
180
188
|
var r;
|
|
181
|
-
const t =
|
|
189
|
+
const t = m.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
|
|
182
190
|
this.store.patchCurrentBlockConfig({
|
|
183
191
|
strategy: t.strategy,
|
|
184
192
|
language: t.language,
|
|
@@ -193,6 +201,8 @@ class K extends g {
|
|
|
193
201
|
// for filters (edited via the filter drawer).
|
|
194
202
|
...o ? {} : { filters: t.filters },
|
|
195
203
|
shuffleProducts: t.shuffleProducts,
|
|
204
|
+
priceMovedToNextLine: t.priceMovedToNextLine,
|
|
205
|
+
priceHideIfSameAsDiscounted: t.priceHideIfSameAsDiscounted,
|
|
196
206
|
currencySettings: {
|
|
197
207
|
name: t.currency.code,
|
|
198
208
|
value: t.currency.code,
|
|
@@ -239,36 +249,36 @@ class K extends g {
|
|
|
239
249
|
_applySmartDefaults() {
|
|
240
250
|
if (!this.currentNode || !this.api)
|
|
241
251
|
return;
|
|
242
|
-
const t =
|
|
252
|
+
const t = m.getConfig(this.currentNode), e = {};
|
|
243
253
|
let o = null, r = null, n = null;
|
|
244
|
-
if (t.currency.code ===
|
|
254
|
+
if (t.currency.code === c.currency.code) {
|
|
245
255
|
const { currencyList: i } = this.store;
|
|
246
256
|
i.length > 0 && (i.some(
|
|
247
|
-
(u) => u.value === `price.${
|
|
257
|
+
(u) => u.value === `price.${c.currency.code}`
|
|
248
258
|
) || (o = i[0].value.replace("price.", ""), e.currency = {
|
|
249
|
-
...
|
|
259
|
+
...c.currency,
|
|
250
260
|
code: o,
|
|
251
261
|
symbol: o
|
|
252
262
|
}));
|
|
253
263
|
}
|
|
254
|
-
if (t.strategy ===
|
|
264
|
+
if (t.strategy === c.strategy) {
|
|
255
265
|
const i = this.store.getActivePredictiveAlgorithms;
|
|
256
266
|
i.length > 0 && (i.some(
|
|
257
|
-
(u) => u.value ===
|
|
267
|
+
(u) => u.value === c.strategy
|
|
258
268
|
) || (r = i[0].value, e.strategy = r));
|
|
259
269
|
}
|
|
260
|
-
if (t.language ===
|
|
270
|
+
if (t.language === c.language) {
|
|
261
271
|
const i = this.store.getLanguages;
|
|
262
272
|
i.length > 0 && (i.some(
|
|
263
|
-
(u) => u.value ===
|
|
273
|
+
(u) => u.value === c.language
|
|
264
274
|
) || (n = i[0].value, e.language = n));
|
|
265
275
|
}
|
|
266
|
-
!o && !r && !n || (
|
|
276
|
+
!o && !r && !n || (m.updateConfig(
|
|
267
277
|
this.api,
|
|
268
278
|
this.currentNode,
|
|
269
279
|
e,
|
|
270
280
|
"Applied smart defaults"
|
|
271
|
-
), o && e.currency &&
|
|
281
|
+
), o && e.currency && S({
|
|
272
282
|
currentNode: this.currentNode,
|
|
273
283
|
documentModifier: this.api.getDocumentModifier(),
|
|
274
284
|
currency: e.currency
|
|
@@ -278,10 +288,10 @@ class K extends g {
|
|
|
278
288
|
name: o,
|
|
279
289
|
value: o,
|
|
280
290
|
symbol: o,
|
|
281
|
-
alignment:
|
|
282
|
-
decimalCount:
|
|
283
|
-
decimalSeparator:
|
|
284
|
-
thousandSeparator:
|
|
291
|
+
alignment: c.currency.alignment === "before" ? "0" : "1",
|
|
292
|
+
decimalCount: c.currency.decimalCount.toString(),
|
|
293
|
+
decimalSeparator: c.currency.decimalSeparator,
|
|
294
|
+
thousandSeparator: c.currency.thousandSeparator
|
|
285
295
|
}
|
|
286
296
|
} : {},
|
|
287
297
|
...r ? { strategy: r } : {},
|
|
@@ -292,10 +302,10 @@ class K extends g {
|
|
|
292
302
|
* Reads the recommendation-id attribute from the block element within the node
|
|
293
303
|
*/
|
|
294
304
|
_getRecommendationIdFromNode(t) {
|
|
295
|
-
const e =
|
|
305
|
+
const e = k(t);
|
|
296
306
|
if (!e || !("getAttribute" in e))
|
|
297
307
|
return null;
|
|
298
|
-
const o = e.getAttribute(
|
|
308
|
+
const o = e.getAttribute(w);
|
|
299
309
|
if (!o)
|
|
300
310
|
return null;
|
|
301
311
|
const r = parseInt(o);
|
|
@@ -325,8 +335,8 @@ class K extends g {
|
|
|
325
335
|
}
|
|
326
336
|
const i = t.$state.configVersion;
|
|
327
337
|
i !== o && (o = i, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
|
|
328
|
-
const
|
|
329
|
-
u &&
|
|
338
|
+
const a = t.recommendationProducts, u = a !== e, C = Array.isArray(a) && a.length > 0;
|
|
339
|
+
u && C && (e = a, this._debouncedRegenerateWithProducts());
|
|
330
340
|
});
|
|
331
341
|
}
|
|
332
342
|
/**
|
|
@@ -337,7 +347,7 @@ class K extends g {
|
|
|
337
347
|
if (!this.currentNode || !this.api)
|
|
338
348
|
return;
|
|
339
349
|
const { filters: t } = this.store.recommendationConfigs;
|
|
340
|
-
|
|
350
|
+
m.updateConfig(
|
|
341
351
|
this.api,
|
|
342
352
|
this.currentNode,
|
|
343
353
|
{ filters: t },
|
|
@@ -346,35 +356,37 @@ class K extends g {
|
|
|
346
356
|
}
|
|
347
357
|
}
|
|
348
358
|
export {
|
|
349
|
-
|
|
359
|
+
Z as ALGORITHM_CONTROL_ID,
|
|
350
360
|
R as AlgorithmControl,
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
at as
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
T as
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
361
|
+
A as CONTROL_BLOCK_ID,
|
|
362
|
+
et as CURRENCY_CONTROL_ID,
|
|
363
|
+
N as CurrencyControl,
|
|
364
|
+
rt as FILTERS_CONTROL_ID,
|
|
365
|
+
I as FiltersControl,
|
|
366
|
+
it as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
367
|
+
ct as LOCALE_CONTROL_ID,
|
|
368
|
+
_ as LayoutOrientationControl,
|
|
369
|
+
b as LocaleControl,
|
|
370
|
+
at as PRICE_PLACEMENT_CONTROL_ID,
|
|
371
|
+
dt as PRODUCT_COUNT_CONTROL_ID,
|
|
372
|
+
ht as PRODUCT_LAYOUT_CONTROL_ID,
|
|
373
|
+
T as PricePlacementControl,
|
|
374
|
+
P as ProductCountControl,
|
|
375
|
+
O as ProductLayoutControl,
|
|
376
|
+
J as RecommendationBlockControl,
|
|
377
|
+
ft as SHUFFLE_CONTROL_ID,
|
|
378
|
+
L as ShuffleControl,
|
|
379
|
+
gt as adjustProductsToSize,
|
|
380
|
+
yt as formatProductPrice,
|
|
381
|
+
k as getBlockElement,
|
|
382
|
+
Rt as getCardComposition,
|
|
383
|
+
Nt as getCurrentLayout,
|
|
384
|
+
It as reapplySpacing,
|
|
385
|
+
_t as regenerateMobileProductRows,
|
|
386
|
+
bt as regenerateProductRows,
|
|
387
|
+
E as regenerateProductRowsWithStyles,
|
|
388
|
+
S as setCurrencyAttributes,
|
|
389
|
+
Tt as updatePricesInPlace,
|
|
390
|
+
D as updateProductContentInPlace,
|
|
391
|
+
Pt as updateSingleProductContent
|
|
380
392
|
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var p = (i, o, e) => o in i ? m(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
|
|
3
|
+
var d = (i, o, e) => p(i, typeof o != "symbol" ? o + "" : o, e);
|
|
4
|
+
import { UEAttr as u, ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as f } from "../../../common-control.js";
|
|
6
|
+
import { ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OLD_PRICE as I } from "../../constants/selectors.js";
|
|
7
|
+
import { RecommendationConfigService as n } from "../../services/configService.js";
|
|
8
|
+
import { useRecommendationExtensionStore as T } from "../../store/recommendation.js";
|
|
9
|
+
import { getBlockElement as l, regenerateProductRowsWithStyles as g } from "./utils.js";
|
|
10
|
+
const E = "recommendation-price-placement-control", N = "hide-price", r = {
|
|
11
|
+
ORIENTATION: "priceOrientation",
|
|
12
|
+
HIDE_IF_SAME: "priceHideIfSameAsDiscounted"
|
|
13
|
+
}, A = [
|
|
14
|
+
{ icon: "vertical-orientation", value: "vertical" },
|
|
15
|
+
{ icon: "horizontal-orientation", value: "horizontal" }
|
|
16
|
+
], C = (i) => i ? "vertical" : "horizontal";
|
|
17
|
+
class P extends f {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
d(this, "store", T());
|
|
21
|
+
}
|
|
22
|
+
getId() {
|
|
23
|
+
return E;
|
|
24
|
+
}
|
|
25
|
+
getTemplate() {
|
|
26
|
+
return `
|
|
27
|
+
<div class="price-placement-control-container" style="border-bottom: 1px solid #e0e0e0;">
|
|
28
|
+
${this._GuTwoColumns([
|
|
29
|
+
this._GuLabel({ text: this.api.translate("Product Price Orientation") }),
|
|
30
|
+
this._GuRadioButton({
|
|
31
|
+
name: r.ORIENTATION,
|
|
32
|
+
buttons: A
|
|
33
|
+
})
|
|
34
|
+
])}
|
|
35
|
+
${this._GuTwoColumns([
|
|
36
|
+
this._GuLabel({ text: this.api.translate("Hide if same as discounted") }),
|
|
37
|
+
this._GuToggle(r.HIDE_IF_SAME)
|
|
38
|
+
])}
|
|
39
|
+
</div>
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
onRender() {
|
|
43
|
+
const e = n.getConfig(this.currentNode);
|
|
44
|
+
this._initializeHideToggle(e), this._setFormValues(e), this._updateOrientationDisabled(), this._listenToFormUpdates();
|
|
45
|
+
}
|
|
46
|
+
onTemplateNodeUpdated(e) {
|
|
47
|
+
super.onTemplateNodeUpdated(e), this._setFormValues(n.getConfig(this.currentNode)), this._updateOrientationDisabled();
|
|
48
|
+
}
|
|
49
|
+
_setFormValues(e) {
|
|
50
|
+
this.api.updateValues({
|
|
51
|
+
[r.ORIENTATION]: C(e.priceMovedToNextLine),
|
|
52
|
+
[r.HIDE_IF_SAME]: e.priceHideIfSameAsDiscounted
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
_initializeHideToggle(e) {
|
|
56
|
+
this.api.setUIEAttribute(
|
|
57
|
+
r.HIDE_IF_SAME,
|
|
58
|
+
u.SELECTPICKER.items,
|
|
59
|
+
e.priceHideIfSameAsDiscounted
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Disables the orientation radio when a price element is hidden via Card
|
|
64
|
+
* Composition — orientation is meaningless without both prices visible.
|
|
65
|
+
* Visibility lives on the attribute rows' `data-visibility` (set by the Card
|
|
66
|
+
* Composition control). Inline mode has no standalone original-price row, so
|
|
67
|
+
* the merged "Product Prices" entry (the price row) governs.
|
|
68
|
+
*/
|
|
69
|
+
_updateOrientationDisabled() {
|
|
70
|
+
const e = l(this.currentNode);
|
|
71
|
+
if (!e || !("querySelectorAll" in e))
|
|
72
|
+
return;
|
|
73
|
+
const s = Array.from(
|
|
74
|
+
e.querySelectorAll(".recommendation-attribute-row[data-attribute-type]")
|
|
75
|
+
).some((a) => {
|
|
76
|
+
const c = a.getAttribute("data-attribute-type");
|
|
77
|
+
return (c === _ || c === I) && a.getAttribute("data-visibility") === "0";
|
|
78
|
+
});
|
|
79
|
+
this.api.setUIEAttribute(
|
|
80
|
+
r.ORIENTATION,
|
|
81
|
+
u.RADIO_BUTTONS.disabled,
|
|
82
|
+
s ? "true" : "false"
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
_onOrientationChange(e) {
|
|
86
|
+
if (!this.currentNode)
|
|
87
|
+
return;
|
|
88
|
+
const t = e === "vertical";
|
|
89
|
+
n.getConfig(this.currentNode).priceMovedToNextLine !== t && (n.updateConfig(
|
|
90
|
+
this.api,
|
|
91
|
+
this.currentNode,
|
|
92
|
+
{ priceMovedToNextLine: t },
|
|
93
|
+
`${t ? "Stacked" : "Inlined"} recommendation prices`
|
|
94
|
+
), this.store.patchCurrentBlockConfig({ priceMovedToNextLine: t }), this._regenerate());
|
|
95
|
+
}
|
|
96
|
+
_onHideIfSameChange(e) {
|
|
97
|
+
!this.currentNode || n.getConfig(this.currentNode).priceHideIfSameAsDiscounted === e || (n.updateConfig(
|
|
98
|
+
this.api,
|
|
99
|
+
this.currentNode,
|
|
100
|
+
{ priceHideIfSameAsDiscounted: e },
|
|
101
|
+
`${e ? "Enabled" : "Disabled"} hide-if-same price`
|
|
102
|
+
), this.store.patchCurrentBlockConfig({ priceHideIfSameAsDiscounted: e }), this._stampHideIfSameAttr(e));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Mirrors the hide-if-same flag onto the durable `hide-price` block attribute
|
|
106
|
+
* read by email-service at send time.
|
|
107
|
+
*/
|
|
108
|
+
_stampHideIfSameAttr(e) {
|
|
109
|
+
const t = l(this.currentNode);
|
|
110
|
+
t && this.api.getDocumentModifier().modifyHtml(t).setAttribute(N, String(e)).apply(new h("Update hide-if-same price flag"));
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Rebuilds the product rows so the renderer re-reads the inline/stacked
|
|
114
|
+
* layout flag from the store. Used by the orientation change only.
|
|
115
|
+
*/
|
|
116
|
+
_regenerate() {
|
|
117
|
+
this.currentNode && g({
|
|
118
|
+
currentNode: this.currentNode,
|
|
119
|
+
documentModifier: this.api.getDocumentModifier()
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
_listenToFormUpdates() {
|
|
123
|
+
this.api.onValueChanged(r.ORIENTATION, (e) => {
|
|
124
|
+
(e === "vertical" || e === "horizontal") && this._onOrientationChange(e);
|
|
125
|
+
}), this.api.onValueChanged(r.HIDE_IF_SAME, (e) => {
|
|
126
|
+
this._onHideIfSameChange(!!e);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
E as PRICE_PLACEMENT_CONTROL_ID,
|
|
132
|
+
P as PricePlacementControl
|
|
133
|
+
};
|