@useinsider/guido 2.1.0-beta.29e4650 → 2.1.0-beta.2d0ecb3
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/base/Toaster.vue.js +4 -4
- package/dist/components/organisms/base/Toaster.vue2.js +12 -9
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
- package/dist/composables/useBlocksConfig.js +26 -16
- package/dist/composables/useHtmlValidator.js +107 -119
- package/dist/composables/useRecommendation.js +9 -9
- package/dist/composables/useStripo.js +25 -23
- package/dist/composables/useVersionHistoryApi.js +1 -1
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +28 -23
- package/dist/config/i18n/en/index.js +11 -0
- package/dist/config/i18n/en/labels.json.js +7 -0
- package/dist/config/i18n/en/toasters.json.js +56 -0
- package/dist/config/i18n/en/tooltips.json.js +82 -0
- package/dist/config/i18n/index.js +7 -0
- package/dist/config/migrator/itemsBlockMigrator.js +127 -122
- package/dist/config/migrator/recommendationMigrator.js +1 -1
- package/dist/enums/defaults.js +8 -4
- package/dist/extensions/Blocks/Recommendation/block.js +24 -23
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +37 -33
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +16 -12
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -11
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +41 -29
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +16 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +30 -32
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +203 -99
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +97 -39
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +16 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +304 -209
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +10 -10
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +14 -14
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +223 -99
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +94 -55
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +25 -30
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +1 -1
- 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 +47 -31
- package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
- package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
- package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
- package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
- 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/stripoApi.js +20 -17
- package/dist/src/@types/config/schemas.d.ts +8 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/config/i18n/en/index.d.ts +1 -0
- package/dist/src/config/i18n/index.d.ts +16 -0
- package/dist/src/enums/defaults.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +12 -2
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +12 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +45 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +22 -4
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +36 -16
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +50 -17
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/migration.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +11 -2
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +14 -0
- package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -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 +19 -0
- package/dist/static/styles/components/tools.css.js +6 -2
- 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 +59 -31
- package/dist/static/styles/variables.css.js +2 -0
- package/dist/static/templates/empty/index.html.js +74 -0
- package/dist/static/templates/empty/style.css.js +779 -0
- package/dist/stores/unsubscribe.js +37 -34
- package/package.json +1 -1
|
@@ -1,14 +1,16 @@
|
|
|
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
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { RecommendationFeedSourceMaps as S, PriceAttributes as R } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as k } from "../../../../services/recommendationApi.js";
|
|
3
|
+
import { useConfigStore as y } from "../../../../stores/config.js";
|
|
4
|
+
import { defineStore as C } from "pinia";
|
|
5
|
+
import { DEFAULT_CARDS_IN_ROW as G } from "../constants/layout.js";
|
|
6
|
+
import { EXCLUDED_ALGORITHM_IDS as P } from "../constants/defaultConfig.js";
|
|
7
|
+
import { getDefaultProducts as p } from "../templates/utils.js";
|
|
8
|
+
import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
|
|
9
|
+
const h = k();
|
|
10
|
+
let a = null, l = null, u = null;
|
|
11
|
+
function I() {
|
|
10
12
|
return {
|
|
11
|
-
cardsInRow:
|
|
13
|
+
cardsInRow: G,
|
|
12
14
|
currencySettings: {
|
|
13
15
|
name: "USD",
|
|
14
16
|
value: "USD",
|
|
@@ -32,9 +34,9 @@ function h() {
|
|
|
32
34
|
size: "6"
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
|
-
function
|
|
37
|
+
function v() {
|
|
36
38
|
return {
|
|
37
|
-
recommendationConfigs:
|
|
39
|
+
recommendationConfigs: I(),
|
|
38
40
|
recommendationProducts: [],
|
|
39
41
|
filterStatus: !1,
|
|
40
42
|
filterSelectionDrawerStatus: !1,
|
|
@@ -42,7 +44,7 @@ function C() {
|
|
|
42
44
|
isInitialized: !1
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
|
-
const
|
|
47
|
+
const D = () => ({
|
|
46
48
|
recommendationCampaignUrls: {},
|
|
47
49
|
activePredictiveAlgorithms: [],
|
|
48
50
|
languages: {},
|
|
@@ -51,8 +53,8 @@ const y = () => ({
|
|
|
51
53
|
blockStates: {},
|
|
52
54
|
currentRecommendationId: null,
|
|
53
55
|
configVersion: 0
|
|
54
|
-
}),
|
|
55
|
-
state: () =>
|
|
56
|
+
}), _ = C("guidoRecommendationExtension", {
|
|
57
|
+
state: () => D(),
|
|
56
58
|
getters: {
|
|
57
59
|
// ====================================================================
|
|
58
60
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -62,7 +64,7 @@ const y = () => ({
|
|
|
62
64
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
63
65
|
*/
|
|
64
66
|
recommendationConfigs(t) {
|
|
65
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs :
|
|
67
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : I();
|
|
66
68
|
},
|
|
67
69
|
/**
|
|
68
70
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -100,8 +102,8 @@ const y = () => ({
|
|
|
100
102
|
},
|
|
101
103
|
getActivePredictiveAlgorithms: (t) => {
|
|
102
104
|
const r = [];
|
|
103
|
-
return t.activePredictiveAlgorithms.forEach((e) => {
|
|
104
|
-
r.push(...
|
|
105
|
+
return t.activePredictiveAlgorithms.filter((e) => !P.includes(e)).forEach((e) => {
|
|
106
|
+
r.push(...S.filter((n) => n.id === e));
|
|
105
107
|
}), r.map((e) => ({
|
|
106
108
|
text: e.name,
|
|
107
109
|
value: e.key
|
|
@@ -117,7 +119,7 @@ const y = () => ({
|
|
|
117
119
|
})),
|
|
118
120
|
getFilterList() {
|
|
119
121
|
return Object.values(this.filterList).map((t) => {
|
|
120
|
-
const r = t.type === "defaultAttribute", e =
|
|
122
|
+
const r = t.type === "defaultAttribute", e = R.includes(t.attributeName);
|
|
121
123
|
let n = r ? t.attributeName : `product_attributes.${t.attributeName}`;
|
|
122
124
|
return n = e ? `${n}.${this.recommendationConfigs.currencySettings.value}` : n, {
|
|
123
125
|
text: t.displayName,
|
|
@@ -141,7 +143,7 @@ const y = () => ({
|
|
|
141
143
|
setCurrentBlock(t) {
|
|
142
144
|
this.blockStates[t] || (this.blockStates = {
|
|
143
145
|
...this.blockStates,
|
|
144
|
-
[t]:
|
|
146
|
+
[t]: v()
|
|
145
147
|
}), this.currentRecommendationId = t;
|
|
146
148
|
},
|
|
147
149
|
/**
|
|
@@ -213,24 +215,46 @@ const y = () => ({
|
|
|
213
215
|
// Shared Data Fetching (fetched once, used by all blocks)
|
|
214
216
|
// ====================================================================
|
|
215
217
|
async fetchRecommendationCreateData() {
|
|
216
|
-
if (this.activePredictiveAlgorithms.length)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
218
|
+
if (!this.activePredictiveAlgorithms.length) {
|
|
219
|
+
if (a) {
|
|
220
|
+
await a;
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
a = (async () => {
|
|
224
|
+
const {
|
|
225
|
+
activePredictiveAlgorithms: t,
|
|
226
|
+
languages: r,
|
|
227
|
+
currencies: e
|
|
228
|
+
} = await h.fetchRecommendationCreateData();
|
|
229
|
+
if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
230
|
+
const n = this.blockStates[this.currentRecommendationId];
|
|
231
|
+
n.filterStatus = !!n.recommendationConfigs.filters.length;
|
|
232
|
+
}
|
|
233
|
+
this.currencyList = e;
|
|
234
|
+
})();
|
|
235
|
+
try {
|
|
236
|
+
await a;
|
|
237
|
+
} finally {
|
|
238
|
+
a = null;
|
|
239
|
+
}
|
|
228
240
|
}
|
|
229
|
-
this.currencyList = e;
|
|
230
241
|
},
|
|
231
242
|
async fetchRecommendationFilters() {
|
|
232
|
-
|
|
233
|
-
|
|
243
|
+
if (!Object.keys(this.filterList).length) {
|
|
244
|
+
if (l) {
|
|
245
|
+
await l;
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
l = (async () => {
|
|
249
|
+
const t = await h.fetchRecommendationFilters();
|
|
250
|
+
this.filterList = t;
|
|
251
|
+
})();
|
|
252
|
+
try {
|
|
253
|
+
await l;
|
|
254
|
+
} finally {
|
|
255
|
+
l = null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
234
258
|
},
|
|
235
259
|
// ====================================================================
|
|
236
260
|
// Per-Block Filter Actions
|
|
@@ -270,47 +294,62 @@ const y = () => ({
|
|
|
270
294
|
addFilter(t) {
|
|
271
295
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
272
296
|
return;
|
|
273
|
-
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters],
|
|
274
|
-
(
|
|
275
|
-
).length + 1,
|
|
276
|
-
|
|
297
|
+
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], s = e.filter(
|
|
298
|
+
(o) => o.filterGroup === t.filterGroup
|
|
299
|
+
).length + 1, m = e.findLastIndex((o) => o.filterGroup === t.filterGroup);
|
|
300
|
+
m !== -1 ? e.splice(m + 1, 0, {
|
|
277
301
|
...t,
|
|
278
|
-
filterNumber:
|
|
302
|
+
filterNumber: s
|
|
279
303
|
}) : e.push({
|
|
280
304
|
...t,
|
|
281
|
-
filterNumber:
|
|
305
|
+
filterNumber: s
|
|
282
306
|
}), r.recommendationConfigs.filters = e;
|
|
283
307
|
},
|
|
284
308
|
generateFilterQuery() {
|
|
285
|
-
return
|
|
309
|
+
return b(this.recommendationConfigs.filters);
|
|
286
310
|
},
|
|
287
311
|
// ====================================================================
|
|
288
312
|
// Per-Block Product Fetching
|
|
289
313
|
// ====================================================================
|
|
290
314
|
async fetchRecommendationProducts() {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
315
|
+
if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
|
|
316
|
+
if (u) {
|
|
317
|
+
await u;
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
u = this._doFetchProducts();
|
|
321
|
+
try {
|
|
322
|
+
await u;
|
|
323
|
+
} finally {
|
|
324
|
+
u = null;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
async _doFetchProducts() {
|
|
329
|
+
var g;
|
|
330
|
+
const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((i) => i.isValid), s = b(n), m = ((g = S.find((i) => i.key === e.strategy)) == null ? void 0 : g.path) || "", o = y(), c = {
|
|
295
331
|
locale: e.language,
|
|
296
332
|
currency: e.currencySettings.value,
|
|
297
|
-
partnerName:
|
|
333
|
+
partnerName: o.partnerName,
|
|
298
334
|
size: e.size,
|
|
299
335
|
details: !0,
|
|
300
|
-
campaignId:
|
|
336
|
+
campaignId: o.variationId
|
|
301
337
|
};
|
|
302
|
-
e.strategy === "manualMerchandising" ?
|
|
303
|
-
const
|
|
304
|
-
let
|
|
338
|
+
e.strategy === "manualMerchandising" ? c.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (c.productId = "{itemId}"), e.strategy === "userBased" && (c.userId = "{user_id}"), s && (c.filter = s), e.shuffleProducts && (c.shuffle = !0);
|
|
339
|
+
const f = parseInt(e.size) || 6;
|
|
340
|
+
let d;
|
|
305
341
|
try {
|
|
306
|
-
|
|
342
|
+
d = await h.fetchRecommendationProducts(m, c);
|
|
307
343
|
} catch {
|
|
308
|
-
|
|
344
|
+
d = [];
|
|
345
|
+
}
|
|
346
|
+
if (this.blockStates[t]) {
|
|
347
|
+
const i = d.length > 0 ? d : p(f);
|
|
348
|
+
this.blockStates[t].recommendationProducts = i.length < f ? [...i, ...p(f - i.length)] : i;
|
|
309
349
|
}
|
|
310
|
-
this.blockStates[t] && (this.blockStates[t].recommendationProducts = a.length > 0 ? a : k(g));
|
|
311
350
|
}
|
|
312
351
|
}
|
|
313
352
|
});
|
|
314
353
|
export {
|
|
315
|
-
|
|
354
|
+
_ as useRecommendationExtensionStore
|
|
316
355
|
};
|
|
@@ -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
|
};
|
|
@@ -5,7 +5,7 @@ const u = `
|
|
|
5
5
|
align="left"
|
|
6
6
|
esd-extension-block-id="recommendation-block"
|
|
7
7
|
esd-handler-name="esd-extension-RecommendationBlock"
|
|
8
|
-
class="
|
|
8
|
+
class="recommendation-block-v2 esd-block-recommendation-v3-block esd-extension-block es-p20"
|
|
9
9
|
>
|
|
10
10
|
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
|
11
11
|
<tr>
|
|
@@ -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-}-}", _.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
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RecommendationBlockId as o } from "../../constants/blockIds.js";
|
|
2
|
-
import { ATTR_PRODUCT_BUTTON as l, ATTR_PRODUCT_IMAGE as d, ATTR_PRODUCT_OMNIBUS_DISCOUNT as
|
|
2
|
+
import { ATTR_PRODUCT_BUTTON as l, ATTR_PRODUCT_IMAGE as d, ATTR_PRODUCT_OMNIBUS_DISCOUNT as u, ATTR_PRODUCT_OMNIBUS_PRICE as m, ATTR_PRODUCT_OLD_PRICE as g, ATTR_PRODUCT_PRICE as f, ATTR_PRODUCT_NAME as x } from "../../constants/selectors.js";
|
|
3
3
|
import { useRecommendationExtensionStore as T } from "../../store/recommendation.js";
|
|
4
4
|
import { formatPrice as _ } from "../../utils/priceFormatter.js";
|
|
5
5
|
import { sanitizeImageUrl as y } from "../utils.js";
|
|
@@ -14,14 +14,14 @@ function p() {
|
|
|
14
14
|
thousandSeparator: e.thousandSeparator
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
const n = p(), r = t[e],
|
|
17
|
+
function s(t, e = "price") {
|
|
18
|
+
const n = p(), r = t[e], a = (r == null ? void 0 : r[n.code]) ?? Object.values(r ?? {})[0] ?? 0;
|
|
19
19
|
return _({
|
|
20
|
-
price:
|
|
20
|
+
price: a,
|
|
21
21
|
currency: n
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const $ = {
|
|
25
25
|
/**
|
|
26
26
|
* Image cell - left column (120px fixed width)
|
|
27
27
|
* Has recommendation-attribute-row class and data attributes for Card Composition control
|
|
@@ -35,18 +35,13 @@ const P = {
|
|
|
35
35
|
data-visibility="1"
|
|
36
36
|
align="center"
|
|
37
37
|
valign="middle">
|
|
38
|
-
<
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
style="
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
alt="${t.name}"
|
|
46
|
-
style="max-width: 100%; max-height: 100%; object-fit: contain; display: block;"
|
|
47
|
-
class="adapt-img product-image">
|
|
48
|
-
</a>
|
|
49
|
-
</div>
|
|
38
|
+
<a target="_blank" href="${t.url}">
|
|
39
|
+
<img
|
|
40
|
+
src="${y(t.image_url)}"
|
|
41
|
+
alt="${t.name}"
|
|
42
|
+
style="display: block; max-width: 100%; height: auto;"
|
|
43
|
+
class="adapt-img product-image">
|
|
44
|
+
</a>
|
|
50
45
|
</td>
|
|
51
46
|
`,
|
|
52
47
|
/**
|
|
@@ -74,7 +69,7 @@ const P = {
|
|
|
74
69
|
esd-extension-block-id="${o.PRICE}"
|
|
75
70
|
align="left">
|
|
76
71
|
<p contenteditable="false" style="font-size: 16px; color: #333333; font-weight: bold; margin: 0;">
|
|
77
|
-
<strong>${
|
|
72
|
+
<strong>${s(t, "price")}</strong>
|
|
78
73
|
</p>
|
|
79
74
|
</td>
|
|
80
75
|
</tr>
|
|
@@ -91,7 +86,7 @@ const P = {
|
|
|
91
86
|
<p
|
|
92
87
|
contenteditable="false"
|
|
93
88
|
style="font-size: 14px; color: #999999; text-decoration: line-through; margin: 0;">
|
|
94
|
-
<strong>${
|
|
89
|
+
<strong>${s(t, "original_price")}</strong>
|
|
95
90
|
</p>
|
|
96
91
|
</td>
|
|
97
92
|
</tr>
|
|
@@ -99,7 +94,7 @@ const P = {
|
|
|
99
94
|
/**
|
|
100
95
|
* Omnibus price element - row for info cell table
|
|
101
96
|
*/
|
|
102
|
-
[
|
|
97
|
+
[m]: (t) => `
|
|
103
98
|
<tr>
|
|
104
99
|
<td
|
|
105
100
|
class="esd-block-text product-omnibus-price"
|
|
@@ -109,7 +104,7 @@ const P = {
|
|
|
109
104
|
align="left">
|
|
110
105
|
<p style="font-size: 12px; color: #666666; margin: 0;">
|
|
111
106
|
<span class="omnibus-text-before">Lowest 30-day price: </span>
|
|
112
|
-
<span class="omnibus-price-value">${
|
|
107
|
+
<span class="omnibus-price-value">${s(t, "original_price")}</span>
|
|
113
108
|
<span class="omnibus-text-after"></span>
|
|
114
109
|
</p>
|
|
115
110
|
</td>
|
|
@@ -118,9 +113,9 @@ const P = {
|
|
|
118
113
|
/**
|
|
119
114
|
* Omnibus discount element - row for info cell table
|
|
120
115
|
*/
|
|
121
|
-
[
|
|
122
|
-
var
|
|
123
|
-
const e = p(), n = ((
|
|
116
|
+
[u]: (t) => {
|
|
117
|
+
var i, c;
|
|
118
|
+
const e = p(), n = ((i = t.original_price) == null ? void 0 : i[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, r = ((c = t.price) == null ? void 0 : c[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, a = n > 0 ? Math.round((n - r) / n * 100) : 0, b = a > 0 ? `-${a}%` : "0%";
|
|
124
119
|
return `
|
|
125
120
|
<tr>
|
|
126
121
|
<td
|
|
@@ -170,5 +165,5 @@ const P = {
|
|
|
170
165
|
`
|
|
171
166
|
};
|
|
172
167
|
export {
|
|
173
|
-
|
|
168
|
+
$ as listElementRenderer
|
|
174
169
|
};
|