@useinsider/guido 2.1.0-beta.9ba2e9d → 2.1.0-beta.a67f307
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/README.md +36 -0
- package/dist/@types/config/schemas.js +70 -65
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +69 -58
- package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
- package/dist/composables/useBlocksConfig.js +26 -16
- package/dist/composables/useHtmlValidator.js +107 -119
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +70 -96
- package/dist/config/migrator/itemsBlockMigrator.js +101 -97
- package/dist/enums/defaults.js +8 -4
- package/dist/enums/extensions/recommendationBlock.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +26 -23
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +27 -26
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +6 -4
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +12 -10
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +103 -70
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +87 -37
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +138 -117
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +117 -107
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +25 -30
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -30
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +20 -25
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +43 -31
- package/dist/extensions/ModulesTabIcons/extension.js +17 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +257 -187
- package/dist/services/recommendationApi.js +11 -9
- package/dist/src/@types/config/schemas.d.ts +8 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
- package/dist/src/enums/defaults.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +12 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +22 -4
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -3
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
- package/dist/src/stores/config.d.ts +36 -0
- package/dist/static/styles/components/notification.css.js +1 -0
- package/dist/static/styles/components/version-history.css.js +10 -2
- package/dist/static/styles/components/wide-panel.css.js +18 -2
- package/dist/static/styles/customEditorStyle.css.js +10 -9
- package/package.json +2 -2
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { RecommendationFeedSourceMaps as
|
|
2
|
-
import { useRecommendationApi as
|
|
3
|
-
import { useConfigStore as
|
|
4
|
-
import { defineStore as
|
|
5
|
-
import { DEFAULT_CARDS_IN_ROW as
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { RecommendationFeedSourceMaps as d, PriceAttributes as S } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as p } from "../../../../services/recommendationApi.js";
|
|
3
|
+
import { useConfigStore as b } from "../../../../stores/config.js";
|
|
4
|
+
import { defineStore as I } from "pinia";
|
|
5
|
+
import { DEFAULT_CARDS_IN_ROW as R } from "../constants/layout.js";
|
|
6
|
+
import { getDefaultProducts as k } from "../templates/utils.js";
|
|
7
|
+
import { generateCompleteFilterQuery as f } from "../utils/filterUtil.js";
|
|
8
|
+
const m = p();
|
|
9
|
+
function h() {
|
|
9
10
|
return {
|
|
10
|
-
cardsInRow:
|
|
11
|
+
cardsInRow: R,
|
|
11
12
|
currencySettings: {
|
|
12
13
|
name: "USD",
|
|
13
14
|
value: "USD",
|
|
@@ -20,7 +21,7 @@ function f() {
|
|
|
20
21
|
filters: [],
|
|
21
22
|
productIds: [],
|
|
22
23
|
id: 1,
|
|
23
|
-
language: "
|
|
24
|
+
language: "en_US",
|
|
24
25
|
orientation: "grid",
|
|
25
26
|
recommendedProducts: [],
|
|
26
27
|
sendProductRequestFlag: !1,
|
|
@@ -31,16 +32,17 @@ function f() {
|
|
|
31
32
|
size: "6"
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
+
function C() {
|
|
35
36
|
return {
|
|
36
|
-
recommendationConfigs:
|
|
37
|
+
recommendationConfigs: h(),
|
|
37
38
|
recommendationProducts: [],
|
|
38
39
|
filterStatus: !1,
|
|
39
40
|
filterSelectionDrawerStatus: !1,
|
|
40
|
-
filterGroup: 1
|
|
41
|
+
filterGroup: 1,
|
|
42
|
+
isInitialized: !1
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
|
-
const
|
|
45
|
+
const y = () => ({
|
|
44
46
|
recommendationCampaignUrls: {},
|
|
45
47
|
activePredictiveAlgorithms: [],
|
|
46
48
|
languages: {},
|
|
@@ -49,8 +51,8 @@ const k = () => ({
|
|
|
49
51
|
blockStates: {},
|
|
50
52
|
currentRecommendationId: null,
|
|
51
53
|
configVersion: 0
|
|
52
|
-
}),
|
|
53
|
-
state: () =>
|
|
54
|
+
}), A = I("guidoRecommendationExtension", {
|
|
55
|
+
state: () => y(),
|
|
54
56
|
getters: {
|
|
55
57
|
// ====================================================================
|
|
56
58
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -59,32 +61,32 @@ const k = () => ({
|
|
|
59
61
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationConfigs
|
|
60
62
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
61
63
|
*/
|
|
62
|
-
recommendationConfigs(
|
|
63
|
-
return
|
|
64
|
+
recommendationConfigs(t) {
|
|
65
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : h();
|
|
64
66
|
},
|
|
65
67
|
/**
|
|
66
68
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
67
69
|
*/
|
|
68
|
-
recommendationProducts(
|
|
69
|
-
return
|
|
70
|
+
recommendationProducts(t) {
|
|
71
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationProducts : [];
|
|
70
72
|
},
|
|
71
73
|
/**
|
|
72
74
|
* Proxy getter: delegates to blockStates[currentRecommendationId].filterSelectionDrawerStatus
|
|
73
75
|
*/
|
|
74
|
-
filterSelectionDrawerStatus(
|
|
75
|
-
return
|
|
76
|
+
filterSelectionDrawerStatus(t) {
|
|
77
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterSelectionDrawerStatus : !1;
|
|
76
78
|
},
|
|
77
79
|
/**
|
|
78
80
|
* Proxy getter: delegates to blockStates[currentRecommendationId].filterStatus
|
|
79
81
|
*/
|
|
80
|
-
filterStatus(
|
|
81
|
-
return
|
|
82
|
+
filterStatus(t) {
|
|
83
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterStatus : !1;
|
|
82
84
|
},
|
|
83
85
|
/**
|
|
84
86
|
* Proxy getter: delegates to blockStates[currentRecommendationId].filterGroup
|
|
85
87
|
*/
|
|
86
|
-
filterGroup(
|
|
87
|
-
return
|
|
88
|
+
filterGroup(t) {
|
|
89
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterGroup : 1;
|
|
88
90
|
},
|
|
89
91
|
// ====================================================================
|
|
90
92
|
// Existing Getters (now reading through proxy)
|
|
@@ -93,39 +95,39 @@ const k = () => ({
|
|
|
93
95
|
return !!this.recommendationConfigs.filters.length;
|
|
94
96
|
},
|
|
95
97
|
getFilterGroupCount() {
|
|
96
|
-
const { filters:
|
|
97
|
-
return
|
|
98
|
+
const { filters: t } = this.recommendationConfigs;
|
|
99
|
+
return t.length && t[t.length - 1].filterGroup || 0;
|
|
98
100
|
},
|
|
99
|
-
getActivePredictiveAlgorithms: (
|
|
101
|
+
getActivePredictiveAlgorithms: (t) => {
|
|
100
102
|
const r = [];
|
|
101
|
-
return
|
|
102
|
-
r.push(...
|
|
103
|
-
}), r.map((
|
|
104
|
-
text:
|
|
105
|
-
value:
|
|
103
|
+
return t.activePredictiveAlgorithms.forEach((e) => {
|
|
104
|
+
r.push(...d.filter((n) => n.id === e));
|
|
105
|
+
}), r.map((e) => ({
|
|
106
|
+
text: e.name,
|
|
107
|
+
value: e.key
|
|
106
108
|
}));
|
|
107
109
|
},
|
|
108
|
-
getLanguages: (
|
|
109
|
-
text:
|
|
110
|
+
getLanguages: (t) => Object.entries(t.languages).map(([r, e]) => ({
|
|
111
|
+
text: e,
|
|
110
112
|
value: r
|
|
111
113
|
})),
|
|
112
|
-
getCurrencySymbolList: (
|
|
114
|
+
getCurrencySymbolList: (t) => t.currencyList.map((r) => ({
|
|
113
115
|
text: r.text,
|
|
114
116
|
value: r.text
|
|
115
117
|
})),
|
|
116
118
|
getFilterList() {
|
|
117
|
-
return Object.values(this.filterList).map((
|
|
118
|
-
const r =
|
|
119
|
-
let n = r ?
|
|
120
|
-
return n =
|
|
121
|
-
text:
|
|
119
|
+
return Object.values(this.filterList).map((t) => {
|
|
120
|
+
const r = t.type === "defaultAttribute", e = S.includes(t.attributeName);
|
|
121
|
+
let n = r ? t.attributeName : `product_attributes.${t.attributeName}`;
|
|
122
|
+
return n = e ? `${n}.${this.recommendationConfigs.currencySettings.value}` : n, {
|
|
123
|
+
text: t.displayName,
|
|
122
124
|
value: n,
|
|
123
|
-
type:
|
|
125
|
+
type: t.attributeType
|
|
124
126
|
};
|
|
125
127
|
});
|
|
126
128
|
},
|
|
127
129
|
getSelectedFilterGroup() {
|
|
128
|
-
return (
|
|
130
|
+
return (t) => [...this.recommendationConfigs.filters].filter((r) => r.filterGroup === t);
|
|
129
131
|
}
|
|
130
132
|
},
|
|
131
133
|
actions: {
|
|
@@ -136,37 +138,44 @@ const k = () => ({
|
|
|
136
138
|
* Sets the currently active block ID.
|
|
137
139
|
* Creates a new entry in blockStates if one doesn't exist.
|
|
138
140
|
*/
|
|
139
|
-
setCurrentBlock(
|
|
140
|
-
this.blockStates[
|
|
141
|
+
setCurrentBlock(t) {
|
|
142
|
+
this.blockStates[t] || (this.blockStates = {
|
|
141
143
|
...this.blockStates,
|
|
142
|
-
[
|
|
143
|
-
}), this.currentRecommendationId =
|
|
144
|
+
[t]: C()
|
|
145
|
+
}), this.currentRecommendationId = t;
|
|
144
146
|
},
|
|
145
147
|
/**
|
|
146
148
|
* Removes a block's state from the store.
|
|
147
149
|
* Resets currentRecommendationId if it was the deleted block.
|
|
148
150
|
*/
|
|
149
|
-
removeBlockState(
|
|
151
|
+
removeBlockState(t) {
|
|
150
152
|
const r = { ...this.blockStates };
|
|
151
|
-
if (delete r[
|
|
152
|
-
const
|
|
153
|
-
this.currentRecommendationId =
|
|
153
|
+
if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
|
|
154
|
+
const e = Object.keys(this.blockStates).map(Number);
|
|
155
|
+
this.currentRecommendationId = e.length > 0 ? e[0] : null;
|
|
154
156
|
}
|
|
155
157
|
},
|
|
158
|
+
/**
|
|
159
|
+
* Marks a block as initialized (initial API data has been fetched).
|
|
160
|
+
* Automatically cleaned up when removeBlockState deletes the block entry.
|
|
161
|
+
*/
|
|
162
|
+
markBlockInitialized(t) {
|
|
163
|
+
this.blockStates[t] && (this.blockStates[t].isInitialized = !0);
|
|
164
|
+
},
|
|
156
165
|
/**
|
|
157
166
|
* Patches the current block's recommendationConfigs.
|
|
158
167
|
* Replaces `store.$patch({ recommendationConfigs: { ... } })` pattern.
|
|
159
168
|
*/
|
|
160
|
-
patchCurrentBlockConfig(
|
|
169
|
+
patchCurrentBlockConfig(t, r = {}) {
|
|
161
170
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
162
171
|
return;
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
...
|
|
166
|
-
...
|
|
172
|
+
const e = this.blockStates[this.currentRecommendationId];
|
|
173
|
+
e.recommendationConfigs = {
|
|
174
|
+
...e.recommendationConfigs,
|
|
175
|
+
...t,
|
|
167
176
|
currencySettings: {
|
|
168
|
-
...
|
|
169
|
-
...
|
|
177
|
+
...e.recommendationConfigs.currencySettings,
|
|
178
|
+
...t.currencySettings || {}
|
|
170
179
|
}
|
|
171
180
|
};
|
|
172
181
|
const { triggerRefetch: n = !0 } = r;
|
|
@@ -180,8 +189,8 @@ const k = () => ({
|
|
|
180
189
|
openFilterDrawer() {
|
|
181
190
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
182
191
|
return;
|
|
183
|
-
const
|
|
184
|
-
|
|
192
|
+
const t = this.blockStates[this.currentRecommendationId];
|
|
193
|
+
t.recommendationConfigs.filters.length || (t.recommendationConfigs.filters = [{
|
|
185
194
|
type: "standardFilter",
|
|
186
195
|
attribute: "",
|
|
187
196
|
operatorReplace: "",
|
|
@@ -192,7 +201,7 @@ const k = () => ({
|
|
|
192
201
|
filterGroup: 1,
|
|
193
202
|
isValid: !1,
|
|
194
203
|
value: ""
|
|
195
|
-
}]),
|
|
204
|
+
}]), t.filterSelectionDrawerStatus = !0;
|
|
196
205
|
},
|
|
197
206
|
/**
|
|
198
207
|
* Closes the filter selection drawer for the current block
|
|
@@ -207,26 +216,24 @@ const k = () => ({
|
|
|
207
216
|
if (this.activePredictiveAlgorithms.length)
|
|
208
217
|
return;
|
|
209
218
|
const {
|
|
210
|
-
activePredictiveAlgorithms:
|
|
219
|
+
activePredictiveAlgorithms: t,
|
|
211
220
|
languages: r,
|
|
212
|
-
currencies:
|
|
213
|
-
} = await
|
|
214
|
-
this.activePredictiveAlgorithms =
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const i = this.blockStates[this.currentRecommendationId];
|
|
218
|
-
i.recommendationConfigs.currencySettings.name = n.text, i.recommendationConfigs.currencySettings.value = o, i.filterStatus = !!i.recommendationConfigs.filters.length;
|
|
221
|
+
currencies: e
|
|
222
|
+
} = await m.fetchRecommendationCreateData();
|
|
223
|
+
if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
224
|
+
const n = this.blockStates[this.currentRecommendationId];
|
|
225
|
+
n.filterStatus = !!n.recommendationConfigs.filters.length;
|
|
219
226
|
}
|
|
220
|
-
this.currencyList =
|
|
227
|
+
this.currencyList = e;
|
|
221
228
|
},
|
|
222
229
|
async fetchRecommendationFilters() {
|
|
223
|
-
const
|
|
224
|
-
this.filterList =
|
|
230
|
+
const t = await m.fetchRecommendationFilters();
|
|
231
|
+
this.filterList = t;
|
|
225
232
|
},
|
|
226
233
|
// ====================================================================
|
|
227
234
|
// Per-Block Filter Actions
|
|
228
235
|
// ====================================================================
|
|
229
|
-
addFilterGroup(
|
|
236
|
+
addFilterGroup(t) {
|
|
230
237
|
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || this.blockStates[this.currentRecommendationId].recommendationConfigs.filters.push({
|
|
231
238
|
type: "standardFilter",
|
|
232
239
|
attribute: "",
|
|
@@ -237,68 +244,71 @@ const k = () => ({
|
|
|
237
244
|
value: "",
|
|
238
245
|
filterNumber: 1,
|
|
239
246
|
isValid: !0,
|
|
240
|
-
filterGroup:
|
|
247
|
+
filterGroup: t
|
|
241
248
|
});
|
|
242
249
|
},
|
|
243
|
-
updateFilter(
|
|
250
|
+
updateFilter(t) {
|
|
244
251
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
245
252
|
return;
|
|
246
|
-
const r = this.blockStates[this.currentRecommendationId],
|
|
247
|
-
if (
|
|
253
|
+
const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
254
|
+
if (e !== -1) {
|
|
248
255
|
const n = [...r.recommendationConfigs.filters];
|
|
249
|
-
n[
|
|
256
|
+
n[e] = t, t.value.length && t.operator && t.attribute && t.innerGroupOperator && t.outerGroupOperator ? n[e].isValid = !0 : n[e].isValid = !1, r.recommendationConfigs.filters = n;
|
|
250
257
|
}
|
|
251
258
|
},
|
|
252
|
-
deleteFilter(
|
|
259
|
+
deleteFilter(t) {
|
|
253
260
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
254
261
|
return;
|
|
255
|
-
const r = this.blockStates[this.currentRecommendationId],
|
|
256
|
-
if (
|
|
262
|
+
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
263
|
+
if (e !== -1) {
|
|
257
264
|
const n = [...r.recommendationConfigs.filters];
|
|
258
|
-
n.splice(
|
|
265
|
+
n.splice(e, 1), r.recommendationConfigs.filters = n;
|
|
259
266
|
}
|
|
260
267
|
},
|
|
261
|
-
addFilter(
|
|
268
|
+
addFilter(t) {
|
|
262
269
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
263
270
|
return;
|
|
264
|
-
const r = this.blockStates[this.currentRecommendationId],
|
|
265
|
-
(
|
|
266
|
-
).length + 1,
|
|
267
|
-
|
|
268
|
-
...
|
|
271
|
+
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], o = e.filter(
|
|
272
|
+
(i) => i.filterGroup === t.filterGroup
|
|
273
|
+
).length + 1, s = e.findLastIndex((i) => i.filterGroup === t.filterGroup);
|
|
274
|
+
s !== -1 ? e.splice(s + 1, 0, {
|
|
275
|
+
...t,
|
|
269
276
|
filterNumber: o
|
|
270
|
-
}) :
|
|
271
|
-
...
|
|
277
|
+
}) : e.push({
|
|
278
|
+
...t,
|
|
272
279
|
filterNumber: o
|
|
273
|
-
}), r.recommendationConfigs.filters =
|
|
280
|
+
}), r.recommendationConfigs.filters = e;
|
|
274
281
|
},
|
|
275
282
|
generateFilterQuery() {
|
|
276
|
-
return
|
|
283
|
+
return f(this.recommendationConfigs.filters);
|
|
277
284
|
},
|
|
278
285
|
// ====================================================================
|
|
279
286
|
// Per-Block Product Fetching
|
|
280
287
|
// ====================================================================
|
|
281
288
|
async fetchRecommendationProducts() {
|
|
282
|
-
var
|
|
289
|
+
var u;
|
|
283
290
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
284
291
|
return;
|
|
285
|
-
const
|
|
286
|
-
locale:
|
|
287
|
-
currency:
|
|
288
|
-
partnerName:
|
|
289
|
-
size:
|
|
292
|
+
const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((l) => l.isValid), o = f(n), s = ((u = d.find((l) => l.key === e.strategy)) == null ? void 0 : u.path) || "", i = b(), c = {
|
|
293
|
+
locale: e.language,
|
|
294
|
+
currency: e.currencySettings.value,
|
|
295
|
+
partnerName: i.partnerName,
|
|
296
|
+
size: e.size,
|
|
290
297
|
details: !0,
|
|
291
|
-
campaignId:
|
|
298
|
+
campaignId: i.variationId
|
|
292
299
|
};
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
300
|
+
e.strategy === "manualMerchandising" ? c.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (c.productId = "{itemId}"), o && (c.filter = o), e.shuffleProducts && (c.shuffle = !0);
|
|
301
|
+
const g = parseInt(e.size) || 6;
|
|
302
|
+
let a;
|
|
303
|
+
try {
|
|
304
|
+
a = await m.fetchRecommendationProducts(s, c);
|
|
305
|
+
} catch {
|
|
306
|
+
a = [];
|
|
307
|
+
}
|
|
308
|
+
this.blockStates[t] && (this.blockStates[t].recommendationProducts = a.length > 0 ? a : k(g));
|
|
299
309
|
}
|
|
300
310
|
}
|
|
301
311
|
});
|
|
302
312
|
export {
|
|
303
|
-
|
|
313
|
+
A as useRecommendationExtensionStore
|
|
304
314
|
};
|
|
@@ -3,7 +3,7 @@ import { ATTR_PRODUCT_BUTTON as b, ATTR_PRODUCT_OMNIBUS_DISCOUNT as u, ATTR_PROD
|
|
|
3
3
|
import { useRecommendationExtensionStore as T } from "../../store/recommendation.js";
|
|
4
4
|
import { formatPrice as _ } from "../../utils/priceFormatter.js";
|
|
5
5
|
import { sanitizeImageUrl as $ } from "../utils.js";
|
|
6
|
-
const
|
|
6
|
+
const a = "0 5px", o = "attribute-cell";
|
|
7
7
|
function p() {
|
|
8
8
|
const t = T(), { currencySettings: e } = t.recommendationConfigs;
|
|
9
9
|
return {
|
|
@@ -15,16 +15,16 @@ function p() {
|
|
|
15
15
|
thousandSeparator: e.thousandSeparator
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
const n = p(), l = t[e],
|
|
18
|
+
function c(t, e = "price") {
|
|
19
|
+
const n = p(), l = t[e], r = (l == null ? void 0 : l[n.code]) ?? Object.values(l ?? {})[0] ?? 0;
|
|
20
20
|
return _({
|
|
21
|
-
price:
|
|
21
|
+
price: r,
|
|
22
22
|
currency: n
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
const P = {
|
|
26
26
|
[x]: (t) => `
|
|
27
|
-
<td class="${
|
|
27
|
+
<td class="${o}" style="padding: ${a}; height: 100%;" valign="top">
|
|
28
28
|
<table
|
|
29
29
|
class="product-card-segment"
|
|
30
30
|
width="100%"
|
|
@@ -38,18 +38,13 @@ const P = {
|
|
|
38
38
|
class="esd-block-image product-image"
|
|
39
39
|
align="center"
|
|
40
40
|
esd-extension-block-id="${s.IMAGE}">
|
|
41
|
-
<
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
style="
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
alt="${t.name}"
|
|
49
|
-
style="max-width: 100%; max-height: 100%; object-fit: contain; display: block;"
|
|
50
|
-
class="adapt-img">
|
|
51
|
-
</a>
|
|
52
|
-
</div>
|
|
41
|
+
<a target="_blank" href="${t.url}">
|
|
42
|
+
<img
|
|
43
|
+
src="${$(t.image_url)}"
|
|
44
|
+
alt="${t.name}"
|
|
45
|
+
style="display: block; max-width: 100%; height: auto;"
|
|
46
|
+
class="adapt-img">
|
|
47
|
+
</a>
|
|
53
48
|
</td>
|
|
54
49
|
</tr>
|
|
55
50
|
</tbody>
|
|
@@ -57,7 +52,7 @@ const P = {
|
|
|
57
52
|
</td>
|
|
58
53
|
`,
|
|
59
54
|
[f]: (t) => `
|
|
60
|
-
<td class="${
|
|
55
|
+
<td class="${o}" style="padding: ${a}; height: 100%;" valign="middle">
|
|
61
56
|
<table
|
|
62
57
|
class="product-card-segment"
|
|
63
58
|
width="100%"
|
|
@@ -82,7 +77,7 @@ const P = {
|
|
|
82
77
|
</td>
|
|
83
78
|
`,
|
|
84
79
|
[y]: (t) => `
|
|
85
|
-
<td class="${
|
|
80
|
+
<td class="${o}" style="padding: ${a}; height: 100%;" valign="top">
|
|
86
81
|
<table
|
|
87
82
|
class="product-card-segment"
|
|
88
83
|
width="100%"
|
|
@@ -97,7 +92,7 @@ const P = {
|
|
|
97
92
|
align="center"
|
|
98
93
|
esd-extension-block-id="${s.PRICE}">
|
|
99
94
|
<p contenteditable="false" style="font-size: 16px; color: #333333;">
|
|
100
|
-
<strong>${
|
|
95
|
+
<strong>${c(t, "price")}</strong>
|
|
101
96
|
</p>
|
|
102
97
|
</td>
|
|
103
98
|
</tr>
|
|
@@ -106,7 +101,7 @@ const P = {
|
|
|
106
101
|
</td>
|
|
107
102
|
`,
|
|
108
103
|
[h]: (t) => `
|
|
109
|
-
<td class="${
|
|
104
|
+
<td class="${o}" style="padding: ${a}; height: 100%;" valign="top">
|
|
110
105
|
<table
|
|
111
106
|
class="product-card-segment"
|
|
112
107
|
width="100%"
|
|
@@ -121,7 +116,7 @@ const P = {
|
|
|
121
116
|
align="center"
|
|
122
117
|
esd-extension-block-id="${s.OLD_PRICE}">
|
|
123
118
|
<p contenteditable="false" style="font-size: 14px; color: #999999;">
|
|
124
|
-
<strong>${
|
|
119
|
+
<strong>${c(t, "original_price")}</strong>
|
|
125
120
|
</p>
|
|
126
121
|
</td>
|
|
127
122
|
</tr>
|
|
@@ -130,7 +125,7 @@ const P = {
|
|
|
130
125
|
</td>
|
|
131
126
|
`,
|
|
132
127
|
[m]: (t) => `
|
|
133
|
-
<td class="${
|
|
128
|
+
<td class="${o}" style="padding: ${a}; height: 100%;" valign="top">
|
|
134
129
|
<table
|
|
135
130
|
class="product-card-segment"
|
|
136
131
|
width="100%"
|
|
@@ -148,7 +143,7 @@ const P = {
|
|
|
148
143
|
esd-extension-block-id="${s.OMNIBUS_PRICE}">
|
|
149
144
|
<p style="font-size: 12px; color: #666666;">
|
|
150
145
|
<span class="omnibus-text-before">Lowest 30-day price: </span>
|
|
151
|
-
<span class="omnibus-price-value">${
|
|
146
|
+
<span class="omnibus-price-value">${c(t, "original_price")}</span>
|
|
152
147
|
<span class="omnibus-text-after"></span>
|
|
153
148
|
</p>
|
|
154
149
|
</td>
|
|
@@ -158,10 +153,10 @@ const P = {
|
|
|
158
153
|
</td>
|
|
159
154
|
`,
|
|
160
155
|
[u]: (t) => {
|
|
161
|
-
var d,
|
|
162
|
-
const e = p(), n = ((d = t.original_price) == null ? void 0 : d[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, l = ((
|
|
156
|
+
var d, i;
|
|
157
|
+
const e = p(), n = ((d = t.original_price) == null ? void 0 : d[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, l = ((i = t.price) == null ? void 0 : i[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, r = n > 0 ? Math.round((n - l) / n * 100) : 0, g = r > 0 ? `-${r}%` : "0%";
|
|
163
158
|
return `
|
|
164
|
-
<td class="${
|
|
159
|
+
<td class="${o}" style="padding: ${a}; height: 100%;" valign="top">
|
|
165
160
|
<table
|
|
166
161
|
class="product-card-segment"
|
|
167
162
|
width="100%"
|
|
@@ -190,7 +185,7 @@ const P = {
|
|
|
190
185
|
`;
|
|
191
186
|
},
|
|
192
187
|
[b]: () => `
|
|
193
|
-
<td class="${
|
|
188
|
+
<td class="${o}" style="padding: ${a}; height: 100%;" valign="top">
|
|
194
189
|
<table
|
|
195
190
|
class="product-card-segment"
|
|
196
191
|
width="100%"
|
|
@@ -227,7 +222,7 @@ const P = {
|
|
|
227
222
|
`
|
|
228
223
|
};
|
|
229
224
|
export {
|
|
230
|
-
|
|
231
|
-
|
|
225
|
+
o as ATTRIBUTE_CELL_CLASS,
|
|
226
|
+
a as DEFAULT_CELL_PADDING,
|
|
232
227
|
P as gridElementRenderer
|
|
233
228
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DEFAULT_PRODUCTS_PER_ROW as
|
|
2
|
-
import { DEFAULT_CARD_COMPOSITION as
|
|
3
|
-
import { gridElementRenderer as
|
|
4
|
-
const
|
|
1
|
+
import { DEFAULT_PRODUCTS_PER_ROW as m, DEFAULT_MOBILE_CARDS_IN_ROW as I } from "../../constants/layout.js";
|
|
2
|
+
import { DEFAULT_CARD_COMPOSITION as _, spacer as E, getDefaultProducts as S, createBlockTemplate as A, DEFAULTS as b, DEFAULT_CARD_VISIBILITY as D } from "../utils.js";
|
|
3
|
+
import { gridElementRenderer as w, ATTRIBUTE_CELL_CLASS as C, DEFAULT_CELL_PADDING as f } from "./elementRenderer.js";
|
|
4
|
+
const O = `
|
|
5
5
|
<tr class="recommendation-product-row">
|
|
6
6
|
<td>
|
|
7
7
|
<table
|
|
@@ -18,7 +18,7 @@ const D = `
|
|
|
18
18
|
</table>
|
|
19
19
|
</td>
|
|
20
20
|
</tr>
|
|
21
|
-
`,
|
|
21
|
+
`, U = `
|
|
22
22
|
<tr
|
|
23
23
|
class="recommendation-attribute-row"
|
|
24
24
|
data-attribute-type="{-{-ATTR_TYPE-}-}"
|
|
@@ -27,43 +27,40 @@ const D = `
|
|
|
27
27
|
{-{-CELLS-}-}
|
|
28
28
|
</tr>
|
|
29
29
|
`;
|
|
30
|
-
function g(t, e, r,
|
|
31
|
-
const
|
|
32
|
-
return
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
return
|
|
30
|
+
function g(t, e, r, n = _) {
|
|
31
|
+
const c = (100 / e).toFixed(2), s = e - t.length, o = `<td class="${C}" style="padding: ${f};" width="${c}%"></td>`, i = s > 0 ? o.repeat(s) : "";
|
|
32
|
+
return n.filter((l) => r[l]).map((l) => {
|
|
33
|
+
const p = D[l] ?? !0, T = p ? "" : 'style="display: none;"', u = t.map((R) => {
|
|
34
|
+
const L = r[l];
|
|
35
|
+
return L(R).replace("<td", `<td width="${c}%"`);
|
|
36
36
|
}).join("");
|
|
37
|
-
return
|
|
37
|
+
return U.replace("{-{-ATTR_TYPE-}-}", l).replace("{-{-VISIBILITY-}-}", p ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", T).replace("{-{-CELLS-}-}", u + i);
|
|
38
38
|
}).join("");
|
|
39
39
|
}
|
|
40
|
-
function P(t, e, r,
|
|
41
|
-
const
|
|
40
|
+
function P(t, e, r, n) {
|
|
41
|
+
const c = [];
|
|
42
42
|
for (let o = 0; o < t.length; o += e)
|
|
43
|
-
|
|
44
|
-
return
|
|
45
|
-
const
|
|
43
|
+
c.push(t.slice(o, o + e));
|
|
44
|
+
return c.map((o, i) => {
|
|
45
|
+
const a = g(
|
|
46
46
|
o,
|
|
47
47
|
e,
|
|
48
48
|
r,
|
|
49
|
-
|
|
50
|
-
), l =
|
|
51
|
-
return
|
|
49
|
+
n
|
|
50
|
+
), l = O.replace("{-{-ATTRIBUTE_ROWS-}-}", a);
|
|
51
|
+
return i > 0 ? E + l : l;
|
|
52
52
|
}).join("");
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
return P(t, e,
|
|
54
|
+
function d(t, e, r) {
|
|
55
|
+
return P(t, e, w, r);
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
const e = t ? `ins-recommendation-v3-block-${t}` : void 0, r =
|
|
59
|
-
|
|
60
|
-
L
|
|
61
|
-
);
|
|
62
|
-
return r.replace("{-{-TITLE-}-}", S.TITLE).replace("{-{-PRODUCT_ROWS-}-}", c);
|
|
57
|
+
function W(t) {
|
|
58
|
+
const e = t ? `ins-recommendation-v3-block-${t}` : void 0, r = A("grid", e), n = S(), c = d(n, m), s = d(n, I);
|
|
59
|
+
return r.replace("{-{-TITLE-}-}", b.TITLE).replace("{-{-PRODUCT_ROWS-}-}", c).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", s);
|
|
63
60
|
}
|
|
64
61
|
export {
|
|
65
|
-
|
|
62
|
+
W as getDefaultTemplate,
|
|
66
63
|
g as prepareGridAttributeRows,
|
|
67
64
|
P as prepareGridProductRows,
|
|
68
|
-
|
|
65
|
+
d as prepareProductRows
|
|
69
66
|
};
|