@useinsider/guido 3.6.1-beta.03230b7 → 3.7.0-beta.2037cb1
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 +14 -0
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +75 -72
- package/dist/components/organisms/header/EditorActions.vue.js +1 -1
- package/dist/components/organisms/header/EditorActions.vue2.js +6 -6
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +9 -9
- package/dist/composables/useActionsApi.js +16 -15
- package/dist/composables/useHtmlCompiler.js +40 -22
- package/dist/composables/useRecommendation.js +34 -33
- package/dist/composables/useStripo.js +44 -39
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +127 -123
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +12 -11
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +46 -46
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +13 -9
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +35 -29
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +28 -28
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +56 -49
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +21 -0
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +17 -17
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +9 -9
- package/dist/guido.css +1 -1
- package/dist/src/components/Guido.vue.d.ts +1 -0
- package/dist/src/composables/useHtmlCompiler.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerCustomizations.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +2 -3
- package/dist/src/utils/ampErrorFilter.d.ts +2 -0
- package/dist/src/utils/templatePreparation.d.ts +16 -0
- package/dist/stores/dynamic-content.js +1 -1
- package/dist/utils/ampErrorFilter.js +8 -0
- package/dist/utils/templatePreparation.js +59 -58
- package/package.json +1 -1
- package/dist/src/composables/useApiExample.d.ts +0 -63
- package/dist/src/composables/useRecommendation.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/extractors.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendationMigrator.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/filterUtil.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +0 -1
- package/dist/src/stores/config.test.d.ts +0 -1
- package/dist/src/utils/htmlEscape.test.d.ts +0 -1
- package/dist/src/vitest.setup.d.ts +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ModificationDescription as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { RecommendationBlockId as m } from "../../constants/blockIds.js";
|
|
3
|
-
import { CURRENCY_ATTR as y, MOBILE_CONTAINER_SELECTOR as q, MOBILE_ROW_SELECTOR as k, DESKTOP_CONTAINER_SELECTOR as P, CONTAINER_SELECTOR as v, ATTR_PRODUCT_ATTR as
|
|
3
|
+
import { CURRENCY_ATTR as y, MOBILE_CONTAINER_SELECTOR as q, MOBILE_ROW_SELECTOR as k, DESKTOP_CONTAINER_SELECTOR as P, CONTAINER_SELECTOR as v, ATTR_PRODUCT_ATTR as V } from "../../constants/selectors.js";
|
|
4
4
|
import { RecommendationConfigService as E } from "../../services/configService.js";
|
|
5
5
|
import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
|
|
6
6
|
import { prepareProductRows as _ } from "../../templates/index.js";
|
|
7
|
-
import { formatPrice as
|
|
8
|
-
import { isTdNode as
|
|
9
|
-
import { getDefaultProducts as L, DEFAULT_CARD_COMPOSITION as
|
|
7
|
+
import { formatPrice as W } from "../../utils/priceFormatter.js";
|
|
8
|
+
import { isTdNode as j } from "../../utils/tagName.js";
|
|
9
|
+
import { getDefaultProducts as L, DEFAULT_CARD_COMPOSITION as h, sanitizeImageUrl as F, toDisplayableAttributeValue as G } from "../../templates/utils.js";
|
|
10
10
|
const M = "recommendation-block-v2";
|
|
11
|
-
function
|
|
11
|
+
function R(t) {
|
|
12
12
|
if (!t)
|
|
13
13
|
return null;
|
|
14
14
|
if ("getAttribute" in t) {
|
|
@@ -19,18 +19,18 @@ function h(t) {
|
|
|
19
19
|
return "querySelector" in t ? t.querySelector(`.${M}`) ?? null : null;
|
|
20
20
|
}
|
|
21
21
|
function b(t) {
|
|
22
|
-
const e =
|
|
22
|
+
const e = R(t);
|
|
23
23
|
if (!e || !("getAttribute" in e))
|
|
24
24
|
return "grid";
|
|
25
25
|
const o = e.getAttribute("data-layout");
|
|
26
26
|
return o === "list" || o === "horizontal" ? "list" : "grid";
|
|
27
27
|
}
|
|
28
28
|
function x(t) {
|
|
29
|
-
const e =
|
|
29
|
+
const e = R(t);
|
|
30
30
|
if (!e || !("getAttribute" in e))
|
|
31
|
-
return
|
|
31
|
+
return h;
|
|
32
32
|
const o = e.getAttribute("data-card-composition");
|
|
33
|
-
return o ? o.split(",").filter(Boolean) :
|
|
33
|
+
return o ? o.split(",").filter(Boolean) : h;
|
|
34
34
|
}
|
|
35
35
|
function D(t) {
|
|
36
36
|
if (!t || !("childNodes" in t))
|
|
@@ -47,14 +47,14 @@ function S(t, e, o) {
|
|
|
47
47
|
function U(t, e) {
|
|
48
48
|
return t && t.length > 0 ? t : e.length > 0 ? e : L();
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Y(t) {
|
|
51
51
|
const { currentNode: e, documentModifier: o } = t;
|
|
52
52
|
if (!e || !("querySelector" in e))
|
|
53
53
|
return;
|
|
54
54
|
const n = e.querySelector(k);
|
|
55
55
|
n && (o.modifyHtml(n).setInnerHtml(""), o.apply(new p("Cleared mobile row content")));
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function K(t) {
|
|
58
58
|
const {
|
|
59
59
|
currentNode: e,
|
|
60
60
|
documentModifier: o,
|
|
@@ -66,7 +66,7 @@ function Y(t) {
|
|
|
66
66
|
return;
|
|
67
67
|
const r = i ?? b(e), s = E.getConfig(e);
|
|
68
68
|
if (r === "list" || !s.mobileLayoutEnabled) {
|
|
69
|
-
|
|
69
|
+
Y({ currentNode: e, documentModifier: o });
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
const u = e.querySelector(k);
|
|
@@ -79,7 +79,7 @@ function Y(t) {
|
|
|
79
79
|
})}</table></td>`;
|
|
80
80
|
o.modifyHtml(u).setInnerHtml(g), o.apply(new p("Updated mobile product rows"));
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function X(t) {
|
|
83
83
|
const {
|
|
84
84
|
currentNode: e,
|
|
85
85
|
documentModifier: o,
|
|
@@ -98,7 +98,7 @@ function K(t) {
|
|
|
98
98
|
composition: a,
|
|
99
99
|
filterList: u.filterList
|
|
100
100
|
});
|
|
101
|
-
o.modifyHtml(s).setInnerHtml(g).apply(new p("Updated product")),
|
|
101
|
+
o.modifyHtml(s).setInnerHtml(g).apply(new p("Updated product")), K(t), n == null || n();
|
|
102
102
|
}
|
|
103
103
|
function T(t, e, o, n) {
|
|
104
104
|
const c = `0 ${Math.floor(o / 2)}px`;
|
|
@@ -111,7 +111,7 @@ function T(t, e, o, n) {
|
|
|
111
111
|
t.querySelectorAll(".product-card-wrapper")
|
|
112
112
|
).forEach((u) => {
|
|
113
113
|
const l = "parentNode" in u ? u.parentNode : null;
|
|
114
|
-
l &&
|
|
114
|
+
l && j(l) && (e.modifyHtml(l).setStyle("padding", c), r = !0);
|
|
115
115
|
}), r;
|
|
116
116
|
}
|
|
117
117
|
function I(t, e, o) {
|
|
@@ -121,7 +121,7 @@ function I(t, e, o) {
|
|
|
121
121
|
e.modifyHtml(r).setStyle("height", n), c = !0;
|
|
122
122
|
}), c;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function z(t) {
|
|
125
125
|
const { currentNode: e, documentModifier: o } = t;
|
|
126
126
|
if (!e)
|
|
127
127
|
return;
|
|
@@ -160,9 +160,9 @@ function X(t) {
|
|
|
160
160
|
}
|
|
161
161
|
c && o.apply(new p("Reapply spacing after regeneration"));
|
|
162
162
|
}
|
|
163
|
-
function
|
|
163
|
+
function ae(t) {
|
|
164
164
|
const { currentNode: e, documentModifier: o, afterRegenerate: n, products: i, layout: c, composition: r } = t;
|
|
165
|
-
e &&
|
|
165
|
+
e && X({
|
|
166
166
|
currentNode: e,
|
|
167
167
|
documentModifier: o,
|
|
168
168
|
products: i,
|
|
@@ -170,12 +170,12 @@ function se(t) {
|
|
|
170
170
|
composition: r,
|
|
171
171
|
afterRegenerate: () => {
|
|
172
172
|
setTimeout(() => {
|
|
173
|
-
|
|
173
|
+
z({ currentNode: e, documentModifier: o });
|
|
174
174
|
}, 0), n == null || n();
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function de(t, e) {
|
|
179
179
|
return t.length === e ? t : t.length > e ? t.slice(0, e) : [...t, ...L(e - t.length)];
|
|
180
180
|
}
|
|
181
181
|
function H() {
|
|
@@ -191,12 +191,12 @@ function H() {
|
|
|
191
191
|
}
|
|
192
192
|
function A(t, e = "price") {
|
|
193
193
|
const o = H(), n = t[e], i = (n == null ? void 0 : n[o.code]) ?? Object.values(n ?? {})[0] ?? 0;
|
|
194
|
-
return
|
|
194
|
+
return W({
|
|
195
195
|
price: i,
|
|
196
196
|
currency: o
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function J(t) {
|
|
200
200
|
var c, r;
|
|
201
201
|
const e = H(), o = ((c = t.original_price) == null ? void 0 : c[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, n = ((r = t.price) == null ? void 0 : r[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, i = o > 0 ? Math.round((o - n) / o * 100) : 0;
|
|
202
202
|
return i > 0 ? `-${i}%` : "0%";
|
|
@@ -217,12 +217,12 @@ function $(t) {
|
|
|
217
217
|
S(e, u, l) && (s = !0);
|
|
218
218
|
}
|
|
219
219
|
if (r && "querySelector" in r) {
|
|
220
|
-
const u = r.querySelector(".omnibus-discount-value") ?? null, l =
|
|
220
|
+
const u = r.querySelector(".omnibus-discount-value") ?? null, l = J(o);
|
|
221
221
|
S(e, u, l) && (s = !0);
|
|
222
222
|
}
|
|
223
223
|
return s;
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function Q(t) {
|
|
226
226
|
const {
|
|
227
227
|
documentModifier: e,
|
|
228
228
|
product: o,
|
|
@@ -237,7 +237,7 @@ function J(t) {
|
|
|
237
237
|
let d = !1;
|
|
238
238
|
if (n && "querySelector" in n) {
|
|
239
239
|
const a = n.querySelector("img");
|
|
240
|
-
a && (e.modifyHtml(a).setAttribute("src",
|
|
240
|
+
a && (e.modifyHtml(a).setAttribute("src", F(o.image_url)).setAttribute("alt", o.name), d = !0);
|
|
241
241
|
const f = n.querySelector("a");
|
|
242
242
|
f && (e.modifyHtml(f).setAttribute("href", o.url), d = !0);
|
|
243
243
|
}
|
|
@@ -262,7 +262,7 @@ function B(t) {
|
|
|
262
262
|
return "querySelector" in t ? t.querySelector(P) ?? t : t;
|
|
263
263
|
}
|
|
264
264
|
const O = "product_attribute.";
|
|
265
|
-
function
|
|
265
|
+
function Z(t, e) {
|
|
266
266
|
var n;
|
|
267
267
|
let o;
|
|
268
268
|
if (t.startsWith(O)) {
|
|
@@ -270,9 +270,9 @@ function Q(t, e) {
|
|
|
270
270
|
o = (n = e.product_attributes) == null ? void 0 : n[i];
|
|
271
271
|
} else
|
|
272
272
|
o = e[t];
|
|
273
|
-
return
|
|
273
|
+
return G(o) || null;
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function ee(t, e, o) {
|
|
276
276
|
if (!("querySelectorAll" in t))
|
|
277
277
|
return !1;
|
|
278
278
|
const n = t.querySelectorAll(
|
|
@@ -284,7 +284,7 @@ function Z(t, e, o) {
|
|
|
284
284
|
n.forEach((r) => {
|
|
285
285
|
if (!("getAttribute" in r))
|
|
286
286
|
return;
|
|
287
|
-
const s = r.getAttribute(
|
|
287
|
+
const s = r.getAttribute(V);
|
|
288
288
|
if (!s)
|
|
289
289
|
return;
|
|
290
290
|
const u = i.get(s) ?? [];
|
|
@@ -296,7 +296,7 @@ function Z(t, e, o) {
|
|
|
296
296
|
r.slice(0, u).forEach((l, d) => {
|
|
297
297
|
if (!("querySelector" in l))
|
|
298
298
|
return;
|
|
299
|
-
const a =
|
|
299
|
+
const a = Z(s, o[d]);
|
|
300
300
|
if (a === null)
|
|
301
301
|
return;
|
|
302
302
|
const f = l.querySelector("p") ?? null;
|
|
@@ -324,7 +324,7 @@ function w(t, e, o) {
|
|
|
324
324
|
), d = Math.min(n.length, o.length);
|
|
325
325
|
let a = !1;
|
|
326
326
|
for (let f = 0; f < d; f++) {
|
|
327
|
-
const g =
|
|
327
|
+
const g = Q({
|
|
328
328
|
documentModifier: e,
|
|
329
329
|
product: o[f],
|
|
330
330
|
imageEl: n[f] ?? null,
|
|
@@ -337,9 +337,9 @@ function w(t, e, o) {
|
|
|
337
337
|
});
|
|
338
338
|
a = a || g;
|
|
339
339
|
}
|
|
340
|
-
return
|
|
340
|
+
return ee(t, e, o) && (a = !0), a;
|
|
341
341
|
}
|
|
342
|
-
function
|
|
342
|
+
function fe(t) {
|
|
343
343
|
const { currentNode: e, documentModifier: o, products: n } = t;
|
|
344
344
|
if (!e || !("querySelectorAll" in e))
|
|
345
345
|
return !1;
|
|
@@ -387,7 +387,7 @@ function N(t, e, o) {
|
|
|
387
387
|
}) && (u = !0);
|
|
388
388
|
return u;
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function me(t) {
|
|
391
391
|
const { currentNode: e, documentModifier: o } = t;
|
|
392
392
|
if (!e || !("querySelectorAll" in e))
|
|
393
393
|
return !1;
|
|
@@ -406,8 +406,8 @@ function fe(t) {
|
|
|
406
406
|
}
|
|
407
407
|
return r && o.apply(new p("Updated price formatting in-place")), r;
|
|
408
408
|
}
|
|
409
|
-
function
|
|
410
|
-
const { currentNode: e, documentModifier: o, currency: n } = t, i =
|
|
409
|
+
function pe(t) {
|
|
410
|
+
const { currentNode: e, documentModifier: o, currency: n } = t, i = R(e);
|
|
411
411
|
if (!i)
|
|
412
412
|
return;
|
|
413
413
|
const c = n.alignment === "before" ? "0" : "1", r = (s, u) => {
|
|
@@ -416,17 +416,17 @@ function me(t) {
|
|
|
416
416
|
r(y.CURRENCY, n.code), r(y.SYMBOL, n.symbol), r(y.ALIGNMENT, c), r(y.THOUSAND_SEPARATOR, n.thousandSeparator), r(y.DECIMAL_SEPARATOR, n.decimalSeparator), r(y.DECIMAL_COUNT, n.decimalCount.toString()), o.apply(new p("Update currency attributes"));
|
|
417
417
|
}
|
|
418
418
|
export {
|
|
419
|
-
|
|
419
|
+
de as adjustProductsToSize,
|
|
420
420
|
A as formatProductPrice,
|
|
421
|
-
|
|
421
|
+
R as getBlockElement,
|
|
422
422
|
x as getCardComposition,
|
|
423
423
|
b as getCurrentLayout,
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
424
|
+
z as reapplySpacing,
|
|
425
|
+
K as regenerateMobileProductRows,
|
|
426
|
+
X as regenerateProductRows,
|
|
427
|
+
ae as regenerateProductRowsWithStyles,
|
|
428
|
+
pe as setCurrencyAttributes,
|
|
429
|
+
me as updatePricesInPlace,
|
|
430
|
+
fe as updateProductContentInPlace,
|
|
431
|
+
Q as updateSingleProductContent
|
|
432
432
|
};
|
|
@@ -6,8 +6,9 @@ import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
|
|
|
6
6
|
import { EXCLUDED_ALGORITHM_IDS as D } 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 w } from "../validation/filterSchema.js";
|
|
11
|
+
import { isConfigValid as N } from "../validation/requiredFields.js";
|
|
11
12
|
const h = y();
|
|
12
13
|
let m = null, u = null, d = null;
|
|
13
14
|
function I() {
|
|
@@ -49,7 +50,7 @@ function k() {
|
|
|
49
50
|
filterSnapshot: null
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
|
-
const
|
|
53
|
+
const x = () => ({
|
|
53
54
|
recommendationCampaignUrls: {},
|
|
54
55
|
activePredictiveAlgorithms: [],
|
|
55
56
|
languages: {},
|
|
@@ -58,8 +59,8 @@ const N = () => ({
|
|
|
58
59
|
blockStates: {},
|
|
59
60
|
currentRecommendationId: null,
|
|
60
61
|
configVersion: 0
|
|
61
|
-
}),
|
|
62
|
-
state: () =>
|
|
62
|
+
}), T = P("guidoRecommendationExtension", {
|
|
63
|
+
state: () => x(),
|
|
63
64
|
getters: {
|
|
64
65
|
// ====================================================================
|
|
65
66
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -378,7 +379,7 @@ const N = () => ({
|
|
|
378
379
|
const n = [...e.recommendationConfigs.filters];
|
|
379
380
|
n[r] = {
|
|
380
381
|
...t,
|
|
381
|
-
isValid:
|
|
382
|
+
isValid: w(t)
|
|
382
383
|
}, e.recommendationConfigs.filters = n;
|
|
383
384
|
}
|
|
384
385
|
},
|
|
@@ -424,7 +425,7 @@ const N = () => ({
|
|
|
424
425
|
* every block's recommendationConfigs across user edits.
|
|
425
426
|
*/
|
|
426
427
|
hasInvalidBlock() {
|
|
427
|
-
return Object.values(this.blockStates).some((t) => !
|
|
428
|
+
return Object.values(this.blockStates).some((t) => !N(t.recommendationConfigs, this));
|
|
428
429
|
},
|
|
429
430
|
// ====================================================================
|
|
430
431
|
// Per-Block Product Fetching
|
|
@@ -453,7 +454,10 @@ const N = () => ({
|
|
|
453
454
|
details: !0,
|
|
454
455
|
campaignId: o.variationId
|
|
455
456
|
};
|
|
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)
|
|
457
|
+
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(
|
|
458
|
+
a,
|
|
459
|
+
v(o.partnerName, r.strategy)
|
|
460
|
+
);
|
|
457
461
|
let f;
|
|
458
462
|
try {
|
|
459
463
|
f = await h.fetchRecommendationProducts(i, a);
|
|
@@ -471,5 +475,5 @@ const N = () => ({
|
|
|
471
475
|
}
|
|
472
476
|
});
|
|
473
477
|
export {
|
|
474
|
-
|
|
478
|
+
T as useRecommendationExtensionStore
|
|
475
479
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { RecommendationBlockId 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
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
1
|
+
import { RecommendationBlockId as l } 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 $, ATTR_PRODUCT_IMAGE as _ } from "../../constants/selectors.js";
|
|
3
|
+
import { useRecommendationExtensionStore as x } 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";
|
|
6
|
-
const
|
|
6
|
+
const s = "0 5px", a = "attribute-cell";
|
|
7
|
+
function S(t, e = s) {
|
|
8
|
+
return `<td class="${a}" style="padding: ${e};" width="${t}%"></td>`;
|
|
9
|
+
}
|
|
7
10
|
function g() {
|
|
8
|
-
const t =
|
|
11
|
+
const t = x(), { currencySettings: e } = t.recommendationConfigs;
|
|
9
12
|
return {
|
|
10
13
|
code: e.value,
|
|
11
14
|
symbol: e.symbol,
|
|
@@ -22,9 +25,9 @@ function i(t, e = "price") {
|
|
|
22
25
|
currency: o
|
|
23
26
|
});
|
|
24
27
|
}
|
|
25
|
-
const
|
|
26
|
-
[
|
|
27
|
-
<td class="${
|
|
28
|
+
const A = {
|
|
29
|
+
[_]: (t) => `
|
|
30
|
+
<td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
|
|
28
31
|
<table
|
|
29
32
|
class="product-card-segment"
|
|
30
33
|
width="100%"
|
|
@@ -37,7 +40,7 @@ const S = {
|
|
|
37
40
|
<td
|
|
38
41
|
class="esd-block-image product-image"
|
|
39
42
|
align="center"
|
|
40
|
-
esd-extension-block-id="${
|
|
43
|
+
esd-extension-block-id="${l.IMAGE}">
|
|
41
44
|
<a target="_blank" href="${t.url}" class="${p}">
|
|
42
45
|
<img
|
|
43
46
|
src="${O(t.image_url)}"
|
|
@@ -51,8 +54,8 @@ const S = {
|
|
|
51
54
|
</table>
|
|
52
55
|
</td>
|
|
53
56
|
`,
|
|
54
|
-
[
|
|
55
|
-
<td class="${
|
|
57
|
+
[$]: (t) => `
|
|
58
|
+
<td class="${a}" style="padding: ${s}; height: 100%;" valign="middle">
|
|
56
59
|
<table
|
|
57
60
|
class="product-card-segment"
|
|
58
61
|
width="100%"
|
|
@@ -66,7 +69,7 @@ const S = {
|
|
|
66
69
|
<td
|
|
67
70
|
class="esd-block-text product-name es-p10t es-p10b es-p15l es-p15r"
|
|
68
71
|
align="center"
|
|
69
|
-
esd-extension-block-id="${
|
|
72
|
+
esd-extension-block-id="${l.NAME}">
|
|
70
73
|
<p contenteditable="false" style="font-size: 16px; color: #333333;">
|
|
71
74
|
<strong>${t.name}</strong>
|
|
72
75
|
</p>
|
|
@@ -77,7 +80,7 @@ const S = {
|
|
|
77
80
|
</td>
|
|
78
81
|
`,
|
|
79
82
|
[f]: (t) => `
|
|
80
|
-
<td class="${
|
|
83
|
+
<td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
|
|
81
84
|
<table
|
|
82
85
|
class="product-card-segment"
|
|
83
86
|
width="100%"
|
|
@@ -90,7 +93,7 @@ const S = {
|
|
|
90
93
|
<td
|
|
91
94
|
class="esd-block-text product-price es-p15l es-p15r"
|
|
92
95
|
align="center"
|
|
93
|
-
esd-extension-block-id="${
|
|
96
|
+
esd-extension-block-id="${l.PRICE}">
|
|
94
97
|
<p contenteditable="false" style="font-size: 16px; color: #333333;">
|
|
95
98
|
<strong>${i(t, "price")}</strong>
|
|
96
99
|
</p>
|
|
@@ -101,7 +104,7 @@ const S = {
|
|
|
101
104
|
</td>
|
|
102
105
|
`,
|
|
103
106
|
[T]: (t) => `
|
|
104
|
-
<td class="${
|
|
107
|
+
<td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
|
|
105
108
|
<table
|
|
106
109
|
class="product-card-segment"
|
|
107
110
|
width="100%"
|
|
@@ -114,9 +117,11 @@ const S = {
|
|
|
114
117
|
<td
|
|
115
118
|
class="esd-block-text product-old-price es-p15l es-p15r"
|
|
116
119
|
align="center"
|
|
117
|
-
esd-extension-block-id="${
|
|
118
|
-
<p
|
|
119
|
-
|
|
120
|
+
esd-extension-block-id="${l.OLD_PRICE}">
|
|
121
|
+
<p
|
|
122
|
+
contenteditable="false"
|
|
123
|
+
style="font-size: 14px; color: #999999;">
|
|
124
|
+
<s><strong>${i(t, "original_price")}</strong></s>
|
|
120
125
|
</p>
|
|
121
126
|
</td>
|
|
122
127
|
</tr>
|
|
@@ -125,7 +130,7 @@ const S = {
|
|
|
125
130
|
</td>
|
|
126
131
|
`,
|
|
127
132
|
[y]: (t) => `
|
|
128
|
-
<td class="${
|
|
133
|
+
<td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
|
|
129
134
|
<table
|
|
130
135
|
class="product-card-segment"
|
|
131
136
|
width="100%"
|
|
@@ -140,7 +145,7 @@ const S = {
|
|
|
140
145
|
align="center"
|
|
141
146
|
data-text-before="Lowest 30-day price: "
|
|
142
147
|
data-text-after=""
|
|
143
|
-
esd-extension-block-id="${
|
|
148
|
+
esd-extension-block-id="${l.OMNIBUS_PRICE}">
|
|
144
149
|
<p contenteditable="false" style="font-size: 12px; color: #666666;">
|
|
145
150
|
<span class="omnibus-text-before">Lowest 30-day price: </span>
|
|
146
151
|
<span class="omnibus-price-value">${i(t, "original_price")}</span>
|
|
@@ -156,7 +161,7 @@ const S = {
|
|
|
156
161
|
var r, c;
|
|
157
162
|
const e = g(), o = ((r = t.original_price) == null ? void 0 : r[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, n = ((c = t.price) == null ? void 0 : c[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, d = o > 0 ? Math.round((o - n) / o * 100) : 0, b = d > 0 ? `-${d}%` : "0%";
|
|
158
163
|
return `
|
|
159
|
-
<td class="${
|
|
164
|
+
<td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
|
|
160
165
|
<table
|
|
161
166
|
class="product-card-segment"
|
|
162
167
|
width="100%"
|
|
@@ -171,7 +176,7 @@ const S = {
|
|
|
171
176
|
align="center"
|
|
172
177
|
data-text-before=""
|
|
173
178
|
data-text-after=""
|
|
174
|
-
esd-extension-block-id="${
|
|
179
|
+
esd-extension-block-id="${l.OMNIBUS_DISCOUNT}">
|
|
175
180
|
<p contenteditable="false" style="font-size: 12px; color: #666666;">
|
|
176
181
|
<span class="omnibus-text-before"></span>
|
|
177
182
|
<span class="omnibus-discount-value">${b}</span>
|
|
@@ -185,7 +190,7 @@ const S = {
|
|
|
185
190
|
`;
|
|
186
191
|
},
|
|
187
192
|
[m]: () => `
|
|
188
|
-
<td class="${
|
|
193
|
+
<td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
|
|
189
194
|
<table
|
|
190
195
|
class="product-card-segment"
|
|
191
196
|
width="100%"
|
|
@@ -198,7 +203,7 @@ const S = {
|
|
|
198
203
|
<td
|
|
199
204
|
class="esd-block-button product-button es-p10t es-p10b"
|
|
200
205
|
align="center"
|
|
201
|
-
esd-extension-block-id="${
|
|
206
|
+
esd-extension-block-id="${l.BUTTON}">
|
|
202
207
|
<span
|
|
203
208
|
class="es-button-border"
|
|
204
209
|
style="
|
|
@@ -237,7 +242,7 @@ const S = {
|
|
|
237
242
|
* @param content - Display content for the cell
|
|
238
243
|
*/
|
|
239
244
|
[R]: (t, e) => `
|
|
240
|
-
<td class="${
|
|
245
|
+
<td class="${a}" style="padding: ${s}; height: 100%;" valign="middle">
|
|
241
246
|
<table
|
|
242
247
|
class="product-card-segment"
|
|
243
248
|
width="100%"
|
|
@@ -252,7 +257,7 @@ const S = {
|
|
|
252
257
|
${u}="${t}"
|
|
253
258
|
class="esd-block-text product-custom-attribute es-p0t es-p0b es-p15l es-p15r"
|
|
254
259
|
align="center"
|
|
255
|
-
esd-extension-block-id="${
|
|
260
|
+
esd-extension-block-id="${l.CUSTOM_ATTRIBUTE}">
|
|
256
261
|
<p contenteditable="false" style="font-size: 12px; color: #666666;">${e}</p>
|
|
257
262
|
</td>
|
|
258
263
|
</tr>
|
|
@@ -262,7 +267,8 @@ const S = {
|
|
|
262
267
|
`
|
|
263
268
|
};
|
|
264
269
|
export {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
S as
|
|
270
|
+
a as ATTRIBUTE_CELL_CLASS,
|
|
271
|
+
s as DEFAULT_CELL_PADDING,
|
|
272
|
+
S as buildFillerCell,
|
|
273
|
+
A as gridElementRenderer
|
|
268
274
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DEFAULT_PRODUCTS_PER_ROW as
|
|
2
|
-
import { getDefaultProducts as
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
1
|
+
import { DEFAULT_PRODUCTS_PER_ROW as m } from "../../constants/layout.js";
|
|
2
|
+
import { getDefaultProducts as I, DEFAULTS as b, createBlockTemplate as E, DEFAULT_CARD_COMPOSITION as L, spacer as S, buildElementRenderer as _, DEFAULT_CARD_VISIBILITY as f } from "../utils.js";
|
|
3
|
+
import { buildFillerCell as w, gridElementRenderer as A } from "./elementRenderer.js";
|
|
4
|
+
const D = `
|
|
5
5
|
<tr class="recommendation-product-row">
|
|
6
6
|
<td>
|
|
7
7
|
<table
|
|
@@ -18,7 +18,7 @@ const O = `
|
|
|
18
18
|
</table>
|
|
19
19
|
</td>
|
|
20
20
|
</tr>
|
|
21
|
-
`,
|
|
21
|
+
`, C = `
|
|
22
22
|
<tr
|
|
23
23
|
class="recommendation-attribute-row"
|
|
24
24
|
data-attribute-type="{-{-ATTR_TYPE-}-}"
|
|
@@ -27,38 +27,38 @@ const O = `
|
|
|
27
27
|
{-{-CELLS-}-}
|
|
28
28
|
</tr>
|
|
29
29
|
`;
|
|
30
|
-
function
|
|
31
|
-
const
|
|
32
|
-
return r.filter((
|
|
33
|
-
const
|
|
34
|
-
return
|
|
30
|
+
function O(t, e, n, r = L, c = {}) {
|
|
31
|
+
const a = (100 / e).toFixed(2), s = e - t.length, l = s > 0 ? w(a).repeat(s) : "", i = _(n, r, c);
|
|
32
|
+
return r.filter((o) => i[o]).map((o) => {
|
|
33
|
+
const p = f[o] ?? !0, u = p ? "" : 'style="display: none;"', T = t.map((R) => i[o](R).replace("<td", `<td width="${a}%"`)).join("");
|
|
34
|
+
return C.replace("{-{-ATTR_TYPE-}-}", o).replace("{-{-VISIBILITY-}-}", p ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", u).replace("{-{-CELLS-}-}", T + l);
|
|
35
35
|
}).join("");
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
37
|
+
function g(t, e, n, r, c = {}) {
|
|
38
|
+
const a = [];
|
|
39
39
|
for (let l = 0; l < t.length; l += e)
|
|
40
|
-
|
|
41
|
-
return
|
|
42
|
-
const
|
|
40
|
+
a.push(t.slice(l, l + e));
|
|
41
|
+
return a.map((l, i) => {
|
|
42
|
+
const d = O(
|
|
43
43
|
l,
|
|
44
44
|
e,
|
|
45
|
-
|
|
45
|
+
n,
|
|
46
46
|
r,
|
|
47
|
-
|
|
48
|
-
),
|
|
49
|
-
return
|
|
47
|
+
c
|
|
48
|
+
), o = D.replace("{-{-ATTRIBUTE_ROWS-}-}", d);
|
|
49
|
+
return i > 0 ? S + o : o;
|
|
50
50
|
}).join("");
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
return
|
|
52
|
+
function P(t, e, n, r = {}) {
|
|
53
|
+
return g(t, e, A, n, r);
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
const e = t ? `ins-recommendation-v3-block-${t}` : void 0,
|
|
57
|
-
return
|
|
55
|
+
function B(t) {
|
|
56
|
+
const e = t ? `ins-recommendation-v3-block-${t}` : void 0, n = E("grid", e), r = I(), c = P(r, m);
|
|
57
|
+
return n.replace("{-{-TITLE-}-}", b.TITLE).replace("{-{-PRODUCT_ROWS-}-}", c).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
|
|
58
58
|
}
|
|
59
59
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
B as getDefaultTemplate,
|
|
61
|
+
O as prepareGridAttributeRows,
|
|
62
|
+
g as prepareGridProductRows,
|
|
63
|
+
P as prepareProductRows
|
|
64
64
|
};
|
|
@@ -14,10 +14,10 @@ function b() {
|
|
|
14
14
|
thousandSeparator: e.thousandSeparator
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
const n = b(),
|
|
17
|
+
function r(t, e = "price") {
|
|
18
|
+
const n = b(), s = t[e], a = (s == null ? void 0 : s[n.code]) ?? Object.values(s ?? {})[0] ?? 0;
|
|
19
19
|
return R({
|
|
20
|
-
price:
|
|
20
|
+
price: a,
|
|
21
21
|
currency: n
|
|
22
22
|
});
|
|
23
23
|
}
|
|
@@ -69,7 +69,7 @@ const I = {
|
|
|
69
69
|
esd-extension-block-id="${o.PRICE}"
|
|
70
70
|
align="left">
|
|
71
71
|
<p contenteditable="false" style="font-size: 16px; color: #333333; font-weight: bold; margin: 0;">
|
|
72
|
-
<strong>${
|
|
72
|
+
<strong>${r(t, "price")}</strong>
|
|
73
73
|
</p>
|
|
74
74
|
</td>
|
|
75
75
|
</tr>
|
|
@@ -85,8 +85,8 @@ const I = {
|
|
|
85
85
|
align="left">
|
|
86
86
|
<p
|
|
87
87
|
contenteditable="false"
|
|
88
|
-
style="font-size: 14px; color: #999999;
|
|
89
|
-
<strong>${
|
|
88
|
+
style="font-size: 14px; color: #999999; margin: 0;">
|
|
89
|
+
<s><strong>${r(t, "original_price")}</strong></s>
|
|
90
90
|
</p>
|
|
91
91
|
</td>
|
|
92
92
|
</tr>
|
|
@@ -104,7 +104,7 @@ const I = {
|
|
|
104
104
|
align="left">
|
|
105
105
|
<p contenteditable="false" style="font-size: 12px; color: #666666; margin: 0;">
|
|
106
106
|
<span class="omnibus-text-before">Lowest 30-day price: </span>
|
|
107
|
-
<span class="omnibus-price-value">${
|
|
107
|
+
<span class="omnibus-price-value">${r(t, "original_price")}</span>
|
|
108
108
|
<span class="omnibus-text-after"></span>
|
|
109
109
|
</p>
|
|
110
110
|
</td>
|
|
@@ -115,7 +115,7 @@ const I = {
|
|
|
115
115
|
*/
|
|
116
116
|
[g]: (t) => {
|
|
117
117
|
var i, l;
|
|
118
|
-
const e = b(), n = ((i = t.original_price) == null ? void 0 : i[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0,
|
|
118
|
+
const e = b(), n = ((i = t.original_price) == null ? void 0 : i[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, s = ((l = t.price) == null ? void 0 : l[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, a = n > 0 ? Math.round((n - s) / n * 100) : 0, m = a > 0 ? `-${a}%` : "0%";
|
|
119
119
|
return `
|
|
120
120
|
<tr>
|
|
121
121
|
<td
|