@useinsider/guido 3.9.1 → 3.10.0-beta.06d1f41
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/useCortexBlueprintBridge.js +36 -32
- package/dist/composables/useCustomInterfaceAppearance.js +16 -18
- package/dist/composables/useEmailTemplateApplier.js +17 -15
- package/dist/composables/useExport.js +18 -18
- package/dist/composables/useHtmlValidator.js +90 -90
- package/dist/composables/useStripo.js +53 -51
- package/dist/composables/useStripoNotifications.js +26 -0
- package/dist/composables/useToaster.js +11 -11
- package/dist/composables/useVersionHistoryApi.js +2 -2
- package/dist/composables/validators/useLiquidValidator.js +1 -1
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +10 -10
- package/dist/config/compiler/htmlCompilerRules.js +30 -7
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +137 -119
- package/dist/enums/defaults.js +7 -4
- package/dist/enums/toaster.js +2 -2
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +1 -1
- package/dist/extensions/Blocks/Recommendation/useRecommendationBlockWarning.js +7 -7
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +75 -69
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +18 -17
- package/dist/services/blankTemplate.js +34 -0
- package/dist/services/stripoApi.js +13 -18
- package/dist/services/templateLibraryApi.js +8 -7
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +5 -2
- package/dist/src/composables/useEmailTemplateApplier.d.ts +8 -3
- package/dist/src/composables/useStripoNotifications.d.ts +10 -0
- package/dist/src/enums/defaults.d.ts +3 -0
- package/dist/src/enums/toaster.d.ts +2 -2
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +1 -0
- package/dist/src/services/blankTemplate.d.ts +11 -0
- package/dist/src/stores/toaster.d.ts +2 -3
- package/dist/stores/toaster.js +10 -10
- package/dist/utils/pairProductVariables.js +64 -65
- package/package.json +2 -2
- package/dist/static/styles/components/notification.css.js +0 -74
- package/dist/static/templates/empty/index.html.js +0 -74
- package/dist/static/templates/empty/style.css.js +0 -779
|
@@ -1,189 +1,207 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import { CSS_CLASS_RECO_BUTTON as
|
|
1
|
+
import { useConfig as C } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as E } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
4
|
import { useRecommendationExtensionStore as w } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
5
|
import { isIgnoredRecommendationBlock as P } from "./recommendationIgnoreUtils.js";
|
|
6
|
-
function
|
|
7
|
-
const i = `{{${s}${t}_${
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
for (;
|
|
13
|
-
[
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
function
|
|
17
|
-
switch (
|
|
6
|
+
function R(t, r, e, o, s = "") {
|
|
7
|
+
const i = `{{${s}${t}_${r}_${e}}}`, n = `{{${s}${t}_${r}_currency}}`;
|
|
8
|
+
return o === "before" ? `${n} ${i}` : `${i} ${n}`;
|
|
9
|
+
}
|
|
10
|
+
function y(t) {
|
|
11
|
+
let r = t;
|
|
12
|
+
for (; r.children.length === 1; )
|
|
13
|
+
[r] = r.children;
|
|
14
|
+
return r;
|
|
15
|
+
}
|
|
16
|
+
function A(t, r, e, o, s, i) {
|
|
17
|
+
switch (r) {
|
|
18
18
|
case "productImage": {
|
|
19
|
-
const
|
|
20
|
-
|
|
19
|
+
const n = t.querySelector("img");
|
|
20
|
+
n && (n.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), n.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
|
|
21
21
|
const c = t.querySelector("a");
|
|
22
|
-
c && (c.setAttribute("href", `{{${i}${e}_${
|
|
22
|
+
c && (c.setAttribute("href", `{{${i}${e}_${o}_url}}`), c.classList.add(q));
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
25
|
case "productName": {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
case "productPrice": {
|
|
31
|
-
const r = t.querySelector(".product-price p") ?? t.querySelector("p");
|
|
32
|
-
r && (m(r).textContent = f(
|
|
33
|
-
e,
|
|
34
|
-
n,
|
|
35
|
-
"price",
|
|
36
|
-
s,
|
|
37
|
-
i
|
|
38
|
-
));
|
|
39
|
-
const c = t.querySelector(".product-old-price p");
|
|
40
|
-
c && (m(c).textContent = f(
|
|
41
|
-
e,
|
|
42
|
-
n,
|
|
43
|
-
"original_price",
|
|
44
|
-
s,
|
|
45
|
-
i
|
|
46
|
-
));
|
|
26
|
+
const n = t.querySelector("p");
|
|
27
|
+
n && (y(n).textContent = `{{${i}${e}_${o}_name}}`);
|
|
47
28
|
break;
|
|
48
29
|
}
|
|
30
|
+
// Inline mode ("Move to next line" OFF) merges BOTH prices into one row
|
|
31
|
+
// anchored on whichever attribute comes first in the composition, so
|
|
32
|
+
// substitute by cell content, not by the row's anchor (SD-145161).
|
|
33
|
+
case "productPrice":
|
|
49
34
|
case "productOldPrice": {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
35
|
+
const n = (l, d) => {
|
|
36
|
+
l && (y(l).textContent = R(
|
|
37
|
+
e,
|
|
38
|
+
o,
|
|
39
|
+
d,
|
|
40
|
+
s,
|
|
41
|
+
i
|
|
42
|
+
));
|
|
43
|
+
}, c = t.querySelector(".product-price p"), a = t.querySelector(".product-old-price p"), u = !c && !a ? t.querySelector("p") : null;
|
|
44
|
+
n(c ?? (r === "productPrice" ? u : null), "price"), n(a ?? (r === "productOldPrice" ? u : null), "original_price");
|
|
58
45
|
break;
|
|
59
46
|
}
|
|
60
47
|
case "productButton": {
|
|
61
|
-
const
|
|
62
|
-
|
|
48
|
+
const n = t.querySelector("a");
|
|
49
|
+
n && n.setAttribute("href", `{{${i}${e}_${o}_url}}`);
|
|
63
50
|
break;
|
|
64
51
|
}
|
|
65
52
|
case "productOmnibusPrice": {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
const c =
|
|
53
|
+
const n = t.querySelector(".omnibus-price-value");
|
|
54
|
+
if (n) {
|
|
55
|
+
n.textContent = `{{${i}${e}_${o}_omnibus_price}}`;
|
|
56
|
+
const c = n.closest("p");
|
|
70
57
|
c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
|
|
71
58
|
}
|
|
72
59
|
break;
|
|
73
60
|
}
|
|
74
61
|
case "productOmnibusDiscount": {
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
const c =
|
|
62
|
+
const n = t.querySelector(".omnibus-discount-value");
|
|
63
|
+
if (n) {
|
|
64
|
+
n.textContent = `{{${i}${e}_${o}_omnibus_discount}}`;
|
|
65
|
+
const c = n.closest("p");
|
|
79
66
|
c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
|
|
80
67
|
}
|
|
81
68
|
break;
|
|
82
69
|
}
|
|
83
70
|
default: {
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
const c =
|
|
87
|
-
|
|
71
|
+
const n = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
|
|
72
|
+
if (n) {
|
|
73
|
+
const c = n.getAttribute("product-attr"), a = n.querySelector("p");
|
|
74
|
+
a && (y(a).textContent = `{{${i}${e}_${o}_${c}}}`);
|
|
88
75
|
}
|
|
89
76
|
break;
|
|
90
77
|
}
|
|
91
78
|
}
|
|
92
79
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
80
|
+
const B = "name";
|
|
81
|
+
function S(t, r, e, o) {
|
|
82
|
+
const s = `${o}${r}_${e}_${B}`;
|
|
83
|
+
return {
|
|
84
|
+
open: t.createComment(`{% if ${s} and ${s} != "" %}`),
|
|
85
|
+
close: t.createComment("{% endif %}")
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function L(t, r, e) {
|
|
89
|
+
return S(t, r, 0, e);
|
|
90
|
+
}
|
|
91
|
+
function N(t, r, e, o) {
|
|
92
|
+
if (!t.innerHTML.includes("{{"))
|
|
93
|
+
return;
|
|
94
|
+
const { open: s, close: i } = S(t.ownerDocument, r, e, o);
|
|
95
|
+
t.insertBefore(s, t.firstChild), t.appendChild(i);
|
|
96
|
+
}
|
|
97
|
+
function T(t, r, e, o) {
|
|
98
|
+
var n, c;
|
|
99
|
+
if (!t.innerHTML.includes("{{"))
|
|
100
|
+
return;
|
|
101
|
+
const { open: s, close: i } = S(t.ownerDocument, r, e, o);
|
|
102
|
+
(n = t.parentNode) == null || n.insertBefore(s, t), (c = t.parentNode) == null || c.insertBefore(i, t.nextSibling);
|
|
103
|
+
}
|
|
104
|
+
function v(t, r, e, o) {
|
|
105
|
+
t.querySelectorAll(".recommendation-product-row").forEach((i, n) => {
|
|
106
|
+
i.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
107
|
+
const u = a.getAttribute("data-attribute-type") || "", l = a.querySelectorAll(".attribute-cell");
|
|
108
|
+
l.length > 0 ? l.forEach((d) => {
|
|
109
|
+
A(d, u, r, n, e, o);
|
|
110
|
+
}) : A(a, u, r, n, e, o);
|
|
111
|
+
}), T(i, r, n, o);
|
|
101
112
|
});
|
|
102
113
|
}
|
|
103
|
-
function
|
|
114
|
+
function O(t, r, e, o) {
|
|
104
115
|
const s = t.querySelectorAll(".recommendation-product-row");
|
|
105
116
|
if (!s.length)
|
|
106
117
|
return;
|
|
107
|
-
const [i] = s,
|
|
108
|
-
s.forEach((
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
118
|
+
const [i] = s, n = i.querySelector("[data-attribute-type]"), c = n ? n.querySelectorAll(".attribute-cell").length : 1;
|
|
119
|
+
s.forEach((a, u) => {
|
|
120
|
+
a.querySelectorAll("[data-attribute-type]").forEach((d) => {
|
|
121
|
+
const p = d.getAttribute("data-attribute-type") || "";
|
|
122
|
+
d.querySelectorAll(".attribute-cell").forEach((m, f) => {
|
|
123
|
+
const h = u * c + f;
|
|
124
|
+
A(m, p, r, h, e, o), N(m, r, h, o);
|
|
114
125
|
});
|
|
115
126
|
});
|
|
116
127
|
});
|
|
117
128
|
}
|
|
118
|
-
function
|
|
129
|
+
function W(t, r, e, o) {
|
|
119
130
|
t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
|
|
120
|
-
|
|
131
|
+
O(i, r, e, o);
|
|
121
132
|
});
|
|
122
133
|
}
|
|
123
|
-
function
|
|
124
|
-
const
|
|
125
|
-
|
|
134
|
+
function D(t, r, e) {
|
|
135
|
+
const o = t.getAttribute("data-layout") || "grid", s = t.getAttribute("currency-alignment") || "after";
|
|
136
|
+
o === "list" ? v(t, r, s, e) : W(t, r, s, e);
|
|
126
137
|
}
|
|
127
|
-
function
|
|
128
|
-
const
|
|
138
|
+
function $(t, r, e) {
|
|
139
|
+
const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(o);
|
|
129
140
|
return s ? parseInt(s[1]) : e;
|
|
130
141
|
}
|
|
131
|
-
function
|
|
132
|
-
const
|
|
133
|
-
return
|
|
142
|
+
function _(t) {
|
|
143
|
+
const r = t.trim();
|
|
144
|
+
return r.endsWith("%") ? parseFloat(r) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(r) && parseInt(r) > 0;
|
|
134
145
|
}
|
|
135
|
-
function
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
return
|
|
146
|
+
function g(t) {
|
|
147
|
+
const r = t.getAttribute("width");
|
|
148
|
+
if (r && _(r))
|
|
149
|
+
return r.trim();
|
|
139
150
|
const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
|
|
140
|
-
return e &&
|
|
151
|
+
return e && _(e[1]) ? e[1] : null;
|
|
141
152
|
}
|
|
142
|
-
function
|
|
153
|
+
function M(t, r) {
|
|
143
154
|
let e = t.parentElement;
|
|
144
|
-
for (; e && e !==
|
|
145
|
-
if (e.tagName === "TD" &&
|
|
155
|
+
for (; e && e !== r; ) {
|
|
156
|
+
if (e.tagName === "TD" && g(e))
|
|
146
157
|
return e;
|
|
147
158
|
e = e.parentElement;
|
|
148
159
|
}
|
|
149
160
|
return null;
|
|
150
161
|
}
|
|
151
|
-
function
|
|
152
|
-
const
|
|
162
|
+
function G(t) {
|
|
163
|
+
const r = t.getAttribute("style") || "", e = $(r, "width", 600), o = $(r, "padding", 0) * 2, s = Math.max(0, e - o);
|
|
153
164
|
s !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
154
165
|
if (i.hasAttribute("width"))
|
|
155
166
|
return;
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
167
|
+
const n = M(i, t);
|
|
168
|
+
if (!n)
|
|
158
169
|
return;
|
|
159
|
-
const c =
|
|
160
|
-
i.setAttribute("width", String(
|
|
161
|
-
const
|
|
162
|
-
if (!/\bwidth\s*:\s*\d/i.test(
|
|
163
|
-
const
|
|
164
|
-
i.setAttribute("style", `${
|
|
170
|
+
const c = g(n), a = $(n.getAttribute("style") || "", "padding", 0) * 2, u = c.endsWith("%") ? Math.floor(s * parseFloat(c) / 100) : parseInt(c), 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`);
|
|
165
176
|
}
|
|
166
177
|
});
|
|
167
178
|
}
|
|
168
|
-
function
|
|
179
|
+
function H(t, r) {
|
|
169
180
|
const e = t.match(/<!DOCTYPE[^>]*>/i);
|
|
170
181
|
return (e ? `${e[0]}
|
|
171
|
-
` : "") +
|
|
182
|
+
` : "") + r.documentElement.outerHTML;
|
|
172
183
|
}
|
|
173
|
-
function
|
|
174
|
-
const
|
|
175
|
-
if (!
|
|
184
|
+
function Y(t) {
|
|
185
|
+
const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
186
|
+
if (!o.length)
|
|
176
187
|
return t;
|
|
177
|
-
const { buildCampaignUrl: s } =
|
|
188
|
+
const { buildCampaignUrl: s } = E(), i = w();
|
|
178
189
|
i.recommendationCampaignUrls = {};
|
|
179
|
-
const { isFeatureEnabled:
|
|
180
|
-
return
|
|
181
|
-
var
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
190
|
+
const { isFeatureEnabled: n } = C(), c = n("liquidSyntax") ? "reco_" : "";
|
|
191
|
+
return o.forEach((u) => {
|
|
192
|
+
var d, p, b, m;
|
|
193
|
+
const l = u.getAttribute("recommendation-id");
|
|
194
|
+
if (l) {
|
|
195
|
+
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((f) => f.remove()), s(l), !P(u)) {
|
|
196
|
+
D(u, l, c);
|
|
197
|
+
const { open: f, close: h } = L(e, l, c);
|
|
198
|
+
(b = u.parentNode) == null || b.insertBefore(f, u), (m = u.parentNode) == null || m.insertBefore(h, u.nextSibling);
|
|
199
|
+
}
|
|
200
|
+
G(u);
|
|
201
|
+
}
|
|
202
|
+
}), H(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
185
203
|
}
|
|
186
204
|
export {
|
|
187
|
-
|
|
188
|
-
|
|
205
|
+
R as formatPriceVariable,
|
|
206
|
+
Y as prepareRecommendationBlocks
|
|
189
207
|
};
|
package/dist/enums/defaults.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
const e = {
|
|
2
2
|
transactional: 2
|
|
3
|
-
},
|
|
3
|
+
}, s = 2, a = 13, t = "https://email-static.useinsider.com", o = `${t}/templates/campaign/default.html`, l = `${t}/templates/campaign/default.css`, E = {
|
|
4
4
|
SAVED_MODULES: "savedModules",
|
|
5
5
|
DEFAULT_MODULES: "defaultModules"
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
l as BLANK_TEMPLATE_CSS_URL,
|
|
9
|
+
o as BLANK_TEMPLATE_HTML_URL,
|
|
10
|
+
t as EMAIL_STATIC_BASE_URL,
|
|
11
|
+
s as EditorType,
|
|
12
|
+
a as MAX_DEFAULT_TEMPLATE_ID,
|
|
13
|
+
E as ModuleFolderDefaults,
|
|
11
14
|
e as TemplateTypes
|
|
12
15
|
};
|
package/dist/enums/toaster.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n = /* @__PURE__ */ ((r) => (r.Success = "success", r.Warning = "warning", r.Error = "error", r.Info = "information", r))(n || {});
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
n as ToasterTypeOptions
|
|
4
4
|
};
|
|
@@ -53,7 +53,7 @@ class P extends E {
|
|
|
53
53
|
if (!m)
|
|
54
54
|
return;
|
|
55
55
|
const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, f(S));
|
|
56
|
-
i.modifyHtml(m).setInnerHtml(b);
|
|
56
|
+
i.modifyHtml(m).setInnerHtml(b).setAttribute("data-currency_symbol", n);
|
|
57
57
|
}), i.apply(new B(
|
|
58
58
|
`Updated currency symbol to ${n || "removed"}`
|
|
59
59
|
));
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { useToaster as
|
|
1
|
+
import { useToaster as n } from "../../../composables/useToaster.js";
|
|
2
2
|
import { useTranslations as s } from "../../../composables/useTranslations.js";
|
|
3
|
-
import { ToasterTypeOptions as
|
|
3
|
+
import { ToasterTypeOptions as r } from "../../../enums/toaster.js";
|
|
4
4
|
import { countLiveRecommendationBlocks as i } from "./utils/recommendationBlockCount.js";
|
|
5
|
-
const
|
|
6
|
-
const { showToaster: o } =
|
|
5
|
+
const c = "newsletter.multiple-reco-blocks-warning", u = () => {
|
|
6
|
+
const { showToaster: o } = n(), t = s();
|
|
7
7
|
return { warnIfMultipleBlocks: (e) => {
|
|
8
8
|
i(e) > 1 && o({
|
|
9
|
-
type:
|
|
10
|
-
message: t(
|
|
9
|
+
type: r.Info,
|
|
10
|
+
message: t(c)
|
|
11
11
|
});
|
|
12
12
|
} };
|
|
13
13
|
};
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
u as useRecommendationBlockWarning
|
|
16
16
|
};
|