@useinsider/guido 3.8.1-beta.95947aa → 3.8.1-beta.9f4cb2c
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/useHtmlValidator.js +133 -180
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +57 -58
- package/dist/config/migrator/recommendation/extractors.js +22 -44
- package/dist/config/migrator/recommendation/htmlBuilder.js +169 -175
- package/dist/config/migrator/recommendationMigrator.js +31 -30
- package/dist/extensions/Blocks/Recommendation/block.js +1 -4
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +20 -26
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +145 -176
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +57 -58
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +31 -43
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +2 -3
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +45 -55
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +59 -66
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +6 -7
- package/dist/extensions/Blocks/Recommendation/extension.js +2 -3
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +2 -3
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +2 -3
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +12 -13
- package/dist/extensions/Blocks/Recommendation/templates/index.js +6 -7
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
- package/dist/src/composables/useHtmlValidator.d.ts +0 -27
- package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -15
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +0 -8
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -21
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -9
- package/package.json +1 -1
- package/dist/config/compiler/utils/recommendationIgnoreUtils.js +0 -15
- package/dist/src/composables/useHtmlValidator.test.d.ts +0 -1
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +0 -17
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +0 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
var C = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var s = (d,
|
|
4
|
-
import { CommonControl as
|
|
5
|
-
import { DEFAULT_NODE_CONFIG as
|
|
2
|
+
var p = (d, a, t) => a in d ? C(d, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[a] = t;
|
|
3
|
+
var s = (d, a, t) => p(d, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import { CommonControl as g } from "../../../common-control.js";
|
|
5
|
+
import { DEFAULT_NODE_CONFIG as l } from "../../constants/defaultConfig.js";
|
|
6
6
|
import { RecommendationConfigService as h } 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
|
|
9
|
+
import { ALGORITHM_CONTROL_ID as Q } from "./algorithm.js";
|
|
10
|
+
import { CurrencyControl as b } from "./currency.js";
|
|
11
|
+
import { CURRENCY_CONTROL_ID as Z } from "./currency.js";
|
|
12
|
+
import { FiltersControl as N } from "./filters.js";
|
|
13
|
+
import { FILTERS_CONTROL_ID as et } from "./filters.js";
|
|
14
14
|
import { LayoutOrientationControl as I } from "./layoutOrientation.js";
|
|
15
|
-
import { LAYOUT_ORIENTATION_CONTROL_ID as
|
|
15
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as rt } from "./layoutOrientation.js";
|
|
16
16
|
import { LocaleControl as _ } from "./locale.js";
|
|
17
|
-
import { LOCALE_CONTROL_ID as
|
|
17
|
+
import { LOCALE_CONTROL_ID as it } from "./locale.js";
|
|
18
18
|
import { ProductCountControl as O } from "./productCount.js";
|
|
19
|
-
import { PRODUCT_COUNT_CONTROL_ID as
|
|
19
|
+
import { PRODUCT_COUNT_CONTROL_ID as lt } from "./productCount.js";
|
|
20
20
|
import { ProductLayoutControl as T } from "./productLayout.js";
|
|
21
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
21
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as ct } from "./productLayout.js";
|
|
22
22
|
import { ShuffleControl as S } from "./shuffle.js";
|
|
23
|
-
import { SHUFFLE_CONTROL_ID as
|
|
24
|
-
import { setCurrencyAttributes as L, getBlockElement as P,
|
|
25
|
-
import { adjustProductsToSize as
|
|
23
|
+
import { SHUFFLE_CONTROL_ID as dt } from "./shuffle.js";
|
|
24
|
+
import { setCurrencyAttributes as L, getBlockElement as P, updateProductContentInPlace as k, regenerateProductRowsWithStyles as D } from "./utils.js";
|
|
25
|
+
import { adjustProductsToSize as mt, formatProductPrice as ft, getCardComposition as Ct, getCurrentLayout as pt, regenerateMobileProductRows as gt, updatePricesInPlace as yt, updateSingleProductContent as Rt } from "./utils.js";
|
|
26
26
|
import { useDebounceFn as m } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
27
|
-
const
|
|
28
|
-
class
|
|
27
|
+
const E = "recommendation-id", w = "ui-elements-recommendation-block";
|
|
28
|
+
class K extends g {
|
|
29
29
|
constructor() {
|
|
30
30
|
super(...arguments);
|
|
31
31
|
s(this, "store", y());
|
|
@@ -60,14 +60,14 @@ class q extends p {
|
|
|
60
60
|
*/
|
|
61
61
|
s(this, "_debouncedRegenerateWithProducts", m(() => {
|
|
62
62
|
const t = this.store.recommendationProducts;
|
|
63
|
-
if (!this.currentNode || !this.api
|
|
63
|
+
if (!this.currentNode || !this.api)
|
|
64
64
|
return;
|
|
65
65
|
const e = this.api.getDocumentModifier();
|
|
66
|
-
|
|
66
|
+
k({
|
|
67
67
|
currentNode: this.currentNode,
|
|
68
68
|
documentModifier: e,
|
|
69
69
|
products: t
|
|
70
|
-
}) ||
|
|
70
|
+
}) || D({
|
|
71
71
|
currentNode: this.currentNode,
|
|
72
72
|
documentModifier: e,
|
|
73
73
|
products: t
|
|
@@ -75,10 +75,10 @@ class q extends p {
|
|
|
75
75
|
}, 100));
|
|
76
76
|
}
|
|
77
77
|
getId() {
|
|
78
|
-
return
|
|
78
|
+
return w;
|
|
79
79
|
}
|
|
80
80
|
getTemplate() {
|
|
81
|
-
return this.algorithmControl = new R(), this.localeControl = new _(), this.currencyControl = new
|
|
81
|
+
return this.algorithmControl = new R(), this.localeControl = new _(), this.currencyControl = new b(), this.productCountControl = new O(), this.productLayoutControl = new T(), this.filtersControl = new N(), this.shuffleControl = new S(), this.layoutOrientationControl = new I(), [
|
|
82
82
|
this.algorithmControl,
|
|
83
83
|
this.localeControl,
|
|
84
84
|
this.currencyControl,
|
|
@@ -241,26 +241,26 @@ class q extends p {
|
|
|
241
241
|
return;
|
|
242
242
|
const t = h.getConfig(this.currentNode), e = {};
|
|
243
243
|
let o = null, r = null, n = null;
|
|
244
|
-
if (t.currency.code ===
|
|
244
|
+
if (t.currency.code === l.currency.code) {
|
|
245
245
|
const { currencyList: i } = this.store;
|
|
246
246
|
i.length > 0 && (i.some(
|
|
247
|
-
(u) => u.value === `price.${
|
|
247
|
+
(u) => u.value === `price.${l.currency.code}`
|
|
248
248
|
) || (o = i[0].value.replace("price.", ""), e.currency = {
|
|
249
|
-
...
|
|
249
|
+
...l.currency,
|
|
250
250
|
code: o,
|
|
251
251
|
symbol: o
|
|
252
252
|
}));
|
|
253
253
|
}
|
|
254
|
-
if (t.strategy ===
|
|
254
|
+
if (t.strategy === l.strategy) {
|
|
255
255
|
const i = this.store.getActivePredictiveAlgorithms;
|
|
256
256
|
i.length > 0 && (i.some(
|
|
257
|
-
(u) => u.value ===
|
|
257
|
+
(u) => u.value === l.strategy
|
|
258
258
|
) || (r = i[0].value, e.strategy = r));
|
|
259
259
|
}
|
|
260
|
-
if (t.language ===
|
|
260
|
+
if (t.language === l.language) {
|
|
261
261
|
const i = this.store.getLanguages;
|
|
262
262
|
i.length > 0 && (i.some(
|
|
263
|
-
(u) => u.value ===
|
|
263
|
+
(u) => u.value === l.language
|
|
264
264
|
) || (n = i[0].value, e.language = n));
|
|
265
265
|
}
|
|
266
266
|
!o && !r && !n || (h.updateConfig(
|
|
@@ -278,10 +278,10 @@ class q extends p {
|
|
|
278
278
|
name: o,
|
|
279
279
|
value: o,
|
|
280
280
|
symbol: o,
|
|
281
|
-
alignment:
|
|
282
|
-
decimalCount:
|
|
283
|
-
decimalSeparator:
|
|
284
|
-
thousandSeparator:
|
|
281
|
+
alignment: l.currency.alignment === "before" ? "0" : "1",
|
|
282
|
+
decimalCount: l.currency.decimalCount.toString(),
|
|
283
|
+
decimalSeparator: l.currency.decimalSeparator,
|
|
284
|
+
thousandSeparator: l.currency.thousandSeparator
|
|
285
285
|
}
|
|
286
286
|
} : {},
|
|
287
287
|
...r ? { strategy: r } : {},
|
|
@@ -295,7 +295,7 @@ class q extends p {
|
|
|
295
295
|
const e = P(t);
|
|
296
296
|
if (!e || !("getAttribute" in e))
|
|
297
297
|
return null;
|
|
298
|
-
const o = e.getAttribute(
|
|
298
|
+
const o = e.getAttribute(E);
|
|
299
299
|
if (!o)
|
|
300
300
|
return null;
|
|
301
301
|
const r = parseInt(o);
|
|
@@ -325,8 +325,8 @@ class q extends p {
|
|
|
325
325
|
}
|
|
326
326
|
const i = t.$state.configVersion;
|
|
327
327
|
i !== o && (o = i, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
|
|
328
|
-
const
|
|
329
|
-
u && f && (e =
|
|
328
|
+
const c = t.recommendationProducts, u = c !== e, f = Array.isArray(c) && c.length > 0;
|
|
329
|
+
u && f && (e = c, this._debouncedRegenerateWithProducts());
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
/**
|
|
@@ -346,34 +346,33 @@ class q extends p {
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
export {
|
|
349
|
-
|
|
349
|
+
Q as ALGORITHM_CONTROL_ID,
|
|
350
350
|
R as AlgorithmControl,
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
351
|
+
w as CONTROL_BLOCK_ID,
|
|
352
|
+
Z as CURRENCY_CONTROL_ID,
|
|
353
|
+
b as CurrencyControl,
|
|
354
|
+
et as FILTERS_CONTROL_ID,
|
|
355
|
+
N as FiltersControl,
|
|
356
|
+
rt as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
357
|
+
it as LOCALE_CONTROL_ID,
|
|
358
358
|
I as LayoutOrientationControl,
|
|
359
359
|
_ as LocaleControl,
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
lt as PRODUCT_COUNT_CONTROL_ID,
|
|
361
|
+
ct as PRODUCT_LAYOUT_CONTROL_ID,
|
|
362
362
|
O as ProductCountControl,
|
|
363
363
|
T as ProductLayoutControl,
|
|
364
|
-
|
|
365
|
-
|
|
364
|
+
K as RecommendationBlockControl,
|
|
365
|
+
dt as SHUFFLE_CONTROL_ID,
|
|
366
366
|
S as ShuffleControl,
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
mt as adjustProductsToSize,
|
|
368
|
+
ft as formatProductPrice,
|
|
369
369
|
P as getBlockElement,
|
|
370
|
-
|
|
370
|
+
Ct as getCardComposition,
|
|
371
371
|
pt as getCurrentLayout,
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
E as regenerateProductRowsWithStyles,
|
|
372
|
+
gt as regenerateMobileProductRows,
|
|
373
|
+
D as regenerateProductRowsWithStyles,
|
|
375
374
|
L as setCurrencyAttributes,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
375
|
+
yt as updatePricesInPlace,
|
|
376
|
+
k as updateProductContentInPlace,
|
|
377
|
+
Rt as updateSingleProductContent
|
|
379
378
|
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import "../../constants/
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
const y = "recommendation-layout-orientation-control", s = {
|
|
1
|
+
var L = Object.defineProperty;
|
|
2
|
+
var _ = (o, e, t) => e in o ? L(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var s = (o, e, t) => _(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as N } from "../../../common-control.js";
|
|
6
|
+
import { LAYOUT_OPTIONS as O, DEFAULT_MOBILE_ROW_SPACING as m, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as l, DEFAULT_COLUMN_SPACING as g } from "../../constants/layout.js";
|
|
7
|
+
import { RecommendationConfigService as a } from "../../services/configService.js";
|
|
8
|
+
import { useRecommendationExtensionStore as A } from "../../store/recommendation.js";
|
|
9
|
+
import { getCurrentLayout as C, getBlockElement as f, getCardComposition as S, regenerateProductRowsWithStyles as T } from "./utils.js";
|
|
10
|
+
const I = "recommendation-layout-orientation-control", u = {
|
|
12
11
|
LAYOUT: "layout"
|
|
13
12
|
}, n = {
|
|
14
13
|
LAYOUT: "data-layout",
|
|
@@ -17,14 +16,14 @@ const y = "recommendation-layout-orientation-control", s = {
|
|
|
17
16
|
MOBILE_COLUMN_SPACING: "data-mobile-column-spacing",
|
|
18
17
|
MOBILE_ROW_SPACING: "data-mobile-row-spacing"
|
|
19
18
|
};
|
|
20
|
-
class
|
|
19
|
+
class w extends N {
|
|
21
20
|
constructor() {
|
|
22
21
|
super(...arguments);
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
s(this, "store", A());
|
|
23
|
+
s(this, "isChangingLayout", !1);
|
|
25
24
|
}
|
|
26
25
|
getId() {
|
|
27
|
-
return
|
|
26
|
+
return I;
|
|
28
27
|
}
|
|
29
28
|
getTemplate() {
|
|
30
29
|
return `
|
|
@@ -32,7 +31,7 @@ class F extends A {
|
|
|
32
31
|
${this._GuTwoColumns([
|
|
33
32
|
this._GuLabel({ text: this.api.translate("Layout Orientation") }),
|
|
34
33
|
this._GuRadioButton({
|
|
35
|
-
name:
|
|
34
|
+
name: u.LAYOUT,
|
|
36
35
|
buttons: O
|
|
37
36
|
})
|
|
38
37
|
])}
|
|
@@ -40,26 +39,15 @@ class F extends A {
|
|
|
40
39
|
`;
|
|
41
40
|
}
|
|
42
41
|
onRender() {
|
|
43
|
-
this._setFormValues(), this.
|
|
42
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
44
43
|
}
|
|
45
44
|
onTemplateNodeUpdated(t) {
|
|
46
|
-
super.onTemplateNodeUpdated(t), this._setFormValues()
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Layout orientation restructures the whole block, which is meaningless for
|
|
50
|
-
* partner-managed (`ins-skip-compile`) blocks — disable the control there.
|
|
51
|
-
*/
|
|
52
|
-
_syncDisabledState() {
|
|
53
|
-
this.api.setUIEAttribute(
|
|
54
|
-
s.LAYOUT,
|
|
55
|
-
L.RADIO_BUTTONS.disabled,
|
|
56
|
-
f(this.currentNode)
|
|
57
|
-
);
|
|
45
|
+
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
58
46
|
}
|
|
59
47
|
_setFormValues() {
|
|
60
|
-
const r =
|
|
48
|
+
const r = a.getConfig(this.currentNode).layout || C(this.currentNode);
|
|
61
49
|
this.api.updateValues({
|
|
62
|
-
[
|
|
50
|
+
[u.LAYOUT]: r
|
|
63
51
|
});
|
|
64
52
|
}
|
|
65
53
|
/**
|
|
@@ -67,27 +55,27 @@ class F extends A {
|
|
|
67
55
|
* Updates node config, data attribute and regenerates product rows
|
|
68
56
|
*/
|
|
69
57
|
_onLayoutChange(t) {
|
|
70
|
-
if (this.isChangingLayout || !this.currentNode || (
|
|
58
|
+
if (this.isChangingLayout || !this.currentNode || (a.getConfig(this.currentNode).layout || C(this.currentNode)) === t)
|
|
71
59
|
return;
|
|
72
|
-
const c =
|
|
60
|
+
const c = f(this.currentNode);
|
|
73
61
|
if (c) {
|
|
74
62
|
this.isChangingLayout = !0;
|
|
75
63
|
try {
|
|
76
|
-
const
|
|
77
|
-
|
|
64
|
+
const p = S(this.currentNode);
|
|
65
|
+
a.updateConfig(
|
|
78
66
|
this.api,
|
|
79
67
|
this.currentNode,
|
|
80
68
|
{
|
|
81
69
|
layout: t,
|
|
82
70
|
columnSpacing: g,
|
|
83
71
|
rowSpacing: l,
|
|
84
|
-
mobileColumnSpacing:
|
|
85
|
-
mobileRowSpacing:
|
|
72
|
+
mobileColumnSpacing: d,
|
|
73
|
+
mobileRowSpacing: m
|
|
86
74
|
},
|
|
87
75
|
`Changed layout to ${t}`
|
|
88
76
|
), this.store.patchCurrentBlockConfig({ orientation: t });
|
|
89
|
-
const i = this.api.getDocumentModifier().modifyHtml(c).setAttribute(n.LAYOUT, t).setAttribute(n.COLUMN_SPACING, g.toString()).setAttribute(n.ROW_SPACING, l.toString()).setAttribute(n.MOBILE_COLUMN_SPACING,
|
|
90
|
-
t === "list" ? (i.setClass("es-m-p0"), i.setClass("ins-recommendation-list-layout")) : (i.removeClass("es-m-p0"), i.removeClass("ins-recommendation-list-layout")), i.apply(new
|
|
77
|
+
const i = this.api.getDocumentModifier().modifyHtml(c).setAttribute(n.LAYOUT, t).setAttribute(n.COLUMN_SPACING, g.toString()).setAttribute(n.ROW_SPACING, l.toString()).setAttribute(n.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(n.MOBILE_ROW_SPACING, m.toString());
|
|
78
|
+
t === "list" ? (i.setClass("es-m-p0"), i.setClass("ins-recommendation-list-layout")) : (i.removeClass("es-m-p0"), i.removeClass("ins-recommendation-list-layout")), i.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t, p);
|
|
91
79
|
} finally {
|
|
92
80
|
this.isChangingLayout = !1;
|
|
93
81
|
}
|
|
@@ -100,7 +88,7 @@ class F extends A {
|
|
|
100
88
|
* @param composition - The preserved card composition, incl. customAttr:* entries
|
|
101
89
|
*/
|
|
102
90
|
_regenerateProductRows(t, r) {
|
|
103
|
-
this.currentNode &&
|
|
91
|
+
this.currentNode && T({
|
|
104
92
|
currentNode: this.currentNode,
|
|
105
93
|
documentModifier: this.api.getDocumentModifier(),
|
|
106
94
|
layout: t,
|
|
@@ -108,12 +96,12 @@ class F extends A {
|
|
|
108
96
|
});
|
|
109
97
|
}
|
|
110
98
|
_listenToFormUpdates() {
|
|
111
|
-
this.api.onValueChanged(
|
|
99
|
+
this.api.onValueChanged(u.LAYOUT, (t) => {
|
|
112
100
|
this._onLayoutChange(t);
|
|
113
101
|
});
|
|
114
102
|
}
|
|
115
103
|
}
|
|
116
104
|
export {
|
|
117
|
-
|
|
118
|
-
|
|
105
|
+
I as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
106
|
+
w as LayoutOrientationControl
|
|
119
107
|
};
|
|
@@ -2,14 +2,13 @@ var s = Object.defineProperty;
|
|
|
2
2
|
var u = (e, o, t) => o in e ? s(e, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[o] = t;
|
|
3
3
|
var i = (e, o, t) => u(e, typeof o != "symbol" ? o + "" : o, t);
|
|
4
4
|
import { CommonControl as a } from "../../../common-control.js";
|
|
5
|
-
import "../../constants/selectors.js";
|
|
6
5
|
import { MAX_PRODUCT_COUNT as c } from "../../constants/layout.js";
|
|
7
6
|
import { RecommendationConfigService as n } from "../../services/configService.js";
|
|
8
7
|
import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
|
|
9
8
|
const C = "recommendation-product-count-control", r = {
|
|
10
9
|
PRODUCT_COUNT: "size"
|
|
11
10
|
};
|
|
12
|
-
class
|
|
11
|
+
class g extends a {
|
|
13
12
|
constructor() {
|
|
14
13
|
super(...arguments);
|
|
15
14
|
i(this, "store", d());
|
|
@@ -55,5 +54,5 @@ class U extends a {
|
|
|
55
54
|
}
|
|
56
55
|
export {
|
|
57
56
|
C as PRODUCT_COUNT_CONTROL_ID,
|
|
58
|
-
|
|
57
|
+
g as ProductCountControl
|
|
59
58
|
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var f = (a, n, t) => n in a ? E(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
|
|
3
|
+
var c = (a, n, t) => f(a, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { EditorStatePropertyType as O, PreviewDeviceMode as T, UEAttr as N } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as P } from "../../../common-control.js";
|
|
6
|
-
import "../../constants/
|
|
7
|
-
import { MAX_PRODUCTS_PER_ROW as C, MAX_MOBILE_PRODUCTS_PER_ROW as D, DEFAULT_MOBILE_CARDS_IN_ROW as _ } from "../../constants/layout.js";
|
|
6
|
+
import { MAX_PRODUCTS_PER_ROW as m, MAX_MOBILE_PRODUCTS_PER_ROW as M, DEFAULT_MOBILE_CARDS_IN_ROW as l } from "../../constants/layout.js";
|
|
8
7
|
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
9
|
-
import { useRecommendationExtensionStore as
|
|
10
|
-
import { setMobileLayoutOptOut as
|
|
11
|
-
import {
|
|
12
|
-
import { useDebounceFn as
|
|
8
|
+
import { useRecommendationExtensionStore as w } from "../../store/recommendation.js";
|
|
9
|
+
import { setMobileLayoutOptOut as C, ensureMobileCssRulesExist as b } from "../mobileLayout/cssRules.js";
|
|
10
|
+
import { getCurrentLayout as y, getBlockElement as D, adjustProductsToSize as L, regenerateProductRowsWithStyles as g, regenerateMobileProductRows as I } from "./utils.js";
|
|
11
|
+
import { useDebounceFn as U } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
13
12
|
const B = "recommendation-product-layout-control", e = {
|
|
14
13
|
// "Products in One Row" — shown when toggle is OFF
|
|
15
14
|
PRODUCT_IN_ROW: "cardsInRow",
|
|
@@ -24,14 +23,14 @@ const B = "recommendation-product-layout-control", e = {
|
|
|
24
23
|
MOBILE_LAYOUT_TOGGLE: "mobileLayoutEnabled",
|
|
25
24
|
MOBILE_LAYOUT_LABEL: "mobileLayoutLabel"
|
|
26
25
|
};
|
|
27
|
-
class
|
|
26
|
+
class v extends P {
|
|
28
27
|
constructor() {
|
|
29
28
|
super(...arguments);
|
|
30
29
|
// Store is used for backward compatibility with product fetching and regeneration
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
c(this, "store", w());
|
|
31
|
+
c(this, "storeUnsubscription", () => {
|
|
33
32
|
});
|
|
34
|
-
|
|
33
|
+
c(this, "_debouncedRegenerateProductRows", U(() => {
|
|
35
34
|
this._regenerateProductRows();
|
|
36
35
|
}, 500));
|
|
37
36
|
}
|
|
@@ -46,19 +45,19 @@ class F extends P {
|
|
|
46
45
|
text: this.api.translate("Products in One Row"),
|
|
47
46
|
name: e.PRODUCT_IN_ROW_LABEL
|
|
48
47
|
}),
|
|
49
|
-
this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue:
|
|
48
|
+
this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: m }),
|
|
50
49
|
this._GuLabel({
|
|
51
50
|
text: this.api.translate("Products in One Row on Desktop"),
|
|
52
51
|
name: e.PRODUCT_IN_ROW_DESKTOP_LABEL
|
|
53
52
|
}),
|
|
54
|
-
this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue:
|
|
53
|
+
this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue: m }),
|
|
55
54
|
this._GuLabel({
|
|
56
55
|
text: this.api.translate("Products in One Row on Mobile"),
|
|
57
56
|
name: e.MOBILE_CARDS_IN_ROW_LABEL
|
|
58
57
|
}),
|
|
59
58
|
this._GuCounter({
|
|
60
59
|
name: e.MOBILE_CARDS_IN_ROW,
|
|
61
|
-
maxValue:
|
|
60
|
+
maxValue: M
|
|
62
61
|
}),
|
|
63
62
|
this._GuLabel({
|
|
64
63
|
text: this.api.translate("Mobile Layout Optimization"),
|
|
@@ -75,19 +74,10 @@ class F extends P {
|
|
|
75
74
|
`;
|
|
76
75
|
}
|
|
77
76
|
onRender() {
|
|
78
|
-
this._initializeMobileLayoutToggle(), this._setFormValues(), this._updateProductsInRowVisibility(), this.
|
|
77
|
+
this._initializeMobileLayoutToggle(), this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates(), this._listenEditorModeChanges();
|
|
79
78
|
}
|
|
80
79
|
onTemplateNodeUpdated(t) {
|
|
81
|
-
super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility()
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Products-per-row and mobile-layout restructure the block, which is
|
|
85
|
-
* meaningless for partner-managed (`ins-skip-compile`) blocks — disable
|
|
86
|
-
* these inputs there. Disabling coexists with the visibility logic above.
|
|
87
|
-
*/
|
|
88
|
-
_syncDisabledState() {
|
|
89
|
-
const t = y(this.currentNode);
|
|
90
|
-
this.api.setUIEAttribute(e.PRODUCT_IN_ROW, d.COUNTER.disabled, t), this.api.setUIEAttribute(e.PRODUCT_IN_ROW_DESKTOP, d.COUNTER.disabled, t), this.api.setUIEAttribute(e.MOBILE_CARDS_IN_ROW, d.COUNTER.disabled, t), this.api.setUIEAttribute(e.MOBILE_LAYOUT_TOGGLE, d.SWITCHER.disabled, t);
|
|
80
|
+
super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
|
|
91
81
|
}
|
|
92
82
|
onDestroy() {
|
|
93
83
|
this.storeUnsubscription();
|
|
@@ -105,7 +95,7 @@ class F extends P {
|
|
|
105
95
|
* Returns true when the editor preview is in mobile mode.
|
|
106
96
|
*/
|
|
107
97
|
_isMobilePreview() {
|
|
108
|
-
return this.api.getEditorState()[
|
|
98
|
+
return this.api.getEditorState()[O.previewDeviceMode] === T.MOBILE;
|
|
109
99
|
}
|
|
110
100
|
/**
|
|
111
101
|
* Updates counter visibility based on layout, mobileLayoutEnabled, and editor preview mode.
|
|
@@ -120,12 +110,12 @@ class F extends P {
|
|
|
120
110
|
*/
|
|
121
111
|
_updateProductsInRowVisibility() {
|
|
122
112
|
var p;
|
|
123
|
-
const t = s.getConfig(this.currentNode),
|
|
124
|
-
this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE,
|
|
125
|
-
const
|
|
126
|
-
this.api.setVisibility(e.PRODUCT_IN_ROW,
|
|
127
|
-
const
|
|
128
|
-
|
|
113
|
+
const t = s.getConfig(this.currentNode), o = (t.layout || y(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, u = this._isMobilePreview();
|
|
114
|
+
this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE, o), this.api.setVisibility(e.MOBILE_LAYOUT_LABEL, o);
|
|
115
|
+
const d = o && !r, _ = o && r && !u, h = o && r && u;
|
|
116
|
+
this.api.setVisibility(e.PRODUCT_IN_ROW, d), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, d), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP, _), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP_LABEL, _), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, h), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, h);
|
|
117
|
+
const R = (p = this.getContainer()) == null ? void 0 : p.querySelector("[data-product-layout-control]");
|
|
118
|
+
R && (R.style.display = o ? "" : "none");
|
|
129
119
|
}
|
|
130
120
|
/**
|
|
131
121
|
* Initializes the mobile layout toggle using the same pattern as shuffle.ts.
|
|
@@ -135,7 +125,7 @@ class F extends P {
|
|
|
135
125
|
const t = s.getConfig(this.currentNode);
|
|
136
126
|
this.api.setUIEAttribute(
|
|
137
127
|
e.MOBILE_LAYOUT_TOGGLE,
|
|
138
|
-
|
|
128
|
+
N.SELECTPICKER.items,
|
|
139
129
|
t.mobileLayoutEnabled
|
|
140
130
|
);
|
|
141
131
|
}
|
|
@@ -147,12 +137,12 @@ class F extends P {
|
|
|
147
137
|
_onMobileLayoutToggleChange(t) {
|
|
148
138
|
if (!this.currentNode)
|
|
149
139
|
return;
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
140
|
+
const i = s.getConfig(this.currentNode);
|
|
141
|
+
if (i.mobileLayoutEnabled === t)
|
|
152
142
|
return;
|
|
153
|
-
const
|
|
143
|
+
const o = D(this.currentNode);
|
|
154
144
|
if (t) {
|
|
155
|
-
const r =
|
|
145
|
+
const r = i.previousMobileCardsInRow || l;
|
|
156
146
|
s.updateConfig(
|
|
157
147
|
this.api,
|
|
158
148
|
this.currentNode,
|
|
@@ -167,31 +157,31 @@ class F extends P {
|
|
|
167
157
|
mobileCardsInRow: r
|
|
168
158
|
},
|
|
169
159
|
{ triggerRefetch: !1 }
|
|
170
|
-
),
|
|
171
|
-
const u = parseInt(
|
|
160
|
+
), o && C(this.api, o, !1), b(this.api);
|
|
161
|
+
const u = parseInt(i.size) || 6, d = L(this.store.recommendationProducts, u);
|
|
172
162
|
g({
|
|
173
163
|
currentNode: this.currentNode,
|
|
174
164
|
documentModifier: this.api.getDocumentModifier(),
|
|
175
|
-
products:
|
|
165
|
+
products: d
|
|
176
166
|
});
|
|
177
167
|
} else {
|
|
178
|
-
const r =
|
|
168
|
+
const r = i.mobileCardsInRow;
|
|
179
169
|
s.updateConfig(
|
|
180
170
|
this.api,
|
|
181
171
|
this.currentNode,
|
|
182
172
|
{
|
|
183
173
|
mobileLayoutEnabled: !1,
|
|
184
174
|
previousMobileCardsInRow: r,
|
|
185
|
-
mobileCardsInRow:
|
|
175
|
+
mobileCardsInRow: l
|
|
186
176
|
},
|
|
187
177
|
"Disabled mobile layout optimization"
|
|
188
178
|
), this.store.patchCurrentBlockConfig(
|
|
189
179
|
{
|
|
190
180
|
mobileLayoutEnabled: !1,
|
|
191
|
-
mobileCardsInRow:
|
|
181
|
+
mobileCardsInRow: l
|
|
192
182
|
},
|
|
193
183
|
{ triggerRefetch: !1 }
|
|
194
|
-
),
|
|
184
|
+
), o && C(this.api, o, !0), I({
|
|
195
185
|
currentNode: this.currentNode,
|
|
196
186
|
documentModifier: this.api.getDocumentModifier()
|
|
197
187
|
});
|
|
@@ -212,20 +202,20 @@ class F extends P {
|
|
|
212
202
|
this.currentNode,
|
|
213
203
|
{ mobileCardsInRow: t },
|
|
214
204
|
`Changed mobile products per row to ${t}`
|
|
215
|
-
),
|
|
205
|
+
), b(this.api), this.store.patchCurrentBlockConfig(
|
|
216
206
|
{ mobileCardsInRow: t },
|
|
217
207
|
{ triggerRefetch: !1 }
|
|
218
|
-
),
|
|
208
|
+
), I({
|
|
219
209
|
currentNode: this.currentNode,
|
|
220
210
|
documentModifier: this.api.getDocumentModifier()
|
|
221
211
|
}));
|
|
222
212
|
}
|
|
223
213
|
_regenerateProductRows() {
|
|
224
|
-
const t = s.getConfig(this.currentNode),
|
|
214
|
+
const t = s.getConfig(this.currentNode), i = parseInt(t.size) || 6, o = L(this.store.recommendationProducts, i);
|
|
225
215
|
g({
|
|
226
216
|
currentNode: this.currentNode,
|
|
227
217
|
documentModifier: this.api.getDocumentModifier(),
|
|
228
|
-
products:
|
|
218
|
+
products: o
|
|
229
219
|
});
|
|
230
220
|
}
|
|
231
221
|
_listenToFormUpdates() {
|
|
@@ -246,8 +236,8 @@ class F extends P {
|
|
|
246
236
|
_listenStateUpdates() {
|
|
247
237
|
let t = this.store.recommendationConfigs.orientation;
|
|
248
238
|
this.storeUnsubscription = this.store.$subscribe(() => {
|
|
249
|
-
const
|
|
250
|
-
|
|
239
|
+
const i = this.store.recommendationConfigs.orientation;
|
|
240
|
+
i !== t && (t = i, this._updateProductsInRowVisibility());
|
|
251
241
|
});
|
|
252
242
|
}
|
|
253
243
|
/**
|
|
@@ -257,7 +247,7 @@ class F extends P {
|
|
|
257
247
|
*/
|
|
258
248
|
_listenEditorModeChanges() {
|
|
259
249
|
this.api.onEditorStatePropUpdated(
|
|
260
|
-
|
|
250
|
+
O.previewDeviceMode,
|
|
261
251
|
() => {
|
|
262
252
|
s.getConfig(this.currentNode).mobileLayoutEnabled && this._updateProductsInRowVisibility();
|
|
263
253
|
}
|
|
@@ -266,5 +256,5 @@ class F extends P {
|
|
|
266
256
|
}
|
|
267
257
|
export {
|
|
268
258
|
B as PRODUCT_LAYOUT_CONTROL_ID,
|
|
269
|
-
|
|
259
|
+
v as ProductLayoutControl
|
|
270
260
|
};
|