@useinsider/guido 3.20.0-beta.12889e0 → 3.20.0-beta.30c96fc
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/config/compiler/itemsCompilerRules.js +14 -5
- package/dist/config/compiler/utils/itemsCompilerUtils.js +48 -21
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +57 -72
- package/dist/config/migrator/itemsBlockMigrator.js +112 -108
- package/dist/extensions/Blocks/Items/block.js +78 -67
- package/dist/extensions/Blocks/Items/constants/cardWidth.js +20 -0
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +41 -63
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +11 -15
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +16 -16
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +87 -91
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +12 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +2 -5
- package/dist/src/utils/liquidProtection.d.ts +3 -0
- package/dist/utils/liquidProtection.js +5 -0
- package/package.json +1 -1
- package/dist/src/utils/fluidImageStyle.d.ts +0 -7
- package/dist/utils/fluidImageStyle.js +0 -26
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { pairProductVariables as o } from "../../utils/pairProductVariables.js";
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
2
|
+
import { normalizeItemsBlockWidths as r, wrapHiddenPriceTdsForOutlook as e, MSO_ITEMS_HIDE_START as t, MSO_ITEMS_HIDE_END as s } from "./utils/itemsCompilerUtils.js";
|
|
3
|
+
const d = [
|
|
4
|
+
{
|
|
5
|
+
id: "normalize-items-block-widths",
|
|
6
|
+
// Runs before the other items rules so they see non-zero widths; not AMP-safe.
|
|
7
|
+
description: "Normalize zero Items card widths in the compiled email",
|
|
8
|
+
type: "custom",
|
|
9
|
+
processor: r,
|
|
10
|
+
priority: 55
|
|
11
|
+
// Before pair-product-variables (60)
|
|
12
|
+
},
|
|
4
13
|
{
|
|
5
14
|
id: "pair-product-variables",
|
|
6
15
|
description: "Replace product default values with template variables",
|
|
@@ -16,7 +25,7 @@ const a = [
|
|
|
16
25
|
// with safe placeholder comments and collapse them inline for web-engine Outlook.
|
|
17
26
|
description: "Mark hidden Items price tds for Outlook conditional hiding",
|
|
18
27
|
type: "custom",
|
|
19
|
-
processor:
|
|
28
|
+
processor: e,
|
|
20
29
|
priority: 65
|
|
21
30
|
// After pair-product-variables (60), before outlook rules (70+)
|
|
22
31
|
},
|
|
@@ -26,10 +35,10 @@ const a = [
|
|
|
26
35
|
// and reco swap P100) keeps it out of every whitespace/comment-mangling pass.
|
|
27
36
|
description: "Swap Items MSO markers into [if !mso] conditional comments",
|
|
28
37
|
type: "custom",
|
|
29
|
-
processor: (i) => i.replaceAll(`<!--${
|
|
38
|
+
processor: (i) => i.replaceAll(`<!--${t}-->`, "<!--[if !mso]><!-- -->").replaceAll(`<!--${s}-->`, "<!--<![endif]-->"),
|
|
30
39
|
priority: 101
|
|
31
40
|
}
|
|
32
41
|
];
|
|
33
42
|
export {
|
|
34
|
-
|
|
43
|
+
d as itemsCompilerRules
|
|
35
44
|
};
|
|
@@ -1,28 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { PRODUCT_WRAPPER_SELECTOR as A, hasZeroWidthDeclaration as E, isZeroWidthValue as u, withWidthPin as h, PRODUCT_TD_SELECTOR as S, withoutZeroWidth as _ } from "../../../extensions/Blocks/Items/constants/cardWidth.js";
|
|
2
|
+
import { protectLiquid as m, restoreLiquid as y } from "../../../utils/liquidProtection.js";
|
|
3
|
+
const f = "MSO_ITEMS_HIDE_START", D = "MSO_ITEMS_HIDE_END", T = "mso-hide:all; max-height:0; overflow:hidden; font-size:0; line-height:0;", M = ".ins-product-cart td.horizontal-price, .ins-product-cart td.vertical-price";
|
|
4
|
+
function g(e) {
|
|
5
|
+
if (!e.includes("vertical-price") || !e.includes("ins-product-cart"))
|
|
6
|
+
return e;
|
|
7
|
+
const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(n, "text/html");
|
|
8
|
+
let s = !1;
|
|
9
|
+
if (r.querySelectorAll(M).forEach((t) => {
|
|
10
|
+
var d, a;
|
|
11
|
+
const o = t.getAttribute("style") || "";
|
|
10
12
|
if (!/display\s*:\s*none/i.test(o))
|
|
11
13
|
return;
|
|
12
|
-
const
|
|
13
|
-
if (((
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const l = t.previousSibling;
|
|
15
|
+
if (((l == null ? void 0 : l.nodeType) !== Node.COMMENT_NODE || l.data !== f) && ((d = t.parentNode) == null || d.insertBefore(r.createComment(f), t), (a = t.parentNode) == null || a.insertBefore(r.createComment(D), t.nextSibling)), !/mso-hide/i.test(o)) {
|
|
16
|
+
const p = o.trim().endsWith(";") ? " " : "; ";
|
|
17
|
+
t.setAttribute("style", `${o}${p}${T}`);
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
}), !
|
|
19
|
-
return
|
|
20
|
-
const
|
|
21
|
-
return ((
|
|
19
|
+
s = !0;
|
|
20
|
+
}), !s)
|
|
21
|
+
return e;
|
|
22
|
+
const c = n.match(/<!DOCTYPE[^>]*>/i);
|
|
23
|
+
return ((c ? `${c[0]}
|
|
22
24
|
` : "") + r.documentElement.outerHTML).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
23
25
|
}
|
|
26
|
+
function I(e) {
|
|
27
|
+
if (!e.includes("ins-product-wrapper") && !e.includes("ins-product-td"))
|
|
28
|
+
return e;
|
|
29
|
+
const n = new DOMParser().parseFromString(m(e), "text/html");
|
|
30
|
+
let r = !1;
|
|
31
|
+
if (n.querySelectorAll(A).forEach((i) => {
|
|
32
|
+
const t = i.getAttribute("style") || "";
|
|
33
|
+
if (!E(t) && !u(i.getAttribute("width")))
|
|
34
|
+
return;
|
|
35
|
+
const o = h(t);
|
|
36
|
+
o !== t && (i.setAttribute("style", o), r = !0), u(i.getAttribute("width")) && (i.setAttribute("width", "100%"), r = !0);
|
|
37
|
+
}), n.querySelectorAll(S).forEach((i) => {
|
|
38
|
+
const t = i.getAttribute("style") || "";
|
|
39
|
+
if (E(t)) {
|
|
40
|
+
const o = _(t);
|
|
41
|
+
o ? i.setAttribute("style", o) : i.removeAttribute("style"), r = !0;
|
|
42
|
+
}
|
|
43
|
+
u(i.getAttribute("width")) && (i.removeAttribute("width"), r = !0);
|
|
44
|
+
}), !r)
|
|
45
|
+
return e;
|
|
46
|
+
const s = e.match(/<!DOCTYPE[^>]*>/i), c = s ? `${s[0]}
|
|
47
|
+
` : "";
|
|
48
|
+
return y(c + n.documentElement.outerHTML);
|
|
49
|
+
}
|
|
24
50
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
51
|
+
D as MSO_ITEMS_HIDE_END,
|
|
52
|
+
f as MSO_ITEMS_HIDE_START,
|
|
53
|
+
I as normalizeItemsBlockWidths,
|
|
54
|
+
g as wrapHiddenPriceTdsForOutlook
|
|
28
55
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import { MOBILE_ROW_SELECTOR as
|
|
4
|
-
import { useRecommendationExtensionStore as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
function D(t, r, e, o, c = "") {
|
|
1
|
+
import { useConfig as g } from "../../../composables/useConfig.js";
|
|
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 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
|
}
|
|
@@ -14,13 +13,13 @@ function _(t) {
|
|
|
14
13
|
[r] = r.children;
|
|
15
14
|
return r;
|
|
16
15
|
}
|
|
17
|
-
function
|
|
16
|
+
function A(t, r, e, o, c, i) {
|
|
18
17
|
switch (r) {
|
|
19
18
|
case "productImage": {
|
|
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": {
|
|
@@ -34,7 +33,7 @@ function E(t, r, e, o, c, i) {
|
|
|
34
33
|
case "productPrice":
|
|
35
34
|
case "productOldPrice": {
|
|
36
35
|
const n = (l, d) => {
|
|
37
|
-
l && (_(l).textContent =
|
|
36
|
+
l && (_(l).textContent = L(
|
|
38
37
|
e,
|
|
39
38
|
o,
|
|
40
39
|
d,
|
|
@@ -78,24 +77,24 @@ function E(t, r, e, o, c, i) {
|
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
|
-
const
|
|
80
|
+
const P = "name";
|
|
82
81
|
function b(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 b(t, r, 0, e);
|
|
91
90
|
}
|
|
92
|
-
function
|
|
91
|
+
function D(t, r, e, o) {
|
|
93
92
|
if (!t.innerHTML.includes("{{"))
|
|
94
93
|
return;
|
|
95
94
|
const { open: c, close: i } = b(t.ownerDocument, r, e, o);
|
|
96
95
|
t.insertBefore(c, t.firstChild), t.appendChild(i);
|
|
97
96
|
}
|
|
98
|
-
function
|
|
97
|
+
function w(t, r, e, o) {
|
|
99
98
|
var n, s;
|
|
100
99
|
if (!t.innerHTML.includes("{{"))
|
|
101
100
|
return;
|
|
@@ -107,36 +106,36 @@ function W(t, r, e, o) {
|
|
|
107
106
|
i.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
108
107
|
const u = a.getAttribute("data-attribute-type") || "", l = a.querySelectorAll(".attribute-cell");
|
|
109
108
|
l.length > 0 ? l.forEach((d) => {
|
|
110
|
-
|
|
111
|
-
}) :
|
|
112
|
-
}),
|
|
109
|
+
A(d, u, r, n, e, o);
|
|
110
|
+
}) : A(a, u, r, n, e, o);
|
|
111
|
+
}), w(i, r, n, o);
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
|
-
function
|
|
114
|
+
function v(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
119
|
c.forEach((a, u) => {
|
|
121
120
|
a.querySelectorAll("[data-attribute-type]").forEach((d) => {
|
|
122
|
-
const
|
|
123
|
-
d.querySelectorAll(".attribute-cell").forEach((
|
|
124
|
-
const
|
|
125
|
-
|
|
121
|
+
const p = d.getAttribute("data-attribute-type") || "";
|
|
122
|
+
d.querySelectorAll(".attribute-cell").forEach((f, m) => {
|
|
123
|
+
const h = u * s + m;
|
|
124
|
+
A(f, p, r, h, e, o), D(f, r, h, o);
|
|
126
125
|
});
|
|
127
126
|
});
|
|
128
127
|
});
|
|
129
128
|
}
|
|
130
|
-
function
|
|
129
|
+
function H(t, r, e, o) {
|
|
131
130
|
t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
|
|
132
|
-
|
|
131
|
+
v(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") || "after";
|
|
137
|
-
o === "list" ? W(t, r, c, e) :
|
|
136
|
+
o === "list" ? W(t, r, c, e) : H(t, r, c, e);
|
|
138
137
|
}
|
|
139
|
-
function
|
|
138
|
+
function y(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 C(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 G(t, r) {
|
|
155
154
|
let e = t.parentElement;
|
|
156
155
|
for (; e && e !== r; ) {
|
|
157
156
|
if (e.tagName === "TD" && C(e))
|
|
@@ -160,74 +159,60 @@ function V(t, r) {
|
|
|
160
159
|
}
|
|
161
160
|
return null;
|
|
162
161
|
}
|
|
163
|
-
function
|
|
164
|
-
const r =
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
);
|
|
168
|
-
Object.entries(r).forEach(([e, o]) => t.style.setProperty(e, o));
|
|
169
|
-
}
|
|
170
|
-
function X(t) {
|
|
171
|
-
const r = t.getAttribute("style") || "", e = S(r, "width", 600), o = S(r, "padding", 0) * 2, c = Math.max(0, e - o);
|
|
172
|
-
t.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
173
|
-
if (i.hasAttribute("width") || c === 0) {
|
|
174
|
-
A(i);
|
|
162
|
+
function V(t) {
|
|
163
|
+
const r = t.getAttribute("style") || "", e = y(r, "width", 600), o = y(r, "padding", 0) * 2, c = Math.max(0, e - o);
|
|
164
|
+
c !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
165
|
+
if (i.hasAttribute("width"))
|
|
175
166
|
return;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (!n) {
|
|
179
|
-
A(i);
|
|
167
|
+
const n = G(i, t);
|
|
168
|
+
if (!n)
|
|
180
169
|
return;
|
|
170
|
+
const s = C(n), a = y(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), l = Math.max(1, u - a);
|
|
171
|
+
i.setAttribute("width", String(l));
|
|
172
|
+
const d = i.getAttribute("style") || "";
|
|
173
|
+
if (!/\bwidth\s*:\s*\d/i.test(d)) {
|
|
174
|
+
const p = d && !d.trim().endsWith(";") ? "; " : "";
|
|
175
|
+
i.setAttribute("style", `${d}${p}width: ${l}px`);
|
|
181
176
|
}
|
|
182
|
-
const s = C(n), a = S(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), l = Math.max(1, u - a);
|
|
183
|
-
i.setAttribute("width", String(l)), A(i);
|
|
184
177
|
});
|
|
185
178
|
}
|
|
186
|
-
const
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
if (!e || o || !t.head)
|
|
190
|
-
return;
|
|
191
|
-
const c = t.createElement("style");
|
|
192
|
-
c.setAttribute("type", "text/css"), c.textContent = T, t.head.appendChild(c);
|
|
193
|
-
}
|
|
194
|
-
const g = "MSO_MOBILE_HIDE_START", Y = "MSO_MOBILE_HIDE_END";
|
|
195
|
-
function k(t, r) {
|
|
196
|
-
t.querySelectorAll(L).forEach((e) => {
|
|
179
|
+
const E = "MSO_MOBILE_HIDE_START", U = "MSO_MOBILE_HIDE_END";
|
|
180
|
+
function X(t, r) {
|
|
181
|
+
t.querySelectorAll(q).forEach((e) => {
|
|
197
182
|
var i, n;
|
|
198
183
|
const o = e.querySelector(M);
|
|
199
184
|
if (!o || o.children.length === 0)
|
|
200
185
|
return;
|
|
201
186
|
const c = e.previousSibling;
|
|
202
|
-
(c == null ? void 0 : c.nodeType) === Node.COMMENT_NODE && c.data ===
|
|
187
|
+
(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(U), e.nextSibling));
|
|
203
188
|
});
|
|
204
189
|
}
|
|
205
|
-
function
|
|
190
|
+
function j(t, r) {
|
|
206
191
|
const e = t.match(/<!DOCTYPE[^>]*>/i);
|
|
207
192
|
return (e ? `${e[0]}
|
|
208
193
|
` : "") + r.documentElement.outerHTML;
|
|
209
194
|
}
|
|
210
|
-
function
|
|
195
|
+
function Q(t) {
|
|
211
196
|
const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
212
197
|
if (!o.length)
|
|
213
198
|
return t;
|
|
214
|
-
const { buildCampaignUrl: c } =
|
|
199
|
+
const { buildCampaignUrl: c } = O(), i = N();
|
|
215
200
|
i.recommendationCampaignUrls = {};
|
|
216
|
-
const { isFeatureEnabled: n } =
|
|
201
|
+
const { isFeatureEnabled: n } = g(), s = n("liquidSyntax") ? "reco_" : "";
|
|
217
202
|
return o.forEach((u) => {
|
|
218
|
-
var d,
|
|
203
|
+
var d, p, S, f;
|
|
219
204
|
const l = u.getAttribute("recommendation-id");
|
|
220
205
|
if (l) {
|
|
221
|
-
if ((d = u.parentNode) == null || d.insertBefore(e.createComment("REC_START"), u), (
|
|
222
|
-
|
|
223
|
-
const { open: m, close:
|
|
224
|
-
(
|
|
206
|
+
if ((d = u.parentNode) == null || d.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), c(l), X(u, e), !T(u)) {
|
|
207
|
+
F(u, l, s);
|
|
208
|
+
const { open: m, close: h } = R(e, l, s);
|
|
209
|
+
(S = u.parentNode) == null || S.insertBefore(m, u), (f = u.parentNode) == null || f.insertBefore(h, u.nextSibling);
|
|
225
210
|
}
|
|
226
|
-
|
|
211
|
+
V(u);
|
|
227
212
|
}
|
|
228
|
-
}),
|
|
213
|
+
}), j(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
229
214
|
}
|
|
230
215
|
export {
|
|
231
|
-
|
|
232
|
-
|
|
216
|
+
L as formatPriceVariable,
|
|
217
|
+
Q as prepareRecommendationBlocks
|
|
233
218
|
};
|