@useinsider/guido 3.7.2-beta.a114aa7 → 3.7.2-beta.aa197be
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/useHtmlValidator.js +133 -180
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +27 -28
- package/dist/config/migrator/recommendation/extractors.js +22 -44
- package/dist/config/migrator/recommendation/htmlBuilder.js +169 -175
- package/dist/config/migrator/recommendationMigrator.js +31 -30
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -21
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +41 -55
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +42 -43
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +33 -44
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +2 -3
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +49 -59
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +82 -89
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +6 -7
- package/dist/extensions/Blocks/Recommendation/extension.js +5 -6
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +2 -3
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +2 -3
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +12 -13
- package/dist/extensions/Blocks/Recommendation/templates/index.js +4 -5
- package/dist/src/composables/useHtmlValidator.d.ts +0 -27
- package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -15
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +0 -8
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -21
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -9
- package/package.json +1 -1
- package/dist/config/compiler/utils/recommendationIgnoreUtils.js +0 -15
- package/dist/src/composables/useHtmlValidator.test.d.ts +0 -1
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +0 -17
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +0 -1
|
@@ -1,40 +1,36 @@
|
|
|
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
|
|
3
|
+
import { CURRENCY_ATTR as g, MOBILE_CONTAINER_SELECTOR as q, MOBILE_ROW_SELECTOR as k, DESKTOP_CONTAINER_SELECTOR as P, CONTAINER_SELECTOR as v, ATTR_PRODUCT_ATTR as j } from "../../constants/selectors.js";
|
|
4
4
|
import { RecommendationConfigService as b } from "../../services/configService.js";
|
|
5
5
|
import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
|
|
6
|
-
import { prepareProductRows as
|
|
7
|
-
import { formatPrice as
|
|
8
|
-
import { isTdNode as
|
|
9
|
-
import { getDefaultProducts as L, DEFAULT_CARD_COMPOSITION as
|
|
10
|
-
const
|
|
11
|
-
function
|
|
6
|
+
import { prepareProductRows as _ } from "../../templates/index.js";
|
|
7
|
+
import { formatPrice as V } from "../../utils/priceFormatter.js";
|
|
8
|
+
import { isTdNode as W } from "../../utils/tagName.js";
|
|
9
|
+
import { getDefaultProducts as L, DEFAULT_CARD_COMPOSITION as T, sanitizeImageUrl as F, toDisplayableAttributeValue as G } from "../../templates/utils.js";
|
|
10
|
+
const h = "recommendation-block-v2";
|
|
11
|
+
function R(t) {
|
|
12
12
|
if (!t)
|
|
13
13
|
return null;
|
|
14
14
|
if ("getAttribute" in t) {
|
|
15
15
|
const e = t.getAttribute("class");
|
|
16
|
-
if (e && e.includes(
|
|
16
|
+
if (e && e.includes(h))
|
|
17
17
|
return t;
|
|
18
18
|
}
|
|
19
|
-
return "querySelector" in t ? t.querySelector(`.${
|
|
20
|
-
}
|
|
21
|
-
function Y(t) {
|
|
22
|
-
const e = A(t);
|
|
23
|
-
return !e || !("getAttribute" in e) ? !1 : (e.getAttribute("class") ?? "").split(/\s+/).includes(v);
|
|
19
|
+
return "querySelector" in t ? t.querySelector(`.${h}`) ?? null : null;
|
|
24
20
|
}
|
|
25
21
|
function E(t) {
|
|
26
|
-
const e =
|
|
22
|
+
const e = R(t);
|
|
27
23
|
if (!e || !("getAttribute" in e))
|
|
28
24
|
return "grid";
|
|
29
25
|
const o = e.getAttribute("data-layout");
|
|
30
26
|
return o === "list" || o === "horizontal" ? "list" : "grid";
|
|
31
27
|
}
|
|
32
28
|
function H(t) {
|
|
33
|
-
const e =
|
|
29
|
+
const e = R(t);
|
|
34
30
|
if (!e || !("getAttribute" in e))
|
|
35
|
-
return
|
|
31
|
+
return T;
|
|
36
32
|
const o = e.getAttribute("data-card-composition");
|
|
37
|
-
return o ? o.split(",").filter(Boolean) :
|
|
33
|
+
return o ? o.split(",").filter(Boolean) : T;
|
|
38
34
|
}
|
|
39
35
|
function x(t) {
|
|
40
36
|
if (!t || !("childNodes" in t))
|
|
@@ -44,35 +40,35 @@ function x(t) {
|
|
|
44
40
|
);
|
|
45
41
|
return o || e.reduce((n, r) => n || !("getType" in r) || r.getType() === "text" ? n : x(r), null);
|
|
46
42
|
}
|
|
47
|
-
function
|
|
43
|
+
function S(t, e, o) {
|
|
48
44
|
const n = x(e);
|
|
49
45
|
return n ? (t.modifyHtml(n).setText(o), !0) : !1;
|
|
50
46
|
}
|
|
51
47
|
function D(t, e) {
|
|
52
48
|
return t && t.length > 0 ? t : e.length > 0 ? e : L();
|
|
53
49
|
}
|
|
54
|
-
function
|
|
50
|
+
function Y(t) {
|
|
55
51
|
const { currentNode: e, documentModifier: o } = t;
|
|
56
52
|
if (!e || !("querySelector" in e))
|
|
57
53
|
return;
|
|
58
|
-
const n = e.querySelector(
|
|
54
|
+
const n = e.querySelector(k);
|
|
59
55
|
n && (o.modifyHtml(n).setInnerHtml(""), o.apply(new p("Cleared mobile row content")));
|
|
60
56
|
}
|
|
61
|
-
function
|
|
57
|
+
function K(t) {
|
|
62
58
|
return "getOuterHTML" in t && typeof t.getOuterHTML == "function" ? t.getOuterHTML() : "";
|
|
63
59
|
}
|
|
64
|
-
function
|
|
60
|
+
function X(t) {
|
|
65
61
|
const e = t.querySelector(".container");
|
|
66
62
|
return !e || !("childNodes" in e) ? null : e.childNodes().find((n) => "getTagName" in n && n.getTagName() === "tbody") ?? e.querySelector("tbody") ?? null;
|
|
67
63
|
}
|
|
68
|
-
function
|
|
69
|
-
const n =
|
|
64
|
+
function z(t, e, o) {
|
|
65
|
+
const n = X(t);
|
|
70
66
|
if (!n || !("childNodes" in n))
|
|
71
67
|
return;
|
|
72
|
-
const r = n.childNodes().map(
|
|
68
|
+
const r = n.childNodes().map(K).join(""), l = `<tr class="ins-recommendation-mobile-row">${o}</tr>`;
|
|
73
69
|
e.modifyHtml(n).setInnerHtml(r + l), e.apply(new p("Added mobile product row"));
|
|
74
70
|
}
|
|
75
|
-
function
|
|
71
|
+
function J(t) {
|
|
76
72
|
const {
|
|
77
73
|
currentNode: e,
|
|
78
74
|
documentModifier: o,
|
|
@@ -84,21 +80,21 @@ function Z(t) {
|
|
|
84
80
|
return;
|
|
85
81
|
const i = r ?? E(e), s = b.getConfig(e);
|
|
86
82
|
if (i === "list" || !s.mobileLayoutEnabled) {
|
|
87
|
-
|
|
83
|
+
Y({ currentNode: e, documentModifier: o });
|
|
88
84
|
return;
|
|
89
85
|
}
|
|
90
|
-
const u = C(), c = D(n, u.recommendationProducts), d = l ?? H(e), a = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${
|
|
86
|
+
const u = C(), c = D(n, u.recommendationProducts), d = l ?? H(e), a = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${_(c, i, {
|
|
91
87
|
productsPerRow: s.mobileCardsInRow,
|
|
92
88
|
composition: d,
|
|
93
89
|
filterList: u.filterList
|
|
94
|
-
})}</table></td>`, y = e.querySelector(
|
|
90
|
+
})}</table></td>`, y = e.querySelector(k);
|
|
95
91
|
if (!y) {
|
|
96
|
-
|
|
92
|
+
z(e, o, a);
|
|
97
93
|
return;
|
|
98
94
|
}
|
|
99
95
|
o.modifyHtml(y).setInnerHtml(a), o.apply(new p("Updated mobile product rows"));
|
|
100
96
|
}
|
|
101
|
-
function
|
|
97
|
+
function Q(t) {
|
|
102
98
|
const {
|
|
103
99
|
currentNode: e,
|
|
104
100
|
documentModifier: o,
|
|
@@ -109,17 +105,17 @@ function ee(t) {
|
|
|
109
105
|
} = t;
|
|
110
106
|
if (!e || !("querySelector" in e))
|
|
111
107
|
return;
|
|
112
|
-
const s = e.querySelector(
|
|
108
|
+
const s = e.querySelector(P) ?? e.querySelector(v);
|
|
113
109
|
if (!s)
|
|
114
110
|
return;
|
|
115
|
-
const u = C(), c = D(r, u.recommendationProducts), { cardsInRow: d } = b.getConfig(e), f = i ?? H(e), a = l ?? E(e), y =
|
|
111
|
+
const u = C(), c = D(r, u.recommendationProducts), { cardsInRow: d } = b.getConfig(e), f = i ?? H(e), a = l ?? E(e), y = _(c, a, {
|
|
116
112
|
productsPerRow: d,
|
|
117
113
|
composition: f,
|
|
118
114
|
filterList: u.filterList
|
|
119
115
|
});
|
|
120
|
-
o.modifyHtml(s).setInnerHtml(y).apply(new p("Updated product")),
|
|
116
|
+
o.modifyHtml(s).setInnerHtml(y).apply(new p("Updated product")), J(t), n == null || n();
|
|
121
117
|
}
|
|
122
|
-
function
|
|
118
|
+
function M(t, e, o, n) {
|
|
123
119
|
const l = `0 ${Math.floor(o / 2)}px`;
|
|
124
120
|
let i = !1;
|
|
125
121
|
return n === "grid" ? Array.from(
|
|
@@ -130,7 +126,7 @@ function h(t, e, o, n) {
|
|
|
130
126
|
t.querySelectorAll(".product-card-wrapper")
|
|
131
127
|
).forEach((u) => {
|
|
132
128
|
const c = "parentNode" in u ? u.parentNode : null;
|
|
133
|
-
c &&
|
|
129
|
+
c && W(c) && (e.modifyHtml(c).setStyle("padding", l), i = !0);
|
|
134
130
|
}), i;
|
|
135
131
|
}
|
|
136
132
|
function I(t, e, o) {
|
|
@@ -140,15 +136,15 @@ function I(t, e, o) {
|
|
|
140
136
|
e.modifyHtml(i).setStyle("height", n), l = !0;
|
|
141
137
|
}), l;
|
|
142
138
|
}
|
|
143
|
-
function
|
|
139
|
+
function Z(t) {
|
|
144
140
|
const { currentNode: e, documentModifier: o } = t;
|
|
145
141
|
if (!e)
|
|
146
142
|
return;
|
|
147
143
|
const n = b.getConfig(e), r = E(e);
|
|
148
144
|
let l = !1;
|
|
149
|
-
const i = e.querySelector(
|
|
145
|
+
const i = e.querySelector(P);
|
|
150
146
|
if (i) {
|
|
151
|
-
l =
|
|
147
|
+
l = M(
|
|
152
148
|
i,
|
|
153
149
|
o,
|
|
154
150
|
n.columnSpacing,
|
|
@@ -161,9 +157,9 @@ function te(t) {
|
|
|
161
157
|
);
|
|
162
158
|
l = l || c;
|
|
163
159
|
}
|
|
164
|
-
const s = e.querySelector(
|
|
160
|
+
const s = e.querySelector(q);
|
|
165
161
|
if (s) {
|
|
166
|
-
const u =
|
|
162
|
+
const u = M(
|
|
167
163
|
s,
|
|
168
164
|
o,
|
|
169
165
|
n.mobileColumnSpacing,
|
|
@@ -179,9 +175,9 @@ function te(t) {
|
|
|
179
175
|
}
|
|
180
176
|
l && o.apply(new p("Reapply spacing after regeneration"));
|
|
181
177
|
}
|
|
182
|
-
function
|
|
178
|
+
function me(t) {
|
|
183
179
|
const { currentNode: e, documentModifier: o, afterRegenerate: n, products: r, layout: l, composition: i } = t;
|
|
184
|
-
e &&
|
|
180
|
+
e && Q({
|
|
185
181
|
currentNode: e,
|
|
186
182
|
documentModifier: o,
|
|
187
183
|
products: r,
|
|
@@ -189,12 +185,12 @@ function ye(t) {
|
|
|
189
185
|
composition: i,
|
|
190
186
|
afterRegenerate: () => {
|
|
191
187
|
setTimeout(() => {
|
|
192
|
-
|
|
188
|
+
Z({ currentNode: e, documentModifier: o });
|
|
193
189
|
}, 0), n == null || n();
|
|
194
190
|
}
|
|
195
191
|
});
|
|
196
192
|
}
|
|
197
|
-
function
|
|
193
|
+
function pe(t, e) {
|
|
198
194
|
return t.length === e ? t : t.length > e ? t.slice(0, e) : [...t, ...L(e - t.length)];
|
|
199
195
|
}
|
|
200
196
|
function U() {
|
|
@@ -208,14 +204,14 @@ function U() {
|
|
|
208
204
|
thousandSeparator: e.thousandSeparator
|
|
209
205
|
};
|
|
210
206
|
}
|
|
211
|
-
function
|
|
207
|
+
function A(t, e = "price") {
|
|
212
208
|
const o = U(), n = t[e], r = (n == null ? void 0 : n[o.code]) ?? Object.values(n ?? {})[0] ?? 0;
|
|
213
|
-
return
|
|
209
|
+
return V({
|
|
214
210
|
price: r,
|
|
215
211
|
currency: o
|
|
216
212
|
});
|
|
217
213
|
}
|
|
218
|
-
function
|
|
214
|
+
function ee(t) {
|
|
219
215
|
var l, i;
|
|
220
216
|
const e = U(), o = ((l = t.original_price) == null ? void 0 : l[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, n = ((i = t.price) == null ? void 0 : i[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, r = o > 0 ? Math.round((o - n) / o * 100) : 0;
|
|
221
217
|
return r > 0 ? `-${r}%` : "0%";
|
|
@@ -224,24 +220,24 @@ function $(t) {
|
|
|
224
220
|
const { documentModifier: e, product: o, priceEl: n, oldPriceEl: r, omnibusPriceEl: l, omnibusDiscountEl: i } = t;
|
|
225
221
|
let s = !1;
|
|
226
222
|
if (n && "querySelector" in n) {
|
|
227
|
-
const u = n.querySelector("strong") ?? n.querySelector("p"), c =
|
|
228
|
-
|
|
223
|
+
const u = n.querySelector("strong") ?? n.querySelector("p"), c = A(o, "price");
|
|
224
|
+
S(e, u ?? null, c) && (s = !0);
|
|
229
225
|
}
|
|
230
226
|
if (r && "querySelector" in r) {
|
|
231
|
-
const u = r.querySelector("strong") ?? r.querySelector("p"), c =
|
|
232
|
-
|
|
227
|
+
const u = r.querySelector("strong") ?? r.querySelector("p"), c = A(o, "original_price");
|
|
228
|
+
S(e, u ?? null, c) && (s = !0);
|
|
233
229
|
}
|
|
234
230
|
if (l && "querySelector" in l) {
|
|
235
|
-
const u = l.querySelector(".omnibus-price-value") ?? null, c =
|
|
236
|
-
|
|
231
|
+
const u = l.querySelector(".omnibus-price-value") ?? null, c = A(o, "original_price");
|
|
232
|
+
S(e, u, c) && (s = !0);
|
|
237
233
|
}
|
|
238
234
|
if (i && "querySelector" in i) {
|
|
239
|
-
const u = i.querySelector(".omnibus-discount-value") ?? null, c =
|
|
240
|
-
|
|
235
|
+
const u = i.querySelector(".omnibus-discount-value") ?? null, c = ee(o);
|
|
236
|
+
S(e, u, c) && (s = !0);
|
|
241
237
|
}
|
|
242
238
|
return s;
|
|
243
239
|
}
|
|
244
|
-
function
|
|
240
|
+
function te(t) {
|
|
245
241
|
const {
|
|
246
242
|
documentModifier: e,
|
|
247
243
|
product: o,
|
|
@@ -256,13 +252,13 @@ function ne(t) {
|
|
|
256
252
|
let d = !1;
|
|
257
253
|
if (n && "querySelector" in n) {
|
|
258
254
|
const f = n.querySelector("img");
|
|
259
|
-
f && (e.modifyHtml(f).setAttribute("src",
|
|
255
|
+
f && (e.modifyHtml(f).setAttribute("src", F(o.image_url)).setAttribute("alt", o.name), d = !0);
|
|
260
256
|
const a = n.querySelector("a");
|
|
261
257
|
a && (e.modifyHtml(a).setAttribute("href", o.url), d = !0);
|
|
262
258
|
}
|
|
263
259
|
if (r && "querySelector" in r) {
|
|
264
260
|
const f = r.querySelector("strong") ?? r.querySelector("p");
|
|
265
|
-
|
|
261
|
+
S(e, f ?? null, o.name) && (d = !0);
|
|
266
262
|
}
|
|
267
263
|
if ($({
|
|
268
264
|
documentModifier: e,
|
|
@@ -278,10 +274,10 @@ function ne(t) {
|
|
|
278
274
|
return d;
|
|
279
275
|
}
|
|
280
276
|
function B(t) {
|
|
281
|
-
return "querySelector" in t ? t.querySelector(
|
|
277
|
+
return "querySelector" in t ? t.querySelector(P) ?? t : t;
|
|
282
278
|
}
|
|
283
279
|
const O = "product_attribute.";
|
|
284
|
-
function
|
|
280
|
+
function oe(t, e) {
|
|
285
281
|
var n;
|
|
286
282
|
let o;
|
|
287
283
|
if (t.startsWith(O)) {
|
|
@@ -289,9 +285,9 @@ function re(t, e) {
|
|
|
289
285
|
o = (n = e.product_attributes) == null ? void 0 : n[r];
|
|
290
286
|
} else
|
|
291
287
|
o = e[t];
|
|
292
|
-
return
|
|
288
|
+
return G(o) || null;
|
|
293
289
|
}
|
|
294
|
-
function
|
|
290
|
+
function ne(t, e, o) {
|
|
295
291
|
if (!("querySelectorAll" in t))
|
|
296
292
|
return !1;
|
|
297
293
|
const n = t.querySelectorAll(
|
|
@@ -303,7 +299,7 @@ function ie(t, e, o) {
|
|
|
303
299
|
n.forEach((i) => {
|
|
304
300
|
if (!("getAttribute" in i))
|
|
305
301
|
return;
|
|
306
|
-
const s = i.getAttribute(
|
|
302
|
+
const s = i.getAttribute(j);
|
|
307
303
|
if (!s)
|
|
308
304
|
return;
|
|
309
305
|
const u = r.get(s) ?? [];
|
|
@@ -315,11 +311,11 @@ function ie(t, e, o) {
|
|
|
315
311
|
i.slice(0, u).forEach((c, d) => {
|
|
316
312
|
if (!("querySelector" in c))
|
|
317
313
|
return;
|
|
318
|
-
const f =
|
|
314
|
+
const f = oe(s, o[d]);
|
|
319
315
|
if (f === null)
|
|
320
316
|
return;
|
|
321
317
|
const a = c.querySelector("p") ?? null;
|
|
322
|
-
|
|
318
|
+
S(e, a, f) && (l = !0);
|
|
323
319
|
});
|
|
324
320
|
}), l;
|
|
325
321
|
}
|
|
@@ -343,7 +339,7 @@ function w(t, e, o) {
|
|
|
343
339
|
), d = Math.min(n.length, o.length);
|
|
344
340
|
let f = !1;
|
|
345
341
|
for (let a = 0; a < d; a++) {
|
|
346
|
-
const y =
|
|
342
|
+
const y = te({
|
|
347
343
|
documentModifier: e,
|
|
348
344
|
product: o[a],
|
|
349
345
|
imageEl: n[a] ?? null,
|
|
@@ -356,9 +352,9 @@ function w(t, e, o) {
|
|
|
356
352
|
});
|
|
357
353
|
f = f || y;
|
|
358
354
|
}
|
|
359
|
-
return
|
|
355
|
+
return ne(t, e, o) && (f = !0), f;
|
|
360
356
|
}
|
|
361
|
-
function
|
|
357
|
+
function ye(t) {
|
|
362
358
|
const { currentNode: e, documentModifier: o, products: n } = t;
|
|
363
359
|
if (!e || !("querySelectorAll" in e))
|
|
364
360
|
return !1;
|
|
@@ -370,7 +366,7 @@ function ge(t) {
|
|
|
370
366
|
let i = w(r, o, n);
|
|
371
367
|
const s = E(e), u = b.getConfig(e);
|
|
372
368
|
if (s !== "list" && u.mobileLayoutEnabled && "querySelector" in e) {
|
|
373
|
-
const c = e.querySelector(
|
|
369
|
+
const c = e.querySelector(q);
|
|
374
370
|
if (c) {
|
|
375
371
|
const d = w(
|
|
376
372
|
c,
|
|
@@ -406,12 +402,10 @@ function N(t, e, o) {
|
|
|
406
402
|
}) && (u = !0);
|
|
407
403
|
return u;
|
|
408
404
|
}
|
|
409
|
-
function
|
|
405
|
+
function ge(t) {
|
|
410
406
|
const { currentNode: e, documentModifier: o } = t;
|
|
411
407
|
if (!e || !("querySelectorAll" in e))
|
|
412
408
|
return !1;
|
|
413
|
-
if (Y(e))
|
|
414
|
-
return !0;
|
|
415
409
|
const r = C().recommendationProducts;
|
|
416
410
|
if (r.length === 0)
|
|
417
411
|
return !1;
|
|
@@ -419,7 +413,7 @@ function be(t) {
|
|
|
419
413
|
let i = N(l, o, r);
|
|
420
414
|
const s = E(e), u = b.getConfig(e);
|
|
421
415
|
if (s !== "list" && u.mobileLayoutEnabled && "querySelector" in e) {
|
|
422
|
-
const c = e.querySelector(
|
|
416
|
+
const c = e.querySelector(q);
|
|
423
417
|
if (c) {
|
|
424
418
|
const d = N(c, o, r);
|
|
425
419
|
i = i || d;
|
|
@@ -427,28 +421,27 @@ function be(t) {
|
|
|
427
421
|
}
|
|
428
422
|
return i && o.apply(new p("Updated price formatting in-place")), i;
|
|
429
423
|
}
|
|
430
|
-
function
|
|
431
|
-
const { currentNode: e, documentModifier: o, currency: n } = t, r =
|
|
424
|
+
function Se(t) {
|
|
425
|
+
const { currentNode: e, documentModifier: o, currency: n } = t, r = R(e);
|
|
432
426
|
if (!r)
|
|
433
427
|
return;
|
|
434
428
|
const l = n.alignment === "before" ? "0" : "1", i = (s, u) => {
|
|
435
429
|
o.modifyHtml(r).setAttribute(s, u);
|
|
436
430
|
};
|
|
437
|
-
i(
|
|
431
|
+
i(g.CURRENCY, n.code), i(g.SYMBOL, n.symbol), i(g.ALIGNMENT, l), i(g.THOUSAND_SEPARATOR, n.thousandSeparator), i(g.DECIMAL_SEPARATOR, n.decimalSeparator), i(g.DECIMAL_COUNT, n.decimalCount.toString()), o.apply(new p("Update currency attributes"));
|
|
438
432
|
}
|
|
439
433
|
export {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
434
|
+
pe as adjustProductsToSize,
|
|
435
|
+
A as formatProductPrice,
|
|
436
|
+
R as getBlockElement,
|
|
443
437
|
H as getCardComposition,
|
|
444
438
|
E as getCurrentLayout,
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
ne as updateSingleProductContent
|
|
439
|
+
Z as reapplySpacing,
|
|
440
|
+
J as regenerateMobileProductRows,
|
|
441
|
+
Q as regenerateProductRows,
|
|
442
|
+
me as regenerateProductRowsWithStyles,
|
|
443
|
+
Se as setCurrencyAttributes,
|
|
444
|
+
ge as updatePricesInPlace,
|
|
445
|
+
ye as updateProductContentInPlace,
|
|
446
|
+
te as updateSingleProductContent
|
|
454
447
|
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var a = (o, e, t) =>
|
|
4
|
-
import { UIElementType as c, UEAttr as
|
|
2
|
+
var _ = (o, e, t) => e in o ? m(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var a = (o, e, t) => _(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { UIElementType as c, UEAttr as p } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as d } from "../../common-control.js";
|
|
6
6
|
import { RecommendationControlId as C } from "../constants/controlIds.js";
|
|
7
|
-
import "../constants/selectors.js";
|
|
8
7
|
const S = C.SYNC_INFO_MESSAGE, r = "sync-info-message", u = "Note that changes will be applied to all product cards in your recommendation block.";
|
|
9
|
-
class
|
|
8
|
+
class h extends d {
|
|
10
9
|
constructor() {
|
|
11
10
|
super(...arguments);
|
|
12
11
|
a(this, "_repositionedElement", null);
|
|
@@ -18,7 +17,7 @@ class O extends d {
|
|
|
18
17
|
return `
|
|
19
18
|
<div class="${r}">
|
|
20
19
|
<${c.ICON}
|
|
21
|
-
${
|
|
20
|
+
${p.ICON.src}="migration-info-icon"
|
|
22
21
|
class="${r}__icon">
|
|
23
22
|
</${c.ICON}>
|
|
24
23
|
<p class="${r}__text">
|
|
@@ -62,5 +61,5 @@ class O extends d {
|
|
|
62
61
|
}
|
|
63
62
|
export {
|
|
64
63
|
S as SYNC_INFO_MESSAGE_CONTROL_ID,
|
|
65
|
-
|
|
64
|
+
h as SyncInfoMessageControl
|
|
66
65
|
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { ExtensionBuilder as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { RecommendationBlock as m } from "./block.js";
|
|
3
3
|
import { RecommendationBlockControl as n } from "./controls/main/index.js";
|
|
4
|
-
import "./constants/selectors.js";
|
|
5
4
|
import "./store/recommendation.js";
|
|
6
5
|
import { NameControls as i } from "./controls/name/index.js";
|
|
7
6
|
import { PriceControls as e } from "./controls/price/index.js";
|
|
8
7
|
import { OldPriceControls as s } from "./controls/oldPrice/index.js";
|
|
9
8
|
import { OmnibusPriceControls as l } from "./controls/omnibusPrice/index.js";
|
|
10
|
-
import { OmnibusDiscountControls as
|
|
11
|
-
import { ButtonControls as
|
|
9
|
+
import { OmnibusDiscountControls as a } from "./controls/omnibusDiscount/index.js";
|
|
10
|
+
import { ButtonControls as p } from "./controls/button/index.js";
|
|
12
11
|
import { ImageControls as c } from "./controls/image/index.js";
|
|
13
12
|
import { CustomAttributeControls as C } from "./controls/customAttribute/index.js";
|
|
14
13
|
import { SpacingControl as f } from "./controls/spacing/index.js";
|
|
@@ -23,8 +22,8 @@ const b = [
|
|
|
23
22
|
e,
|
|
24
23
|
s,
|
|
25
24
|
l,
|
|
26
|
-
p,
|
|
27
25
|
a,
|
|
26
|
+
p,
|
|
28
27
|
c,
|
|
29
28
|
C
|
|
30
29
|
], P = [
|
|
@@ -36,10 +35,10 @@ const b = [
|
|
|
36
35
|
], S = [
|
|
37
36
|
...P,
|
|
38
37
|
...b.flatMap((o) => Object.values(o))
|
|
39
|
-
],
|
|
38
|
+
], K = S.reduce(
|
|
40
39
|
(o, t) => o.addControl(t),
|
|
41
40
|
new r().addBlock(m).withSettingsPanelRegistry(B)
|
|
42
41
|
).addStyles(y).withIconsRegistry(R).build();
|
|
43
42
|
export {
|
|
44
|
-
|
|
43
|
+
K as default
|
|
45
44
|
};
|
|
@@ -2,7 +2,6 @@ import { SettingsPanelRegistry as E, SettingsPanelTab as _, SettingsTab as O, Co
|
|
|
2
2
|
import { BLOCK_ID as U } from "./block.js";
|
|
3
3
|
import { RecommendationBlockId as S } from "./constants/blockIds.js";
|
|
4
4
|
import { RecommendationControlId as T } from "./constants/controlIds.js";
|
|
5
|
-
import "./constants/selectors.js";
|
|
6
5
|
import { CONTROL_BLOCK_ID as A } from "./controls/main/index.js";
|
|
7
6
|
import "./store/recommendation.js";
|
|
8
7
|
import "./controls/name/index.js";
|
|
@@ -16,7 +15,7 @@ import { SPACING_CONTROL_ID as L } from "./controls/spacing/index.js";
|
|
|
16
15
|
import { CARD_BACKGROUND_COLOR_CONTROL_ID as D } from "./controls/cardBackground/index.js";
|
|
17
16
|
import { COMPOSITION_CONTROL_BLOCK_ID as B } from "./controls/cardComposition/index.js";
|
|
18
17
|
import { SYNC_INFO_MESSAGE_CONTROL_ID as N } from "./controls/syncInfoMessage.js";
|
|
19
|
-
class
|
|
18
|
+
class Z extends E {
|
|
20
19
|
registerBlockControls(I) {
|
|
21
20
|
I[U] = [
|
|
22
21
|
new _(
|
|
@@ -195,5 +194,5 @@ class a extends E {
|
|
|
195
194
|
}
|
|
196
195
|
}
|
|
197
196
|
export {
|
|
198
|
-
|
|
197
|
+
Z as SettingsPanel
|
|
199
198
|
};
|
|
@@ -2,7 +2,6 @@ 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 "../constants/selectors.js";
|
|
6
5
|
import { DEFAULT_MOBILE_CARDS_IN_ROW as D, DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
|
|
7
6
|
import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
|
|
8
7
|
import { getDefaultProducts as S } from "../templates/utils.js";
|
|
@@ -61,7 +60,7 @@ const L = () => ({
|
|
|
61
60
|
blockStates: {},
|
|
62
61
|
currentRecommendationId: null,
|
|
63
62
|
configVersion: 0
|
|
64
|
-
}),
|
|
63
|
+
}), K = P("guidoRecommendationExtension", {
|
|
65
64
|
state: () => L(),
|
|
66
65
|
getters: {
|
|
67
66
|
// ====================================================================
|
|
@@ -477,5 +476,5 @@ const L = () => ({
|
|
|
477
476
|
}
|
|
478
477
|
});
|
|
479
478
|
export {
|
|
480
|
-
|
|
479
|
+
K as useRecommendationExtensionStore
|
|
481
480
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../../constants/selectors.js";
|
|
2
1
|
import { DEFAULT_PRODUCTS_PER_ROW as m } from "../../constants/layout.js";
|
|
3
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";
|
|
4
3
|
import { buildFillerCell as w, gridElementRenderer as A } from "./elementRenderer.js";
|
|
@@ -29,36 +28,36 @@ const D = `
|
|
|
29
28
|
</tr>
|
|
30
29
|
`;
|
|
31
30
|
function O(t, e, n, r = L, c = {}) {
|
|
32
|
-
const
|
|
33
|
-
return r.filter((o) =>
|
|
34
|
-
const
|
|
35
|
-
return C.replace("{-{-ATTR_TYPE-}-}", o).replace("{-{-VISIBILITY-}-}",
|
|
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);
|
|
36
35
|
}).join("");
|
|
37
36
|
}
|
|
38
37
|
function g(t, e, n, r, c = {}) {
|
|
39
|
-
const
|
|
38
|
+
const a = [];
|
|
40
39
|
for (let l = 0; l < t.length; l += e)
|
|
41
|
-
|
|
42
|
-
return
|
|
43
|
-
const
|
|
40
|
+
a.push(t.slice(l, l + e));
|
|
41
|
+
return a.map((l, i) => {
|
|
42
|
+
const d = O(
|
|
44
43
|
l,
|
|
45
44
|
e,
|
|
46
45
|
n,
|
|
47
46
|
r,
|
|
48
47
|
c
|
|
49
|
-
), o = D.replace("{-{-ATTRIBUTE_ROWS-}-}",
|
|
50
|
-
return
|
|
48
|
+
), o = D.replace("{-{-ATTRIBUTE_ROWS-}-}", d);
|
|
49
|
+
return i > 0 ? S + o : o;
|
|
51
50
|
}).join("");
|
|
52
51
|
}
|
|
53
52
|
function P(t, e, n, r = {}) {
|
|
54
53
|
return g(t, e, A, n, r);
|
|
55
54
|
}
|
|
56
|
-
function
|
|
55
|
+
function B(t) {
|
|
57
56
|
const e = t ? `ins-recommendation-v3-block-${t}` : void 0, n = E("grid", e), r = I(), c = P(r, m);
|
|
58
57
|
return n.replace("{-{-TITLE-}-}", b.TITLE).replace("{-{-PRODUCT_ROWS-}-}", c).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
|
|
59
58
|
}
|
|
60
59
|
export {
|
|
61
|
-
|
|
60
|
+
B as getDefaultTemplate,
|
|
62
61
|
O as prepareGridAttributeRows,
|
|
63
62
|
g as prepareGridProductRows,
|
|
64
63
|
P as prepareProductRows
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import "../constants/selectors.js";
|
|
2
1
|
import { DEFAULT_PRODUCTS_PER_ROW as s } from "../constants/layout.js";
|
|
3
2
|
import { prepareProductRows as c } from "./grid/template.js";
|
|
4
|
-
import { prepareProductRows as
|
|
5
|
-
function
|
|
3
|
+
import { prepareProductRows as R } from "./list/template.js";
|
|
4
|
+
function a(o, t, r = {}) {
|
|
6
5
|
if (t === "list")
|
|
7
|
-
return
|
|
6
|
+
return R(o, r.composition, r.filterList);
|
|
8
7
|
const { productsPerRow: e = s, composition: p, filterList: i } = r;
|
|
9
8
|
return c(o, e, p, i);
|
|
10
9
|
}
|
|
11
10
|
export {
|
|
12
|
-
|
|
11
|
+
a as prepareProductRows
|
|
13
12
|
};
|
|
@@ -1,31 +1,4 @@
|
|
|
1
1
|
import type { DynamicContent } from '@@/Types/generic';
|
|
2
|
-
import type { FiltersResponse } from '@@/Types/recommendation';
|
|
3
|
-
/**
|
|
4
|
-
* Parses a `{{recoId_index_attributeName}}` variable (already stripped of the
|
|
5
|
-
* braces/whitespace) into its recommendation id and attribute name. Returns
|
|
6
|
-
* null for anything that isn't a well-formed recommendation variable.
|
|
7
|
-
*/
|
|
8
|
-
export declare function parseRecommendationVariable(field: string): {
|
|
9
|
-
recoId: string;
|
|
10
|
-
attribute: string;
|
|
11
|
-
} | null;
|
|
12
|
-
/**
|
|
13
|
-
* Builds the set of attribute forms valid inside partner-authored
|
|
14
|
-
* `{{recoId_index_attribute}}` variables: the built-in compiler attributes plus
|
|
15
|
-
* each account attribute in its canonical token form — bare for
|
|
16
|
-
* `defaultAttribute`, `product_attribute.<name>` for `productAttribute`. Using
|
|
17
|
-
* `resolveProductAttrValue` (the same producer the block builder uses) keeps the
|
|
18
|
-
* validator's notion of "valid form" identical to what is actually emitted.
|
|
19
|
-
*/
|
|
20
|
-
export declare function buildPartnerAttributeNameSet(filterList: FiltersResponse): Set<string>;
|
|
21
|
-
/**
|
|
22
|
-
* Returns the `{{...}}` custom fields in the HTML that are invalid. Partner
|
|
23
|
-
* attributes in `ins-skip-compile` blocks (recoId ∈ ignoredIds) are checked
|
|
24
|
-
* against `ignoredAttributeNames`; Guido-generated reco variables and known merge
|
|
25
|
-
* tags pass. An unrecognized dotted token is ignored: it was never captured
|
|
26
|
-
* before, so flagging it would false-positive on merge tags like `{{user.name}}`.
|
|
27
|
-
*/
|
|
28
|
-
export declare function findInvalidCustomFields(html: string, validCustomFields: string[], recommendationBlockIds: string[], ignoredIds: Set<string>, ignoredAttributeNames: Set<string> | null): string[];
|
|
29
2
|
export declare const useHtmlValidator: () => {
|
|
30
3
|
validateHtml: (html: string, customFields: DynamicContent[], isOnSaveValidation?: boolean) => Promise<boolean>;
|
|
31
4
|
};
|
|
@@ -5,18 +5,3 @@ export declare function extractTitleText(block: Element): string;
|
|
|
5
5
|
* the caller treats that as "no segment background".
|
|
6
6
|
*/
|
|
7
7
|
export declare function extractCardBgColor(block: Element): string;
|
|
8
|
-
/**
|
|
9
|
-
* Reads the legacy block's own `currency-*` attributes into a
|
|
10
|
-
* `currencySettings`-shaped object that `mapCurrency` understands. Used as a
|
|
11
|
-
* fallback when the external recommendationConfigs map has no entry for this
|
|
12
|
-
* block, so the migrated block keeps its real currency instead of defaulting.
|
|
13
|
-
* Returns undefined when the block carries no `currency` attribute.
|
|
14
|
-
*/
|
|
15
|
-
export declare function extractCurrencyFromBlock(block: Element): Record<string, string> | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* True when a PM has manually opted the legacy block out of content
|
|
18
|
-
* regeneration by adding the `ins-skip-compile` class. Detected before rebuild
|
|
19
|
-
* so the migrator preserves the partner's markup verbatim (keeping their
|
|
20
|
-
* hand-authored variables) instead of regenerating the block.
|
|
21
|
-
*/
|
|
22
|
-
export declare function isPartnerManagedBlock(block: Element): boolean;
|