@useinsider/guido 3.15.0-beta.0b5dc39 → 3.15.0-beta.0cbd17f
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 +20 -19
- package/dist/composables/useStripo.js +29 -30
- package/dist/extensions/Blocks/Items/block.js +44 -42
- package/dist/extensions/Blocks/Items/template.js +86 -86
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +37 -26
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +21 -21
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +13 -12
- package/dist/extensions/Blocks/Recommendation/utils/productIds.js +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +6 -0
- package/dist/utils/pairProductVariables.js +105 -99
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { escapeHtml as m } from "../../../utils/htmlEscape.js";
|
|
2
2
|
import { BlockType as R, BlockAttr as S } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
3
3
|
import { ItemsBlockId as O } from "./enums/controlEnums.js";
|
|
4
|
-
import { productPairs as h, templateFirstLine as
|
|
5
|
-
import { ItemInCartOptions as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { deriveItemNumber as
|
|
9
|
-
let [
|
|
10
|
-
const
|
|
11
|
-
const
|
|
4
|
+
import { productPairs as h, templateFirstLine as q } from "./enums/productEnums.js";
|
|
5
|
+
import { ItemInCartOptions as j, SETTINGS_ENUMS as N, DefaultConfigValues as M } from "./enums/settingsEnums.js";
|
|
6
|
+
import C from "./layouts/horizontal.html.js";
|
|
7
|
+
import J from "./layouts/vertical.html.js";
|
|
8
|
+
import { deriveItemNumber as Z, escapeReplacement as g } from "./utils/nodeConfigUtils.js";
|
|
9
|
+
let [v] = h.PAIRS_FOR_EXTENSION.imageSrc.CART_ITEMS.DEFAULT, [F] = h.PAIRS_FOR_EXTENSION.name.CART_ITEMS.DEFAULT, [x] = h.PAIRS_FOR_EXTENSION.price.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [L] = h.PAIRS_FOR_EXTENSION.originalPrice.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [X] = h.PAIRS_FOR_EXTENSION.quantity.CART_ITEMS.DEFAULT;
|
|
10
|
+
const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCase().startsWith(e.toLowerCase())).join("; ").replace(/;\s*$/, ""), k = (s) => U(s, "text-align"), y = (s, e) => {
|
|
11
|
+
const r = new RegExp(`${e}\\s*:\\s*([^;]+)`, "i"), a = s.match(r);
|
|
12
12
|
return a ? a[1].trim() : null;
|
|
13
|
-
}, w = (s) => `<tr>${s}</tr>`,
|
|
14
|
-
const i =
|
|
13
|
+
}, w = (s) => `<tr>${s}</tr>`, f = (s, e, r, a) => {
|
|
14
|
+
const i = r || M.productImageHeight, d = (a == null ? void 0 : a.imageVisible) === !1 ? "display: none; " : "";
|
|
15
15
|
return w(`
|
|
16
16
|
<td class="esd-block-image document-node-component default-block-component selectable ng-star-inserted"
|
|
17
17
|
align="center"
|
|
@@ -26,7 +26,7 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
26
26
|
href="#!">
|
|
27
27
|
<img class="adapt-img document-node-component ng-star-inserted"
|
|
28
28
|
style="object-fit: contain;"
|
|
29
|
-
src="${
|
|
29
|
+
src="${v}"
|
|
30
30
|
alt="${F}"
|
|
31
31
|
width="${i}"
|
|
32
32
|
height="${i}">
|
|
@@ -35,18 +35,18 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
35
35
|
`);
|
|
36
36
|
}, tt = (s, e) => `
|
|
37
37
|
<${R.BLOCK_IMAGE}
|
|
38
|
-
${S.BLOCK_IMAGE.src}="${
|
|
38
|
+
${S.BLOCK_IMAGE.src}="${v}"
|
|
39
39
|
${S.BLOCK_IMAGE.alt}="${F}"
|
|
40
40
|
${S.BLOCK_IMAGE.href}="#!"
|
|
41
|
-
${S.BLOCK_IMAGE.width}="${
|
|
42
|
-
${S.BLOCK_IMAGE.height}="${
|
|
41
|
+
${S.BLOCK_IMAGE.width}="${M.productImageWidth}"
|
|
42
|
+
${S.BLOCK_IMAGE.height}="${M.productImageWidth}"
|
|
43
43
|
esd-extension-block-id="${O.IMAGE}"
|
|
44
44
|
data-slot-1
|
|
45
45
|
product-attr="imageSrc"
|
|
46
46
|
data-type="${s}"
|
|
47
47
|
data-number="${e}"
|
|
48
48
|
/>
|
|
49
|
-
`, et = (s, e,
|
|
49
|
+
`, et = (s, e, r, a) => {
|
|
50
50
|
const i = `
|
|
51
51
|
word-wrap: break-word;
|
|
52
52
|
white-space: nowrap;
|
|
@@ -56,15 +56,15 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
56
56
|
max-width: 100%;
|
|
57
57
|
`;
|
|
58
58
|
if (e) {
|
|
59
|
-
const d = y(
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
const d = y(r || "", "text-align") || "center", n = k(r || i), c = y(n, "font-weight"), l = y(n, "font-style"), o = c === "bold" || c === "700", t = l === "italic", p = U(
|
|
60
|
+
U(
|
|
61
|
+
U(n, "font-weight"),
|
|
62
62
|
"font-style"
|
|
63
63
|
),
|
|
64
64
|
"text-decoration"
|
|
65
|
-
), T = (a == null ? void 0 : a.nameVisible) === !1 ? "display: none;" : "display: table-cell;", _ =
|
|
66
|
-
let
|
|
67
|
-
return
|
|
65
|
+
), T = (a == null ? void 0 : a.nameVisible) === !1 ? "display: none;" : "display: table-cell;", _ = p ? ` style="${m(p)}"` : "";
|
|
66
|
+
let E = F;
|
|
67
|
+
return o && (E = `<strong>${E}</strong>`), t && (E = `<em>${E}</em>`), w(`
|
|
68
68
|
<td class="esd-block-text es-p10"
|
|
69
69
|
align="${d}"
|
|
70
70
|
width="100%"
|
|
@@ -76,7 +76,7 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
76
76
|
path="1"
|
|
77
77
|
product-attr="name"
|
|
78
78
|
data-slot-2${_}>
|
|
79
|
-
${
|
|
79
|
+
${E}
|
|
80
80
|
</p>
|
|
81
81
|
</td>
|
|
82
82
|
`);
|
|
@@ -97,15 +97,15 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
97
97
|
</p>
|
|
98
98
|
</${R.BLOCK_TEXT}>
|
|
99
99
|
`;
|
|
100
|
-
}, at = (s, e,
|
|
100
|
+
}, at = (s, e, r, a, i, d, n, c, l, o) => {
|
|
101
101
|
let t = x;
|
|
102
102
|
if (a && a.trim()) {
|
|
103
|
-
const
|
|
104
|
-
t = (i || "0") === "1" ? `${x} ${
|
|
103
|
+
const $ = `${a.trim()}`;
|
|
104
|
+
t = (i || "0") === "1" ? `${x} ${$}` : `${$} ${x}`;
|
|
105
105
|
}
|
|
106
|
-
const
|
|
106
|
+
const p = i === "1" ? "after" : "before", T = `data-formated="${r ? "true" : "false"}"`, _ = `data-curency="${p}"`, E = a ? `data-currency_symbol="${a}"` : "", u = `data-single_price="${c ? "true" : "false"}"`, I = l === N.ORIENTATION.VERTICAL ? " es-p10b es-p10t" : "";
|
|
107
107
|
if (d) {
|
|
108
|
-
const b =
|
|
108
|
+
const b = k(n || "color: #060606; white-space: nowrap; font-size: 20px;"), A = o ? "" : ' style="display: none;"';
|
|
109
109
|
return w(`
|
|
110
110
|
<td class="esd-block-text items-block-price${I}"
|
|
111
111
|
align="center"
|
|
@@ -119,7 +119,7 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
119
119
|
data-number="${e}"
|
|
120
120
|
${T}
|
|
121
121
|
${_}
|
|
122
|
-
${
|
|
122
|
+
${E}
|
|
123
123
|
${u}
|
|
124
124
|
style="${m(b)}">
|
|
125
125
|
${t}
|
|
@@ -149,20 +149,20 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
149
149
|
</p>
|
|
150
150
|
</${R.BLOCK_TEXT}>
|
|
151
151
|
`;
|
|
152
|
-
}, st = (s, e,
|
|
152
|
+
}, st = (s, e, r, a, i, d, n = !0, c, l, o) => {
|
|
153
153
|
let t = L;
|
|
154
154
|
if (a && a.trim()) {
|
|
155
|
-
const
|
|
156
|
-
t = (i || "0") === "1" ? `${L} ${
|
|
155
|
+
const $ = `${a.trim()}`;
|
|
156
|
+
t = (i || "0") === "1" ? `${L} ${$}` : `${$} ${L}`;
|
|
157
157
|
}
|
|
158
|
-
const
|
|
158
|
+
const p = i === "1" ? "after" : "before", T = `data-formated="${r ? "true" : "false"}"`, _ = `data-curency="${p}"`, E = n ? "" : ' style="display: none;"', u = `data-single_price="${l ? "true" : "false"}"`, I = o === N.ORIENTATION.VERTICAL ? " es-p10b es-p10t" : "";
|
|
159
159
|
if (d) {
|
|
160
|
-
const b =
|
|
160
|
+
const b = k(c || "color: #cc0000; white-space: nowrap; font-size: 19px;");
|
|
161
161
|
return w(`
|
|
162
162
|
<td class="esd-block-text items-block-price${I}"
|
|
163
163
|
esd-extension-block-id="${O.ORIGINAL_PRICE}"
|
|
164
164
|
width="100%"
|
|
165
|
-
align="center"${
|
|
165
|
+
align="center"${E}>
|
|
166
166
|
<p
|
|
167
167
|
product-attr="originalPrice"
|
|
168
168
|
contenteditable="false"
|
|
@@ -203,10 +203,10 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
203
203
|
</p>
|
|
204
204
|
</${R.BLOCK_TEXT}>
|
|
205
205
|
`;
|
|
206
|
-
}, lt = (s = !0, e,
|
|
206
|
+
}, lt = (s = !0, e, r) => {
|
|
207
207
|
const a = s ? "" : 'style="display: none;"';
|
|
208
208
|
if (e) {
|
|
209
|
-
const i = "font-size: 14px;", d = y(
|
|
209
|
+
const i = "font-size: 14px;", d = y(r || "", "text-align") || "center", n = k(r || i);
|
|
210
210
|
return w(`
|
|
211
211
|
<td class="esd-block-text es-p10 document-node-component default-block-component selectable"
|
|
212
212
|
width="100%" align="${d}"
|
|
@@ -218,7 +218,7 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
218
218
|
width="100%"
|
|
219
219
|
path="1"
|
|
220
220
|
style="${m(n)}">
|
|
221
|
-
${
|
|
221
|
+
${X}
|
|
222
222
|
</p>
|
|
223
223
|
</td>
|
|
224
224
|
`);
|
|
@@ -236,26 +236,26 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
236
236
|
data-slot-3
|
|
237
237
|
contenteditable="false"
|
|
238
238
|
width="100%">
|
|
239
|
-
${
|
|
239
|
+
${X}
|
|
240
240
|
</p>
|
|
241
241
|
</${R.BLOCK_TEXT}>
|
|
242
242
|
`;
|
|
243
|
-
}, rt = (s, e,
|
|
243
|
+
}, rt = (s, e, r = "Buy", a, i, d = !0, n = !0) => {
|
|
244
244
|
if (a) {
|
|
245
|
-
const c = y(i || "", "background") || y(i || "", "background-color"),
|
|
245
|
+
const c = y(i || "", "background") || y(i || "", "background-color"), l = c ? `border-width: 0px; background: ${c};` : "border-width: 0px;", o = d ? "es-fw" : "es-il", t = (i || "").replace("border-width: 0;", "");
|
|
246
246
|
return w(`
|
|
247
247
|
<td class="esd-block-button ins-button default-block-component selectable"
|
|
248
|
-
align="center" width="100%" name="buy-button" caption="${
|
|
248
|
+
align="center" width="100%" name="buy-button" caption="${r}"
|
|
249
249
|
esd-extension-block-id="${O.BUTTON}"
|
|
250
250
|
product-attr="button" data-slot-6="" data-type="${s}" data-number="${e}"
|
|
251
251
|
${n ? "" : ' style="display: none;"'}>
|
|
252
|
-
<span class="es-button-border ${
|
|
252
|
+
<span class="es-button-border ${o}" style="${m(l)}">
|
|
253
253
|
<a
|
|
254
254
|
class="es-button"
|
|
255
255
|
href="#!"
|
|
256
256
|
target="_blank"
|
|
257
257
|
style="${m(t)} padding: 5px 12px;">
|
|
258
|
-
${
|
|
258
|
+
${r}
|
|
259
259
|
</a>
|
|
260
260
|
</span>
|
|
261
261
|
</td>
|
|
@@ -266,27 +266,27 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
266
266
|
width="100%"
|
|
267
267
|
class="ins-button"
|
|
268
268
|
name="buy-button"
|
|
269
|
-
caption="${
|
|
269
|
+
caption="${r}"
|
|
270
270
|
align="center"
|
|
271
271
|
esd-extension-block-id="${O.BUTTON}"
|
|
272
272
|
product-attr="button"
|
|
273
273
|
data-slot-6
|
|
274
274
|
data-type="${s}"
|
|
275
275
|
data-number="${e}"
|
|
276
|
-
>${
|
|
276
|
+
>${r}
|
|
277
277
|
</${R.BLOCK_BUTTON}>
|
|
278
278
|
`;
|
|
279
|
-
}, ct = (s, e,
|
|
280
|
-
const d = e === N.ORIENTATION.VERTICAL, n =
|
|
279
|
+
}, ct = (s, e, r, a = !0, i = !0) => {
|
|
280
|
+
const d = e === N.ORIENTATION.VERTICAL, n = r === "horizontal";
|
|
281
281
|
if (d) {
|
|
282
|
-
const c = !n,
|
|
282
|
+
const c = !n, l = c || !i ? "100%" : "50%", o = c || !a ? "100%" : "50%";
|
|
283
283
|
let t = s.replace(
|
|
284
284
|
/<td\s+[^>]*class="([^"]*product-price-class[^"]*)"[^>]*>/gi,
|
|
285
|
-
(
|
|
285
|
+
(p) => p.replace(/width="[^"]*"/gi, `width="${l}"`).replace(/width:\s*[^;]+;/gi, `width: ${l};`)
|
|
286
286
|
);
|
|
287
287
|
return t = t.replace(
|
|
288
288
|
/<td\s+[^>]*class="([^"]*product-original-price-class[^"]*)"[^>]*>/gi,
|
|
289
|
-
(
|
|
289
|
+
(p) => p.replace(/width="[^"]*"/gi, `width="${o}"`).replace(/width:\s*[^;]+;/gi, `width: ${o};`)
|
|
290
290
|
), t;
|
|
291
291
|
}
|
|
292
292
|
return n ? s : s.replace(
|
|
@@ -298,74 +298,74 @@ const D = (s, e) => s.split(";").map((l) => l.trim()).filter((l) => !l.toLowerCa
|
|
|
298
298
|
);
|
|
299
299
|
}, it = (s) => s ? `<td align="center"
|
|
300
300
|
esd-extension-block-id="items-block"
|
|
301
|
-
class="ins-product-td items-block items-block-v2 esd-items-block esd-extension-block esd-container-frame">` :
|
|
302
|
-
const A = `${`data-type="${e}" data-number="${
|
|
301
|
+
class="ins-product-td items-block items-block-v2 esd-items-block esd-extension-block esd-container-frame">` : q, B = (s, e, r, a, i, d, n, c, l, o, t, p, T, _ = "horizontal", E, u, P, I) => {
|
|
302
|
+
const $ = o !== void 0 ? ` data-nodup="${o}"` : "", A = `${`data-type="${e}" data-number="${r}"`} data-orientation="${a}"${$}`, D = l == null ? void 0 : l["data-product_image_control_image-height"], V = d ? f(e, r, D, t) : tt(e, r), W = (t == null ? void 0 : t.buttonLabel) || "Buy", z = (t == null ? void 0 : t.buttonFullWidth) !== void 0 ? t.buttonFullWidth : !0, H = e === N.ITEMS_TYPE.BROWSED_ITEMS ? !1 : t == null ? void 0 : t.quantityControlEnabled, Q = (t == null ? void 0 : t.buttonVisible) !== void 0 ? t.buttonVisible : (l == null ? void 0 : l["data-product_button_control_enabled"]) !== "false", G = (t == null ? void 0 : t.priceVisible) !== void 0 ? t.priceVisible : (l == null ? void 0 : l["data-product_price_control_enabled"]) !== "false", K = (t == null ? void 0 : t.originalPriceVisible) !== void 0 ? t.originalPriceVisible : (l == null ? void 0 : l["data-product_original_price_control_enabled"]) !== "false", Y = s.replace("{-{-TEMPLATE_FIRST_LINE-}-}", it(d)).replace("{-{-PRODUCT_IMAGE-}-}", V).replace("{-{-PRODUCT_NAME-}-}", et(e, d, p, t)).replaceAll(
|
|
303
303
|
"{-{-PRODUCT_PRICE-}-}",
|
|
304
|
-
|
|
304
|
+
g(at(
|
|
305
305
|
e,
|
|
306
|
-
|
|
306
|
+
r,
|
|
307
307
|
i,
|
|
308
308
|
n,
|
|
309
309
|
c,
|
|
310
310
|
d,
|
|
311
|
-
|
|
311
|
+
E,
|
|
312
312
|
I,
|
|
313
313
|
a,
|
|
314
|
-
|
|
314
|
+
G
|
|
315
315
|
))
|
|
316
316
|
).replaceAll(
|
|
317
317
|
"{-{-PRODUCT_ORIGINAL_PRICE-}-}",
|
|
318
|
-
|
|
318
|
+
g(st(
|
|
319
319
|
e,
|
|
320
|
-
|
|
320
|
+
r,
|
|
321
321
|
i,
|
|
322
322
|
n,
|
|
323
323
|
c,
|
|
324
324
|
d,
|
|
325
|
-
|
|
325
|
+
K,
|
|
326
326
|
u,
|
|
327
327
|
I,
|
|
328
328
|
a
|
|
329
329
|
))
|
|
330
|
-
).replace("{-{-PRODUCT_QUANTITY-}-}", lt(
|
|
330
|
+
).replace("{-{-PRODUCT_QUANTITY-}-}", lt(H, d, P)).replace(
|
|
331
331
|
"{-{-PRODUCT_BUTTON-}-}",
|
|
332
|
-
rt(e,
|
|
332
|
+
rt(e, r, W, d, T, z, Q)
|
|
333
333
|
).replace(
|
|
334
334
|
/<td([^>]*class="[^"]*ins-product-td[^"]*"[^>]*)>/,
|
|
335
335
|
`<td$1 ${A}>`
|
|
336
336
|
);
|
|
337
337
|
return ct(
|
|
338
|
-
|
|
338
|
+
Y,
|
|
339
339
|
a,
|
|
340
340
|
_,
|
|
341
|
-
|
|
342
|
-
|
|
341
|
+
G,
|
|
342
|
+
K
|
|
343
343
|
);
|
|
344
344
|
};
|
|
345
345
|
function It({
|
|
346
346
|
orientation: s,
|
|
347
347
|
itemsType: e = N.ITEMS_TYPE.CART_ITEMS,
|
|
348
|
-
itemId:
|
|
348
|
+
itemId: r,
|
|
349
349
|
currencySymbol: a,
|
|
350
350
|
currencyLocation: i,
|
|
351
351
|
migrate: d = !1,
|
|
352
352
|
formattedPrice: n = !0,
|
|
353
353
|
configBlockAttributes: c,
|
|
354
|
-
nodeConfig:
|
|
355
|
-
nameStyles:
|
|
354
|
+
nodeConfig: l,
|
|
355
|
+
nameStyles: o,
|
|
356
356
|
buttonStyles: t,
|
|
357
|
-
priceStyles:
|
|
357
|
+
priceStyles: p,
|
|
358
358
|
originalPriceStyles: T,
|
|
359
359
|
quantityStyles: _,
|
|
360
|
-
priceOrientation:
|
|
360
|
+
priceOrientation: E
|
|
361
361
|
}) {
|
|
362
|
-
const u =
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
I ? (x = n ?
|
|
366
|
-
const A =
|
|
367
|
-
return s === N.ORIENTATION.VERTICAL ?
|
|
368
|
-
|
|
362
|
+
const u = j[e].findIndex((V) => V.value === r), P = Z(r, e), I = (l == null ? void 0 : l.priceSinglePrice) ?? (c == null ? void 0 : c["data-product_price_control_single_price"]) === "1" ?? !1;
|
|
363
|
+
v = h.PAIRS_FOR_EXTENSION.imageSrc[e].DEFAULT[u >= 0 ? u : 0], F = h.PAIRS_FOR_EXTENSION.name[e].DEFAULT[u >= 0 ? u : 0];
|
|
364
|
+
const $ = h.PAIRS_FOR_EXTENSION.price[e], b = h.PAIRS_FOR_EXTENSION.originalPrice[e];
|
|
365
|
+
I ? (x = n ? $.DEFAULT_SINGLE_PRICE_FORMATTED : $.DEFAULT_SINGLE_PRICE, L = n ? b.DEFAULT_SINGLE_PRICE_FORMATTED : b.DEFAULT_SINGLE_PRICE) : (x = n ? $.DEFAULT_PRICE_FORMATTED : $.DEFAULT_PRICE, L = n ? b.DEFAULT_PRICE_FORMATTED : b.DEFAULT_PRICE), X = h.PAIRS_FOR_EXTENSION.quantity[e].DEFAULT;
|
|
366
|
+
const A = E || (l == null ? void 0 : l.priceOrientation) || "horizontal", D = (l == null ? void 0 : l.priceHideDiscount) ?? M.productPriceHideDiscountControlValue === "1";
|
|
367
|
+
return s === N.ORIENTATION.VERTICAL ? B(
|
|
368
|
+
J,
|
|
369
369
|
e,
|
|
370
370
|
P,
|
|
371
371
|
s,
|
|
@@ -374,18 +374,18 @@ function It({
|
|
|
374
374
|
a,
|
|
375
375
|
i,
|
|
376
376
|
c,
|
|
377
|
-
|
|
377
|
+
String(D),
|
|
378
378
|
// nodup
|
|
379
|
-
|
|
380
|
-
|
|
379
|
+
l,
|
|
380
|
+
o,
|
|
381
381
|
t,
|
|
382
382
|
A,
|
|
383
|
-
|
|
383
|
+
p,
|
|
384
384
|
T,
|
|
385
385
|
_,
|
|
386
386
|
I
|
|
387
|
-
) :
|
|
388
|
-
|
|
387
|
+
) : B(
|
|
388
|
+
C,
|
|
389
389
|
e,
|
|
390
390
|
P,
|
|
391
391
|
s,
|
|
@@ -394,13 +394,13 @@ function It({
|
|
|
394
394
|
a,
|
|
395
395
|
i,
|
|
396
396
|
c,
|
|
397
|
-
|
|
397
|
+
String(D),
|
|
398
398
|
// nodup
|
|
399
|
-
|
|
400
|
-
|
|
399
|
+
l,
|
|
400
|
+
o,
|
|
401
401
|
t,
|
|
402
402
|
A,
|
|
403
|
-
|
|
403
|
+
p,
|
|
404
404
|
T,
|
|
405
405
|
_,
|
|
406
406
|
I
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UEAttr as
|
|
5
|
-
import { CommonControl as
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var h = (r, s, t) => s in r ? d(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
|
|
3
|
+
var c = (r, s, t) => h(r, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
+
import { UEAttr as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as g } from "../../../common-control.js";
|
|
6
6
|
import { RecommendationConfigService as n } from "../../services/configService.js";
|
|
7
7
|
import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
|
|
8
|
-
import { mapLegacyStrategy as
|
|
9
|
-
const
|
|
8
|
+
import { mapLegacyStrategy as u } from "../../utils/legacyStrategyMap.js";
|
|
9
|
+
const p = "recommendation-algorithm-control", i = {
|
|
10
10
|
ALGORITHM: "strategy",
|
|
11
11
|
PRODUCT_IDS: "productIds"
|
|
12
12
|
};
|
|
13
|
-
class R extends
|
|
13
|
+
class R extends g {
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...arguments);
|
|
16
16
|
// Store is used ONLY for API-fetched data (algorithms list), not for config
|
|
17
|
-
|
|
17
|
+
c(this, "store", m());
|
|
18
18
|
}
|
|
19
19
|
getId() {
|
|
20
|
-
return
|
|
20
|
+
return p;
|
|
21
21
|
}
|
|
22
22
|
getTemplate() {
|
|
23
23
|
return `
|
|
@@ -46,11 +46,10 @@ class R extends d {
|
|
|
46
46
|
super.onTemplateNodeUpdated(t), this._initializeSelectItems(), this._setFormValues();
|
|
47
47
|
}
|
|
48
48
|
_setFormValues() {
|
|
49
|
-
const t = n.getConfig(this.currentNode), e =
|
|
50
|
-
this._setProductIdsVisibility(e)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
49
|
+
const t = n.getConfig(this.currentNode), e = u(t.strategy) ?? t.strategy;
|
|
50
|
+
this._setProductIdsVisibility(e);
|
|
51
|
+
const o = { [i.ALGORITHM]: e }, a = t.productIds.join(",");
|
|
52
|
+
this.api.getValues()[i.PRODUCT_IDS] !== a && (o[i.PRODUCT_IDS] = a), this.api.updateValues(o);
|
|
54
53
|
}
|
|
55
54
|
_initializeSelectItems() {
|
|
56
55
|
var e;
|
|
@@ -59,35 +58,47 @@ class R extends d {
|
|
|
59
58
|
try {
|
|
60
59
|
this.api.setUIEAttribute(
|
|
61
60
|
i.ALGORITHM,
|
|
62
|
-
|
|
61
|
+
l.SELECTPICKER.items,
|
|
63
62
|
t
|
|
64
63
|
);
|
|
65
|
-
} catch (
|
|
66
|
-
console.warn("[AlgorithmControl] Failed to set algorithm options:",
|
|
64
|
+
} catch (o) {
|
|
65
|
+
console.warn("[AlgorithmControl] Failed to set algorithm options:", o);
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
_setProductIdsVisibility(t) {
|
|
70
|
-
const
|
|
71
|
-
this.api.setVisibility(i.PRODUCT_IDS,
|
|
69
|
+
const o = (t ?? n.getConfig(this.currentNode).strategy) === "manualMerchandising";
|
|
70
|
+
this.api.setVisibility(i.PRODUCT_IDS, o), this.api.setVisibility(`${i.PRODUCT_IDS}_label`, o);
|
|
72
71
|
}
|
|
73
72
|
_onAlgorithmChange(t) {
|
|
74
|
-
|
|
73
|
+
if (!this.currentNode)
|
|
74
|
+
return;
|
|
75
|
+
const e = n.getConfig(this.currentNode);
|
|
76
|
+
if (e.strategy === t) {
|
|
77
|
+
this.store.recommendationConfigs.strategy !== t && this.store.patchCurrentBlockConfig({ strategy: e.strategy, filters: e.filters });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
n.updateConfig(
|
|
75
81
|
this.api,
|
|
76
82
|
this.currentNode,
|
|
77
83
|
{ strategy: t },
|
|
78
84
|
`Changed algorithm to ${t}`
|
|
79
|
-
), this.store.patchCurrentBlockConfig({ strategy: t }), this._setProductIdsVisibility(t)
|
|
85
|
+
), this.store.patchCurrentBlockConfig({ strategy: t }), this._setProductIdsVisibility(t);
|
|
80
86
|
}
|
|
81
87
|
_onProductIdsChange(t) {
|
|
82
88
|
if (!this.currentNode)
|
|
83
89
|
return;
|
|
84
|
-
const e =
|
|
90
|
+
const e = n.getConfig(this.currentNode);
|
|
91
|
+
if (e.productIds.join(",") === t) {
|
|
92
|
+
this.store.recommendationConfigs.productIds.join(",") !== t && this.store.patchCurrentBlockConfig({ productIds: e.productIds, filters: e.filters });
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const o = t === "" ? [] : t.split(",");
|
|
85
96
|
n.updateConfig(
|
|
86
97
|
this.api,
|
|
87
98
|
this.currentNode,
|
|
88
|
-
{ productIds:
|
|
99
|
+
{ productIds: o },
|
|
89
100
|
"Updated product IDs"
|
|
90
|
-
), this.store.patchCurrentBlockConfig({ productIds:
|
|
101
|
+
), this.store.patchCurrentBlockConfig({ productIds: o });
|
|
91
102
|
}
|
|
92
103
|
_listenToFormUpdates() {
|
|
93
104
|
this.api.onValueChanged(i.ALGORITHM, (t) => {
|
|
@@ -98,6 +109,6 @@ class R extends d {
|
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
111
|
export {
|
|
101
|
-
|
|
112
|
+
p as ALGORITHM_CONTROL_ID,
|
|
102
113
|
R as AlgorithmControl
|
|
103
114
|
};
|
|
@@ -3,7 +3,7 @@ var p = (d, l, t) => l in d ? f(d, l, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var s = (d, l, t) => p(d, typeof l != "symbol" ? l + "" : l, t);
|
|
4
4
|
import { CommonControl as g } from "../../../common-control.js";
|
|
5
5
|
import { DEFAULT_NODE_CONFIG as c } from "../../constants/defaultConfig.js";
|
|
6
|
-
import { RecommendationConfigService as
|
|
6
|
+
import { RecommendationConfigService as h } from "../../services/configService.js";
|
|
7
7
|
import { useRecommendationExtensionStore as y } from "../../store/recommendation.js";
|
|
8
8
|
import { AlgorithmControl as N } from "./algorithm.js";
|
|
9
9
|
import { ALGORITHM_CONTROL_ID as tt } from "./algorithm.js";
|
|
@@ -17,15 +17,15 @@ import { LocaleControl as b } from "./locale.js";
|
|
|
17
17
|
import { LOCALE_CONTROL_ID as lt } from "./locale.js";
|
|
18
18
|
import { PricePlacementControl as T } from "./pricePlacement.js";
|
|
19
19
|
import { PRICE_PLACEMENT_CONTROL_ID as ut } from "./pricePlacement.js";
|
|
20
|
-
import { ProductCountControl as
|
|
21
|
-
import { PRODUCT_COUNT_CONTROL_ID as
|
|
22
|
-
import { ProductLayoutControl as
|
|
20
|
+
import { ProductCountControl as O } from "./productCount.js";
|
|
21
|
+
import { PRODUCT_COUNT_CONTROL_ID as ht } from "./productCount.js";
|
|
22
|
+
import { ProductLayoutControl as P } from "./productLayout.js";
|
|
23
23
|
import { PRODUCT_LAYOUT_CONTROL_ID as Ct } from "./productLayout.js";
|
|
24
|
-
import { ShuffleControl as
|
|
24
|
+
import { ShuffleControl as S } from "./shuffle.js";
|
|
25
25
|
import { SHUFFLE_CONTROL_ID as pt } from "./shuffle.js";
|
|
26
|
-
import { setCurrencyAttributes as
|
|
26
|
+
import { setCurrencyAttributes as L, getBlockElement as k, isPartnerManagedBlock as D, updateProductContentInPlace as E, regenerateProductRowsWithStyles as A } from "./utils.js";
|
|
27
27
|
import { adjustProductsToSize as yt, formatProductPrice as Nt, getCardComposition as Rt, getCurrentLayout as It, regenerateMobileProductRows as _t, updatePricesInPlace as bt, updateSingleProductContent as Tt } from "./utils.js";
|
|
28
|
-
import { useDebounceFn as
|
|
28
|
+
import { useDebounceFn as m } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
29
29
|
const v = "recommendation-id", w = "ui-elements-recommendation-block";
|
|
30
30
|
class Q extends g {
|
|
31
31
|
constructor() {
|
|
@@ -47,7 +47,7 @@ class Q extends g {
|
|
|
47
47
|
/**
|
|
48
48
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
49
49
|
*/
|
|
50
|
-
s(this, "_debouncedFetchProducts",
|
|
50
|
+
s(this, "_debouncedFetchProducts", m(() => {
|
|
51
51
|
this.store.fetchRecommendationProducts();
|
|
52
52
|
}, 500));
|
|
53
53
|
/**
|
|
@@ -61,7 +61,7 @@ class Q extends g {
|
|
|
61
61
|
* count. The store pads products to the configured size, so in-place only
|
|
62
62
|
* fails when the size actually changed.
|
|
63
63
|
*/
|
|
64
|
-
s(this, "_debouncedRegenerateWithProducts",
|
|
64
|
+
s(this, "_debouncedRegenerateWithProducts", m(() => {
|
|
65
65
|
const t = this.store.recommendationProducts;
|
|
66
66
|
if (!this.currentNode || !this.api || D(this.currentNode))
|
|
67
67
|
return;
|
|
@@ -81,7 +81,7 @@ class Q extends g {
|
|
|
81
81
|
return w;
|
|
82
82
|
}
|
|
83
83
|
getTemplate() {
|
|
84
|
-
return this.algorithmControl = new N(), this.localeControl = new b(), this.currencyControl = new R(), this.productCountControl = new
|
|
84
|
+
return this.algorithmControl = new N(), this.localeControl = new b(), this.currencyControl = new R(), this.productCountControl = new O(), this.productLayoutControl = new P(), this.filtersControl = new I(), this.shuffleControl = new S(), this.pricePlacementControl = new T(), this.layoutOrientationControl = new _(), [
|
|
85
85
|
this.algorithmControl,
|
|
86
86
|
this.localeControl,
|
|
87
87
|
this.currencyControl,
|
|
@@ -186,7 +186,7 @@ class Q extends g {
|
|
|
186
186
|
*/
|
|
187
187
|
_syncNodeConfigToStore() {
|
|
188
188
|
var r;
|
|
189
|
-
const t =
|
|
189
|
+
const t = h.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
|
|
190
190
|
this.store.patchCurrentBlockConfig({
|
|
191
191
|
strategy: t.strategy,
|
|
192
192
|
language: t.language,
|
|
@@ -249,7 +249,7 @@ class Q extends g {
|
|
|
249
249
|
_applySmartDefaults() {
|
|
250
250
|
if (!this.currentNode || !this.api)
|
|
251
251
|
return;
|
|
252
|
-
const t =
|
|
252
|
+
const t = h.getConfig(this.currentNode), e = {};
|
|
253
253
|
let o = null, r = null, n = null;
|
|
254
254
|
if (t.currency.code === c.currency.code) {
|
|
255
255
|
const { currencyList: i } = this.store;
|
|
@@ -273,12 +273,12 @@ class Q extends g {
|
|
|
273
273
|
(u) => u.value === c.language
|
|
274
274
|
) || (n = i[0].value, e.language = n));
|
|
275
275
|
}
|
|
276
|
-
!o && !r && !n || (
|
|
276
|
+
!o && !r && !n || (h.updateConfig(
|
|
277
277
|
this.api,
|
|
278
278
|
this.currentNode,
|
|
279
279
|
e,
|
|
280
280
|
"Applied smart defaults"
|
|
281
|
-
), o && e.currency &&
|
|
281
|
+
), o && e.currency && L({
|
|
282
282
|
currentNode: this.currentNode,
|
|
283
283
|
documentModifier: this.api.getDocumentModifier(),
|
|
284
284
|
currency: e.currency
|
|
@@ -346,8 +346,8 @@ class Q extends g {
|
|
|
346
346
|
_persistFiltersToNodeConfig() {
|
|
347
347
|
if (!this.currentNode || !this.api)
|
|
348
348
|
return;
|
|
349
|
-
const { filters: t } = this.store.recommendationConfigs;
|
|
350
|
-
|
|
349
|
+
const { filters: t } = this.store.recommendationConfigs, e = h.getConfig(this.currentNode).filters;
|
|
350
|
+
JSON.stringify(e) !== JSON.stringify(t) && h.updateConfig(
|
|
351
351
|
this.api,
|
|
352
352
|
this.currentNode,
|
|
353
353
|
{ filters: t },
|
|
@@ -368,14 +368,14 @@ export {
|
|
|
368
368
|
_ as LayoutOrientationControl,
|
|
369
369
|
b as LocaleControl,
|
|
370
370
|
ut as PRICE_PLACEMENT_CONTROL_ID,
|
|
371
|
-
|
|
371
|
+
ht as PRODUCT_COUNT_CONTROL_ID,
|
|
372
372
|
Ct as PRODUCT_LAYOUT_CONTROL_ID,
|
|
373
373
|
T as PricePlacementControl,
|
|
374
|
-
|
|
375
|
-
|
|
374
|
+
O as ProductCountControl,
|
|
375
|
+
P as ProductLayoutControl,
|
|
376
376
|
Q as RecommendationBlockControl,
|
|
377
377
|
pt as SHUFFLE_CONTROL_ID,
|
|
378
|
-
|
|
378
|
+
S as ShuffleControl,
|
|
379
379
|
yt as adjustProductsToSize,
|
|
380
380
|
Nt as formatProductPrice,
|
|
381
381
|
k as getBlockElement,
|
|
@@ -384,7 +384,7 @@ export {
|
|
|
384
384
|
D as isPartnerManagedBlock,
|
|
385
385
|
_t as regenerateMobileProductRows,
|
|
386
386
|
A as regenerateProductRowsWithStyles,
|
|
387
|
-
|
|
387
|
+
L as setCurrencyAttributes,
|
|
388
388
|
bt as updatePricesInPlace,
|
|
389
389
|
E as updateProductContentInPlace,
|
|
390
390
|
Tt as updateSingleProductContent
|