@useinsider/guido 3.8.2-beta.ba80e01 → 3.8.3-beta.96b5eeb
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.
|
@@ -3,35 +3,35 @@ import { useRecommendation as g } from "../../../composables/useRecommendation.j
|
|
|
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
5
|
import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
|
|
6
|
-
function
|
|
7
|
-
const i = `{{${c}${
|
|
8
|
-
return
|
|
6
|
+
function h(r, n, e, o, c = "") {
|
|
7
|
+
const i = `{{${c}${r}_${n}_${e}}}`, t = `{{${c}${r}_${n}_currency}}`;
|
|
8
|
+
return o === "before" ? `${t} ${i}` : `${i} ${t}`;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
for (;
|
|
13
|
-
[
|
|
14
|
-
return
|
|
10
|
+
function f(r) {
|
|
11
|
+
let n = r;
|
|
12
|
+
for (; n.children.length === 1; )
|
|
13
|
+
[n] = n.children;
|
|
14
|
+
return n;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
switch (
|
|
16
|
+
function A(r, n, e, o, c, i) {
|
|
17
|
+
switch (n) {
|
|
18
18
|
case "productImage": {
|
|
19
|
-
const t =
|
|
20
|
-
t && (t.setAttribute("src", `{{${i}${
|
|
21
|
-
const s =
|
|
22
|
-
s && (s.setAttribute("href", `{{${i}${
|
|
19
|
+
const t = r.querySelector("img");
|
|
20
|
+
t && (t.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
|
|
21
|
+
const s = r.querySelector("a");
|
|
22
|
+
s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(q));
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
25
|
case "productName": {
|
|
26
|
-
const t =
|
|
27
|
-
t && (
|
|
26
|
+
const t = r.querySelector("p");
|
|
27
|
+
t && (f(t).textContent = `{{${i}${e}_${o}_name}}`);
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
case "productPrice": {
|
|
31
|
-
const t =
|
|
32
|
-
t && (
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const t = r.querySelector("p");
|
|
32
|
+
t && (f(t).textContent = h(
|
|
33
|
+
e,
|
|
34
|
+
o,
|
|
35
35
|
"price",
|
|
36
36
|
c,
|
|
37
37
|
i
|
|
@@ -39,10 +39,10 @@ function b(e, o, r, n, c, i) {
|
|
|
39
39
|
break;
|
|
40
40
|
}
|
|
41
41
|
case "productOldPrice": {
|
|
42
|
-
const t =
|
|
43
|
-
t && (
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
const t = r.querySelector("p");
|
|
43
|
+
t && (f(t).textContent = h(
|
|
44
|
+
e,
|
|
45
|
+
o,
|
|
46
46
|
"original_price",
|
|
47
47
|
c,
|
|
48
48
|
i
|
|
@@ -50,128 +50,124 @@ function b(e, o, r, n, c, i) {
|
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
52
|
case "productButton": {
|
|
53
|
-
const t =
|
|
54
|
-
t && t.setAttribute("href", `{{${i}${
|
|
53
|
+
const t = r.querySelector("a");
|
|
54
|
+
t && t.setAttribute("href", `{{${i}${e}_${o}_url}}`);
|
|
55
55
|
break;
|
|
56
56
|
}
|
|
57
57
|
case "productOmnibusPrice": {
|
|
58
|
-
const t =
|
|
58
|
+
const t = r.querySelector(".omnibus-price-value");
|
|
59
59
|
if (t) {
|
|
60
|
-
t.textContent = `{{${i}${
|
|
60
|
+
t.textContent = `{{${i}${e}_${o}_omnibus_price}}`;
|
|
61
61
|
const s = t.closest("p");
|
|
62
62
|
s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
|
|
63
63
|
}
|
|
64
64
|
break;
|
|
65
65
|
}
|
|
66
66
|
case "productOmnibusDiscount": {
|
|
67
|
-
const t =
|
|
67
|
+
const t = r.querySelector(".omnibus-discount-value");
|
|
68
68
|
if (t) {
|
|
69
|
-
t.textContent = `{{${i}${
|
|
69
|
+
t.textContent = `{{${i}${e}_${o}_omnibus_discount}}`;
|
|
70
70
|
const s = t.closest("p");
|
|
71
71
|
s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
|
|
72
72
|
}
|
|
73
73
|
break;
|
|
74
74
|
}
|
|
75
75
|
default: {
|
|
76
|
-
const t =
|
|
76
|
+
const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
|
|
77
77
|
if (t) {
|
|
78
|
-
const s = t.getAttribute("product-attr"),
|
|
79
|
-
|
|
78
|
+
const s = t.getAttribute("product-attr"), a = t.querySelector("p");
|
|
79
|
+
a && (f(a).textContent = `{{${i}${e}_${o}_${s}}}`);
|
|
80
80
|
}
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
function E(
|
|
86
|
-
|
|
87
|
-
i.querySelectorAll("[data-attribute-type]").forEach((
|
|
88
|
-
const u =
|
|
89
|
-
p.length > 0 ? p.forEach((
|
|
90
|
-
|
|
91
|
-
}) :
|
|
85
|
+
function E(r, n, e, o) {
|
|
86
|
+
r.querySelectorAll(".recommendation-product-row").forEach((i, t) => {
|
|
87
|
+
i.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
88
|
+
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
89
|
+
p.length > 0 ? p.forEach((l) => {
|
|
90
|
+
A(l, u, n, t, e, o);
|
|
91
|
+
}) : A(a, u, n, t, e, o);
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
function R(
|
|
96
|
-
const c =
|
|
95
|
+
function R(r, n, e, o) {
|
|
96
|
+
const c = r.querySelectorAll(".recommendation-product-row");
|
|
97
97
|
if (!c.length)
|
|
98
98
|
return;
|
|
99
99
|
const [i] = c, t = i.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
100
|
-
c.forEach((
|
|
101
|
-
|
|
102
|
-
const m =
|
|
103
|
-
|
|
100
|
+
c.forEach((a, u) => {
|
|
101
|
+
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
102
|
+
const m = l.getAttribute("data-attribute-type") || "";
|
|
103
|
+
l.querySelectorAll(".attribute-cell").forEach((y, $) => {
|
|
104
104
|
const S = u * s + $;
|
|
105
|
-
|
|
105
|
+
A(y, m, n, S, e, o);
|
|
106
106
|
});
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
function P(
|
|
111
|
-
|
|
112
|
-
R(i,
|
|
110
|
+
function P(r, n, e, o) {
|
|
111
|
+
r.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
|
|
112
|
+
R(i, n, e, o);
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
const
|
|
117
|
-
|
|
115
|
+
function T(r, n, e) {
|
|
116
|
+
const o = r.getAttribute("data-layout") || "grid", c = r.getAttribute("currency-alignment") || "after";
|
|
117
|
+
o === "list" ? E(r, n, c, e) : P(r, n, c, e);
|
|
118
118
|
}
|
|
119
|
-
function
|
|
120
|
-
const
|
|
121
|
-
return c ? parseInt(c[1]) :
|
|
119
|
+
function b(r, n, e) {
|
|
120
|
+
const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), c = r.match(o);
|
|
121
|
+
return c ? parseInt(c[1]) : e;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (r.tagName === "TD") {
|
|
131
|
-
const n = r.getAttribute("width");
|
|
132
|
-
if (n && T(n))
|
|
133
|
-
return r;
|
|
123
|
+
function v(r, n) {
|
|
124
|
+
let e = r.parentElement;
|
|
125
|
+
for (; e && e !== n; ) {
|
|
126
|
+
if (e.tagName === "TD") {
|
|
127
|
+
const o = e.getAttribute("width");
|
|
128
|
+
if (o && o.endsWith("%") && parseFloat(o) < 100)
|
|
129
|
+
return e;
|
|
134
130
|
}
|
|
135
|
-
|
|
131
|
+
e = e.parentElement;
|
|
136
132
|
}
|
|
137
133
|
return null;
|
|
138
134
|
}
|
|
139
|
-
function O(
|
|
140
|
-
const
|
|
141
|
-
c !== 0 &&
|
|
135
|
+
function O(r) {
|
|
136
|
+
const n = r.getAttribute("style") || "", e = b(n, "width", 600), o = b(n, "padding", 0) * 2, c = Math.max(0, e - o);
|
|
137
|
+
c !== 0 && r.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
142
138
|
if (i.hasAttribute("width"))
|
|
143
139
|
return;
|
|
144
|
-
const t =
|
|
140
|
+
const t = v(i, r);
|
|
145
141
|
if (!t)
|
|
146
142
|
return;
|
|
147
|
-
const s = t.getAttribute("width"),
|
|
148
|
-
i.setAttribute("width", String(
|
|
149
|
-
const
|
|
150
|
-
if (!/\bwidth\s*:\s*\d/i.test(
|
|
151
|
-
const
|
|
152
|
-
i.setAttribute("style", `${
|
|
143
|
+
const s = t.getAttribute("width"), a = parseFloat(s), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(c * a / 100), l = Math.max(1, p - u);
|
|
144
|
+
i.setAttribute("width", String(l));
|
|
145
|
+
const m = i.getAttribute("style") || "";
|
|
146
|
+
if (!/\bwidth\s*:\s*\d/i.test(m)) {
|
|
147
|
+
const d = m && !m.trim().endsWith(";") ? "; " : "";
|
|
148
|
+
i.setAttribute("style", `${m}${d}width: ${l}px`);
|
|
153
149
|
}
|
|
154
150
|
});
|
|
155
151
|
}
|
|
156
|
-
function
|
|
157
|
-
const
|
|
158
|
-
return (
|
|
159
|
-
` : "") +
|
|
152
|
+
function W(r, n) {
|
|
153
|
+
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
154
|
+
return (e ? `${e[0]}
|
|
155
|
+
` : "") + n.documentElement.outerHTML;
|
|
160
156
|
}
|
|
161
|
-
function
|
|
162
|
-
const
|
|
163
|
-
if (!
|
|
164
|
-
return
|
|
157
|
+
function F(r) {
|
|
158
|
+
const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
159
|
+
if (!o.length)
|
|
160
|
+
return r;
|
|
165
161
|
const { buildCampaignUrl: c } = g(), i = C();
|
|
166
162
|
i.recommendationCampaignUrls = {};
|
|
167
163
|
const { isFeatureEnabled: t } = _(), s = t("liquidSyntax") ? "reco_" : "";
|
|
168
|
-
return
|
|
169
|
-
var
|
|
164
|
+
return o.forEach((u) => {
|
|
165
|
+
var l, m;
|
|
170
166
|
const p = u.getAttribute("recommendation-id");
|
|
171
|
-
p && ((
|
|
172
|
-
}),
|
|
167
|
+
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()), c(p), w(u) || T(u, p, s), O(u));
|
|
168
|
+
}), W(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
173
169
|
}
|
|
174
170
|
export {
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
h as formatPriceVariable,
|
|
172
|
+
F as prepareRecommendationBlocks
|
|
177
173
|
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
const n = "newsletter.already-in-progress", e = "newsletter.campaign-could-not-be-saved", s = / (==|<=|>=|!=|>|<|in) | (if|elif|endif|else|and|or) |("[\S ]+")|('[\S ]+')|([^”\s\n]+)|(({%)|( %}))/gm, o = /{%( )*now( )(".*")( )*%}/gm, E = /\{\{[^{}]+\}\}/g,
|
|
1
|
+
const n = "newsletter.already-in-progress", e = "newsletter.campaign-could-not-be-saved", s = / (==|<=|>=|!=|>|<|in) | (if|elif|endif|else|and|or) |("[\S ]+")|('[\S ]+')|([^”\s\n]+)|(({%)|( %}))/gm, o = /{%( )*now( )(".*")( )*%}/gm, E = /\{\{[^{}]+\}\}/g, _ = /(\s)data-[\w-]+=(?:"[^"]*"|'[^']*')/g, i = /^[A-Za-z0-9_.]+$/, t = [
|
|
2
2
|
"ins-unsubscribe-link",
|
|
3
3
|
"ins-global-unsubscribe-link",
|
|
4
|
-
"ins-preferences-unsubscribe-link"
|
|
4
|
+
"ins-preferences-unsubscribe-link",
|
|
5
|
+
"@COUPON_CODE"
|
|
5
6
|
];
|
|
6
7
|
export {
|
|
7
|
-
|
|
8
|
+
t as ALLOWED_DYNAMIC_SYSTEM_TOKENS,
|
|
8
9
|
e as CampaignCouldNotBeSavedKey,
|
|
9
10
|
n as CanNotMakeAnyChangesForRunningKey,
|
|
10
|
-
|
|
11
|
+
_ as DATA_ATTRIBUTE_REGEX,
|
|
11
12
|
o as DISPLAY_CONDITIONS_EXCEPTIONS_REGEX,
|
|
12
13
|
s as DISPLAY_CONDITIONS_REGEX,
|
|
13
14
|
E as DYNAMIC_CONTENT_TAG_REGEX,
|
|
14
|
-
|
|
15
|
+
i as VALID_DYNAMIC_VARIABLE_REGEX
|
|
15
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.3-beta.96b5eeb",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|