@useinsider/guido 3.30.0-beta.578752b → 3.30.0-beta.66a43cf
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.
|
@@ -134,7 +134,7 @@ class tt {
|
|
|
134
134
|
if (F().$patch((c) => {
|
|
135
135
|
c.migrations = { ...c.migrations, [H]: a.length };
|
|
136
136
|
}), a.length === 0)
|
|
137
|
-
return console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), this.backfillV2ProductTdAttributes(
|
|
137
|
+
return console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), this.backfillV2ProductTdAttributes(e);
|
|
138
138
|
const n = new Set(Array.from(a).filter(q));
|
|
139
139
|
return a.forEach((c) => {
|
|
140
140
|
const r = this.extractConfiguration(c), i = $({
|
package/dist/package.json.js
CHANGED
|
@@ -1,128 +1,129 @@
|
|
|
1
|
-
import { isNewPriceFormatRoot as
|
|
2
|
-
import { productPairs as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { isNewPriceFormatRoot as G, ITEMS_PRICE_FORMAT_ATTR as N, currencyPositionFromLocation as Y, ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as B } from "../extensions/Blocks/Items/constants/currency.js";
|
|
2
|
+
import { productPairs as k } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
3
|
+
import { escapeReplacement as v } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
|
|
4
|
+
import { preserveTextStyles as w } from "./preserveTextStyles.js";
|
|
5
|
+
import { protectTableText as X, restoreTableText as j } from "./protectTableText.js";
|
|
6
|
+
import { unwrapProductNameLinks as Q } from "./unwrapProductNameLink.js";
|
|
7
|
+
const q = {
|
|
7
8
|
CART_ITEMS: "ins_apr",
|
|
8
9
|
BROWSED_ITEMS: "browsed_item",
|
|
9
10
|
PURCHASED_ITEMS: "purchased_item"
|
|
10
|
-
},
|
|
11
|
-
function
|
|
12
|
-
let
|
|
13
|
-
for (;
|
|
14
|
-
|
|
15
|
-
return
|
|
11
|
+
}, W = (r) => r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
12
|
+
function z(r, h, p) {
|
|
13
|
+
let u = h;
|
|
14
|
+
for (; u > 0 && /\s/.test(r[u - 1]); )
|
|
15
|
+
u -= 1;
|
|
16
|
+
return p.some((A) => r.endsWith(A, u));
|
|
16
17
|
}
|
|
17
|
-
const
|
|
18
|
-
function
|
|
19
|
-
var
|
|
20
|
-
const
|
|
21
|
-
for (let
|
|
22
|
-
(
|
|
18
|
+
const J = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
|
|
19
|
+
function K(r, h) {
|
|
20
|
+
var u;
|
|
21
|
+
const p = r.ownerDocument.createTreeWalker(r, NodeFilter.SHOW_COMMENT);
|
|
22
|
+
for (let A = p.nextNode(); A; A = p.nextNode())
|
|
23
|
+
(u = A.nodeValue) != null && u.includes("[if mso]") && (A.nodeValue = A.nodeValue.replace(J, (L, P) => `${P}href="${h}"`));
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
+
function Z(r) {
|
|
25
26
|
return {
|
|
26
27
|
isFormatted: r.getAttribute("data-formated") === "true",
|
|
27
28
|
isSinglePrice: r.getAttribute("data-single_price") === "true",
|
|
28
|
-
currencyPosition: r.getAttribute(
|
|
29
|
-
configuredSymbol: (r.getAttribute(
|
|
29
|
+
currencyPosition: r.getAttribute(U.POSITION) || "before",
|
|
30
|
+
configuredSymbol: (r.getAttribute(U.SYMBOL) || "").trim()
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
+
function tt(r) {
|
|
33
34
|
return {
|
|
34
35
|
isFormatted: !1,
|
|
35
|
-
isSinglePrice: r.getAttribute(
|
|
36
|
-
currencyPosition:
|
|
37
|
-
r.getAttribute(
|
|
36
|
+
isSinglePrice: r.getAttribute(N.SINGLE_PRICE) === "true",
|
|
37
|
+
currencyPosition: Y(
|
|
38
|
+
r.getAttribute(N.ALIGNMENT) ?? void 0
|
|
38
39
|
),
|
|
39
|
-
configuredSymbol: (r.getAttribute(
|
|
40
|
+
configuredSymbol: (r.getAttribute(N.SYMBOL) || "").trim()
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
const { isFormatted:
|
|
43
|
+
function et(r, h, p) {
|
|
44
|
+
const { isFormatted: u, isSinglePrice: A, currencyPosition: L, configuredSymbol: P } = p;
|
|
44
45
|
let y;
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
let
|
|
48
|
-
return
|
|
46
|
+
A ? y = u ? r.SINGLE_PRICE_FORMATTED : r.SINGLE_PRICE : y = u ? r.PRICE_FORMATTED : r.PRICE;
|
|
47
|
+
const E = r.CURRENCY;
|
|
48
|
+
let F = `{{${y}_${h}}}`, R = "";
|
|
49
|
+
return B(P) ? R = P : E && (R = `{{${E}_${h}}}`), R && (F = L === "after" ? `${F} ${R}` : `${R} ${F}`), F;
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
Object.entries(
|
|
55
|
-
|
|
56
|
-
const
|
|
51
|
+
function at(r) {
|
|
52
|
+
const h = W(X(r)), p = new DOMParser().parseFromString(h, "text/html");
|
|
53
|
+
Q(p);
|
|
54
|
+
const u = k.PAIRS_FOR_EXTENSION;
|
|
55
|
+
Object.entries(u).forEach(([o, T]) => {
|
|
56
|
+
p.querySelectorAll(".ins-product-td").forEach((n) => {
|
|
57
|
+
const S = n.getAttribute("data-number") || "1", I = n.getAttribute("data-type") || "CART_ITEMS";
|
|
57
58
|
n.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
|
|
58
|
-
var
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
59
|
+
var g, M, x, D;
|
|
60
|
+
const m = t.getAttribute("data-type") || I, c = t.getAttribute("data-number") || S, f = T[m];
|
|
61
|
+
if (f)
|
|
61
62
|
switch (o) {
|
|
62
63
|
case "imageSrc": {
|
|
63
64
|
let e = null, i = null;
|
|
64
65
|
if (t.tagName === "IMG" ? (e = t, i = e.closest("a")) : (e = t.querySelector("img"), i = t.querySelector("a") || t.closest("a")), !e)
|
|
65
66
|
break;
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
return
|
|
67
|
+
const d = f.DEFAULT, a = f.ATTR;
|
|
68
|
+
if (d && e.src) {
|
|
69
|
+
const l = e.src;
|
|
70
|
+
d.some((C) => {
|
|
71
|
+
const $ = C.split("/").pop() || "", V = l.split("/").pop() || "";
|
|
72
|
+
return l.includes(C) || l.includes($) || V === $;
|
|
72
73
|
}) && (e.src = `{{${a}_${c}}}`);
|
|
73
74
|
}
|
|
74
|
-
const s = (
|
|
75
|
+
const s = (M = (g = u.name) == null ? void 0 : g[m]) == null ? void 0 : M.ATTR;
|
|
75
76
|
if (s && e.setAttribute("alt", `{{${s}_${c}}}`), i) {
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
79
|
-
(
|
|
77
|
+
const l = (x = u.itemLink) == null ? void 0 : x[m];
|
|
78
|
+
if (l) {
|
|
79
|
+
const H = l.HREF, C = l.DEFAULT_HREF || "#!", $ = i.href;
|
|
80
|
+
($ === "#" || $ === "" || $.endsWith("#!") || $.endsWith(C) || $ === `${window.location.href}${C}` || !$ || $ === window.location.href) && (i.href = `{{${H}_${c}}}`);
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
break;
|
|
83
84
|
}
|
|
84
85
|
case "name": {
|
|
85
|
-
const e =
|
|
86
|
-
t.textContent && (t.innerHTML =
|
|
86
|
+
const e = f, i = e.ATTR, d = e.DEFAULT_HREF || "#!", a = e.HREF;
|
|
87
|
+
t.textContent && (t.innerHTML = w(t, `{{${i}_${c}}}`));
|
|
87
88
|
const s = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
88
89
|
if (s && a) {
|
|
89
|
-
const
|
|
90
|
-
(
|
|
90
|
+
const l = s.href, H = `${window.location.href}${d}`;
|
|
91
|
+
(l === H || l.endsWith(d)) && (s.href = `{{${a}_${c}}}`);
|
|
91
92
|
}
|
|
92
93
|
break;
|
|
93
94
|
}
|
|
94
95
|
case "price":
|
|
95
96
|
case "originalPrice": {
|
|
96
|
-
const e =
|
|
97
|
-
t.innerHTML =
|
|
97
|
+
const e = f, i = G(n) ? tt(n) : Z(t);
|
|
98
|
+
t.innerHTML = w(t, et(e, c, i));
|
|
98
99
|
break;
|
|
99
100
|
}
|
|
100
101
|
case "quantity": {
|
|
101
|
-
const e =
|
|
102
|
-
a &&
|
|
102
|
+
const e = f, i = e.ATTR, d = [e.DEFAULT, ...e.LEGACY_DEFAULTS], a = (D = t.textContent) == null ? void 0 : D.trim();
|
|
103
|
+
a && d.includes(a) && (t.innerHTML = w(t, `{{${i}_${c}}}`));
|
|
103
104
|
break;
|
|
104
105
|
}
|
|
105
106
|
case "button": {
|
|
106
|
-
const e =
|
|
107
|
+
const e = f, i = e.HREF, d = e.DEFAULT_HREF || "#!", a = t.tagName === "A" ? t : t.querySelector("a");
|
|
107
108
|
if (a) {
|
|
108
|
-
const s = a.href || "",
|
|
109
|
-
(s === "" || s === "#" || s ===
|
|
109
|
+
const s = a.href || "", l = `${window.location.href}${d}`;
|
|
110
|
+
(s === "" || s === "#" || s === l || s.endsWith(d) || s.endsWith("#!") || s === window.location.href) && (a.href = `{{${i}_${c}}}`);
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
+
K(t, `{{${i}_${c}}}`);
|
|
112
113
|
break;
|
|
113
114
|
}
|
|
114
115
|
case "itemLink": {
|
|
115
|
-
const e =
|
|
116
|
+
const e = f, i = e.HREF, d = e.DEFAULT_HREF || "#!", a = t;
|
|
116
117
|
if (a.href) {
|
|
117
|
-
const s = a.href,
|
|
118
|
-
(s ===
|
|
118
|
+
const s = a.href, l = `${window.location.href}${d}`;
|
|
119
|
+
(s === l || s.endsWith(d)) && (a.href = `{{${i}_${c}}}`);
|
|
119
120
|
}
|
|
120
121
|
break;
|
|
121
122
|
}
|
|
122
123
|
default: {
|
|
123
|
-
if ("ATTR" in
|
|
124
|
-
const e =
|
|
125
|
-
t.textContent && (t.innerHTML =
|
|
124
|
+
if ("ATTR" in f) {
|
|
125
|
+
const e = f.ATTR;
|
|
126
|
+
t.textContent && (t.innerHTML = w(t, `{{${e}_${c}}}`));
|
|
126
127
|
}
|
|
127
128
|
break;
|
|
128
129
|
}
|
|
@@ -130,40 +131,49 @@ function nt(r) {
|
|
|
130
131
|
});
|
|
131
132
|
});
|
|
132
133
|
});
|
|
133
|
-
const
|
|
134
|
-
` : "";
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
134
|
+
const A = h.match(/<!DOCTYPE[^>]*>/i), L = A ? `${A[0]}
|
|
135
|
+
` : "", P = p.querySelectorAll(".ins-product-td"), y = [];
|
|
136
|
+
P.forEach((o) => {
|
|
137
|
+
const T = o.getAttribute("data-type") || "CART_ITEMS", _ = o.getAttribute("data-number") || "1", n = o.outerHTML;
|
|
138
|
+
y.push({
|
|
139
|
+
element: o,
|
|
140
|
+
outerHtml: n,
|
|
141
|
+
type: T,
|
|
142
|
+
number: _
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
let E = L + p.documentElement.outerHTML;
|
|
146
|
+
y.reverse().forEach(({ outerHtml: o, type: T, number: _ }) => {
|
|
147
|
+
const n = q[T], S = n ? `${n}_total_product_kind` : "";
|
|
148
|
+
if (S) {
|
|
149
|
+
const b = parseInt(_) - 1, c = `${`{% if ${S} > ${b} %}`}${o}{% endif %}`;
|
|
150
|
+
E = E.replace(o, v(c));
|
|
151
|
+
}
|
|
141
152
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return y.forEach((o) => {
|
|
153
|
+
const F = p.querySelectorAll('[product-attr="originalPrice"][data-type]'), R = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Set();
|
|
154
|
+
return F.forEach((o) => {
|
|
145
155
|
var t;
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
156
|
+
const T = o.getAttribute("data-number"), _ = o.getAttribute("data-type");
|
|
157
|
+
if (!T || !q[_])
|
|
148
158
|
return;
|
|
149
159
|
const n = o.closest(".product-original-price-class");
|
|
150
|
-
if (!n ||
|
|
160
|
+
if (!n || O.has(n))
|
|
151
161
|
return;
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
}),
|
|
156
|
-
if (n.includes("{% if") ||
|
|
162
|
+
O.add(n);
|
|
163
|
+
const S = n.outerHTML, I = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), b = R.get(S) ?? { number: T, type: _, wrap: [] };
|
|
164
|
+
b.wrap.push(I !== "false"), R.set(S, b);
|
|
165
|
+
}), R.forEach(({ number: o, type: T, wrap: _ }, n) => {
|
|
166
|
+
if (n.includes("{% if") || !_.some(Boolean))
|
|
157
167
|
return;
|
|
158
|
-
const
|
|
159
|
-
let
|
|
160
|
-
for (;
|
|
161
|
-
const
|
|
162
|
-
|
|
168
|
+
const S = k.PAIRS_FOR_EXTENSION.price[T].PRICE, I = k.PAIRS_FOR_EXTENSION.originalPrice[T].PRICE, b = `{% if ${S}_${o} != ${I}_${o} %}`, t = [b, W(b)];
|
|
169
|
+
let m = "", c = 0, f = 0, g = E.indexOf(n);
|
|
170
|
+
for (; g !== -1; ) {
|
|
171
|
+
const M = _[f] === !0 && !z(E, g, t);
|
|
172
|
+
m += E.slice(c, g) + (M ? `${b}${n}{% endif %}` : n), c = g + n.length, f += 1, g = E.indexOf(n, c);
|
|
163
173
|
}
|
|
164
|
-
E =
|
|
165
|
-
}),
|
|
174
|
+
E = m + E.slice(c);
|
|
175
|
+
}), j(E.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}"));
|
|
166
176
|
}
|
|
167
177
|
export {
|
|
168
|
-
|
|
178
|
+
at as pairProductVariables
|
|
169
179
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.30.0-beta.
|
|
3
|
+
"version": "3.30.0-beta.66a43cf",
|
|
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",
|