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