@useinsider/guido 3.0.0-beta.7d3a300 → 3.0.0-beta.952fc1f
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/config/i18n/en/tooltips.json.js +1 -2
- package/dist/extensions/Blocks/Recommendation/block.js +56 -38
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +36 -34
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +4 -4
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +15 -15
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +24 -24
- package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +2 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +107 -78
- package/dist/extensions/Blocks/Recommendation/controls/{layout/index.js → main/layoutOrientation.js} +35 -27
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +2 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +58 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +150 -64
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +2 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +198 -204
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +25 -8
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +6 -5
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +21 -21
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +13 -13
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +17 -17
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +134 -142
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +65 -0
- package/dist/extensions/Blocks/Recommendation/extension.js +13 -13
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +35 -0
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -15
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +1 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -27
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +6 -6
- package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +17 -16
- package/dist/extensions/Blocks/common-control.js +90 -41
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +218 -324
- package/dist/package.json.js +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +2 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +2 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/{layout/index.d.ts → main/layoutOrientation.d.ts} +3 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productCount.d.ts +28 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +38 -20
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +23 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +8 -18
- package/dist/src/extensions/Blocks/Recommendation/controls/syncInfoMessage.d.ts +34 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +3 -3
- package/dist/src/extensions/Blocks/common-control.d.ts +24 -2
- package/dist/static/styles/components/button.css.js +7 -13
- package/dist/static/styles/components/narrow-panel.css.js +0 -52
- package/dist/static/styles/components/wide-panel.css.js +1 -0
- package/dist/static/styles/customEditorStyle.css.js +9 -0
- package/package.json +3 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.d.ts +0 -25
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.d.ts +0 -15
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.d.ts +0 -15
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.d.ts +0 -15
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.d.ts +0 -15
- package/dist/src/extensions/Blocks/Recommendation/controls/spacingControl.d.ts +0 -60
|
@@ -1,43 +1,49 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { CommonControl as
|
|
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
|
+
import { CommonControl as g } from "../../../common-control.js";
|
|
5
5
|
import { DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
6
|
-
import { RecommendationConfigService as
|
|
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
|
|
9
|
+
import { ALGORITHM_CONTROL_ID as J } from "./algorithm.js";
|
|
10
10
|
import { CurrencyControl as N } from "./currency.js";
|
|
11
|
-
import { CURRENCY_CONTROL_ID as
|
|
12
|
-
import { FiltersControl as
|
|
13
|
-
import { FILTERS_CONTROL_ID as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
11
|
+
import { CURRENCY_CONTROL_ID as X } from "./currency.js";
|
|
12
|
+
import { FiltersControl as _ } from "./filters.js";
|
|
13
|
+
import { FILTERS_CONTROL_ID as tt } from "./filters.js";
|
|
14
|
+
import { LayoutOrientationControl as b } from "./layoutOrientation.js";
|
|
15
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as ot } from "./layoutOrientation.js";
|
|
16
|
+
import { LocaleControl as O } from "./locale.js";
|
|
17
|
+
import { LOCALE_CONTROL_ID as nt } from "./locale.js";
|
|
18
|
+
import { ProductCountControl as I } from "./productCount.js";
|
|
19
|
+
import { PRODUCT_COUNT_CONTROL_ID as st } from "./productCount.js";
|
|
20
|
+
import { ProductLayoutControl as T } from "./productLayout.js";
|
|
21
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as lt } from "./productLayout.js";
|
|
18
22
|
import { ShuffleControl as S } from "./shuffle.js";
|
|
19
|
-
import { SHUFFLE_CONTROL_ID as
|
|
20
|
-
import { getBlockElement as
|
|
21
|
-
import { adjustProductsToSize as
|
|
22
|
-
import { useDebounceFn as
|
|
23
|
-
const k = "recommendation-id",
|
|
24
|
-
class
|
|
23
|
+
import { SHUFFLE_CONTROL_ID as ut } from "./shuffle.js";
|
|
24
|
+
import { getBlockElement as L, updateProductContentInPlace as P, regenerateProductRowsWithStyles as D } from "./utils.js";
|
|
25
|
+
import { adjustProductsToSize as ht, formatProductPrice as mt, getCardComposition as Ct, getCurrentLayout as ft, reapplySpacing as pt, regenerateMobileProductRows as gt, regenerateProductRows as yt, setCurrencyAttributes as Rt, updatePricesInPlace as Nt, updateSingleProductContent as _t } from "./utils.js";
|
|
26
|
+
import { useDebounceFn as m } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
27
|
+
const k = "recommendation-id", E = "ui-elements-recommendation-block";
|
|
28
|
+
class H extends g {
|
|
25
29
|
constructor() {
|
|
26
30
|
super(...arguments);
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
s(this, "store", y());
|
|
32
|
+
s(this, "storeUnsubscription", () => {
|
|
29
33
|
});
|
|
30
34
|
// Sub-control instances for lifecycle management
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
s(this, "algorithmControl", null);
|
|
36
|
+
s(this, "localeControl", null);
|
|
37
|
+
s(this, "currencyControl", null);
|
|
38
|
+
s(this, "productCountControl", null);
|
|
39
|
+
s(this, "productLayoutControl", null);
|
|
40
|
+
s(this, "filtersControl", null);
|
|
41
|
+
s(this, "shuffleControl", null);
|
|
42
|
+
s(this, "layoutOrientationControl", null);
|
|
37
43
|
/**
|
|
38
44
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
39
45
|
*/
|
|
40
|
-
|
|
46
|
+
s(this, "_debouncedFetchProducts", m(() => {
|
|
41
47
|
this.store.fetchRecommendationProducts();
|
|
42
48
|
}, 500));
|
|
43
49
|
/**
|
|
@@ -51,16 +57,16 @@ class W extends p {
|
|
|
51
57
|
* count. The store pads products to the configured size, so in-place only
|
|
52
58
|
* fails when the size actually changed.
|
|
53
59
|
*/
|
|
54
|
-
|
|
60
|
+
s(this, "_debouncedRegenerateWithProducts", m(() => {
|
|
55
61
|
const t = this.store.recommendationProducts;
|
|
56
62
|
if (!this.currentNode || !this.api)
|
|
57
63
|
return;
|
|
58
64
|
const e = this.api.getDocumentModifier();
|
|
59
|
-
|
|
65
|
+
P({
|
|
60
66
|
currentNode: this.currentNode,
|
|
61
67
|
documentModifier: e,
|
|
62
68
|
products: t
|
|
63
|
-
}) ||
|
|
69
|
+
}) || D({
|
|
64
70
|
currentNode: this.currentNode,
|
|
65
71
|
documentModifier: e,
|
|
66
72
|
products: t
|
|
@@ -68,16 +74,29 @@ class W extends p {
|
|
|
68
74
|
}, 100));
|
|
69
75
|
}
|
|
70
76
|
getId() {
|
|
71
|
-
return
|
|
77
|
+
return E;
|
|
72
78
|
}
|
|
73
79
|
getTemplate() {
|
|
74
|
-
return this.algorithmControl = new R(), this.localeControl = new
|
|
80
|
+
return this.algorithmControl = new R(), this.localeControl = new O(), this.currencyControl = new N(), this.productCountControl = new I(), this.productLayoutControl = new T(), this.filtersControl = new _(), this.shuffleControl = new S(), this.layoutOrientationControl = new b(), [
|
|
81
|
+
this.algorithmControl,
|
|
82
|
+
this.localeControl,
|
|
83
|
+
this.currencyControl,
|
|
84
|
+
this.productCountControl,
|
|
85
|
+
this.productLayoutControl,
|
|
86
|
+
this.filtersControl,
|
|
87
|
+
this.shuffleControl,
|
|
88
|
+
this.layoutOrientationControl
|
|
89
|
+
].forEach((e) => {
|
|
90
|
+
e.api = this.api;
|
|
91
|
+
}), `
|
|
75
92
|
<div class="recommendation-controls-container">
|
|
93
|
+
${this.layoutOrientationControl.getTemplate()}
|
|
94
|
+
${this.productCountControl.getTemplate()}
|
|
95
|
+
${this.productLayoutControl.getTemplate()}
|
|
76
96
|
${this.algorithmControl.getTemplate()}
|
|
77
97
|
${this.localeControl.getTemplate()}
|
|
78
98
|
${this.currencyControl.getTemplate()}
|
|
79
99
|
${this.filtersControl.getTemplate()}
|
|
80
|
-
${this.productLayoutControl.getTemplate()}
|
|
81
100
|
${this.shuffleControl.getTemplate()}
|
|
82
101
|
</div>
|
|
83
102
|
`;
|
|
@@ -96,6 +115,8 @@ class W extends p {
|
|
|
96
115
|
super.onTemplateNodeUpdated(t);
|
|
97
116
|
const e = this._getRecommendationIdFromNode(t);
|
|
98
117
|
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((r = this.store.blockStates[e]) != null && r.isInitialized) && this._fetchBlockData(e), [
|
|
118
|
+
this.layoutOrientationControl,
|
|
119
|
+
this.productCountControl,
|
|
99
120
|
this.algorithmControl,
|
|
100
121
|
this.localeControl,
|
|
101
122
|
this.currencyControl,
|
|
@@ -103,12 +124,14 @@ class W extends p {
|
|
|
103
124
|
this.filtersControl,
|
|
104
125
|
this.shuffleControl
|
|
105
126
|
].forEach((n) => {
|
|
106
|
-
var
|
|
107
|
-
n != null && n.api && (n.currentNode = t, (
|
|
127
|
+
var i;
|
|
128
|
+
n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
|
|
108
129
|
});
|
|
109
130
|
}
|
|
110
131
|
onDestroy() {
|
|
111
132
|
this.storeUnsubscription(), [
|
|
133
|
+
this.layoutOrientationControl,
|
|
134
|
+
this.productCountControl,
|
|
112
135
|
this.algorithmControl,
|
|
113
136
|
this.localeControl,
|
|
114
137
|
this.currencyControl,
|
|
@@ -126,6 +149,8 @@ class W extends p {
|
|
|
126
149
|
*/
|
|
127
150
|
_initializeSubControls() {
|
|
128
151
|
[
|
|
152
|
+
this.layoutOrientationControl,
|
|
153
|
+
this.productCountControl,
|
|
129
154
|
this.algorithmControl,
|
|
130
155
|
this.localeControl,
|
|
131
156
|
this.currencyControl,
|
|
@@ -150,7 +175,7 @@ class W extends p {
|
|
|
150
175
|
*/
|
|
151
176
|
_syncNodeConfigToStore() {
|
|
152
177
|
var r;
|
|
153
|
-
const t =
|
|
178
|
+
const t = h.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
|
|
154
179
|
this.store.patchCurrentBlockConfig({
|
|
155
180
|
strategy: t.strategy,
|
|
156
181
|
language: t.language,
|
|
@@ -207,31 +232,31 @@ class W extends p {
|
|
|
207
232
|
_applySmartDefaults() {
|
|
208
233
|
if (!this.currentNode || !this.api)
|
|
209
234
|
return;
|
|
210
|
-
const t =
|
|
235
|
+
const t = h.getConfig(this.currentNode), e = {};
|
|
211
236
|
let o = null, r = null, n = null;
|
|
212
237
|
if (t.currency.code === a.currency.code) {
|
|
213
|
-
const { currencyList:
|
|
214
|
-
|
|
238
|
+
const { currencyList: i } = this.store;
|
|
239
|
+
i.length > 0 && (i.some(
|
|
215
240
|
(u) => u.value === `price.${a.currency.code}`
|
|
216
|
-
) || (o =
|
|
241
|
+
) || (o = i[0].value.replace("price.", ""), e.currency = {
|
|
217
242
|
...a.currency,
|
|
218
243
|
code: o,
|
|
219
244
|
symbol: o
|
|
220
245
|
}));
|
|
221
246
|
}
|
|
222
247
|
if (t.strategy === a.strategy) {
|
|
223
|
-
const
|
|
224
|
-
|
|
248
|
+
const i = this.store.getActivePredictiveAlgorithms;
|
|
249
|
+
i.length > 0 && (i.some(
|
|
225
250
|
(u) => u.value === a.strategy
|
|
226
|
-
) || (r =
|
|
251
|
+
) || (r = i[0].value, e.strategy = r));
|
|
227
252
|
}
|
|
228
253
|
if (t.language === a.language) {
|
|
229
|
-
const
|
|
230
|
-
|
|
254
|
+
const i = this.store.getLanguages;
|
|
255
|
+
i.length > 0 && (i.some(
|
|
231
256
|
(u) => u.value === a.language
|
|
232
|
-
) || (n =
|
|
257
|
+
) || (n = i[0].value, e.language = n));
|
|
233
258
|
}
|
|
234
|
-
!o && !r && !n || (
|
|
259
|
+
!o && !r && !n || (h.updateConfig(
|
|
235
260
|
this.api,
|
|
236
261
|
this.currentNode,
|
|
237
262
|
e,
|
|
@@ -256,7 +281,7 @@ class W extends p {
|
|
|
256
281
|
* Reads the recommendation-id attribute from the block element within the node
|
|
257
282
|
*/
|
|
258
283
|
_getRecommendationIdFromNode(t) {
|
|
259
|
-
const e =
|
|
284
|
+
const e = L(t);
|
|
260
285
|
if (!e || !("getAttribute" in e))
|
|
261
286
|
return null;
|
|
262
287
|
const o = e.getAttribute(k);
|
|
@@ -287,10 +312,10 @@ class W extends p {
|
|
|
287
312
|
r = n, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
288
313
|
return;
|
|
289
314
|
}
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
u &&
|
|
315
|
+
const i = t.$state.configVersion;
|
|
316
|
+
i !== o && (o = i, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
|
|
317
|
+
const c = t.recommendationProducts, u = c !== e, C = Array.isArray(c) && c.length > 0;
|
|
318
|
+
u && C && (e = c, this._debouncedRegenerateWithProducts());
|
|
294
319
|
});
|
|
295
320
|
}
|
|
296
321
|
/**
|
|
@@ -301,7 +326,7 @@ class W extends p {
|
|
|
301
326
|
if (!this.currentNode || !this.api)
|
|
302
327
|
return;
|
|
303
328
|
const { filters: t } = this.store.recommendationConfigs;
|
|
304
|
-
|
|
329
|
+
h.updateConfig(
|
|
305
330
|
this.api,
|
|
306
331
|
this.currentNode,
|
|
307
332
|
{ filters: t },
|
|
@@ -310,31 +335,35 @@ class W extends p {
|
|
|
310
335
|
}
|
|
311
336
|
}
|
|
312
337
|
export {
|
|
313
|
-
|
|
338
|
+
J as ALGORITHM_CONTROL_ID,
|
|
314
339
|
R as AlgorithmControl,
|
|
315
|
-
|
|
316
|
-
|
|
340
|
+
E as CONTROL_BLOCK_ID,
|
|
341
|
+
X as CURRENCY_CONTROL_ID,
|
|
317
342
|
N as CurrencyControl,
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
343
|
+
tt as FILTERS_CONTROL_ID,
|
|
344
|
+
_ as FiltersControl,
|
|
345
|
+
ot as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
346
|
+
nt as LOCALE_CONTROL_ID,
|
|
347
|
+
b as LayoutOrientationControl,
|
|
348
|
+
O as LocaleControl,
|
|
349
|
+
st as PRODUCT_COUNT_CONTROL_ID,
|
|
350
|
+
lt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
351
|
+
I as ProductCountControl,
|
|
352
|
+
T as ProductLayoutControl,
|
|
353
|
+
H as RecommendationBlockControl,
|
|
354
|
+
ut as SHUFFLE_CONTROL_ID,
|
|
326
355
|
S as ShuffleControl,
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
356
|
+
ht as adjustProductsToSize,
|
|
357
|
+
mt as formatProductPrice,
|
|
358
|
+
L as getBlockElement,
|
|
359
|
+
Ct as getCardComposition,
|
|
360
|
+
ft as getCurrentLayout,
|
|
361
|
+
pt as reapplySpacing,
|
|
362
|
+
gt as regenerateMobileProductRows,
|
|
363
|
+
yt as regenerateProductRows,
|
|
364
|
+
D as regenerateProductRowsWithStyles,
|
|
365
|
+
Rt as setCurrencyAttributes,
|
|
366
|
+
Nt as updatePricesInPlace,
|
|
367
|
+
P as updateProductContentInPlace,
|
|
368
|
+
_t as updateSingleProductContent
|
|
340
369
|
};
|
package/dist/extensions/Blocks/Recommendation/controls/{layout/index.js → main/layoutOrientation.js}
RENAMED
|
@@ -1,53 +1,61 @@
|
|
|
1
|
-
var
|
|
2
|
-
var p = (
|
|
3
|
-
var r = (
|
|
4
|
-
import { ModificationDescription as
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { ATTR_DATA_CUSTOM_ATTRIBUTES as
|
|
7
|
-
import { LAYOUT_OPTIONS as
|
|
8
|
-
import { DEFAULT_COMPOSITION as
|
|
1
|
+
var O = Object.defineProperty;
|
|
2
|
+
var p = (o, e, t) => e in o ? O(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var r = (o, e, t) => p(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 { ATTR_DATA_CUSTOM_ATTRIBUTES as L } from "../../constants/selectors.js";
|
|
7
|
+
import { LAYOUT_OPTIONS as T, 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";
|
|
8
|
+
import { DEFAULT_COMPOSITION as _ } from "../../constants/defaultConfig.js";
|
|
9
9
|
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
import { getCurrentLayout as
|
|
12
|
-
const
|
|
10
|
+
import { useRecommendationExtensionStore as f } from "../../store/recommendation.js";
|
|
11
|
+
import { getCurrentLayout as C, getBlockElement as I, regenerateProductRowsWithStyles as S } from "./utils.js";
|
|
12
|
+
const U = "recommendation-layout-orientation-control", A = "recommendationInfoBannerTest", a = {
|
|
13
13
|
LAYOUT: "layout"
|
|
14
|
-
},
|
|
14
|
+
}, y = "data-card-composition", i = {
|
|
15
15
|
LAYOUT: "data-layout",
|
|
16
16
|
COLUMN_SPACING: "data-column-spacing",
|
|
17
17
|
ROW_SPACING: "data-row-spacing",
|
|
18
18
|
MOBILE_COLUMN_SPACING: "data-mobile-column-spacing",
|
|
19
19
|
MOBILE_ROW_SPACING: "data-mobile-row-spacing"
|
|
20
20
|
};
|
|
21
|
-
class
|
|
21
|
+
class Y extends N {
|
|
22
22
|
constructor() {
|
|
23
23
|
super(...arguments);
|
|
24
|
-
r(this, "store",
|
|
24
|
+
r(this, "store", f());
|
|
25
25
|
r(this, "isChangingLayout", !1);
|
|
26
26
|
}
|
|
27
27
|
getId() {
|
|
28
|
-
return
|
|
28
|
+
return U;
|
|
29
29
|
}
|
|
30
30
|
getTemplate() {
|
|
31
31
|
return `
|
|
32
32
|
<div class="layout-control-container">
|
|
33
|
+
${this._GuOnPageMessage({ name: A })}
|
|
34
|
+
|
|
33
35
|
${this._GuTwoColumns([
|
|
34
|
-
this._GuLabel({ text: "Layout Orientation" }),
|
|
36
|
+
this._GuLabel({ text: this.api.translate("Layout Orientation") }),
|
|
35
37
|
this._GuRadioButton({
|
|
36
38
|
name: a.LAYOUT,
|
|
37
|
-
buttons:
|
|
39
|
+
buttons: T
|
|
38
40
|
})
|
|
39
41
|
])}
|
|
40
42
|
</div>
|
|
41
43
|
`;
|
|
42
44
|
}
|
|
43
45
|
onRender() {
|
|
44
|
-
this.
|
|
46
|
+
this._setInfoMessageValue(
|
|
47
|
+
A,
|
|
48
|
+
this.api.translate(
|
|
49
|
+
`Note that updating the Layout Orientation, Number of Products and
|
|
50
|
+
Products in One Row settings resets the style of your Recommendation block.`
|
|
51
|
+
)
|
|
52
|
+
), this._setFormValues(), this._listenToFormUpdates();
|
|
45
53
|
}
|
|
46
54
|
onTemplateNodeUpdated(t) {
|
|
47
55
|
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
48
56
|
}
|
|
49
57
|
_setFormValues() {
|
|
50
|
-
const u = s.getConfig(this.currentNode).layout ||
|
|
58
|
+
const u = s.getConfig(this.currentNode).layout || C(this.currentNode);
|
|
51
59
|
this.api.updateValues({
|
|
52
60
|
[a.LAYOUT]: u
|
|
53
61
|
});
|
|
@@ -57,9 +65,9 @@ class w extends O {
|
|
|
57
65
|
* Updates node config, data attribute and regenerates product rows
|
|
58
66
|
*/
|
|
59
67
|
_onLayoutChange(t) {
|
|
60
|
-
if (this.isChangingLayout || !this.currentNode || (s.getConfig(this.currentNode).layout ||
|
|
68
|
+
if (this.isChangingLayout || !this.currentNode || (s.getConfig(this.currentNode).layout || C(this.currentNode)) === t)
|
|
61
69
|
return;
|
|
62
|
-
const c =
|
|
70
|
+
const c = I(this.currentNode);
|
|
63
71
|
if (c) {
|
|
64
72
|
this.isChangingLayout = !0;
|
|
65
73
|
try {
|
|
@@ -68,15 +76,15 @@ class w extends O {
|
|
|
68
76
|
this.currentNode,
|
|
69
77
|
{
|
|
70
78
|
layout: t,
|
|
71
|
-
columnSpacing:
|
|
79
|
+
columnSpacing: g,
|
|
72
80
|
rowSpacing: l,
|
|
73
81
|
mobileColumnSpacing: d,
|
|
74
82
|
mobileRowSpacing: m
|
|
75
83
|
},
|
|
76
84
|
`Changed layout to ${t}`
|
|
77
85
|
), this.store.patchCurrentBlockConfig({ orientation: t });
|
|
78
|
-
const
|
|
79
|
-
t === "list" ? (
|
|
86
|
+
const n = this.api.getDocumentModifier().modifyHtml(c).setAttribute(i.LAYOUT, t).setAttribute(i.COLUMN_SPACING, g.toString()).setAttribute(i.ROW_SPACING, l.toString()).setAttribute(i.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(i.MOBILE_ROW_SPACING, m.toString());
|
|
87
|
+
t === "list" ? (n.setClass("es-m-p0"), n.setClass("ins-recommendation-list-layout")) : (n.removeClass("es-m-p0"), n.removeClass("ins-recommendation-list-layout")), n.setAttribute(y, _.join(",")).setAttribute(L, "[]"), n.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t);
|
|
80
88
|
} finally {
|
|
81
89
|
this.isChangingLayout = !1;
|
|
82
90
|
}
|
|
@@ -92,7 +100,7 @@ class w extends O {
|
|
|
92
100
|
currentNode: this.currentNode,
|
|
93
101
|
documentModifier: this.api.getDocumentModifier(),
|
|
94
102
|
layout: t,
|
|
95
|
-
composition:
|
|
103
|
+
composition: _
|
|
96
104
|
});
|
|
97
105
|
}
|
|
98
106
|
_listenToFormUpdates() {
|
|
@@ -102,6 +110,6 @@ class w extends O {
|
|
|
102
110
|
}
|
|
103
111
|
}
|
|
104
112
|
export {
|
|
105
|
-
|
|
106
|
-
|
|
113
|
+
U as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
114
|
+
Y as LayoutOrientationControl
|
|
107
115
|
};
|
|
@@ -21,10 +21,10 @@ class E extends c {
|
|
|
21
21
|
return `
|
|
22
22
|
<div class="locale-control-container">
|
|
23
23
|
${this._GuTwoColumns([
|
|
24
|
-
this._GuLabel({ text: "Recommendation Locale" }),
|
|
24
|
+
this._GuLabel({ text: this.api.translate("Recommendation Locale") }),
|
|
25
25
|
this._GuSelect({
|
|
26
26
|
name: n.LOCALE,
|
|
27
|
-
placeholder: "Select Recommendation Locale",
|
|
27
|
+
placeholder: this.api.translate("Select Recommendation Locale"),
|
|
28
28
|
options: this.store.getLanguages
|
|
29
29
|
})
|
|
30
30
|
])}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var s = Object.defineProperty;
|
|
2
|
+
var u = (e, o, t) => o in e ? s(e, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[o] = t;
|
|
3
|
+
var i = (e, o, t) => u(e, typeof o != "symbol" ? o + "" : o, t);
|
|
4
|
+
import { CommonControl as a } from "../../../common-control.js";
|
|
5
|
+
import { MAX_PRODUCT_COUNT as c } from "../../constants/layout.js";
|
|
6
|
+
import { RecommendationConfigService as n } from "../../services/configService.js";
|
|
7
|
+
import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
|
|
8
|
+
const C = "recommendation-product-count-control", r = {
|
|
9
|
+
PRODUCT_COUNT: "size"
|
|
10
|
+
};
|
|
11
|
+
class g extends a {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
i(this, "store", d());
|
|
15
|
+
}
|
|
16
|
+
getId() {
|
|
17
|
+
return C;
|
|
18
|
+
}
|
|
19
|
+
getTemplate() {
|
|
20
|
+
return `
|
|
21
|
+
<div class="product-count-control-container">
|
|
22
|
+
${this._GuTwoColumns([
|
|
23
|
+
this._GuLabel({ text: this.api.translate("Number of Products") }),
|
|
24
|
+
this._GuCounter({ name: r.PRODUCT_COUNT, maxValue: c })
|
|
25
|
+
])}
|
|
26
|
+
</div>
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
onRender() {
|
|
30
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
31
|
+
}
|
|
32
|
+
onTemplateNodeUpdated(t) {
|
|
33
|
+
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
34
|
+
}
|
|
35
|
+
_setFormValues() {
|
|
36
|
+
const t = n.getConfig(this.currentNode);
|
|
37
|
+
this.api.updateValues({
|
|
38
|
+
[r.PRODUCT_COUNT]: t.size
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
_onProductCountChange(t) {
|
|
42
|
+
!this.currentNode || n.getConfig(this.currentNode).size === t || (n.updateConfig(
|
|
43
|
+
this.api,
|
|
44
|
+
this.currentNode,
|
|
45
|
+
{ size: t },
|
|
46
|
+
`Changed product count to ${t}`
|
|
47
|
+
), this.store.patchCurrentBlockConfig({ size: t }));
|
|
48
|
+
}
|
|
49
|
+
_listenToFormUpdates() {
|
|
50
|
+
this.api.onValueChanged(r.PRODUCT_COUNT, (t) => {
|
|
51
|
+
this._onProductCountChange(t.toString());
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
C as PRODUCT_COUNT_CONTROL_ID,
|
|
57
|
+
g as ProductCountControl
|
|
58
|
+
};
|