@useinsider/guido 3.6.0-beta.dc3a2aa → 3.6.0-beta.ee02cfc
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/useRecommendation.js +34 -33
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +35 -30
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +11 -12
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +62 -50
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +204 -189
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +23 -18
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +4 -6
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +21 -0
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +19 -19
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerCustomizations.d.ts +7 -0
- package/package.json +1 -1
- /package/dist/src/extensions/Blocks/Recommendation/{utils/priceFormatter.test.d.ts → controls/main/index.test.d.ts} +0 -0
|
@@ -2,15 +2,16 @@ import { getRecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAtt
|
|
|
2
2
|
import { useRecommendationApi as y } from "../../../../services/recommendationApi.js";
|
|
3
3
|
import { useConfigStore as G } from "../../../../stores/config.js";
|
|
4
4
|
import { defineStore as P } from "pinia";
|
|
5
|
-
import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
|
|
6
|
-
import { EXCLUDED_ALGORITHM_IDS as
|
|
5
|
+
import { DEFAULT_MOBILE_CARDS_IN_ROW as D, DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
|
|
6
|
+
import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
|
|
7
7
|
import { getDefaultProducts as S } from "../templates/utils.js";
|
|
8
8
|
import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { getPartnerRecommendationParams as v } from "../utils/partnerCustomizations.js";
|
|
10
|
+
import { isFilterValid as N } from "../validation/filterSchema.js";
|
|
11
|
+
import { isConfigValid as x } from "../validation/requiredFields.js";
|
|
11
12
|
const h = y();
|
|
12
13
|
let m = null, u = null, d = null;
|
|
13
|
-
function
|
|
14
|
+
function k() {
|
|
14
15
|
return {
|
|
15
16
|
cardsInRow: F,
|
|
16
17
|
currencySettings: {
|
|
@@ -26,6 +27,7 @@ function I() {
|
|
|
26
27
|
productIds: [],
|
|
27
28
|
id: 1,
|
|
28
29
|
language: "en_US",
|
|
30
|
+
mobileCardsInRow: D,
|
|
29
31
|
mobileLayoutEnabled: !1,
|
|
30
32
|
orientation: "grid",
|
|
31
33
|
recommendedProducts: [],
|
|
@@ -38,9 +40,9 @@ function I() {
|
|
|
38
40
|
customAttributes: []
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
|
-
function
|
|
43
|
+
function I() {
|
|
42
44
|
return {
|
|
43
|
-
recommendationConfigs:
|
|
45
|
+
recommendationConfigs: k(),
|
|
44
46
|
recommendationProducts: [],
|
|
45
47
|
filterStatus: !1,
|
|
46
48
|
filterSelectionDrawerStatus: !1,
|
|
@@ -49,7 +51,7 @@ function k() {
|
|
|
49
51
|
filterSnapshot: null
|
|
50
52
|
};
|
|
51
53
|
}
|
|
52
|
-
const
|
|
54
|
+
const L = () => ({
|
|
53
55
|
recommendationCampaignUrls: {},
|
|
54
56
|
activePredictiveAlgorithms: [],
|
|
55
57
|
languages: {},
|
|
@@ -58,8 +60,8 @@ const N = () => ({
|
|
|
58
60
|
blockStates: {},
|
|
59
61
|
currentRecommendationId: null,
|
|
60
62
|
configVersion: 0
|
|
61
|
-
}),
|
|
62
|
-
state: () =>
|
|
63
|
+
}), K = P("guidoRecommendationExtension", {
|
|
64
|
+
state: () => L(),
|
|
63
65
|
getters: {
|
|
64
66
|
// ====================================================================
|
|
65
67
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -69,7 +71,7 @@ const N = () => ({
|
|
|
69
71
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
70
72
|
*/
|
|
71
73
|
recommendationConfigs(t) {
|
|
72
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs :
|
|
74
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : k();
|
|
73
75
|
},
|
|
74
76
|
/**
|
|
75
77
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -115,7 +117,7 @@ const N = () => ({
|
|
|
115
117
|
},
|
|
116
118
|
getActivePredictiveAlgorithms: (t) => {
|
|
117
119
|
const e = g(), r = [];
|
|
118
|
-
return t.activePredictiveAlgorithms.filter((n) => !
|
|
120
|
+
return t.activePredictiveAlgorithms.filter((n) => !w.includes(n)).forEach((n) => {
|
|
119
121
|
r.push(...e.filter((c) => c.id === n));
|
|
120
122
|
}), r.map((n) => ({
|
|
121
123
|
text: n.name,
|
|
@@ -155,7 +157,7 @@ const N = () => ({
|
|
|
155
157
|
setCurrentBlock(t) {
|
|
156
158
|
this.blockStates[t] || (this.blockStates = {
|
|
157
159
|
...this.blockStates,
|
|
158
|
-
[t]:
|
|
160
|
+
[t]: I()
|
|
159
161
|
}), this.currentRecommendationId = t;
|
|
160
162
|
},
|
|
161
163
|
/**
|
|
@@ -223,7 +225,7 @@ const N = () => ({
|
|
|
223
225
|
decimalCount: String(e.currencyDecimalCount),
|
|
224
226
|
decimalSeparator: r(e.currencyDecimalSeparator, ","),
|
|
225
227
|
thousandSeparator: r(e.currencyThousandSeparator, ".")
|
|
226
|
-
}, c = !this.blockStates[t], i = c ?
|
|
228
|
+
}, c = !this.blockStates[t], i = c ? I() : this.blockStates[t];
|
|
227
229
|
i.recommendationConfigs = {
|
|
228
230
|
...i.recommendationConfigs,
|
|
229
231
|
strategy: e.strategy,
|
|
@@ -378,7 +380,7 @@ const N = () => ({
|
|
|
378
380
|
const n = [...e.recommendationConfigs.filters];
|
|
379
381
|
n[r] = {
|
|
380
382
|
...t,
|
|
381
|
-
isValid:
|
|
383
|
+
isValid: N(t)
|
|
382
384
|
}, e.recommendationConfigs.filters = n;
|
|
383
385
|
}
|
|
384
386
|
},
|
|
@@ -424,7 +426,7 @@ const N = () => ({
|
|
|
424
426
|
* every block's recommendationConfigs across user edits.
|
|
425
427
|
*/
|
|
426
428
|
hasInvalidBlock() {
|
|
427
|
-
return Object.values(this.blockStates).some((t) => !
|
|
429
|
+
return Object.values(this.blockStates).some((t) => !x(t.recommendationConfigs, this));
|
|
428
430
|
},
|
|
429
431
|
// ====================================================================
|
|
430
432
|
// Per-Block Product Fetching
|
|
@@ -453,7 +455,10 @@ const N = () => ({
|
|
|
453
455
|
details: !0,
|
|
454
456
|
campaignId: o.variationId
|
|
455
457
|
};
|
|
456
|
-
r.strategy === "manualMerchandising" ? a.productId = r.productIds.join(",") : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0)
|
|
458
|
+
r.strategy === "manualMerchandising" ? a.productId = r.productIds.join(",") : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0), Object.assign(
|
|
459
|
+
a,
|
|
460
|
+
v(o.partnerName, r.strategy)
|
|
461
|
+
);
|
|
457
462
|
let f;
|
|
458
463
|
try {
|
|
459
464
|
f = await h.fetchRecommendationProducts(i, a);
|
|
@@ -471,5 +476,5 @@ const N = () => ({
|
|
|
471
476
|
}
|
|
472
477
|
});
|
|
473
478
|
export {
|
|
474
|
-
|
|
479
|
+
K as useRecommendationExtensionStore
|
|
475
480
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RecommendationBlockId as s } from "../../constants/blockIds.js";
|
|
2
|
-
import { ATTR_PRODUCT_ATTR as u, CSS_CLASS_RECO_BUTTON as p, ATTR_PRODUCT_BUTTON as m, ATTR_PRODUCT_OMNIBUS_DISCOUNT as h, ATTR_PRODUCT_OMNIBUS_PRICE as y, ATTR_PRODUCT_OLD_PRICE as T, ATTR_PRODUCT_PRICE as f, ATTR_PRODUCT_NAME as
|
|
2
|
+
import { ATTR_PRODUCT_ATTR as u, CSS_CLASS_RECO_BUTTON as p, ATTR_PRODUCT_BUTTON as m, ATTR_PRODUCT_OMNIBUS_DISCOUNT as h, ATTR_PRODUCT_OMNIBUS_PRICE as y, ATTR_PRODUCT_OLD_PRICE as T, ATTR_PRODUCT_PRICE as f, ATTR_PRODUCT_NAME as _, ATTR_PRODUCT_IMAGE as x } from "../../constants/selectors.js";
|
|
3
3
|
import { useRecommendationExtensionStore as $ } from "../../store/recommendation.js";
|
|
4
4
|
import { formatPrice as C } from "../../utils/priceFormatter.js";
|
|
5
5
|
import { CUSTOM_CELL_HTML as R, sanitizeImageUrl as O } from "../utils.js";
|
|
@@ -23,7 +23,7 @@ function i(t, e = "price") {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
const S = {
|
|
26
|
-
[
|
|
26
|
+
[x]: (t) => `
|
|
27
27
|
<td class="${l}" style="padding: ${a}; height: 100%;" valign="top">
|
|
28
28
|
<table
|
|
29
29
|
class="product-card-segment"
|
|
@@ -51,7 +51,7 @@ const S = {
|
|
|
51
51
|
</table>
|
|
52
52
|
</td>
|
|
53
53
|
`,
|
|
54
|
-
[
|
|
54
|
+
[_]: (t) => `
|
|
55
55
|
<td class="${l}" style="padding: ${a}; height: 100%;" valign="middle">
|
|
56
56
|
<table
|
|
57
57
|
class="product-card-segment"
|
|
@@ -115,9 +115,7 @@ const S = {
|
|
|
115
115
|
class="esd-block-text product-old-price es-p15l es-p15r"
|
|
116
116
|
align="center"
|
|
117
117
|
esd-extension-block-id="${s.OLD_PRICE}">
|
|
118
|
-
<p
|
|
119
|
-
contenteditable="false"
|
|
120
|
-
style="font-size: 14px; color: #999999; text-decoration: line-through;">
|
|
118
|
+
<p contenteditable="false" style="font-size: 14px; color: #999999;">
|
|
121
119
|
<strong>${i(t, "original_price")}</strong>
|
|
122
120
|
</p>
|
|
123
121
|
</td>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const i = [
|
|
2
|
+
"ozonebg",
|
|
3
|
+
"ozonehr",
|
|
4
|
+
"ozonero",
|
|
5
|
+
"ozoneinfo",
|
|
6
|
+
"babybg",
|
|
7
|
+
"ozongr",
|
|
8
|
+
"iboodat",
|
|
9
|
+
"iboodbe",
|
|
10
|
+
"iboodde",
|
|
11
|
+
"iboodfr",
|
|
12
|
+
"iboodnl",
|
|
13
|
+
"iboodpl"
|
|
14
|
+
], r = ["interencheres", "interencherespreprod"], d = ["lodenfrey", "lodenfreyuat"], c = "manualMerchandising";
|
|
15
|
+
function s(e, n) {
|
|
16
|
+
const o = {};
|
|
17
|
+
return i.includes(e) && (o.excludePurchaseDay = "30", o.userId = "{user_id}"), r.includes(e) && (o.hp = "1"), d.includes(e) && n === c && (o.includeOutOfStockItems = "true"), o;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
s as getPartnerRecommendationParams
|
|
21
|
+
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
function
|
|
2
|
-
const { thousandSeparator:
|
|
1
|
+
function d(a, t) {
|
|
2
|
+
const { thousandSeparator: s, decimalSeparator: e, decimalCount: r } = t, u = Math.abs(a).toFixed(r), [c, o] = u.split("."), n = c.replace(
|
|
3
3
|
/\B(?=(\d{3})+(?!\d))/g,
|
|
4
|
-
|
|
5
|
-
),
|
|
6
|
-
return r > 0 &&
|
|
4
|
+
s
|
|
5
|
+
), i = a < 0 ? "-" : "";
|
|
6
|
+
return r > 0 && o ? `${i}${n}${e}${o}` : `${i}${n}`;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
const { price:
|
|
10
|
-
symbol:
|
|
8
|
+
function m(a) {
|
|
9
|
+
const { price: t, currency: s } = a, {
|
|
10
|
+
symbol: e,
|
|
11
11
|
alignment: r,
|
|
12
|
-
thousandSeparator:
|
|
12
|
+
thousandSeparator: u,
|
|
13
13
|
decimalSeparator: c,
|
|
14
|
-
decimalCount:
|
|
15
|
-
} =
|
|
16
|
-
if (typeof
|
|
17
|
-
const
|
|
18
|
-
return r === "before" ? `${
|
|
14
|
+
decimalCount: o
|
|
15
|
+
} = s;
|
|
16
|
+
if (typeof t != "number" || Number.isNaN(t)) {
|
|
17
|
+
const i = "0".repeat(o), $ = `0${c}${i}`;
|
|
18
|
+
return r === "before" ? `${e} ${$}` : `${$} ${e}`;
|
|
19
19
|
}
|
|
20
|
-
const n =
|
|
21
|
-
thousandSeparator:
|
|
20
|
+
const n = d(t, {
|
|
21
|
+
thousandSeparator: u,
|
|
22
22
|
decimalSeparator: c,
|
|
23
|
-
decimalCount:
|
|
23
|
+
decimalCount: o
|
|
24
24
|
});
|
|
25
|
-
return r === "before" ? `${
|
|
25
|
+
return r === "before" ? `${e} ${n}` : `${n} ${e}`;
|
|
26
26
|
}
|
|
27
27
|
export {
|
|
28
|
-
|
|
28
|
+
m as formatPrice
|
|
29
29
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the extra recommendation feed query params for an account, if any.
|
|
3
|
+
* Accounts without customizations get an empty object.
|
|
4
|
+
* @param partnerName Account subdomain (`config.partner.name`)
|
|
5
|
+
* @param strategy Recommendation strategy key of the block
|
|
6
|
+
*/
|
|
7
|
+
export declare function getPartnerRecommendationParams(partnerName: string, strategy: string): Record<string, string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.6.0-beta.
|
|
3
|
+
"version": "3.6.0-beta.ee02cfc",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|
|
File without changes
|