@useinsider/guido 3.7.0-beta.830822b → 3.7.0-beta.9fddd7d
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/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/enums/extensions/recommendationBlock.js +1 -3
- package/dist/extensions/Blocks/Recommendation/block.js +58 -39
- 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 +84 -72
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +133 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +68 -66
- 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 +12 -10
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +101 -72
- 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 +74 -59
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +88 -57
- package/dist/services/recommendationApi.js +19 -31
- 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/enums/extensions/recommendationBlock.d.ts +0 -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/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 +33 -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 N } from "./algorithm.js";
|
|
9
|
-
import { ALGORITHM_CONTROL_ID as
|
|
9
|
+
import { ALGORITHM_CONTROL_ID as Z } from "./algorithm.js";
|
|
10
10
|
import { CurrencyControl as R } from "./currency.js";
|
|
11
|
-
import { CURRENCY_CONTROL_ID as
|
|
11
|
+
import { CURRENCY_CONTROL_ID as et } from "./currency.js";
|
|
12
12
|
import { FiltersControl as _ } from "./filters.js";
|
|
13
|
-
import { FILTERS_CONTROL_ID as
|
|
13
|
+
import { FILTERS_CONTROL_ID as rt } from "./filters.js";
|
|
14
14
|
import { LayoutOrientationControl as b } from "./layoutOrientation.js";
|
|
15
|
-
import { LAYOUT_ORIENTATION_CONTROL_ID as
|
|
16
|
-
import { LocaleControl as
|
|
17
|
-
import { LOCALE_CONTROL_ID as
|
|
15
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as it } from "./layoutOrientation.js";
|
|
16
|
+
import { LocaleControl as P } 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";
|
|
18
20
|
import { ProductCountControl as I } from "./productCount.js";
|
|
19
|
-
import { PRODUCT_COUNT_CONTROL_ID as
|
|
20
|
-
import { ProductLayoutControl as
|
|
21
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
22
|
-
import { ShuffleControl as
|
|
23
|
-
import { SHUFFLE_CONTROL_ID as
|
|
24
|
-
import { setCurrencyAttributes as
|
|
25
|
-
import { adjustProductsToSize as
|
|
26
|
-
import { useDebounceFn as
|
|
27
|
-
const
|
|
28
|
-
class
|
|
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 D, updateProductContentInPlace as E, regenerateProductRowsWithStyles as k } from "./utils.js";
|
|
27
|
+
import { adjustProductsToSize as gt, formatProductPrice as yt, getCardComposition as Nt, getCurrentLayout as Rt, reapplySpacing as _t, regenerateMobileProductRows as bt, regenerateProductRows as Pt, updatePricesInPlace as Tt, updateSingleProductContent as It } from "./utils.js";
|
|
28
|
+
import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
29
|
+
const A = "recommendation-id", v = "ui-elements-recommendation-block";
|
|
30
|
+
class J extends g {
|
|
29
31
|
constructor() {
|
|
30
32
|
super(...arguments);
|
|
31
33
|
s(this, "store", y());
|
|
@@ -39,11 +41,12 @@ class K extends g {
|
|
|
39
41
|
s(this, "productLayoutControl", null);
|
|
40
42
|
s(this, "filtersControl", null);
|
|
41
43
|
s(this, "shuffleControl", null);
|
|
44
|
+
s(this, "pricePlacementControl", null);
|
|
42
45
|
s(this, "layoutOrientationControl", null);
|
|
43
46
|
/**
|
|
44
47
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
45
48
|
*/
|
|
46
|
-
s(this, "_debouncedFetchProducts",
|
|
49
|
+
s(this, "_debouncedFetchProducts", h(() => {
|
|
47
50
|
this.store.fetchRecommendationProducts();
|
|
48
51
|
}, 500));
|
|
49
52
|
/**
|
|
@@ -57,12 +60,12 @@ class K extends g {
|
|
|
57
60
|
* count. The store pads products to the configured size, so in-place only
|
|
58
61
|
* fails when the size actually changed.
|
|
59
62
|
*/
|
|
60
|
-
s(this, "_debouncedRegenerateWithProducts",
|
|
63
|
+
s(this, "_debouncedRegenerateWithProducts", h(() => {
|
|
61
64
|
const t = this.store.recommendationProducts;
|
|
62
65
|
if (!this.currentNode || !this.api)
|
|
63
66
|
return;
|
|
64
67
|
const e = this.api.getDocumentModifier();
|
|
65
|
-
|
|
68
|
+
E({
|
|
66
69
|
currentNode: this.currentNode,
|
|
67
70
|
documentModifier: e,
|
|
68
71
|
products: t
|
|
@@ -77,7 +80,7 @@ class K extends g {
|
|
|
77
80
|
return v;
|
|
78
81
|
}
|
|
79
82
|
getTemplate() {
|
|
80
|
-
return this.algorithmControl = new N(), this.localeControl = new
|
|
83
|
+
return this.algorithmControl = new N(), this.localeControl = new P(), this.currencyControl = new R(), this.productCountControl = new I(), this.productLayoutControl = new O(), this.filtersControl = new _(), this.shuffleControl = new L(), this.pricePlacementControl = new T(), this.layoutOrientationControl = new b(), [
|
|
81
84
|
this.algorithmControl,
|
|
82
85
|
this.localeControl,
|
|
83
86
|
this.currencyControl,
|
|
@@ -85,6 +88,7 @@ class K extends g {
|
|
|
85
88
|
this.productLayoutControl,
|
|
86
89
|
this.filtersControl,
|
|
87
90
|
this.shuffleControl,
|
|
91
|
+
this.pricePlacementControl,
|
|
88
92
|
this.layoutOrientationControl
|
|
89
93
|
].forEach((e) => {
|
|
90
94
|
e.api = this.api;
|
|
@@ -95,6 +99,7 @@ class K extends g {
|
|
|
95
99
|
${this.productLayoutControl.getTemplate()}
|
|
96
100
|
${this.algorithmControl.getTemplate()}
|
|
97
101
|
${this.localeControl.getTemplate()}
|
|
102
|
+
${this.pricePlacementControl.getTemplate()}
|
|
98
103
|
${this.currencyControl.getTemplate()}
|
|
99
104
|
${this.filtersControl.getTemplate()}
|
|
100
105
|
${this.shuffleControl.getTemplate()}
|
|
@@ -124,7 +129,8 @@ class K extends g {
|
|
|
124
129
|
this.currencyControl,
|
|
125
130
|
this.productLayoutControl,
|
|
126
131
|
this.filtersControl,
|
|
127
|
-
this.shuffleControl
|
|
132
|
+
this.shuffleControl,
|
|
133
|
+
this.pricePlacementControl
|
|
128
134
|
].forEach((n) => {
|
|
129
135
|
var i;
|
|
130
136
|
n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
|
|
@@ -139,7 +145,8 @@ class K extends g {
|
|
|
139
145
|
this.currencyControl,
|
|
140
146
|
this.productLayoutControl,
|
|
141
147
|
this.filtersControl,
|
|
142
|
-
this.shuffleControl
|
|
148
|
+
this.shuffleControl,
|
|
149
|
+
this.pricePlacementControl
|
|
143
150
|
].forEach((e) => {
|
|
144
151
|
var o;
|
|
145
152
|
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
@@ -158,7 +165,8 @@ class K extends g {
|
|
|
158
165
|
this.currencyControl,
|
|
159
166
|
this.productLayoutControl,
|
|
160
167
|
this.filtersControl,
|
|
161
|
-
this.shuffleControl
|
|
168
|
+
this.shuffleControl,
|
|
169
|
+
this.pricePlacementControl
|
|
162
170
|
].forEach((e) => {
|
|
163
171
|
var o;
|
|
164
172
|
e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
|
|
@@ -177,7 +185,7 @@ class K extends g {
|
|
|
177
185
|
*/
|
|
178
186
|
_syncNodeConfigToStore() {
|
|
179
187
|
var r;
|
|
180
|
-
const t =
|
|
188
|
+
const t = m.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
|
|
181
189
|
this.store.patchCurrentBlockConfig({
|
|
182
190
|
strategy: t.strategy,
|
|
183
191
|
language: t.language,
|
|
@@ -188,6 +196,8 @@ class K extends g {
|
|
|
188
196
|
// for filters (edited via the filter drawer).
|
|
189
197
|
...o ? {} : { filters: t.filters },
|
|
190
198
|
shuffleProducts: t.shuffleProducts,
|
|
199
|
+
priceMovedToNextLine: t.priceMovedToNextLine,
|
|
200
|
+
priceHideIfSameAsDiscounted: t.priceHideIfSameAsDiscounted,
|
|
191
201
|
currencySettings: {
|
|
192
202
|
name: t.currency.code,
|
|
193
203
|
value: t.currency.code,
|
|
@@ -234,36 +244,36 @@ class K extends g {
|
|
|
234
244
|
_applySmartDefaults() {
|
|
235
245
|
if (!this.currentNode || !this.api)
|
|
236
246
|
return;
|
|
237
|
-
const t =
|
|
247
|
+
const t = m.getConfig(this.currentNode), e = {};
|
|
238
248
|
let o = null, r = null, n = null;
|
|
239
|
-
if (t.currency.code ===
|
|
249
|
+
if (t.currency.code === c.currency.code) {
|
|
240
250
|
const { currencyList: i } = this.store;
|
|
241
251
|
i.length > 0 && (i.some(
|
|
242
|
-
(u) => u.value === `price.${
|
|
252
|
+
(u) => u.value === `price.${c.currency.code}`
|
|
243
253
|
) || (o = i[0].value.replace("price.", ""), e.currency = {
|
|
244
|
-
...
|
|
254
|
+
...c.currency,
|
|
245
255
|
code: o,
|
|
246
256
|
symbol: o
|
|
247
257
|
}));
|
|
248
258
|
}
|
|
249
|
-
if (t.strategy ===
|
|
259
|
+
if (t.strategy === c.strategy) {
|
|
250
260
|
const i = this.store.getActivePredictiveAlgorithms;
|
|
251
261
|
i.length > 0 && (i.some(
|
|
252
|
-
(u) => u.value ===
|
|
262
|
+
(u) => u.value === c.strategy
|
|
253
263
|
) || (r = i[0].value, e.strategy = r));
|
|
254
264
|
}
|
|
255
|
-
if (t.language ===
|
|
265
|
+
if (t.language === c.language) {
|
|
256
266
|
const i = this.store.getLanguages;
|
|
257
267
|
i.length > 0 && (i.some(
|
|
258
|
-
(u) => u.value ===
|
|
268
|
+
(u) => u.value === c.language
|
|
259
269
|
) || (n = i[0].value, e.language = n));
|
|
260
270
|
}
|
|
261
|
-
!o && !r && !n || (
|
|
271
|
+
!o && !r && !n || (m.updateConfig(
|
|
262
272
|
this.api,
|
|
263
273
|
this.currentNode,
|
|
264
274
|
e,
|
|
265
275
|
"Applied smart defaults"
|
|
266
|
-
), o && e.currency &&
|
|
276
|
+
), o && e.currency && S({
|
|
267
277
|
currentNode: this.currentNode,
|
|
268
278
|
documentModifier: this.api.getDocumentModifier(),
|
|
269
279
|
currency: e.currency
|
|
@@ -273,10 +283,10 @@ class K extends g {
|
|
|
273
283
|
name: o,
|
|
274
284
|
value: o,
|
|
275
285
|
symbol: o,
|
|
276
|
-
alignment:
|
|
277
|
-
decimalCount:
|
|
278
|
-
decimalSeparator:
|
|
279
|
-
thousandSeparator:
|
|
286
|
+
alignment: c.currency.alignment === "before" ? "0" : "1",
|
|
287
|
+
decimalCount: c.currency.decimalCount.toString(),
|
|
288
|
+
decimalSeparator: c.currency.decimalSeparator,
|
|
289
|
+
thousandSeparator: c.currency.thousandSeparator
|
|
280
290
|
}
|
|
281
291
|
} : {},
|
|
282
292
|
...r ? { strategy: r } : {},
|
|
@@ -287,10 +297,10 @@ class K extends g {
|
|
|
287
297
|
* Reads the recommendation-id attribute from the block element within the node
|
|
288
298
|
*/
|
|
289
299
|
_getRecommendationIdFromNode(t) {
|
|
290
|
-
const e =
|
|
300
|
+
const e = D(t);
|
|
291
301
|
if (!e || !("getAttribute" in e))
|
|
292
302
|
return null;
|
|
293
|
-
const o = e.getAttribute(
|
|
303
|
+
const o = e.getAttribute(A);
|
|
294
304
|
if (!o)
|
|
295
305
|
return null;
|
|
296
306
|
const r = parseInt(o);
|
|
@@ -320,8 +330,8 @@ class K extends g {
|
|
|
320
330
|
}
|
|
321
331
|
const i = t.$state.configVersion;
|
|
322
332
|
i !== o && (o = i, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
|
|
323
|
-
const
|
|
324
|
-
u &&
|
|
333
|
+
const a = t.recommendationProducts, u = a !== e, C = Array.isArray(a) && a.length > 0;
|
|
334
|
+
u && C && (e = a, this._debouncedRegenerateWithProducts());
|
|
325
335
|
});
|
|
326
336
|
}
|
|
327
337
|
/**
|
|
@@ -332,7 +342,7 @@ class K extends g {
|
|
|
332
342
|
if (!this.currentNode || !this.api)
|
|
333
343
|
return;
|
|
334
344
|
const { filters: t } = this.store.recommendationConfigs;
|
|
335
|
-
|
|
345
|
+
m.updateConfig(
|
|
336
346
|
this.api,
|
|
337
347
|
this.currentNode,
|
|
338
348
|
{ filters: t },
|
|
@@ -341,35 +351,37 @@ class K extends g {
|
|
|
341
351
|
}
|
|
342
352
|
}
|
|
343
353
|
export {
|
|
344
|
-
|
|
354
|
+
Z as ALGORITHM_CONTROL_ID,
|
|
345
355
|
N as AlgorithmControl,
|
|
346
356
|
v as CONTROL_BLOCK_ID,
|
|
347
|
-
|
|
357
|
+
et as CURRENCY_CONTROL_ID,
|
|
348
358
|
R as CurrencyControl,
|
|
349
|
-
|
|
359
|
+
rt as FILTERS_CONTROL_ID,
|
|
350
360
|
_ as FiltersControl,
|
|
351
|
-
|
|
352
|
-
|
|
361
|
+
it as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
362
|
+
ct as LOCALE_CONTROL_ID,
|
|
353
363
|
b as LayoutOrientationControl,
|
|
354
|
-
|
|
355
|
-
at as
|
|
356
|
-
|
|
364
|
+
P as LocaleControl,
|
|
365
|
+
at as PRICE_PLACEMENT_CONTROL_ID,
|
|
366
|
+
dt as PRODUCT_COUNT_CONTROL_ID,
|
|
367
|
+
ht as PRODUCT_LAYOUT_CONTROL_ID,
|
|
368
|
+
T as PricePlacementControl,
|
|
357
369
|
I as ProductCountControl,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
+
O as ProductLayoutControl,
|
|
371
|
+
J as RecommendationBlockControl,
|
|
372
|
+
ft as SHUFFLE_CONTROL_ID,
|
|
373
|
+
L as ShuffleControl,
|
|
374
|
+
gt as adjustProductsToSize,
|
|
375
|
+
yt as formatProductPrice,
|
|
376
|
+
D as getBlockElement,
|
|
377
|
+
Nt as getCardComposition,
|
|
378
|
+
Rt as getCurrentLayout,
|
|
379
|
+
_t as reapplySpacing,
|
|
380
|
+
bt as regenerateMobileProductRows,
|
|
381
|
+
Pt as regenerateProductRows,
|
|
370
382
|
k as regenerateProductRowsWithStyles,
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
383
|
+
S as setCurrencyAttributes,
|
|
384
|
+
Tt as updatePricesInPlace,
|
|
385
|
+
E as updateProductContentInPlace,
|
|
386
|
+
It as updateSingleProductContent
|
|
375
387
|
};
|
|
@@ -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
|
+
};
|