@useinsider/guido 3.6.0-beta.3eeb930 → 3.6.0-beta.7ac8612
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 +131 -102
- package/dist/composables/useRecommendation.js +33 -34
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +28 -27
- package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
- package/dist/config/migrator/recommendation/extractors.js +44 -22
- package/dist/config/migrator/recommendation/htmlBuilder.js +175 -169
- package/dist/config/migrator/recommendationMigrator.js +30 -31
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -15
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +38 -24
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +57 -52
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +45 -34
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +62 -52
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -67
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
- package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +10 -13
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -2
- package/dist/extensions/Blocks/Recommendation/templates/index.js +5 -4
- package/dist/src/composables/useHtmlValidator.d.ts +9 -0
- package/dist/src/composables/useHtmlValidator.test.d.ts +1 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +21 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -0
- package/package.json +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +0 -21
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerCustomizations.d.ts +0 -7
|
@@ -1,166 +1,195 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useConfig as H } from "./useConfig.js";
|
|
2
|
+
import { getIgnoredRecommendationBlockIds as G } from "../config/compiler/utils/recommendationIgnoreUtils.js";
|
|
3
|
+
import { TemplateTypes as P } from "../enums/defaults.js";
|
|
4
|
+
import { DISPLAY_CONDITIONS_REGEX as $, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as X, CampaignCouldNotBeSavedKey as j, CanNotMakeAnyChangesForRunningKey as q } from "../enums/html-validator.js";
|
|
4
5
|
import { ToasterTypeOptions as c } from "../enums/toaster.js";
|
|
5
|
-
import { itemsBlockDynamicVariables as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
import { itemsBlockDynamicVariables as U } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
7
|
+
import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as z } from "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
8
|
+
import { useRecommendationExtensionStore as K } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
9
|
+
import { RecommendationRequiredFieldsKey as Y } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
10
|
+
import { useRecommendationStore as Z } from "../stores/recommendation.js";
|
|
11
|
+
import { base64EncodeWithSpecialChars as J } from "../utils/base64.js";
|
|
12
|
+
import { useHttp as Q } from "./useHttp.js";
|
|
13
|
+
import { useToaster as ee } from "./useToaster.js";
|
|
14
|
+
import { useTranslations as te } from "./useTranslations.js";
|
|
15
|
+
const se = /recommendation-id="(\d+)"/g;
|
|
16
|
+
function ne(o) {
|
|
17
|
+
return [...o.matchAll(se)].map((d) => d[1]);
|
|
16
18
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
19
|
+
function oe(o, d) {
|
|
20
|
+
return d.some((g) => o.startsWith(`${g}_`));
|
|
19
21
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
const ie = /^(\d+)_\d+_(.+)$/;
|
|
23
|
+
function ae(o) {
|
|
24
|
+
const d = o.match(ie);
|
|
25
|
+
return d ? { recoId: d[1], attribute: d[2] } : null;
|
|
26
|
+
}
|
|
27
|
+
const we = () => {
|
|
28
|
+
var E, b;
|
|
29
|
+
const { showToaster: o } = ee(), { post: d } = Q(), { config: g } = H(), i = te(), v = Z(), p = K(), C = ((b = (E = g.value) == null ? void 0 : E.partner) == null ? void 0 : b.messageType) === P.transactional, w = async (e) => {
|
|
30
|
+
if (e.size === 0)
|
|
31
|
+
return /* @__PURE__ */ new Set();
|
|
32
|
+
try {
|
|
33
|
+
await p.fetchRecommendationFilters();
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const s = new Set(z);
|
|
38
|
+
return Object.values(p.filterList).forEach((t) => {
|
|
39
|
+
s.add(t.attributeName.toLowerCase());
|
|
40
|
+
}), s;
|
|
41
|
+
}, I = async (e) => {
|
|
42
|
+
const t = await d(
|
|
24
43
|
"/newsletter/template-library/check-template-html-body",
|
|
25
|
-
{ html:
|
|
26
|
-
), { status: n, message:
|
|
27
|
-
return n ||
|
|
44
|
+
{ html: J(e) }
|
|
45
|
+
), { status: n, message: r } = t.data;
|
|
46
|
+
return n || o({
|
|
28
47
|
type: c.Alert,
|
|
29
|
-
message: n === void 0 ?
|
|
30
|
-
}),
|
|
48
|
+
message: n === void 0 ? r : i("newsletter.invalid-url-link-for-toaster")
|
|
49
|
+
}), i(j), r === i(q) && o({
|
|
31
50
|
type: c.Alert,
|
|
32
|
-
message:
|
|
51
|
+
message: i("newsletter.already-in-progress")
|
|
33
52
|
}), n;
|
|
34
|
-
},
|
|
53
|
+
}, A = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), R = (e, s) => {
|
|
35
54
|
const t = e.match(/({%(.*?)%})/g);
|
|
36
55
|
let n = !0;
|
|
37
|
-
return t !== null && !
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const [
|
|
41
|
-
|
|
56
|
+
return t !== null && !C && t.forEach((r) => {
|
|
57
|
+
const a = r.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
58
|
+
if (a && a.length > 0) {
|
|
59
|
+
const [l] = a;
|
|
60
|
+
A(l) && !s.includes(l) && (o({
|
|
42
61
|
type: c.Warning,
|
|
43
|
-
message:
|
|
62
|
+
message: i("custom-fields.invalid-custom-fields")
|
|
44
63
|
}), n = !1);
|
|
45
64
|
}
|
|
46
65
|
}), n;
|
|
47
|
-
},
|
|
48
|
-
const n = t ? await
|
|
49
|
-
return
|
|
50
|
-
},
|
|
66
|
+
}, T = async (e, s, t) => {
|
|
67
|
+
const n = t ? await I(e) : !0;
|
|
68
|
+
return R(e, s) && n;
|
|
69
|
+
}, k = (e) => e.length > 0 ? !0 : (o({
|
|
51
70
|
type: c.Warning,
|
|
52
|
-
message:
|
|
53
|
-
}), !1),
|
|
71
|
+
message: i("newsletter.html-content-is-empty")
|
|
72
|
+
}), !1), x = (e) => {
|
|
54
73
|
const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
|
|
55
|
-
return s > t &&
|
|
74
|
+
return s > t && o({
|
|
56
75
|
type: c.Warning,
|
|
57
|
-
message:
|
|
58
|
-
}), s < t &&
|
|
76
|
+
message: i("custom-fields.missing-closing-braces")
|
|
77
|
+
}), s < t && o({
|
|
59
78
|
type: c.Warning,
|
|
60
|
-
message:
|
|
79
|
+
message: i("custom-fields.missing-opening-braces")
|
|
61
80
|
}), s === t;
|
|
62
|
-
},
|
|
81
|
+
}, N = (e) => {
|
|
63
82
|
const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
|
|
64
|
-
return s ||
|
|
83
|
+
return s || o({
|
|
65
84
|
type: c.Warning,
|
|
66
|
-
message:
|
|
85
|
+
message: i("custom-fields.invalid-custom-fields")
|
|
67
86
|
}), s;
|
|
68
|
-
},
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
const m =
|
|
74
|
-
(!
|
|
75
|
-
|
|
76
|
-
const
|
|
87
|
+
}, B = (e, s, t, n) => {
|
|
88
|
+
const r = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
|
|
89
|
+
if (r && !C) {
|
|
90
|
+
const a = new Set(s.map((u) => u.toLowerCase())), l = ne(e), f = [];
|
|
91
|
+
if (r.forEach((u) => {
|
|
92
|
+
const m = u.slice(2, -2).trim().toLowerCase();
|
|
93
|
+
if (!(!a.has(m) || m === ""))
|
|
94
|
+
return;
|
|
95
|
+
const y = ae(m);
|
|
96
|
+
if (y && t.has(y.recoId)) {
|
|
97
|
+
if (!n || n.has(y.attribute))
|
|
98
|
+
return;
|
|
99
|
+
f.push(m);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
oe(m, l) || f.push(m);
|
|
103
|
+
}), f.length > 0) {
|
|
104
|
+
const u = `
|
|
77
105
|
<ul>
|
|
78
|
-
${
|
|
106
|
+
${f.map((m) => `<li>${m}</li>`).join("")}
|
|
79
107
|
</ul>
|
|
80
108
|
`;
|
|
81
|
-
return
|
|
109
|
+
return o({
|
|
82
110
|
type: c.Alert,
|
|
83
|
-
message:
|
|
111
|
+
message: i("custom-fields.invalid-custom-fields") + u
|
|
84
112
|
}), !1;
|
|
85
113
|
}
|
|
86
114
|
}
|
|
87
115
|
return !0;
|
|
88
|
-
},
|
|
116
|
+
}, F = (e) => {
|
|
89
117
|
const s = e.match(/{%(.*?)%}/g), t = [];
|
|
90
118
|
let n = !0;
|
|
91
|
-
if (s && s.forEach((
|
|
92
|
-
const
|
|
93
|
-
(!
|
|
119
|
+
if (s && s.forEach((r) => {
|
|
120
|
+
const a = r.match($), l = r.match(X), f = (a == null ? void 0 : a.join("")) || "";
|
|
121
|
+
(!a || r !== f) && !l && (o({
|
|
94
122
|
type: c.Alert,
|
|
95
|
-
message:
|
|
96
|
-
}), n = !1),
|
|
97
|
-
|
|
123
|
+
message: i("newsletter.display-conditions-invalid-syntax")
|
|
124
|
+
}), n = !1), a && a.forEach((u) => {
|
|
125
|
+
u.trim() === "=" && (o({
|
|
98
126
|
type: c.Alert,
|
|
99
|
-
message:
|
|
127
|
+
message: i("custom-conditions.wrong-equality-operators")
|
|
100
128
|
}), n = !1);
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
129
|
+
const m = u.match(/^[a-zA-Z]*$/g);
|
|
130
|
+
m && m.forEach((h) => {
|
|
131
|
+
S(h) && t.push(h);
|
|
104
132
|
});
|
|
105
133
|
});
|
|
106
134
|
}), t.length) {
|
|
107
|
-
const
|
|
108
|
-
|
|
135
|
+
const r = t.filter((l) => l === "if"), a = t.filter((l) => l === "endif");
|
|
136
|
+
r.length !== a.length && (o({
|
|
109
137
|
type: c.Alert,
|
|
110
|
-
message:
|
|
138
|
+
message: i("custom-conditions.missing-if-endif-tag")
|
|
111
139
|
}), n = !1);
|
|
112
140
|
}
|
|
113
141
|
return n;
|
|
114
|
-
},
|
|
142
|
+
}, O = (e) => {
|
|
115
143
|
const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
|
|
116
|
-
return n ||
|
|
144
|
+
return n || o({
|
|
117
145
|
type: c.Warning,
|
|
118
|
-
message:
|
|
146
|
+
message: i("custom-conditions.no-space-after-braces")
|
|
119
147
|
}), n;
|
|
120
|
-
},
|
|
148
|
+
}, _ = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (o({
|
|
121
149
|
type: c.Warning,
|
|
122
|
-
message:
|
|
123
|
-
}), !1) : !0,
|
|
150
|
+
message: i("custom-conditions.no-braces-inside-if-tag")
|
|
151
|
+
}), !1) : !0, L = () => p.hasInvalidBlock() ? (o({
|
|
124
152
|
type: c.Alert,
|
|
125
|
-
message:
|
|
126
|
-
}), !1) : !0,
|
|
153
|
+
message: i(Y)
|
|
154
|
+
}), !1) : !0, V = () => v.recommendationConfigs && Object.values(v.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (o({
|
|
127
155
|
type: c.Alert,
|
|
128
|
-
message:
|
|
129
|
-
}), !1) : !0,
|
|
156
|
+
message: i("newsletter.fill-all-necessary-fields")
|
|
157
|
+
}), !1) : !0, W = (e) => {
|
|
130
158
|
const s = /src="[^"]*\.(svg|pst)"/gm;
|
|
131
|
-
return e.match(s) === null ? !0 : (
|
|
159
|
+
return e.match(s) === null ? !0 : (o({
|
|
132
160
|
type: c.Alert,
|
|
133
|
-
message:
|
|
161
|
+
message: i("newsletter.invalid-image-type")
|
|
134
162
|
}), !1);
|
|
135
|
-
},
|
|
163
|
+
}, D = (e) => {
|
|
136
164
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
|
|
137
|
-
return Array.from(n).find((
|
|
138
|
-
var
|
|
139
|
-
return !((
|
|
140
|
-
}) ? (
|
|
165
|
+
return Array.from(n).find((a) => {
|
|
166
|
+
var l;
|
|
167
|
+
return !((l = a.id) != null && l.trim());
|
|
168
|
+
}) ? (o({
|
|
141
169
|
type: c.Alert,
|
|
142
|
-
message:
|
|
170
|
+
message: i("unsubscribe-templates.select-checkbox-groups")
|
|
143
171
|
}), !1) : !0;
|
|
144
|
-
},
|
|
172
|
+
}, M = (e) => {
|
|
145
173
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
|
|
146
|
-
return Array.from(n).find((
|
|
147
|
-
var
|
|
148
|
-
return !((
|
|
149
|
-
}) ? (
|
|
174
|
+
return Array.from(n).find((a) => {
|
|
175
|
+
var l;
|
|
176
|
+
return !((l = a.id) != null && l.trim());
|
|
177
|
+
}) ? (o({
|
|
150
178
|
type: c.Alert,
|
|
151
|
-
message:
|
|
179
|
+
message: i("unsubscribe-templates.select-radio-button-groups")
|
|
152
180
|
}), !1) : !0;
|
|
153
181
|
};
|
|
154
182
|
return { validateHtml: async (e, s, t = !1) => {
|
|
155
|
-
var
|
|
183
|
+
var f, u;
|
|
156
184
|
const n = [
|
|
157
185
|
...s.map((m) => m.value),
|
|
158
|
-
...
|
|
159
|
-
...((
|
|
160
|
-
];
|
|
161
|
-
return await
|
|
186
|
+
...U,
|
|
187
|
+
...((u = (f = g.value) == null ? void 0 : f.template) == null ? void 0 : u.customFieldAttributes) ?? []
|
|
188
|
+
], r = G(e), a = await w(r);
|
|
189
|
+
return await T(e, n, t) && k(e) && x(e) && N(e) && B(e, n, r, a) && F(e) && O(e) && _(e) && L() && V() && W(e) && D(e) && M(e);
|
|
162
190
|
} };
|
|
163
191
|
};
|
|
164
192
|
export {
|
|
165
|
-
|
|
193
|
+
ae as parseRecommendationVariable,
|
|
194
|
+
we as useHtmlValidator
|
|
166
195
|
};
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { getRecommendationFeedSourceMaps as I, URLS as
|
|
2
|
-
import { MinDeviceViewport as
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
1
|
+
import { getRecommendationFeedSourceMaps as I, URLS as C } from "../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
|
|
3
|
+
import { useRecommendationExtensionStore as m } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
4
|
import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
5
|
-
import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
|
|
6
5
|
import { useConfigStore as x } from "../stores/config.js";
|
|
7
|
-
const
|
|
6
|
+
const w = () => ({
|
|
8
7
|
calculateCardWidth: ({
|
|
9
|
-
mobileLeftPadding:
|
|
8
|
+
mobileLeftPadding: o,
|
|
10
9
|
mobileRightPadding: s,
|
|
11
|
-
cardsInRow:
|
|
12
|
-
unresponsive:
|
|
10
|
+
cardsInRow: a,
|
|
11
|
+
unresponsive: n
|
|
13
12
|
}) => {
|
|
14
|
-
const r =
|
|
15
|
-
return (
|
|
13
|
+
const r = n ? a : 1, e = o + s + (r - 1) * b;
|
|
14
|
+
return (R - e) / r;
|
|
16
15
|
},
|
|
17
|
-
getRecommendationCampaignData: (
|
|
18
|
-
const s =
|
|
19
|
-
if (!
|
|
16
|
+
getRecommendationCampaignData: (o) => {
|
|
17
|
+
const s = m(), a = Number(o), n = s.blockStates[a];
|
|
18
|
+
if (!n)
|
|
20
19
|
return {
|
|
21
20
|
textTrimming: !1,
|
|
22
21
|
orientation: "vertical",
|
|
@@ -29,7 +28,7 @@ const k = () => ({
|
|
|
29
28
|
discountBeforeTextValue: "",
|
|
30
29
|
discountAfterTextValue: ""
|
|
31
30
|
};
|
|
32
|
-
const { recommendationConfigs: r } =
|
|
31
|
+
const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
|
|
33
32
|
return {
|
|
34
33
|
textTrimming: r.textTrimming,
|
|
35
34
|
orientation: e,
|
|
@@ -43,35 +42,35 @@ const k = () => ({
|
|
|
43
42
|
discountAfterTextValue: ""
|
|
44
43
|
};
|
|
45
44
|
},
|
|
46
|
-
buildCampaignUrl: (
|
|
47
|
-
var
|
|
48
|
-
const
|
|
45
|
+
buildCampaignUrl: (o, s) => {
|
|
46
|
+
var l;
|
|
47
|
+
const a = m(), n = x(), r = Number(o);
|
|
49
48
|
let e;
|
|
50
49
|
if (s)
|
|
51
50
|
e = s;
|
|
52
51
|
else {
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
52
|
+
const c = a.blockStates[r];
|
|
53
|
+
if (!c)
|
|
55
54
|
return "";
|
|
56
|
-
const { recommendationConfigs:
|
|
55
|
+
const { recommendationConfigs: i } = c;
|
|
57
56
|
e = {
|
|
58
|
-
strategy:
|
|
59
|
-
language:
|
|
60
|
-
currencyCode:
|
|
61
|
-
size:
|
|
62
|
-
productIds:
|
|
63
|
-
filters:
|
|
64
|
-
shuffleProducts:
|
|
57
|
+
strategy: i.strategy,
|
|
58
|
+
language: i.language,
|
|
59
|
+
currencyCode: i.currencySettings.value,
|
|
60
|
+
size: i.size,
|
|
61
|
+
productIds: i.productIds,
|
|
62
|
+
filters: i.filters,
|
|
63
|
+
shuffleProducts: i.shuffleProducts
|
|
65
64
|
};
|
|
66
65
|
}
|
|
67
|
-
const f = ((
|
|
68
|
-
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName",
|
|
69
|
-
const g = e.filters.filter((
|
|
70
|
-
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true")
|
|
71
|
-
const p = decodeURIComponent(t.toString()), u = `${
|
|
72
|
-
return
|
|
66
|
+
const f = ((l = I().find((c) => c.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
|
|
67
|
+
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
68
|
+
const g = e.filters.filter((c) => c.isValid), d = h(g);
|
|
69
|
+
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true");
|
|
70
|
+
const p = decodeURIComponent(t.toString()), u = `${C.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
|
|
71
|
+
return a.recommendationCampaignUrls[o] = u, u;
|
|
73
72
|
}
|
|
74
73
|
});
|
|
75
74
|
export {
|
|
76
|
-
|
|
75
|
+
w as useRecommendation
|
|
77
76
|
};
|
|
@@ -2,6 +2,7 @@ import { useConfig as g } from "../../../composables/useConfig.js";
|
|
|
2
2
|
import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
|
|
3
3
|
import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
4
|
import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
+
import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
|
|
5
6
|
function y(r, n, e, o, i = "") {
|
|
6
7
|
const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
|
|
7
8
|
return o === "before" ? `${t} ${c}` : `${c} ${t}`;
|
|
@@ -12,7 +13,7 @@ function A(r) {
|
|
|
12
13
|
[n] = n.children;
|
|
13
14
|
return n;
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function b(r, n, e, o, i, c) {
|
|
16
17
|
switch (n) {
|
|
17
18
|
case "productImage": {
|
|
18
19
|
const t = r.querySelector("img");
|
|
@@ -87,45 +88,45 @@ function f(r, n, e, o, i, c) {
|
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
+
function E(r, n, e, o) {
|
|
91
92
|
r.querySelectorAll(".recommendation-product-row").forEach((c, t) => {
|
|
92
93
|
c.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
93
94
|
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
94
95
|
p.length > 0 ? p.forEach((l) => {
|
|
95
|
-
|
|
96
|
-
}) :
|
|
96
|
+
b(l, u, n, t, e, o);
|
|
97
|
+
}) : b(a, u, n, t, e, o);
|
|
97
98
|
});
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
+
function R(r, n, e, o) {
|
|
101
102
|
const i = r.querySelectorAll(".recommendation-product-row");
|
|
102
103
|
if (!i.length)
|
|
103
104
|
return;
|
|
104
105
|
const [c] = i, t = c.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
105
106
|
i.forEach((a, u) => {
|
|
106
107
|
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
107
|
-
const
|
|
108
|
+
const m = l.getAttribute("data-attribute-type") || "";
|
|
108
109
|
l.querySelectorAll(".attribute-cell").forEach((h, $) => {
|
|
109
110
|
const S = u * s + $;
|
|
110
|
-
|
|
111
|
+
b(h, m, n, S, e, o);
|
|
111
112
|
});
|
|
112
113
|
});
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
|
-
function
|
|
116
|
+
function P(r, n, e, o) {
|
|
116
117
|
r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
|
|
117
|
-
|
|
118
|
+
R(c, n, e, o);
|
|
118
119
|
});
|
|
119
120
|
}
|
|
120
|
-
function
|
|
121
|
+
function T(r, n, e) {
|
|
121
122
|
const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
|
|
122
|
-
o === "list" ?
|
|
123
|
+
o === "list" ? E(r, n, i, e) : P(r, n, i, e);
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
+
function f(r, n, e) {
|
|
125
126
|
const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
|
|
126
127
|
return i ? parseInt(i[1]) : e;
|
|
127
128
|
}
|
|
128
|
-
function
|
|
129
|
+
function v(r, n) {
|
|
129
130
|
let e = r.parentElement;
|
|
130
131
|
for (; e && e !== n; ) {
|
|
131
132
|
if (e.tagName === "TD") {
|
|
@@ -137,29 +138,29 @@ function T(r, n) {
|
|
|
137
138
|
}
|
|
138
139
|
return null;
|
|
139
140
|
}
|
|
140
|
-
function
|
|
141
|
-
const n = r.getAttribute("style") || "", e =
|
|
141
|
+
function O(r) {
|
|
142
|
+
const n = r.getAttribute("style") || "", e = f(n, "width", 600), o = f(n, "padding", 0) * 2, i = Math.max(0, e - o);
|
|
142
143
|
i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
|
|
143
144
|
if (c.hasAttribute("width"))
|
|
144
145
|
return;
|
|
145
|
-
const t =
|
|
146
|
+
const t = v(c, r);
|
|
146
147
|
if (!t)
|
|
147
148
|
return;
|
|
148
|
-
const s = t.getAttribute("width"), a = parseFloat(s), u =
|
|
149
|
+
const s = t.getAttribute("width"), a = parseFloat(s), u = f(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
|
|
149
150
|
c.setAttribute("width", String(l));
|
|
150
|
-
const
|
|
151
|
-
if (!/\bwidth\s*:\s*\d/i.test(
|
|
152
|
-
const
|
|
153
|
-
c.setAttribute("style", `${
|
|
151
|
+
const m = c.getAttribute("style") || "";
|
|
152
|
+
if (!/\bwidth\s*:\s*\d/i.test(m)) {
|
|
153
|
+
const d = m && !m.trim().endsWith(";") ? "; " : "";
|
|
154
|
+
c.setAttribute("style", `${m}${d}width: ${l}px`);
|
|
154
155
|
}
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
|
-
function
|
|
158
|
+
function W(r, n) {
|
|
158
159
|
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
159
160
|
return (e ? `${e[0]}
|
|
160
161
|
` : "") + n.documentElement.outerHTML;
|
|
161
162
|
}
|
|
162
|
-
function
|
|
163
|
+
function F(r) {
|
|
163
164
|
const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
164
165
|
if (!o.length)
|
|
165
166
|
return r;
|
|
@@ -167,12 +168,12 @@ function N(r) {
|
|
|
167
168
|
c.recommendationCampaignUrls = {};
|
|
168
169
|
const { isFeatureEnabled: t } = g(), s = t("liquidSyntax") ? "reco_" : "";
|
|
169
170
|
return o.forEach((u) => {
|
|
170
|
-
var l,
|
|
171
|
+
var l, m;
|
|
171
172
|
const p = u.getAttribute("recommendation-id");
|
|
172
|
-
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (
|
|
173
|
-
}),
|
|
173
|
+
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (m = u.parentNode) == null || m.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((d) => d.remove()), i(p), w(u) || T(u, p, s), O(u));
|
|
174
|
+
}), W(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
174
175
|
}
|
|
175
176
|
export {
|
|
176
177
|
y as formatPriceVariable,
|
|
177
|
-
|
|
178
|
+
F as prepareRecommendationBlocks
|
|
178
179
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CSS_CLASS_SKIP_COMPILE as n, BLOCK_ROOT_SELECTOR as i } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
function m(o) {
|
|
3
|
+
return o.classList.contains(n);
|
|
4
|
+
}
|
|
5
|
+
function a(o) {
|
|
6
|
+
const r = new DOMParser().parseFromString(o, "text/html").querySelectorAll(`${i}.${n}`), t = /* @__PURE__ */ new Set();
|
|
7
|
+
return r.forEach((c) => {
|
|
8
|
+
const e = c.getAttribute("recommendation-id");
|
|
9
|
+
e && t.add(e);
|
|
10
|
+
}), t;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
a as getIgnoredRecommendationBlockIds,
|
|
14
|
+
m as isIgnoredRecommendationBlock
|
|
15
|
+
};
|
|
@@ -1,27 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { CURRENCY_ATTR as n } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
const c = "You May Also Like!";
|
|
3
|
+
function A(t) {
|
|
4
|
+
var o;
|
|
5
|
+
const r = t.querySelector(".ext-recommendation-title");
|
|
6
|
+
if (!r)
|
|
7
|
+
return c;
|
|
8
|
+
const e = (o = r.textContent) == null ? void 0 : o.trim();
|
|
9
|
+
return e && e.length > 0 ? e : c;
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
...Array.from(
|
|
11
|
+
function m(t) {
|
|
12
|
+
const r = [
|
|
13
|
+
t,
|
|
14
|
+
...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
14
15
|
];
|
|
15
|
-
let
|
|
16
|
-
return
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
}),
|
|
16
|
+
let e = "";
|
|
17
|
+
return r.some((o) => {
|
|
18
|
+
const i = o.getAttribute("bgcolor");
|
|
19
|
+
if (i && i.trim())
|
|
20
|
+
return e = i.trim(), !0;
|
|
21
|
+
const u = (o.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
|
|
22
|
+
return u && u[1] ? (e = u[1].trim(), !0) : !1;
|
|
23
|
+
}), e;
|
|
24
|
+
}
|
|
25
|
+
function l(t) {
|
|
26
|
+
const r = t.getAttribute(n.CURRENCY);
|
|
27
|
+
if (!r)
|
|
28
|
+
return;
|
|
29
|
+
const e = t.getAttribute(n.SYMBOL);
|
|
30
|
+
return {
|
|
31
|
+
value: r,
|
|
32
|
+
// An empty `currency-symbol` is omitted so `mapCurrency` falls back to
|
|
33
|
+
// the currency code as the symbol.
|
|
34
|
+
...e ? { symbol: e } : {},
|
|
35
|
+
alignment: t.getAttribute(n.ALIGNMENT) ?? "",
|
|
36
|
+
decimalCount: t.getAttribute(n.DECIMAL_COUNT) ?? "",
|
|
37
|
+
decimalSeparator: t.getAttribute(n.DECIMAL_SEPARATOR) ?? "",
|
|
38
|
+
thousandSeparator: t.getAttribute(n.THOUSAND_SEPARATOR) ?? ""
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function d(t) {
|
|
42
|
+
return /\{\{[^}]+\}\}/.test(t.innerHTML);
|
|
23
43
|
}
|
|
24
44
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
45
|
+
m as extractCardBgColor,
|
|
46
|
+
l as extractCurrencyFromBlock,
|
|
47
|
+
A as extractTitleText,
|
|
48
|
+
d as isCustomizedBlock
|
|
27
49
|
};
|