@useinsider/guido 3.24.0-beta.adaba3e → 3.24.0-beta.bf47c23
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 +6 -2
- package/dist/@types/config/schemas.js +37 -39
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +92 -98
- package/dist/composables/useActionsApi.js +2 -2
- package/dist/composables/useBlocksConfig.js +20 -31
- package/dist/composables/useEditorTrackingIds.js +49 -0
- package/dist/composables/useHtmlCompiler.js +2 -0
- package/dist/composables/useStripo.js +70 -70
- package/dist/composables/useTranslations.js +1 -2
- package/dist/config/compiler/htmlCompilerRules.js +14 -6
- package/dist/config/compiler/utils/itemsCompilerUtils.js +42 -43
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -67
- package/dist/config/migrator/recommendation/inferLegacyConfig.js +133 -0
- package/dist/config/migrator/recommendationMigrator.js +78 -64
- package/dist/enums/academy.js +0 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +92 -93
- package/dist/node_modules/valibot/dist/index.js +261 -297
- package/dist/package.json.js +4 -4
- package/dist/services/templateLibraryApi.js +39 -36
- package/dist/src/@types/config/schemas.d.ts +0 -4
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
- package/dist/src/composables/useStripo.d.ts +1 -1
- package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +6 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
- package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -5
- package/dist/src/enums/academy.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
- package/dist/src/stores/config.d.ts +0 -167
- package/dist/src/utils/linkTrackingIds.d.ts +24 -22
- package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
- package/dist/stores/config.js +6 -13
- package/dist/utils/linkTrackingIds.js +72 -72
- package/dist/utils/pairProductVariables.js +29 -30
- package/dist/utils/templatePreparation.js +59 -72
- package/dist/utils/trimHrefWhitespace.js +10 -0
- package/package.json +1 -1
- package/dist/@types/display-condition.js +0 -25
- package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +0 -18
- package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +0 -41
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +0 -30
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +0 -81
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +0 -34
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +0 -63
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +0 -17
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +0 -22
- package/dist/composables/useDisplayConditions.js +0 -117
- package/dist/enums/display-condition.js +0 -12
- package/dist/extensions/DisplayConditions/bridge.js +0 -25
- package/dist/extensions/DisplayConditions/constants.js +0 -17
- package/dist/extensions/DisplayConditions/control.js +0 -200
- package/dist/extensions/DisplayConditions/display-conditions.css.js +0 -201
- package/dist/extensions/DisplayConditions/extension.js +0 -28
- package/dist/extensions/DisplayConditions/iconsRegistry.js +0 -20
- package/dist/extensions/DisplayConditions/library.js +0 -30
- package/dist/extensions/DisplayConditions/settingsPanel.js +0 -17
- package/dist/extensions/LinkTracking/extension.js +0 -17
- package/dist/extensions/LinkTracking/writer.js +0 -41
- package/dist/services/displayConditionApi.js +0 -39
- package/dist/src/@types/display-condition.d.ts +0 -59
- package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +0 -43
- package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +0 -2
- package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +0 -2
- package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +0 -2
- package/dist/src/composables/useDisplayConditions.d.ts +0 -18
- package/dist/src/enums/display-condition.d.ts +0 -15
- package/dist/src/extensions/DisplayConditions/bridge.d.ts +0 -7
- package/dist/src/extensions/DisplayConditions/constants.d.ts +0 -14
- package/dist/src/extensions/DisplayConditions/control.d.ts +0 -25
- package/dist/src/extensions/DisplayConditions/extension.d.ts +0 -2
- package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +0 -4
- package/dist/src/extensions/DisplayConditions/library.d.ts +0 -8
- package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +0 -5
- package/dist/src/extensions/LinkTracking/extension.d.ts +0 -2
- package/dist/src/extensions/LinkTracking/writer.d.ts +0 -13
- package/dist/src/mock/api/display-conditions.d.ts +0 -2
- package/dist/src/services/displayConditionApi.d.ts +0 -8
- package/dist/src/stores/display-condition.d.ts +0 -84
- package/dist/src/utils/displayCondition.d.ts +0 -11
- package/dist/src/utils/protectTableText.d.ts +0 -2
- package/dist/stores/display-condition.js +0 -29
- package/dist/utils/displayCondition.js +0 -26
- package/dist/utils/protectTableText.js +0 -22
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { useConfig as C } from "../../../composables/useConfig.js";
|
|
2
2
|
import { useRecommendation as O } from "../../../composables/useRecommendation.js";
|
|
3
|
-
import { MOBILE_ROW_SELECTOR as q, MOBILE_CONTAINER_SELECTOR as M, CSS_CLASS_RECO_BUTTON as
|
|
4
|
-
import { useRecommendationExtensionStore as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
function R(t, r, e, o, c = "") {
|
|
3
|
+
import { MOBILE_ROW_SELECTOR as q, MOBILE_CONTAINER_SELECTOR as M, CSS_CLASS_RECO_BUTTON as B } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useRecommendationExtensionStore as N } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
+
import { isIgnoredRecommendationBlock as T } from "./recommendationIgnoreUtils.js";
|
|
6
|
+
function L(t, r, e, o, c = "") {
|
|
8
7
|
const i = `{{${c}${t}_${r}_${e}}}`, n = `{{${c}${t}_${r}_currency}}`;
|
|
9
8
|
return o === "before" ? `${n} ${i}` : `${i} ${n}`;
|
|
10
9
|
}
|
|
11
|
-
function
|
|
10
|
+
function A(t) {
|
|
12
11
|
let r = t;
|
|
13
12
|
for (; r.children.length === 1; )
|
|
14
13
|
[r] = r.children;
|
|
@@ -20,12 +19,12 @@ function _(t, r, e, o, c, i) {
|
|
|
20
19
|
const n = t.querySelector("img");
|
|
21
20
|
n && (n.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), n.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
|
|
22
21
|
const s = t.querySelector("a");
|
|
23
|
-
s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(
|
|
22
|
+
s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(B));
|
|
24
23
|
break;
|
|
25
24
|
}
|
|
26
25
|
case "productName": {
|
|
27
26
|
const n = t.querySelector("p");
|
|
28
|
-
n && (
|
|
27
|
+
n && (A(n).textContent = `{{${i}${e}_${o}_name}}`);
|
|
29
28
|
break;
|
|
30
29
|
}
|
|
31
30
|
// Inline mode ("Move to next line" OFF) merges BOTH prices into one row
|
|
@@ -33,16 +32,16 @@ function _(t, r, e, o, c, i) {
|
|
|
33
32
|
// substitute by cell content, not by the row's anchor (SD-145161).
|
|
34
33
|
case "productPrice":
|
|
35
34
|
case "productOldPrice": {
|
|
36
|
-
const n = (
|
|
37
|
-
|
|
35
|
+
const n = (a, l) => {
|
|
36
|
+
a && (A(a).textContent = L(
|
|
38
37
|
e,
|
|
39
38
|
o,
|
|
40
|
-
|
|
39
|
+
l,
|
|
41
40
|
c,
|
|
42
41
|
i
|
|
43
42
|
));
|
|
44
|
-
}, s = t.querySelector(".product-price p"),
|
|
45
|
-
n(s ?? (r === "productPrice" ? u : null), "price"), n(
|
|
43
|
+
}, s = t.querySelector(".product-price p"), d = t.querySelector(".product-old-price p"), u = !s && !d ? t.querySelector("p") : null;
|
|
44
|
+
n(s ?? (r === "productPrice" ? u : null), "price"), n(d ?? (r === "productOldPrice" ? u : null), "original_price");
|
|
46
45
|
break;
|
|
47
46
|
}
|
|
48
47
|
case "productButton": {
|
|
@@ -71,72 +70,72 @@ function _(t, r, e, o, c, i) {
|
|
|
71
70
|
default: {
|
|
72
71
|
const n = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
|
|
73
72
|
if (n) {
|
|
74
|
-
const s = n.getAttribute("product-attr"),
|
|
75
|
-
|
|
73
|
+
const s = n.getAttribute("product-attr"), d = n.querySelector("p");
|
|
74
|
+
d && (A(d).textContent = `{{${i}${e}_${o}_${s}}}`);
|
|
76
75
|
}
|
|
77
76
|
break;
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
|
-
const
|
|
80
|
+
const P = "name";
|
|
82
81
|
function y(t, r, e, o) {
|
|
83
|
-
const c = `${o}${r}_${e}_${
|
|
82
|
+
const c = `${o}${r}_${e}_${P}`;
|
|
84
83
|
return {
|
|
85
84
|
open: t.createComment(`{% if ${c} and ${c} != "" %}`),
|
|
86
85
|
close: t.createComment("{% endif %}")
|
|
87
86
|
};
|
|
88
87
|
}
|
|
89
|
-
function
|
|
88
|
+
function R(t, r, e) {
|
|
90
89
|
return y(t, r, 0, e);
|
|
91
90
|
}
|
|
92
|
-
function
|
|
91
|
+
function w(t, r, e, o) {
|
|
93
92
|
if (!t.innerHTML.includes("{{"))
|
|
94
93
|
return;
|
|
95
94
|
const { open: c, close: i } = y(t.ownerDocument, r, e, o);
|
|
96
95
|
t.insertBefore(c, t.firstChild), t.appendChild(i);
|
|
97
96
|
}
|
|
98
|
-
function
|
|
97
|
+
function D(t, r, e, o) {
|
|
99
98
|
var n, s;
|
|
100
99
|
if (!t.innerHTML.includes("{{"))
|
|
101
100
|
return;
|
|
102
101
|
const { open: c, close: i } = y(t.ownerDocument, r, e, o);
|
|
103
102
|
(n = t.parentNode) == null || n.insertBefore(c, t), (s = t.parentNode) == null || s.insertBefore(i, t.nextSibling);
|
|
104
103
|
}
|
|
105
|
-
function
|
|
104
|
+
function v(t, r, e, o) {
|
|
106
105
|
t.querySelectorAll(".recommendation-product-row").forEach((i, n) => {
|
|
107
|
-
i.querySelectorAll("[data-attribute-type]").forEach((
|
|
108
|
-
const u =
|
|
109
|
-
|
|
110
|
-
_(
|
|
111
|
-
}) : _(
|
|
112
|
-
}),
|
|
106
|
+
i.querySelectorAll("[data-attribute-type]").forEach((d) => {
|
|
107
|
+
const u = d.getAttribute("data-attribute-type") || "", a = d.querySelectorAll(".attribute-cell");
|
|
108
|
+
a.length > 0 ? a.forEach((l) => {
|
|
109
|
+
_(l, u, r, n, e, o);
|
|
110
|
+
}) : _(d, u, r, n, e, o);
|
|
111
|
+
}), D(i, r, n, o);
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
|
-
function
|
|
114
|
+
function H(t, r, e, o) {
|
|
116
115
|
const c = t.querySelectorAll(".recommendation-product-row");
|
|
117
116
|
if (!c.length)
|
|
118
117
|
return;
|
|
119
118
|
const [i] = c, n = i.querySelector("[data-attribute-type]"), s = n ? n.querySelectorAll(".attribute-cell").length : 1;
|
|
120
|
-
c.forEach((
|
|
121
|
-
|
|
122
|
-
const p =
|
|
123
|
-
|
|
119
|
+
c.forEach((d, u) => {
|
|
120
|
+
d.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
121
|
+
const p = l.getAttribute("data-attribute-type") || "";
|
|
122
|
+
l.querySelectorAll(".attribute-cell").forEach((m, h) => {
|
|
124
123
|
const S = u * s + h;
|
|
125
|
-
_(m, p, r, S, e, o),
|
|
124
|
+
_(m, p, r, S, e, o), w(m, r, S, o);
|
|
126
125
|
});
|
|
127
126
|
});
|
|
128
127
|
});
|
|
129
128
|
}
|
|
130
|
-
function
|
|
129
|
+
function W(t, r, e, o) {
|
|
131
130
|
t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
|
|
132
|
-
|
|
131
|
+
H(i, r, e, o);
|
|
133
132
|
});
|
|
134
133
|
}
|
|
135
|
-
function
|
|
134
|
+
function F(t, r, e) {
|
|
136
135
|
const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment"), i = c === "0" || c === "before" ? "before" : "after";
|
|
137
|
-
o === "list" ?
|
|
136
|
+
o === "list" ? v(t, r, i, e) : W(t, r, i, e);
|
|
138
137
|
}
|
|
139
|
-
function
|
|
138
|
+
function b(t, r, e) {
|
|
140
139
|
const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), c = t.match(o);
|
|
141
140
|
return c ? parseInt(c[1]) : e;
|
|
142
141
|
}
|
|
@@ -151,7 +150,7 @@ function g(t) {
|
|
|
151
150
|
const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
|
|
152
151
|
return e && $(e[1]) ? e[1] : null;
|
|
153
152
|
}
|
|
154
|
-
function
|
|
153
|
+
function x(t, r) {
|
|
155
154
|
let e = t.parentElement;
|
|
156
155
|
for (; e && e !== r; ) {
|
|
157
156
|
if (e.tagName === "TD" && g(e))
|
|
@@ -160,64 +159,62 @@ function V(t, r) {
|
|
|
160
159
|
}
|
|
161
160
|
return null;
|
|
162
161
|
}
|
|
163
|
-
function
|
|
164
|
-
const r = t.getAttribute("style") || "", e =
|
|
162
|
+
function G(t) {
|
|
163
|
+
const r = t.getAttribute("style") || "", e = b(r, "width", 600), o = b(r, "padding", 0) * 2, c = Math.max(0, e - o);
|
|
165
164
|
c !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
166
165
|
if (i.hasAttribute("width"))
|
|
167
166
|
return;
|
|
168
|
-
const n =
|
|
167
|
+
const n = x(i, t);
|
|
169
168
|
if (!n)
|
|
170
169
|
return;
|
|
171
|
-
const s = g(n),
|
|
170
|
+
const s = g(n), d = b(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), a = Math.max(1, u - d), l = i.getAttribute("style") || "", p = /(?:^|[;\s])max-height\s*:\s*(\d+(?:\.\d+)?)px/i.exec(l);
|
|
172
171
|
if (p) {
|
|
173
|
-
i.setAttribute("width", String(Math.max(1, Math.min(
|
|
172
|
+
i.setAttribute("width", String(Math.max(1, Math.min(a, Math.floor(parseFloat(p[1])))))), i.removeAttribute("height");
|
|
174
173
|
return;
|
|
175
174
|
}
|
|
176
|
-
if (i.setAttribute("width", String(
|
|
177
|
-
const f =
|
|
178
|
-
i.setAttribute("style", `${
|
|
175
|
+
if (i.setAttribute("width", String(a)), !/\bwidth\s*:\s*\d/i.test(l)) {
|
|
176
|
+
const f = l && !l.trim().endsWith(";") ? "; " : "";
|
|
177
|
+
i.setAttribute("style", `${l}${f}width: ${a}px`);
|
|
179
178
|
}
|
|
180
179
|
});
|
|
181
180
|
}
|
|
182
|
-
const E = "MSO_MOBILE_HIDE_START",
|
|
183
|
-
function
|
|
181
|
+
const E = "MSO_MOBILE_HIDE_START", V = "MSO_MOBILE_HIDE_END";
|
|
182
|
+
function U(t, r) {
|
|
184
183
|
t.querySelectorAll(q).forEach((e) => {
|
|
185
184
|
var i, n;
|
|
186
185
|
const o = e.querySelector(M);
|
|
187
186
|
if (!o || o.children.length === 0)
|
|
188
187
|
return;
|
|
189
188
|
const c = e.previousSibling;
|
|
190
|
-
(c == null ? void 0 : c.nodeType) === Node.COMMENT_NODE && c.data === E || ((i = e.parentNode) == null || i.insertBefore(r.createComment(E), e), (n = e.parentNode) == null || n.insertBefore(r.createComment(
|
|
189
|
+
(c == null ? void 0 : c.nodeType) === Node.COMMENT_NODE && c.data === E || ((i = e.parentNode) == null || i.insertBefore(r.createComment(E), e), (n = e.parentNode) == null || n.insertBefore(r.createComment(V), e.nextSibling));
|
|
191
190
|
});
|
|
192
191
|
}
|
|
193
|
-
function
|
|
192
|
+
function X(t, r) {
|
|
194
193
|
const e = t.match(/<!DOCTYPE[^>]*>/i);
|
|
195
194
|
return (e ? `${e[0]}
|
|
196
195
|
` : "") + r.documentElement.outerHTML;
|
|
197
196
|
}
|
|
198
|
-
function
|
|
199
|
-
const r =
|
|
197
|
+
function Q(t) {
|
|
198
|
+
const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
200
199
|
if (!o.length)
|
|
201
200
|
return t;
|
|
202
|
-
const { buildCampaignUrl: c } = O(), i =
|
|
201
|
+
const { buildCampaignUrl: c } = O(), i = N();
|
|
203
202
|
i.recommendationCampaignUrls = {};
|
|
204
203
|
const { isFeatureEnabled: n } = C(), s = n("liquidSyntax") ? "reco_" : "";
|
|
205
|
-
o.forEach((u) => {
|
|
206
|
-
var
|
|
207
|
-
const
|
|
208
|
-
if (
|
|
209
|
-
if ((
|
|
210
|
-
|
|
211
|
-
const { open: h, close: S } =
|
|
204
|
+
return o.forEach((u) => {
|
|
205
|
+
var l, p, f, m;
|
|
206
|
+
const a = u.getAttribute("recommendation-id");
|
|
207
|
+
if (a) {
|
|
208
|
+
if ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((h) => h.remove()), c(a), U(u, e), !T(u)) {
|
|
209
|
+
F(u, a, s);
|
|
210
|
+
const { open: h, close: S } = R(e, a, s);
|
|
212
211
|
(f = u.parentNode) == null || f.insertBefore(h, u), (m = u.parentNode) == null || m.insertBefore(S, u.nextSibling);
|
|
213
212
|
}
|
|
214
|
-
|
|
213
|
+
G(u);
|
|
215
214
|
}
|
|
216
|
-
});
|
|
217
|
-
const a = Y(r, e);
|
|
218
|
-
return L(a.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}"));
|
|
215
|
+
}), X(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
219
216
|
}
|
|
220
217
|
export {
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
L as formatPriceVariable,
|
|
219
|
+
Q as prepareRecommendationBlocks
|
|
223
220
|
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { MAX_PRODUCTS_PER_ROW as _ } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
|
|
2
|
+
const T = "td.product-card", x = '[class*="ext-product-"]', d = ".ext-ins-attr p[product-attr]", y = ".ext-ins-attr", S = ["font-family", "font-size", "font-weight", "font-style"], a = [
|
|
3
|
+
["p_image", ".ext-product-image"],
|
|
4
|
+
["p_name", ".ext-product-name"],
|
|
5
|
+
["p_price", ".ext-product-price"],
|
|
6
|
+
["p_original_price", ".ext-product-original-price"],
|
|
7
|
+
["p_omnibus_price", ".ext-product-omnibus-price", !0],
|
|
8
|
+
["p_omnibus_discount", ".ext-product-omnibus-discount", !0],
|
|
9
|
+
["p_button", ".ext-product-button"]
|
|
10
|
+
], l = a.map(([, t]) => t).join(", ");
|
|
11
|
+
function s(t, e) {
|
|
12
|
+
const n = new RegExp(`(?:^|;)\\s*${e}\\s*:\\s*([^;]+)`, "i"), r = ((t == null ? void 0 : t.getAttribute("style")) ?? "").match(n);
|
|
13
|
+
return (r == null ? void 0 : r[1].trim()) || void 0;
|
|
14
|
+
}
|
|
15
|
+
function p(t) {
|
|
16
|
+
return /^none\b/.test(s(t, "display") ?? "");
|
|
17
|
+
}
|
|
18
|
+
function h(t) {
|
|
19
|
+
return p(t) || p(t.closest("tr"));
|
|
20
|
+
}
|
|
21
|
+
function f(t) {
|
|
22
|
+
const e = {};
|
|
23
|
+
return S.forEach((n) => {
|
|
24
|
+
const r = s(t, n);
|
|
25
|
+
r && (e[n] = r);
|
|
26
|
+
}), Object.keys(e).length > 0 ? e : void 0;
|
|
27
|
+
}
|
|
28
|
+
function g(t) {
|
|
29
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
30
|
+
}
|
|
31
|
+
function m(t) {
|
|
32
|
+
const e = t.querySelector("p") ?? t, n = f(e), r = s(e, "color"), i = t.getAttribute("align") ?? s(e, "text-align"), o = s(e, "line-height");
|
|
33
|
+
return g({
|
|
34
|
+
...n ? { textStyle: n } : {},
|
|
35
|
+
...r ? { textColor: { color: r } } : {},
|
|
36
|
+
...i ? { textAlign: { align: i } } : {},
|
|
37
|
+
...o ? { textLineSpacing: { lineSpacing: o } } : {}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function A(t) {
|
|
41
|
+
var u;
|
|
42
|
+
const e = t.querySelector("a") ?? t, n = (u = e.textContent) == null ? void 0 : u.trim(), r = s(e, "background-color") ?? s(e, "background"), i = s(e, "color"), o = f(e), c = t.getAttribute("align");
|
|
43
|
+
return g({
|
|
44
|
+
...n ? { buttonText: { text: n } } : {},
|
|
45
|
+
...r ? { buttonColor: { color: r } } : {},
|
|
46
|
+
...i ? { textButtonColor: { color: i } } : {},
|
|
47
|
+
...o ? { buttonStyle: o } : {},
|
|
48
|
+
...c ? { buttonAlign: { align: c } } : {}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function C(t) {
|
|
52
|
+
const e = t.querySelector("img"), n = Number(e == null ? void 0 : e.getAttribute("width")), r = Number(e == null ? void 0 : e.getAttribute("height")), i = { ...n > 0 ? { width: n } : {}, ...r > 0 ? { height: r } : {} };
|
|
53
|
+
return Object.keys(i).length > 0 ? { imageSize: i } : void 0;
|
|
54
|
+
}
|
|
55
|
+
function R(t, e) {
|
|
56
|
+
switch (t) {
|
|
57
|
+
case "p_image":
|
|
58
|
+
return C(e);
|
|
59
|
+
case "p_button":
|
|
60
|
+
return A(e);
|
|
61
|
+
default:
|
|
62
|
+
return m(e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function L(t, e) {
|
|
66
|
+
const n = Array.from(t.querySelectorAll(`[class*="show-recommendation-${e}-"]`));
|
|
67
|
+
return n.length > 0 ? n : Array.from(t.querySelectorAll(T));
|
|
68
|
+
}
|
|
69
|
+
function w(t, e) {
|
|
70
|
+
const n = (o) => e.filter((c) => o.contains(c)).length;
|
|
71
|
+
let r = e[0].parentElement;
|
|
72
|
+
for (; r && r !== t && n(r) < 2; )
|
|
73
|
+
r = r.parentElement;
|
|
74
|
+
if (!r || r === t)
|
|
75
|
+
return e.length === 1 ? 1 : void 0;
|
|
76
|
+
const i = r.tagName === "TBODY" || r.tagName === "TABLE" ? 1 : n(r);
|
|
77
|
+
return Math.min(i, _);
|
|
78
|
+
}
|
|
79
|
+
function v(t) {
|
|
80
|
+
const e = Array.from(t.querySelectorAll(x)).filter((n) => !n.matches(l) && !n.querySelector(l)).flatMap((n) => Array.from(n.classList).filter((r) => r.startsWith("ext-product-")));
|
|
81
|
+
return [...new Set(e)];
|
|
82
|
+
}
|
|
83
|
+
function O(t, e, n) {
|
|
84
|
+
const r = t.closest(y) ?? t, i = m(r);
|
|
85
|
+
return {
|
|
86
|
+
variable: `p_attribute_${e}`,
|
|
87
|
+
variableType: "p_attribute",
|
|
88
|
+
value: t.getAttribute("product-attr") ?? "",
|
|
89
|
+
positionIdx: n,
|
|
90
|
+
hidden: h(r),
|
|
91
|
+
...i ? { theme: i } : {}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function N(t) {
|
|
95
|
+
const e = /* @__PURE__ */ new Set(), n = [];
|
|
96
|
+
let r = 0;
|
|
97
|
+
t.querySelectorAll(`${l}, ${d}`).forEach((o) => {
|
|
98
|
+
if (o.matches(d)) {
|
|
99
|
+
n.push(O(o, r, n.length)), r += 1;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const c = a.find(
|
|
103
|
+
([b, E]) => !e.has(b) && o.matches(E)
|
|
104
|
+
);
|
|
105
|
+
if (!c)
|
|
106
|
+
return;
|
|
107
|
+
const u = R(c[0], o);
|
|
108
|
+
e.add(c[0]), n.push({
|
|
109
|
+
variable: c[0],
|
|
110
|
+
positionIdx: n.length,
|
|
111
|
+
hidden: h(o),
|
|
112
|
+
...u ? { theme: u } : {}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
const i = a.filter(([o, , c]) => !c && !e.has(o)).map(([o]) => ({ variable: o, hidden: !0 }));
|
|
116
|
+
return [...n, ...i];
|
|
117
|
+
}
|
|
118
|
+
function q(t, e) {
|
|
119
|
+
const n = L(t, e);
|
|
120
|
+
if (n.length === 0)
|
|
121
|
+
return null;
|
|
122
|
+
const r = v(n[0]);
|
|
123
|
+
return r.length > 0 ? (console.warn(
|
|
124
|
+
`[RecommendationMigrator] Block id=${e} — legacy card cells the rebuild cannot map: ${r.join(", ")}`
|
|
125
|
+
), null) : {
|
|
126
|
+
totalCount: n.length,
|
|
127
|
+
rowCount: w(t, n),
|
|
128
|
+
composition: { variables: N(n[0]) }
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
q as inferLegacyConfig
|
|
133
|
+
};
|
|
@@ -1,59 +1,71 @@
|
|
|
1
1
|
import { BlockId as b } from "../../enums/block.js";
|
|
2
|
-
import { DEFAULT_NODE_CONFIG as
|
|
3
|
-
import { ATTR_RECOMMENDATION_TITLE as
|
|
4
|
-
import { useTemplateStore as
|
|
5
|
-
import { mapComposition as
|
|
6
|
-
import { isPriceOnNextLine as
|
|
7
|
-
import { buildBlockHtml as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { DEFAULT_NODE_CONFIG as h } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
3
|
+
import { ATTR_RECOMMENDATION_TITLE as y } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useTemplateStore as x } from "../../stores/template.js";
|
|
5
|
+
import { mapComposition as S } from "./recommendation/compositionMapper.js";
|
|
6
|
+
import { isPriceOnNextLine as L, extractCurrencyFromBlock as A, isOldPriceFirst as B, withRenderedTextTheme as E, extractTitleText as w, hasEmptyTitle as O, hasVisibleTitle as N, extractCardBgColor as P, isPartnerManagedBlock as H, extractRenderedBlockPadding as I } from "./recommendation/extractors.js";
|
|
7
|
+
import { buildBlockHtml as _ } from "./recommendation/htmlBuilder.js";
|
|
8
|
+
import { inferLegacyConfig as F } from "./recommendation/inferLegacyConfig.js";
|
|
9
|
+
import { parseRecommendationId as $, parseLegacyConfig as k } from "./recommendation/parseLegacyConfig.js";
|
|
10
|
+
import { mapSettings as D } from "./recommendation/settingsMapper.js";
|
|
11
|
+
import { mapBlockPadding as G } from "./recommendation/themeMapper.js";
|
|
12
|
+
const T = ":not(.recommendation-block-v2):not([esd-ext-config])", U = `td[class*="ins-recommendation-v3-block-"]${T}, td.product-block[esd-handler-name*="EmailRecommendationV3"]${T}`, V = "esd-dev-product-config";
|
|
13
|
+
function q(o) {
|
|
14
|
+
return !!(o != null && o.strategy);
|
|
15
|
+
}
|
|
16
|
+
function K(o, e, c) {
|
|
17
|
+
var g, f, u;
|
|
18
|
+
const t = $(e);
|
|
15
19
|
if (t === null)
|
|
16
20
|
return console.warn(
|
|
17
21
|
"[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
|
|
18
22
|
), !1;
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
23
|
+
const s = e.hasAttribute(V), m = c[String(t)];
|
|
24
|
+
if (!s && !q(m))
|
|
25
|
+
return console.warn(
|
|
26
|
+
`[RecommendationMigrator] Skipping block id=${t} — no \`esd-dev-product-config\` and no recommendationConfigs strategy to rebuild from`
|
|
27
|
+
), !1;
|
|
28
|
+
const i = s ? k(e) : F(e, t);
|
|
29
|
+
if (!i)
|
|
21
30
|
return console.warn(
|
|
22
|
-
`[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\`
|
|
31
|
+
`[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\` empty or unparsable, or the rendered markup could not be inferred`
|
|
23
32
|
), !1;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
s || console.info(
|
|
34
|
+
`[RecommendationMigrator] Block id=${t} has no \`esd-dev-product-config\` — rebuilt from its rendered markup`
|
|
35
|
+
);
|
|
36
|
+
const r = m ?? {}, n = {
|
|
37
|
+
...r,
|
|
38
|
+
currencySettings: r.currencySettings ?? A(e),
|
|
39
|
+
isPriceMovedToNextLine: r.isPriceMovedToNextLine ?? L(e)
|
|
40
|
+
}, d = D(n, i, t), a = S(
|
|
41
|
+
E((g = i.composition) == null ? void 0 : g.variables, e),
|
|
42
|
+
{ oldPriceFirst: B(e) }
|
|
43
|
+
), C = w(e);
|
|
44
|
+
O(e) ? a.visibility[y] = !1 : a.titleVariable || (a.visibility[y] = N(e));
|
|
45
|
+
const v = P(e), M = {
|
|
46
|
+
...d,
|
|
35
47
|
strategyId: "",
|
|
36
|
-
composition:
|
|
37
|
-
visibility:
|
|
38
|
-
previousTitleHtml:
|
|
39
|
-
textTrimming:
|
|
40
|
-
},
|
|
48
|
+
composition: a.composition,
|
|
49
|
+
visibility: a.visibility,
|
|
50
|
+
previousTitleHtml: h.previousTitleHtml,
|
|
51
|
+
textTrimming: a.anyTextTrimming
|
|
52
|
+
}, l = H(e), R = `
|
|
41
53
|
<table>
|
|
42
54
|
<tbody>
|
|
43
55
|
<tr>
|
|
44
56
|
<td class="esd-structure" align="left">
|
|
45
57
|
<table width="100%" cellpadding="0" cellspacing="0">
|
|
46
58
|
<tbody>
|
|
47
|
-
<tr>${
|
|
48
|
-
nodeConfig:
|
|
49
|
-
composition:
|
|
50
|
-
cardBg:
|
|
51
|
-
titleText:
|
|
59
|
+
<tr>${_({
|
|
60
|
+
nodeConfig: M,
|
|
61
|
+
composition: a,
|
|
62
|
+
cardBg: v,
|
|
63
|
+
titleText: C,
|
|
52
64
|
legacyId: e.getAttribute("id") ?? void 0,
|
|
53
65
|
legacyBgColor: e.getAttribute("bgcolor") ?? void 0,
|
|
54
|
-
preserveInnerHtml:
|
|
55
|
-
skipCompile:
|
|
56
|
-
blockPadding:
|
|
66
|
+
preserveInnerHtml: l ? e.innerHTML : void 0,
|
|
67
|
+
skipCompile: l,
|
|
68
|
+
blockPadding: G(((u = (f = i.theme) == null ? void 0 : f.blockPadding) == null ? void 0 : u.desktop) ?? I(e))
|
|
57
69
|
})}</tr>
|
|
58
70
|
</tbody>
|
|
59
71
|
</table>
|
|
@@ -61,40 +73,42 @@ function $(c, e, m) {
|
|
|
61
73
|
</tr>
|
|
62
74
|
</tbody>
|
|
63
75
|
</table>
|
|
64
|
-
`,
|
|
65
|
-
return !
|
|
76
|
+
`, p = o.parseFromString(R, "text/html").querySelector("td.esd-structure");
|
|
77
|
+
return !p || !e.parentNode ? (console.warn(
|
|
66
78
|
`[RecommendationMigrator] Aborting block id=${t} — failed to construct new HTML element`
|
|
67
|
-
), !1) : (e.parentNode.replaceChild(
|
|
79
|
+
), !1) : (e.parentNode.replaceChild(p, e), !0);
|
|
68
80
|
}
|
|
69
|
-
function
|
|
70
|
-
const
|
|
81
|
+
function ne(o, e = {}) {
|
|
82
|
+
const c = new DOMParser();
|
|
71
83
|
let t;
|
|
72
84
|
try {
|
|
73
|
-
t =
|
|
74
|
-
} catch (
|
|
75
|
-
return console.error("[RecommendationMigrator] Failed to parse template:",
|
|
85
|
+
t = c.parseFromString(o, "text/html");
|
|
86
|
+
} catch (r) {
|
|
87
|
+
return console.error("[RecommendationMigrator] Failed to parse template:", r), o;
|
|
76
88
|
}
|
|
77
|
-
const
|
|
89
|
+
const s = Array.from(t.querySelectorAll(U)), m = s.filter((r) => {
|
|
90
|
+
var n;
|
|
91
|
+
return !((n = r.parentElement) != null && n.closest(".recommendation-block-v2")) && !s.some((d) => d !== r && d.contains(r));
|
|
92
|
+
});
|
|
93
|
+
let i = 0;
|
|
94
|
+
m.forEach((r) => {
|
|
95
|
+
try {
|
|
96
|
+
K(c, r, e) && (i += 1);
|
|
97
|
+
} catch (n) {
|
|
98
|
+
console.error("[RecommendationMigrator] Unexpected error migrating block:", n);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
78
101
|
try {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
...
|
|
82
|
-
[b.Recommendation]:
|
|
102
|
+
x().$patch((n) => {
|
|
103
|
+
n.migrations = {
|
|
104
|
+
...n.migrations,
|
|
105
|
+
[b.Recommendation]: i
|
|
83
106
|
};
|
|
84
107
|
});
|
|
85
108
|
} catch {
|
|
86
109
|
}
|
|
87
|
-
|
|
88
|
-
return c;
|
|
89
|
-
let o = 0;
|
|
90
|
-
return r.forEach((n) => {
|
|
91
|
-
try {
|
|
92
|
-
$(m, n, e) && (o += 1);
|
|
93
|
-
} catch (a) {
|
|
94
|
-
console.error("[RecommendationMigrator] Unexpected error migrating block:", a);
|
|
95
|
-
}
|
|
96
|
-
}), o > 0 && console.info(`[RecommendationMigrator] Migrated ${o} legacy Recommendation block(s)`), t.documentElement.outerHTML;
|
|
110
|
+
return i === 0 ? o : (console.info(`[RecommendationMigrator] Migrated ${i} legacy Recommendation block(s)`), t.documentElement.outerHTML);
|
|
97
111
|
}
|
|
98
112
|
export {
|
|
99
|
-
|
|
113
|
+
ne as migrateRecommendation
|
|
100
114
|
};
|
package/dist/enums/academy.js
CHANGED
|
@@ -2,7 +2,6 @@ const e = "https://academy.insiderone.com", o = {
|
|
|
2
2
|
EMAIL_EDITOR: `${e}/docs/email-drag-and-drop-editor`,
|
|
3
3
|
GLOBAL_UNSUBSCRIBE: `${e}/docs/global-unsubscribe-preference-center`,
|
|
4
4
|
AMP_FOR_EMAILS: `${e}/docs/amp-for-emails`,
|
|
5
|
-
EMAIL_DISPLAY_CONDITIONS: `${e}/docs/new-editor-add-display-conditions-to-an-email`,
|
|
6
5
|
EMAIL_RECOMMENDATION_BLOCK: `${e}/docs/new-editor-email-recommendation-block`
|
|
7
6
|
};
|
|
8
7
|
export {
|
|
@@ -17,9 +17,9 @@ import { CurrencyControl as U } from "./currency.js";
|
|
|
17
17
|
import { CURRENCY_CONTROL_ID as Ie } from "./currency.js";
|
|
18
18
|
import { FiltersControl as v } from "./filters.js";
|
|
19
19
|
import { FILTERS_CONTROL_ID as ke } from "./filters.js";
|
|
20
|
-
import { LayoutOrientationControl as
|
|
20
|
+
import { LayoutOrientationControl as w } from "./layoutOrientation.js";
|
|
21
21
|
import { LAYOUT_ORIENTATION_CONTROL_ID as Oe } from "./layoutOrientation.js";
|
|
22
|
-
import { LocaleControl as
|
|
22
|
+
import { LocaleControl as A } from "./locale.js";
|
|
23
23
|
import { LOCALE_CONTROL_ID as Be } from "./locale.js";
|
|
24
24
|
import { PricePlacementControl as V } from "./pricePlacement.js";
|
|
25
25
|
import { PRICE_PLACEMENT_CONTROL_ID as Le } from "./pricePlacement.js";
|
|
@@ -28,7 +28,7 @@ import { PRODUCT_COUNT_CONTROL_ID as Ee } from "./productCount.js";
|
|
|
28
28
|
import { ProductLayoutControl as x } from "./productLayout.js";
|
|
29
29
|
import { PRODUCT_LAYOUT_CONTROL_ID as ve } from "./productLayout.js";
|
|
30
30
|
import { ShuffleControl as M } from "./shuffle.js";
|
|
31
|
-
import { SHUFFLE_CONTROL_ID as
|
|
31
|
+
import { SHUFFLE_CONTROL_ID as Ae } from "./shuffle.js";
|
|
32
32
|
import { StrategyControl as G } from "./strategy.js";
|
|
33
33
|
import { STRATEGY_CONTROL_ID as We } from "./strategy.js";
|
|
34
34
|
import { setCurrencyAttributes as $, getBlockElement as z, isPartnerManagedBlock as H, updateProductContentInPlace as Y, regenerateProductRowsWithStyles as j } from "./utils.js";
|
|
@@ -128,7 +128,7 @@ class _e extends I {
|
|
|
128
128
|
return this.rrsEnabled = f().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
129
129
|
var o;
|
|
130
130
|
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
131
|
-
}), this.algorithmControl = new E(), this.localeControl = new
|
|
131
|
+
}), this.algorithmControl = new E(), this.localeControl = new A(), this.currencyControl = new U(), this.productCountControl = new W(), this.productLayoutControl = new x(), this.filtersControl = new v(), this.shuffleControl = new M(), this.pricePlacementControl = new V(), this.layoutOrientationControl = new w(), this.strategyControl = this.rrsEnabled ? new G() : null, this._subControls.forEach((t) => {
|
|
132
132
|
t && (t.api = this.api);
|
|
133
133
|
}), `
|
|
134
134
|
<div class="recommendation-controls-container">
|
|
@@ -452,7 +452,9 @@ class _e extends I {
|
|
|
452
452
|
e,
|
|
453
453
|
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
454
454
|
h
|
|
455
|
-
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e })
|
|
455
|
+
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e });
|
|
456
|
+
const s = o && n.drawnProducts !== n.recommendationProducts;
|
|
457
|
+
(i || s) && this._refreshOutsidePanel(e, i);
|
|
456
458
|
} catch (n) {
|
|
457
459
|
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
458
460
|
}
|
|
@@ -552,8 +554,8 @@ export {
|
|
|
552
554
|
v as FiltersControl,
|
|
553
555
|
Oe as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
554
556
|
Be as LOCALE_CONTROL_ID,
|
|
555
|
-
|
|
556
|
-
|
|
557
|
+
w as LayoutOrientationControl,
|
|
558
|
+
A as LocaleControl,
|
|
557
559
|
Le as PRICE_PLACEMENT_CONTROL_ID,
|
|
558
560
|
Ee as PRODUCT_COUNT_CONTROL_ID,
|
|
559
561
|
ve as PRODUCT_LAYOUT_CONTROL_ID,
|
|
@@ -561,7 +563,7 @@ export {
|
|
|
561
563
|
W as ProductCountControl,
|
|
562
564
|
x as ProductLayoutControl,
|
|
563
565
|
_e as RecommendationBlockControl,
|
|
564
|
-
|
|
566
|
+
Ae as SHUFFLE_CONTROL_ID,
|
|
565
567
|
We as STRATEGY_CONTROL_ID,
|
|
566
568
|
M as ShuffleControl,
|
|
567
569
|
G as StrategyControl,
|