@useinsider/guido 3.24.0-beta.8e9f4e2 → 3.24.0-beta.9312ed2
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/README.md +2 -0
- package/dist/@types/config/schemas.js +19 -15
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +79 -77
- package/dist/composables/useModuleRepair.js +14 -12
- package/dist/composables/useSave.js +57 -52
- package/dist/composables/useSaveValidation.js +118 -110
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +48 -33
- package/dist/config/migrator/index.js +16 -15
- package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
- package/dist/config/migrator/recommendationMigrator.js +63 -69
- package/dist/enums/save-validation.js +1 -1
- package/dist/extensions/Blocks/Items/block.js +115 -77
- package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
- package/dist/extensions/Blocks/Items/controls/blockBackground/index.js +11 -0
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -23
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
- package/dist/extensions/Blocks/Items/controls/priceFormat.js +135 -0
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
- package/dist/extensions/Blocks/Items/extension.js +15 -13
- package/dist/extensions/Blocks/Items/items.css.js +19 -0
- package/dist/extensions/Blocks/Items/settingsPanel.js +35 -25
- package/dist/extensions/Blocks/Items/template.js +250 -212
- package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
- package/dist/extensions/Blocks/controlFactories.js +104 -104
- package/dist/guido.css +1 -1
- package/dist/package.json.js +4 -4
- package/dist/src/@types/config/schemas.d.ts +8 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useSaveValidation.d.ts +1 -1
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +4 -0
- package/dist/src/config/migrator/index.d.ts +4 -1
- package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
- package/dist/src/config/migrator/recommendationMigrator.d.ts +5 -1
- package/dist/src/enums/save-validation.d.ts +2 -1
- package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
- package/dist/src/extensions/Blocks/Items/controls/blockBackground/index.d.ts +15 -0
- package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +24 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +66 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -1
- package/dist/src/stores/config.d.ts +40 -0
- package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
- package/dist/utils/itemsCurrencyRepair.js +29 -24
- package/dist/utils/pairProductVariables.js +119 -99
- package/package.json +1 -1
- package/dist/config/migrator/recommendation/inferLegacyConfig.js +0 -133
- package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +0 -6
|
@@ -1,108 +1,128 @@
|
|
|
1
|
-
import { ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as
|
|
2
|
-
import { productPairs as
|
|
3
|
-
import { escapeReplacement as
|
|
4
|
-
import { preserveTextStyles as
|
|
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
5
|
import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
|
|
6
6
|
const q = {
|
|
7
7
|
CART_ITEMS: "ins_apr",
|
|
8
8
|
BROWSED_ITEMS: "browsed_item",
|
|
9
9
|
PURCHASED_ITEMS: "purchased_item"
|
|
10
|
-
}, W = (
|
|
11
|
-
function
|
|
12
|
-
let
|
|
13
|
-
for (;
|
|
14
|
-
|
|
15
|
-
return
|
|
10
|
+
}, W = (r) => r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
+
function j(r, h, p) {
|
|
12
|
+
let u = h;
|
|
13
|
+
for (; u > 0 && /\s/.test(r[u - 1]); )
|
|
14
|
+
u -= 1;
|
|
15
|
+
return p.some((A) => r.endsWith(A, u));
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
function
|
|
19
|
-
var
|
|
20
|
-
const
|
|
21
|
-
for (let
|
|
22
|
-
(
|
|
17
|
+
const Q = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
|
|
18
|
+
function z(r, h) {
|
|
19
|
+
var u;
|
|
20
|
+
const p = r.ownerDocument.createTreeWalker(r, NodeFilter.SHOW_COMMENT);
|
|
21
|
+
for (let A = p.nextNode(); A; A = p.nextNode())
|
|
22
|
+
(u = A.nodeValue) != null && u.includes("[if mso]") && (A.nodeValue = A.nodeValue.replace(Q, (L, P) => `${P}href="${h}"`));
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
function J(r) {
|
|
25
|
+
return {
|
|
26
|
+
isFormatted: r.getAttribute("data-formated") === "true",
|
|
27
|
+
isSinglePrice: r.getAttribute("data-single_price") === "true",
|
|
28
|
+
currencyPosition: r.getAttribute(U.POSITION) || "before",
|
|
29
|
+
configuredSymbol: (r.getAttribute(U.SYMBOL) || "").trim()
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function K(r) {
|
|
33
|
+
return {
|
|
34
|
+
isFormatted: !1,
|
|
35
|
+
isSinglePrice: r.getAttribute(N.SINGLE_PRICE) === "true",
|
|
36
|
+
currencyPosition: Y(
|
|
37
|
+
r.getAttribute(N.ALIGNMENT) ?? void 0
|
|
38
|
+
),
|
|
39
|
+
configuredSymbol: (r.getAttribute(N.SYMBOL) || "").trim()
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function Z(r, h, p) {
|
|
43
|
+
const { isFormatted: u, isSinglePrice: A, currencyPosition: L, configuredSymbol: P } = p;
|
|
44
|
+
let y;
|
|
45
|
+
A ? y = u ? r.SINGLE_PRICE_FORMATTED : r.SINGLE_PRICE : y = u ? r.PRICE_FORMATTED : r.PRICE;
|
|
46
|
+
const E = r.CURRENCY;
|
|
47
|
+
let F = `{{${y}_${h}}}`, R = "";
|
|
48
|
+
return B(P) ? R = P : E && (R = `{{${E}_${h}}}`), R && (F = L === "after" ? `${F} ${R}` : `${R} ${F}`), F;
|
|
49
|
+
}
|
|
50
|
+
function ct(r) {
|
|
51
|
+
const h = W(r), p = new DOMParser().parseFromString(h, "text/html");
|
|
52
|
+
X(p);
|
|
53
|
+
const u = k.PAIRS_FOR_EXTENSION;
|
|
54
|
+
Object.entries(u).forEach(([o, T]) => {
|
|
55
|
+
p.querySelectorAll(".ins-product-td").forEach((n) => {
|
|
56
|
+
const S = n.getAttribute("data-number") || "1", I = n.getAttribute("data-type") || "CART_ITEMS";
|
|
57
|
+
n.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
|
|
58
|
+
var b, M, D, x;
|
|
59
|
+
const m = t.getAttribute("data-type") || I, c = t.getAttribute("data-number") || S, f = T[m];
|
|
34
60
|
if (f)
|
|
35
61
|
switch (o) {
|
|
36
62
|
case "imageSrc": {
|
|
37
|
-
let e = null,
|
|
38
|
-
if (t.tagName === "IMG" ? (e = t,
|
|
63
|
+
let e = null, i = null;
|
|
64
|
+
if (t.tagName === "IMG" ? (e = t, i = e.closest("a")) : (e = t.querySelector("img"), i = t.querySelector("a") || t.closest("a")), !e)
|
|
39
65
|
break;
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
return
|
|
46
|
-
}) && (e.src = `{{${
|
|
66
|
+
const d = f.DEFAULT, a = f.ATTR;
|
|
67
|
+
if (d && e.src) {
|
|
68
|
+
const l = e.src;
|
|
69
|
+
d.some((C) => {
|
|
70
|
+
const $ = C.split("/").pop() || "", V = l.split("/").pop() || "";
|
|
71
|
+
return l.includes(C) || l.includes($) || V === $;
|
|
72
|
+
}) && (e.src = `{{${a}_${c}}}`);
|
|
47
73
|
}
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
53
|
-
(
|
|
74
|
+
const s = (M = (b = u.name) == null ? void 0 : b[m]) == null ? void 0 : M.ATTR;
|
|
75
|
+
if (s && e.setAttribute("alt", `{{${s}_${c}}}`), i) {
|
|
76
|
+
const l = (D = u.itemLink) == null ? void 0 : D[m];
|
|
77
|
+
if (l) {
|
|
78
|
+
const H = l.HREF, C = l.DEFAULT_HREF || "#!", $ = i.href;
|
|
79
|
+
($ === "#" || $ === "" || $.endsWith("#!") || $.endsWith(C) || $ === `${window.location.href}${C}` || !$ || $ === window.location.href) && (i.href = `{{${H}_${c}}}`);
|
|
54
80
|
}
|
|
55
81
|
}
|
|
56
82
|
break;
|
|
57
83
|
}
|
|
58
84
|
case "name": {
|
|
59
|
-
const e = f,
|
|
60
|
-
t.textContent && (t.innerHTML =
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
const
|
|
64
|
-
(
|
|
85
|
+
const e = f, i = e.ATTR, d = e.DEFAULT_HREF || "#!", a = e.HREF;
|
|
86
|
+
t.textContent && (t.innerHTML = w(t, `{{${i}_${c}}}`));
|
|
87
|
+
const s = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
88
|
+
if (s && a) {
|
|
89
|
+
const l = s.href, H = `${window.location.href}${d}`;
|
|
90
|
+
(l === H || l.endsWith(d)) && (s.href = `{{${a}_${c}}}`);
|
|
65
91
|
}
|
|
66
92
|
break;
|
|
67
93
|
}
|
|
68
94
|
case "price":
|
|
69
95
|
case "originalPrice": {
|
|
70
|
-
const e = f,
|
|
71
|
-
|
|
72
|
-
i ? b = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : b = c ? e.PRICE_FORMATTED : e.PRICE;
|
|
73
|
-
const g = e.CURRENCY;
|
|
74
|
-
let u = `{{${b}_${n}}}`;
|
|
75
|
-
const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
|
|
76
|
-
let F = "";
|
|
77
|
-
G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
|
|
96
|
+
const e = f, i = G(n) ? K(n) : J(t);
|
|
97
|
+
t.innerHTML = w(t, Z(e, c, i));
|
|
78
98
|
break;
|
|
79
99
|
}
|
|
80
100
|
case "quantity": {
|
|
81
|
-
const e = f,
|
|
82
|
-
|
|
101
|
+
const e = f, i = e.ATTR, d = [e.DEFAULT, ...e.LEGACY_DEFAULTS], a = (x = t.textContent) == null ? void 0 : x.trim();
|
|
102
|
+
a && d.includes(a) && (t.innerHTML = w(t, `{{${i}_${c}}}`));
|
|
83
103
|
break;
|
|
84
104
|
}
|
|
85
105
|
case "button": {
|
|
86
|
-
const e = f,
|
|
87
|
-
if (
|
|
88
|
-
const
|
|
89
|
-
(
|
|
106
|
+
const e = f, i = e.HREF, d = e.DEFAULT_HREF || "#!", a = t.tagName === "A" ? t : t.querySelector("a");
|
|
107
|
+
if (a) {
|
|
108
|
+
const s = a.href || "", l = `${window.location.href}${d}`;
|
|
109
|
+
(s === "" || s === "#" || s === l || s.endsWith(d) || s.endsWith("#!") || s === window.location.href) && (a.href = `{{${i}_${c}}}`);
|
|
90
110
|
}
|
|
91
|
-
|
|
111
|
+
z(t, `{{${i}_${c}}}`);
|
|
92
112
|
break;
|
|
93
113
|
}
|
|
94
114
|
case "itemLink": {
|
|
95
|
-
const e = f,
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
(
|
|
115
|
+
const e = f, i = e.HREF, d = e.DEFAULT_HREF || "#!", a = t;
|
|
116
|
+
if (a.href) {
|
|
117
|
+
const s = a.href, l = `${window.location.href}${d}`;
|
|
118
|
+
(s === l || s.endsWith(d)) && (a.href = `{{${i}_${c}}}`);
|
|
99
119
|
}
|
|
100
120
|
break;
|
|
101
121
|
}
|
|
102
122
|
default: {
|
|
103
123
|
if ("ATTR" in f) {
|
|
104
124
|
const e = f.ATTR;
|
|
105
|
-
t.textContent && (t.innerHTML =
|
|
125
|
+
t.textContent && (t.innerHTML = w(t, `{{${e}_${c}}}`));
|
|
106
126
|
}
|
|
107
127
|
break;
|
|
108
128
|
}
|
|
@@ -110,49 +130,49 @@ function et($) {
|
|
|
110
130
|
});
|
|
111
131
|
});
|
|
112
132
|
});
|
|
113
|
-
const
|
|
114
|
-
` : "", P =
|
|
133
|
+
const A = h.match(/<!DOCTYPE[^>]*>/i), L = A ? `${A[0]}
|
|
134
|
+
` : "", P = p.querySelectorAll(".ins-product-td"), y = [];
|
|
115
135
|
P.forEach((o) => {
|
|
116
|
-
const
|
|
117
|
-
|
|
136
|
+
const T = o.getAttribute("data-type") || "CART_ITEMS", _ = o.getAttribute("data-number") || "1", n = o.outerHTML;
|
|
137
|
+
y.push({
|
|
118
138
|
element: o,
|
|
119
|
-
outerHtml:
|
|
120
|
-
type:
|
|
121
|
-
number:
|
|
139
|
+
outerHtml: n,
|
|
140
|
+
type: T,
|
|
141
|
+
number: _
|
|
122
142
|
});
|
|
123
143
|
});
|
|
124
|
-
let
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
const
|
|
129
|
-
|
|
144
|
+
let E = L + p.documentElement.outerHTML;
|
|
145
|
+
y.reverse().forEach(({ outerHtml: o, type: T, number: _ }) => {
|
|
146
|
+
const n = q[T], S = n ? `${n}_total_product_kind` : "";
|
|
147
|
+
if (S) {
|
|
148
|
+
const g = parseInt(_) - 1, c = `${`{% if ${S} > ${g} %}`}${o}{% endif %}`;
|
|
149
|
+
E = E.replace(o, v(c));
|
|
130
150
|
}
|
|
131
151
|
});
|
|
132
|
-
const
|
|
133
|
-
return
|
|
152
|
+
const F = p.querySelectorAll('[product-attr="originalPrice"][data-type]'), R = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Set();
|
|
153
|
+
return F.forEach((o) => {
|
|
134
154
|
var t;
|
|
135
|
-
const
|
|
136
|
-
if (!
|
|
155
|
+
const T = o.getAttribute("data-number"), _ = o.getAttribute("data-type");
|
|
156
|
+
if (!T || !q[_])
|
|
137
157
|
return;
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
158
|
+
const n = o.closest(".product-original-price-class");
|
|
159
|
+
if (!n || O.has(n))
|
|
140
160
|
return;
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
}),
|
|
145
|
-
if (
|
|
161
|
+
O.add(n);
|
|
162
|
+
const S = n.outerHTML, I = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), g = R.get(S) ?? { number: T, type: _, wrap: [] };
|
|
163
|
+
g.wrap.push(I !== "false"), R.set(S, g);
|
|
164
|
+
}), R.forEach(({ number: o, type: T, wrap: _ }, n) => {
|
|
165
|
+
if (n.includes("{% if") || !_.some(Boolean))
|
|
146
166
|
return;
|
|
147
|
-
const
|
|
148
|
-
let m = "",
|
|
149
|
-
for (;
|
|
150
|
-
const
|
|
151
|
-
m +=
|
|
167
|
+
const S = k.PAIRS_FOR_EXTENSION.price[T].PRICE, I = k.PAIRS_FOR_EXTENSION.originalPrice[T].PRICE, g = `{% if ${S}_${o} != ${I}_${o} %}`, t = [g, W(g)];
|
|
168
|
+
let m = "", c = 0, f = 0, b = E.indexOf(n);
|
|
169
|
+
for (; b !== -1; ) {
|
|
170
|
+
const M = _[f] === !0 && !j(E, b, t);
|
|
171
|
+
m += E.slice(c, b) + (M ? `${g}${n}{% endif %}` : n), c = b + n.length, f += 1, b = E.indexOf(n, c);
|
|
152
172
|
}
|
|
153
|
-
|
|
154
|
-
}),
|
|
173
|
+
E = m + E.slice(c);
|
|
174
|
+
}), E.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
155
175
|
}
|
|
156
176
|
export {
|
|
157
|
-
|
|
177
|
+
ct as pairProductVariables
|
|
158
178
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.24.0-beta.
|
|
3
|
+
"version": "3.24.0-beta.9312ed2",
|
|
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",
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { MAX_PRODUCTS_PER_ROW as _ } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
|
|
2
|
-
const T = "td.product-card", x = '[class*="ext-product-"]', d = ".ext-ins-attr p[product-attr]", y = ".ext-ins-attr", S = ["font-family", "font-size", "font-weight", "font-style"], l = [
|
|
3
|
-
["p_image", ".ext-product-image"],
|
|
4
|
-
["p_name", ".ext-product-name"],
|
|
5
|
-
["p_price", ".ext-product-price"],
|
|
6
|
-
["p_original_price", ".ext-product-original-price"],
|
|
7
|
-
["p_omnibus_price", ".ext-product-omnibus-price", !0],
|
|
8
|
-
["p_omnibus_discount", ".ext-product-omnibus-discount", !0],
|
|
9
|
-
["p_button", ".ext-product-button"]
|
|
10
|
-
], a = l.map(([, t]) => t).join(", ");
|
|
11
|
-
function s(t, e) {
|
|
12
|
-
const n = new RegExp(`(?:^|;)\\s*${e}\\s*:\\s*([^;]+)`, "i"), r = ((t == null ? void 0 : t.getAttribute("style")) ?? "").match(n);
|
|
13
|
-
return (r == null ? void 0 : r[1].trim()) || void 0;
|
|
14
|
-
}
|
|
15
|
-
function p(t) {
|
|
16
|
-
return /^none\b/.test(s(t, "display") ?? "");
|
|
17
|
-
}
|
|
18
|
-
function h(t) {
|
|
19
|
-
return p(t) || p(t.closest("tr"));
|
|
20
|
-
}
|
|
21
|
-
function f(t) {
|
|
22
|
-
const e = {};
|
|
23
|
-
return S.forEach((n) => {
|
|
24
|
-
const r = s(t, n);
|
|
25
|
-
r && (e[n] = r);
|
|
26
|
-
}), Object.keys(e).length > 0 ? e : void 0;
|
|
27
|
-
}
|
|
28
|
-
function g(t) {
|
|
29
|
-
return Object.keys(t).length > 0 ? t : void 0;
|
|
30
|
-
}
|
|
31
|
-
function m(t) {
|
|
32
|
-
const e = t.querySelector("p") ?? t, n = f(e), r = s(e, "color"), i = t.getAttribute("align") ?? s(e, "text-align"), o = s(e, "line-height");
|
|
33
|
-
return g({
|
|
34
|
-
...n ? { textStyle: n } : {},
|
|
35
|
-
...r ? { textColor: { color: r } } : {},
|
|
36
|
-
...i ? { textAlign: { align: i } } : {},
|
|
37
|
-
...o ? { textLineSpacing: { lineSpacing: o } } : {}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
function A(t) {
|
|
41
|
-
var u;
|
|
42
|
-
const e = t.querySelector("a") ?? t, n = (u = e.textContent) == null ? void 0 : u.trim(), r = s(e, "background-color") ?? s(e, "background"), i = s(e, "color"), o = f(e), c = t.getAttribute("align");
|
|
43
|
-
return g({
|
|
44
|
-
...n ? { buttonText: { text: n } } : {},
|
|
45
|
-
...r ? { buttonColor: { color: r } } : {},
|
|
46
|
-
...i ? { textButtonColor: { color: i } } : {},
|
|
47
|
-
...o ? { buttonStyle: o } : {},
|
|
48
|
-
...c ? { buttonAlign: { align: c } } : {}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function C(t) {
|
|
52
|
-
const e = t.querySelector("img"), n = Number(e == null ? void 0 : e.getAttribute("width")), r = Number(e == null ? void 0 : e.getAttribute("height")), i = { ...n > 0 ? { width: n } : {}, ...r > 0 ? { height: r } : {} };
|
|
53
|
-
return Object.keys(i).length > 0 ? { imageSize: i } : void 0;
|
|
54
|
-
}
|
|
55
|
-
function R(t, e) {
|
|
56
|
-
switch (t) {
|
|
57
|
-
case "p_image":
|
|
58
|
-
return C(e);
|
|
59
|
-
case "p_button":
|
|
60
|
-
return A(e);
|
|
61
|
-
default:
|
|
62
|
-
return m(e);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function L(t, e) {
|
|
66
|
-
const n = Array.from(t.querySelectorAll(`[class*="show-recommendation-${e}-"]`));
|
|
67
|
-
return n.length > 0 ? n : Array.from(t.querySelectorAll(T));
|
|
68
|
-
}
|
|
69
|
-
function w(t, e) {
|
|
70
|
-
const n = (o) => e.filter((c) => o.contains(c)).length;
|
|
71
|
-
let r = e[0].parentElement;
|
|
72
|
-
for (; r && r !== t && n(r) < 2; )
|
|
73
|
-
r = r.parentElement;
|
|
74
|
-
if (!r || r === t)
|
|
75
|
-
return e.length === 1 ? 1 : void 0;
|
|
76
|
-
const i = r.tagName === "TBODY" || r.tagName === "TABLE" ? 1 : n(r);
|
|
77
|
-
return Math.min(i, _);
|
|
78
|
-
}
|
|
79
|
-
function v(t) {
|
|
80
|
-
const e = Array.from(t.querySelectorAll(x)).filter((n) => !n.matches(a) && !n.closest(a) && !n.querySelector(a)).flatMap((n) => Array.from(n.classList).filter((r) => r.startsWith("ext-product-")));
|
|
81
|
-
return [...new Set(e)];
|
|
82
|
-
}
|
|
83
|
-
function O(t, e, n) {
|
|
84
|
-
const r = t.closest(y) ?? t, i = m(r);
|
|
85
|
-
return {
|
|
86
|
-
variable: `p_attribute_${e}`,
|
|
87
|
-
variableType: "p_attribute",
|
|
88
|
-
value: t.getAttribute("product-attr") ?? "",
|
|
89
|
-
positionIdx: n,
|
|
90
|
-
hidden: h(r),
|
|
91
|
-
...i ? { theme: i } : {}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function N(t) {
|
|
95
|
-
const e = /* @__PURE__ */ new Set(), n = [];
|
|
96
|
-
let r = 0;
|
|
97
|
-
t.querySelectorAll(`${a}, ${d}`).forEach((o) => {
|
|
98
|
-
if (o.matches(d)) {
|
|
99
|
-
n.push(O(o, r, n.length)), r += 1;
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const c = l.find(
|
|
103
|
-
([b, E]) => !e.has(b) && o.matches(E)
|
|
104
|
-
);
|
|
105
|
-
if (!c)
|
|
106
|
-
return;
|
|
107
|
-
const u = R(c[0], o);
|
|
108
|
-
e.add(c[0]), n.push({
|
|
109
|
-
variable: c[0],
|
|
110
|
-
positionIdx: n.length,
|
|
111
|
-
hidden: h(o),
|
|
112
|
-
...u ? { theme: u } : {}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
const i = l.filter(([o, , c]) => !c && !e.has(o)).map(([o]) => ({ variable: o, hidden: !0 }));
|
|
116
|
-
return [...n, ...i];
|
|
117
|
-
}
|
|
118
|
-
function q(t, e) {
|
|
119
|
-
const n = L(t, e);
|
|
120
|
-
if (n.length === 0)
|
|
121
|
-
return null;
|
|
122
|
-
const r = v(n[0]);
|
|
123
|
-
return r.length > 0 ? (console.warn(
|
|
124
|
-
`[RecommendationMigrator] Block id=${e} — legacy card cells the rebuild cannot map: ${r.join(", ")}`
|
|
125
|
-
), null) : {
|
|
126
|
-
totalCount: n.length,
|
|
127
|
-
rowCount: w(t, n),
|
|
128
|
-
composition: { variables: N(n[0]) }
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
export {
|
|
132
|
-
q as inferLegacyConfig
|
|
133
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { LegacyProductConfig } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Rebuilds the `esd-dev-product-config` a pre-Guido block never carried from what it rendered.
|
|
4
|
-
* Null when no product card renders or a card cell cannot be mapped (the rebuild would lose it); other fields default.
|
|
5
|
-
*/
|
|
6
|
-
export declare function inferLegacyConfig(block: Element, id: number): LegacyProductConfig | null;
|