@useinsider/guido 3.27.0-beta.aadc015 → 3.27.0-beta.b57163d
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,165 +1,126 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { BLOCK_ID as
|
|
5
|
-
import { hasZeroWidthDeclaration as
|
|
6
|
-
import { ItemInCartOptions as
|
|
7
|
-
import { getDefaultTemplate as
|
|
8
|
-
import { useTemplateStore as
|
|
9
|
-
import { protectLiquid as
|
|
10
|
-
|
|
11
|
-
".es-hidden",
|
|
12
|
-
".ins-product-td",
|
|
13
|
-
"td.esd-cart-items-block",
|
|
14
|
-
"td.esd-browsed-items-block",
|
|
15
|
-
"td.esd-purchased-items-block"
|
|
16
|
-
].join(", ");
|
|
17
|
-
function h(r) {
|
|
18
|
-
const t = Number(r.getAttribute("width"));
|
|
19
|
-
return Number.isFinite(t) && t > 0 ? t : 0;
|
|
20
|
-
}
|
|
21
|
-
function P(r) {
|
|
22
|
-
return Array.from(r.children).filter((t) => t.tagName === "TBODY").flatMap((t) => Array.from(t.children)).flatMap((t) => Array.from(t.children).filter((e) => e.tagName === "TD"));
|
|
23
|
-
}
|
|
24
|
-
function z(r) {
|
|
25
|
-
var e, i;
|
|
26
|
-
let t = (e = r.parentElement) == null ? void 0 : e.closest("table");
|
|
27
|
-
for (; t; ) {
|
|
28
|
-
const o = h(t);
|
|
29
|
-
if (o)
|
|
30
|
-
return o;
|
|
31
|
-
t = (i = t.parentElement) == null ? void 0 : i.closest("table");
|
|
32
|
-
}
|
|
33
|
-
return 0;
|
|
34
|
-
}
|
|
35
|
-
function k(r) {
|
|
36
|
-
var a, c;
|
|
37
|
-
const t = (c = (a = r.parentElement) == null ? void 0 : a.parentElement) == null ? void 0 : c.parentElement, e = t == null ? void 0 : t.parentElement;
|
|
38
|
-
if (!t || !e || !t.matches(D) || !h(r))
|
|
39
|
-
return !1;
|
|
40
|
-
const i = P(t), o = i.some((l) => !l.matches(Y) && h(l));
|
|
41
|
-
if (!i.includes(r) || o)
|
|
42
|
-
return !1;
|
|
43
|
-
const u = Array.from(e.children).filter((l) => l.matches(D)).reduce((l, d) => l + Math.max(0, ...P(d).map(h)), 0), n = z(e);
|
|
44
|
-
return n > 0 && u <= n;
|
|
45
|
-
}
|
|
46
|
-
function j() {
|
|
1
|
+
var B = Object.defineProperty;
|
|
2
|
+
var v = (n, t, e) => t in n ? B(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var M = (n, t, e) => v(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { BLOCK_ID as R } from "../../extensions/Blocks/Items/block.js";
|
|
5
|
+
import { hasZeroWidthDeclaration as L, withoutZeroWidth as x } from "../../extensions/Blocks/Items/constants/cardWidth.js";
|
|
6
|
+
import { ItemInCartOptions as h, DefaultConfigValues as b, SETTINGS_ENUMS as _ } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
7
|
+
import { getDefaultTemplate as V } from "../../extensions/Blocks/Items/template.js";
|
|
8
|
+
import { useTemplateStore as O } from "../../stores/template.js";
|
|
9
|
+
import { protectLiquid as H, restoreLiquid as $ } from "../../utils/liquidProtection.js";
|
|
10
|
+
function F() {
|
|
47
11
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
48
12
|
}
|
|
49
|
-
function
|
|
50
|
-
return
|
|
51
|
-
CartItems:
|
|
52
|
-
BrowsedItems:
|
|
53
|
-
PurchasedItems:
|
|
54
|
-
CART_ITEMS:
|
|
55
|
-
BROWSED_ITEMS:
|
|
56
|
-
PURCHASED_ITEMS:
|
|
57
|
-
}[
|
|
13
|
+
function D(n) {
|
|
14
|
+
return n ? {
|
|
15
|
+
CartItems: _.ITEMS_TYPE.CART_ITEMS,
|
|
16
|
+
BrowsedItems: _.ITEMS_TYPE.BROWSED_ITEMS,
|
|
17
|
+
PurchasedItems: _.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
18
|
+
CART_ITEMS: _.ITEMS_TYPE.CART_ITEMS,
|
|
19
|
+
BROWSED_ITEMS: _.ITEMS_TYPE.BROWSED_ITEMS,
|
|
20
|
+
PURCHASED_ITEMS: _.ITEMS_TYPE.PURCHASED_ITEMS
|
|
21
|
+
}[n] || _.ITEMS_TYPE.CART_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
|
|
58
22
|
}
|
|
59
|
-
function
|
|
60
|
-
return
|
|
23
|
+
function U(n) {
|
|
24
|
+
return n.classList.contains("esd-browsed-items-block") ? _.ITEMS_TYPE.BROWSED_ITEMS : n.classList.contains("esd-purchased-items-block") ? _.ITEMS_TYPE.PURCHASED_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
|
|
61
25
|
}
|
|
62
|
-
function
|
|
63
|
-
var
|
|
64
|
-
const t = (
|
|
65
|
-
let
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
|
|
26
|
+
function P(n) {
|
|
27
|
+
var o;
|
|
28
|
+
const t = (i, d) => i == null ? d : i === "1" || i === "true", e = (i, d) => i || d, a = n["data-type"] || n["data-source"], r = D(a), u = h[r];
|
|
29
|
+
let c = n["data-cart_items_select_control_value"] || ((o = u == null ? void 0 : u[0]) == null ? void 0 : o.value) || b.cartItemsSelectControlValue;
|
|
30
|
+
if (c && !c.includes("{{") && /^\d+$/.test(c)) {
|
|
31
|
+
const i = parseInt(c) - 1, d = h[r];
|
|
32
|
+
d && d[i] && (c = d[i].value);
|
|
69
33
|
}
|
|
70
34
|
return {
|
|
71
35
|
initialized: !0,
|
|
72
|
-
blockInstanceId: e(
|
|
73
|
-
source:
|
|
74
|
-
type:
|
|
75
|
-
itemsSelectValue:
|
|
76
|
-
orientation:
|
|
77
|
-
nameTrimming: t(
|
|
78
|
-
priceHideDiscount: t(
|
|
79
|
-
priceFormatted: t(
|
|
80
|
-
priceSinglePrice: t(
|
|
36
|
+
blockInstanceId: e(n["data-block-instance-id"], F()),
|
|
37
|
+
source: r,
|
|
38
|
+
type: r,
|
|
39
|
+
itemsSelectValue: c,
|
|
40
|
+
orientation: n["data-card_orientation_control_value"] || _.ORIENTATION.VERTICAL,
|
|
41
|
+
nameTrimming: t(n["data-product_name_control_trim"], !0),
|
|
42
|
+
priceHideDiscount: t(n["data-product_price_control_nodup"], !0),
|
|
43
|
+
priceFormatted: t(n["data-product_price_control_formated"], !0),
|
|
44
|
+
priceSinglePrice: t(n["data-product_price_control_single_price"], !1),
|
|
81
45
|
priceCurrencySymbol: e(
|
|
82
|
-
|
|
83
|
-
|
|
46
|
+
n["data-product_price_control_currency_symbol"],
|
|
47
|
+
b.productPriceCurrencySymbolControlValue
|
|
84
48
|
),
|
|
85
49
|
priceCurrencyLocation: e(
|
|
86
|
-
|
|
87
|
-
|
|
50
|
+
n["data-product_price_currency_location"],
|
|
51
|
+
b.productPriceCurrencyLocationControlValue
|
|
88
52
|
),
|
|
89
|
-
priceOrientation:
|
|
90
|
-
quantityControlEnabled: t(
|
|
91
|
-
buttonLink: e(
|
|
92
|
-
imageLink: e(
|
|
93
|
-
buttonLabel: e(
|
|
94
|
-
buttonFullWidth: t(
|
|
95
|
-
imageVisible: t(
|
|
96
|
-
nameVisible: t(
|
|
97
|
-
quantityVisible: t(
|
|
98
|
-
priceVisible: t(
|
|
99
|
-
originalPriceVisible: t(
|
|
100
|
-
buttonVisible: t(
|
|
53
|
+
priceOrientation: n["data-product_original_price_control_orientation"] || "horizontal",
|
|
54
|
+
quantityControlEnabled: t(n["data-product_quantity_control_enabled"], !0),
|
|
55
|
+
buttonLink: e(n["data-product_button_link"], b.productButtonLinkControlValue),
|
|
56
|
+
imageLink: e(n["data-product_image_link"], b.productImageLinkControlValue),
|
|
57
|
+
buttonLabel: e(n["data-product_button_control_label"], "Buy"),
|
|
58
|
+
buttonFullWidth: t(n["data-product_button_control_atw"], !0),
|
|
59
|
+
imageVisible: t(n["data-product_image_control_enabled"], !0),
|
|
60
|
+
nameVisible: t(n["data-product_name_control_enabled"], !0),
|
|
61
|
+
quantityVisible: t(n["data-product_quantity_control_enabled"], !0),
|
|
62
|
+
priceVisible: t(n["data-product_price_control_enabled"], !0),
|
|
63
|
+
originalPriceVisible: t(n["data-product_original_price_control_enabled"], !0),
|
|
64
|
+
buttonVisible: t(n["data-product_button_control_enabled"], !0)
|
|
101
65
|
};
|
|
102
66
|
}
|
|
103
|
-
function
|
|
67
|
+
function Y(n, t) {
|
|
104
68
|
const e = {
|
|
105
69
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
106
70
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
107
71
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
108
72
|
};
|
|
109
|
-
return e[
|
|
73
|
+
return e[n] || e.CART_ITEMS;
|
|
110
74
|
}
|
|
111
|
-
function
|
|
75
|
+
function W(n, t) {
|
|
112
76
|
const e = {
|
|
113
77
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
114
78
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
115
79
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
116
80
|
};
|
|
117
|
-
return e[
|
|
81
|
+
return e[n] || e.CART_ITEMS;
|
|
118
82
|
}
|
|
119
|
-
class
|
|
83
|
+
class z {
|
|
120
84
|
constructor() {
|
|
121
|
-
|
|
85
|
+
M(this, "parser");
|
|
122
86
|
this.parser = new DOMParser();
|
|
123
87
|
}
|
|
124
88
|
migrate(t) {
|
|
125
89
|
try {
|
|
126
90
|
if (!this.containsItemsBlock(t))
|
|
127
91
|
return this.backfillV2ProductTdAttributes(t);
|
|
128
|
-
const e = this.removeJinjaConditionals(t),
|
|
92
|
+
const e = this.removeJinjaConditionals(t), a = this.parser.parseFromString(e, "text/html"), r = a.querySelectorAll(
|
|
129
93
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
130
94
|
);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}),
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
currencyLocation: c.currencyLocation,
|
|
143
|
-
formattedPrice: c.formattedPrice,
|
|
144
|
-
configBlockAttributes: c.configBlockAttributes,
|
|
95
|
+
return O().$patch((c) => {
|
|
96
|
+
c.migrations = { ...c.migrations, [R]: r.length };
|
|
97
|
+
}), r.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), this.backfillV2ProductTdAttributes(e)) : (r.forEach((c) => {
|
|
98
|
+
const o = this.extractConfiguration(c), i = V({
|
|
99
|
+
orientation: o.orientation,
|
|
100
|
+
itemsType: o.itemsType,
|
|
101
|
+
itemId: o.itemId,
|
|
102
|
+
currencySymbol: o.currencySymbol,
|
|
103
|
+
currencyLocation: o.currencyLocation,
|
|
104
|
+
formattedPrice: o.formattedPrice,
|
|
105
|
+
configBlockAttributes: o.configBlockAttributes,
|
|
145
106
|
migrate: !0,
|
|
146
|
-
nameStyles:
|
|
147
|
-
buttonStyles:
|
|
148
|
-
priceStyles:
|
|
149
|
-
originalPriceStyles:
|
|
150
|
-
quantityStyles:
|
|
151
|
-
nodeConfig:
|
|
152
|
-
}),
|
|
153
|
-
`<table><tbody><tr>${
|
|
107
|
+
nameStyles: o.nameStyles,
|
|
108
|
+
buttonStyles: o.buttonStyles,
|
|
109
|
+
priceStyles: o.priceStyles,
|
|
110
|
+
originalPriceStyles: o.originalPriceStyles,
|
|
111
|
+
quantityStyles: o.quantityStyles,
|
|
112
|
+
nodeConfig: P(o.configBlockAttributes)
|
|
113
|
+
}), l = this.parser.parseFromString(
|
|
114
|
+
`<table><tbody><tr>${i}</tr></tbody></table>`,
|
|
154
115
|
"text/html"
|
|
155
116
|
).querySelector("td");
|
|
156
|
-
if (
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
117
|
+
if (l && c.parentNode) {
|
|
118
|
+
const s = P(o.configBlockAttributes);
|
|
119
|
+
l.setAttribute("esd-ext-config", JSON.stringify(s)), l.setAttribute("data-type", s.type);
|
|
120
|
+
const p = l.querySelector("esd-config-block");
|
|
121
|
+
p && p.remove(), c.parentNode.replaceChild(l, c);
|
|
161
122
|
}
|
|
162
|
-
}), this.backfillV2ProductTdAttributes(
|
|
123
|
+
}), this.backfillV2ProductTdAttributes(a.documentElement.outerHTML));
|
|
163
124
|
} catch (e) {
|
|
164
125
|
return console.error("ItemsBlockMigrator failed:", e), t;
|
|
165
126
|
}
|
|
@@ -171,25 +132,25 @@ class K {
|
|
|
171
132
|
* - UI styles from product elements (name, price, button, quantity, etc.)
|
|
172
133
|
*/
|
|
173
134
|
extractConfiguration(t) {
|
|
174
|
-
var
|
|
175
|
-
const e =
|
|
176
|
-
this.readSelfOrDescendantAttribute(t, "data-type") ||
|
|
177
|
-
),
|
|
178
|
-
this.applyDomFallbacks(t,
|
|
179
|
-
const
|
|
135
|
+
var C;
|
|
136
|
+
const e = D(
|
|
137
|
+
this.readSelfOrDescendantAttribute(t, "data-type") || U(t)
|
|
138
|
+
), a = this.readSelfOrDescendantAttribute(t, "data-number") || "1", r = parseInt(a) - 1, u = h[e], c = ((C = u == null ? void 0 : u[r]) == null ? void 0 : C.value) || u[0].value, o = this.extractConfigBlockAttributes(t, e, a);
|
|
139
|
+
this.applyDomFallbacks(t, o);
|
|
140
|
+
const i = t.querySelector('[product-attr="price"]'), d = o["data-product_price_control_currency_symbol"], l = o["data-product_price_currency_location"] || "0", s = o["data-product_price_control_formated"], p = s !== "false" && s !== "0", S = o["data-card_orientation_control_value"] === "horizontal" ? "horizontal" : "vertical", f = t.querySelector('a[product-attr="name"]'), y = (f == null ? void 0 : f.getAttribute("style")) || void 0, g = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), I = (g == null ? void 0 : g.getAttribute("style")) || void 0, k = (i == null ? void 0 : i.getAttribute("style")) || void 0, m = t.querySelector("p.original-price") ?? t.querySelector('[product-attr="originalPrice"]'), A = m != null && m.getAttribute("style") ? m : (m == null ? void 0 : m.closest("p")) ?? m, q = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), w = (E == null ? void 0 : E.getAttribute("style")) || void 0;
|
|
180
141
|
return {
|
|
181
|
-
orientation:
|
|
142
|
+
orientation: S,
|
|
182
143
|
itemsType: e,
|
|
183
|
-
itemId:
|
|
184
|
-
currencySymbol:
|
|
185
|
-
currencyLocation:
|
|
186
|
-
formattedPrice:
|
|
187
|
-
configBlockAttributes:
|
|
144
|
+
itemId: c,
|
|
145
|
+
currencySymbol: d,
|
|
146
|
+
currencyLocation: l,
|
|
147
|
+
formattedPrice: p,
|
|
148
|
+
configBlockAttributes: o,
|
|
188
149
|
nameStyles: y,
|
|
189
150
|
buttonStyles: I,
|
|
190
|
-
priceStyles:
|
|
191
|
-
originalPriceStyles:
|
|
192
|
-
quantityStyles:
|
|
151
|
+
priceStyles: k,
|
|
152
|
+
originalPriceStyles: q,
|
|
153
|
+
quantityStyles: w
|
|
193
154
|
};
|
|
194
155
|
}
|
|
195
156
|
/**
|
|
@@ -200,8 +161,8 @@ class K {
|
|
|
200
161
|
* card migrates with the boilerplate defaults: caption "Buy", USD, full-width button.
|
|
201
162
|
*/
|
|
202
163
|
applyDomFallbacks(t, e) {
|
|
203
|
-
var
|
|
204
|
-
const
|
|
164
|
+
var S, f;
|
|
165
|
+
const a = t.querySelector("esd-config-block"), r = (...y) => !a || y.every((g) => !(a.getAttribute(g) ?? "").trim());
|
|
205
166
|
Object.entries({
|
|
206
167
|
image: '[product-attr="imageSrc"]',
|
|
207
168
|
name: '[product-attr="name"]',
|
|
@@ -209,18 +170,18 @@ class K {
|
|
|
209
170
|
original_price: '[product-attr="originalPrice"], p.original-price',
|
|
210
171
|
quantity: '[product-attr="quantity"]',
|
|
211
172
|
button: '[product-attr="button"]'
|
|
212
|
-
}).forEach(([y,
|
|
173
|
+
}).forEach(([y, g]) => {
|
|
213
174
|
const I = `data-product_${y}_control_enabled`;
|
|
214
|
-
|
|
215
|
-
}),
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
s &&
|
|
222
|
-
const
|
|
223
|
-
|
|
175
|
+
r(I) && (e[I] = t.querySelector(g) ? "true" : "false");
|
|
176
|
+
}), r("data-card_orientation_control_value") && (e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal");
|
|
177
|
+
const c = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), o = (S = c == null ? void 0 : c.textContent) == null ? void 0 : S.replace(/\s+/g, " ").trim();
|
|
178
|
+
o && r("data-product_button_control_label") && (e["data-product_button_control_label"] = o);
|
|
179
|
+
const i = (c == null ? void 0 : c.getAttribute("style")) || "";
|
|
180
|
+
r("data-product_button_control_atw") && /display:\s*inline/.test(i) && !/(?:^|;)\s*width\s*:\s*100%/.test(i) && (e["data-product_button_control_atw"] = "false");
|
|
181
|
+
const d = t.querySelector('[product-attr="imageSrc"]'), l = d ? this.readImageSize(d) : null, s = (l == null ? void 0 : l.height) ?? (l == null ? void 0 : l.width), p = (l == null ? void 0 : l.width) ?? (l == null ? void 0 : l.height);
|
|
182
|
+
s && r("data-product_image_control_image-height") && (e["data-product_image_control_image-height"] = s), p && r("data-product_image_control_image-width") && (e["data-product_image_control_image-width"] = p), this.applyPriceDomFallbacks(t, e, r);
|
|
183
|
+
const T = ((f = t.querySelector('[product-attr="name"]')) == null ? void 0 : f.getAttribute("style")) || "";
|
|
184
|
+
r("data-product_name_control_trim") && /white-space:\s*normal/.test(T) && (e["data-product_name_control_trim"] = "0");
|
|
224
185
|
}
|
|
225
186
|
/**
|
|
226
187
|
* Carries the price cell's own currency/format attributes into the config attributes when
|
|
@@ -229,22 +190,22 @@ class K {
|
|
|
229
190
|
* ₺ but reporting USD/before to the settings panel, and the first unrelated price edit wrote
|
|
230
191
|
* the default back over the real value.
|
|
231
192
|
*/
|
|
232
|
-
applyPriceDomFallbacks(t, e,
|
|
233
|
-
var
|
|
234
|
-
const
|
|
235
|
-
if (!
|
|
193
|
+
applyPriceDomFallbacks(t, e, a) {
|
|
194
|
+
var d;
|
|
195
|
+
const r = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
|
|
196
|
+
if (!r)
|
|
236
197
|
return;
|
|
237
|
-
const u = (
|
|
238
|
-
u &&
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
const
|
|
242
|
-
e["data-product_price_currency_location"] =
|
|
198
|
+
const u = (d = r.getAttribute("data-currency_symbol")) == null ? void 0 : d.trim();
|
|
199
|
+
u && a("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = u);
|
|
200
|
+
const c = r.getAttribute("data-curency");
|
|
201
|
+
if (c && a("data-product_price_currency_location", "data-product_price_control_curency")) {
|
|
202
|
+
const l = c === "after" ? "1" : "0";
|
|
203
|
+
e["data-product_price_currency_location"] = l, e["data-product_price_control_curency"] = l;
|
|
243
204
|
}
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
|
|
205
|
+
const o = r.getAttribute("data-formated");
|
|
206
|
+
o && a("data-product_price_control_formated") && (e["data-product_price_control_formated"] = o);
|
|
207
|
+
const i = r.getAttribute("data-single_price");
|
|
208
|
+
i && a("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = i);
|
|
248
209
|
}
|
|
249
210
|
/**
|
|
250
211
|
* Reads an attribute from the block element itself before falling back to a descendant.
|
|
@@ -252,8 +213,8 @@ class K {
|
|
|
252
213
|
* esd-config-block; when an author deletes the config block only the td's copy survives.
|
|
253
214
|
*/
|
|
254
215
|
readSelfOrDescendantAttribute(t, e) {
|
|
255
|
-
var
|
|
256
|
-
return t.getAttribute(e) || ((
|
|
216
|
+
var a;
|
|
217
|
+
return t.getAttribute(e) || ((a = t.querySelector(`[${e}]`)) == null ? void 0 : a.getAttribute(e)) || null;
|
|
257
218
|
}
|
|
258
219
|
/**
|
|
259
220
|
* Reads the product image's pixel size — `width`/`height` attributes first, then px values
|
|
@@ -273,15 +234,15 @@ class K {
|
|
|
273
234
|
* to nothing, so only a positive integer counts as an answer.
|
|
274
235
|
*/
|
|
275
236
|
readImageDimension(t, e) {
|
|
276
|
-
var
|
|
277
|
-
const
|
|
278
|
-
const s = (
|
|
279
|
-
return
|
|
280
|
-
},
|
|
281
|
-
if (
|
|
282
|
-
return
|
|
283
|
-
const u = t.getAttribute("style") || "",
|
|
284
|
-
return i
|
|
237
|
+
var d;
|
|
238
|
+
const a = (l) => {
|
|
239
|
+
const s = (l ?? "").trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i), p = s ? Math.floor(parseFloat(s[1])) : 0;
|
|
240
|
+
return p > 0 ? String(p) : null;
|
|
241
|
+
}, r = a((d = t.getAttribute(e)) == null ? void 0 : d.trim());
|
|
242
|
+
if (r)
|
|
243
|
+
return r;
|
|
244
|
+
const u = t.getAttribute("style") || "", c = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+(?:\\.\\d+)?)px`), o = new RegExp(`max-${e}:\\s*(\\d+(?:\\.\\d+)?)px`), i = u.match(c) || u.match(o);
|
|
245
|
+
return a(i == null ? void 0 : i[1]);
|
|
285
246
|
}
|
|
286
247
|
/**
|
|
287
248
|
* Extracts all data-* attributes from the esd-config-block element
|
|
@@ -290,27 +251,27 @@ class K {
|
|
|
290
251
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
291
252
|
* @param itemNumber - The item number (1-based index)
|
|
292
253
|
*/
|
|
293
|
-
extractConfigBlockAttributes(t, e,
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
if (Array.from(
|
|
297
|
-
|
|
254
|
+
extractConfigBlockAttributes(t, e, a) {
|
|
255
|
+
const r = t.querySelector("esd-config-block"), u = {};
|
|
256
|
+
if (r) {
|
|
257
|
+
if (Array.from(r.attributes).forEach((o) => {
|
|
258
|
+
o.name.startsWith("data-") && (u[o.name] = o.value);
|
|
298
259
|
}), u["data-cart_items_select_control_value"]) {
|
|
299
|
-
const
|
|
300
|
-
if (/^\d+$/.test(
|
|
301
|
-
const
|
|
302
|
-
|
|
260
|
+
const o = u["data-cart_items_select_control_value"];
|
|
261
|
+
if (/^\d+$/.test(o)) {
|
|
262
|
+
const i = parseInt(o) - 1, d = h[e];
|
|
263
|
+
d && d[i] && (u["data-cart_items_select_control_value"] = d[i].value);
|
|
303
264
|
}
|
|
304
265
|
}
|
|
305
266
|
if (u["data-product_price_control_curency"]) {
|
|
306
|
-
const
|
|
307
|
-
let
|
|
308
|
-
|
|
267
|
+
const o = u["data-product_price_control_curency"];
|
|
268
|
+
let i = o;
|
|
269
|
+
o === "before" ? i = "0" : o === "after" && (i = "1"), u["data-product_price_control_curency"] = i, u["data-product_price_currency_location"] = i;
|
|
309
270
|
}
|
|
310
271
|
(!u["data-product_price_control_currency_symbol"] || u["data-product_price_control_currency_symbol"].trim() === "") && (u["data-product_price_control_currency_symbol"] = "USD");
|
|
311
272
|
}
|
|
312
|
-
const
|
|
313
|
-
return
|
|
273
|
+
const c = { ...this.getDefaultConfigBlockAttributes(), ...u };
|
|
274
|
+
return c["data-type"] = e, c["data-source"] = e, c["data-product_image_link"] = Y(e, a), c["data-product_button_link"] = W(e, a), c;
|
|
314
275
|
}
|
|
315
276
|
/**
|
|
316
277
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -377,7 +338,6 @@ class K {
|
|
|
377
338
|
* no longer emits it; here we heal already-saved templates by removing it so the
|
|
378
339
|
* cell inherits its column width. width="560" was only ever written alongside
|
|
379
340
|
* esd-ext-config, so the guard below still catches every affected template.
|
|
380
|
-
* A cell that is its column's only width carrier keeps its width and frame.
|
|
381
341
|
*
|
|
382
342
|
* Only re-serializes when something actually changed, so healthy templates
|
|
383
343
|
* (data-type present, no static width) pass through byte-for-byte.
|
|
@@ -385,31 +345,29 @@ class K {
|
|
|
385
345
|
backfillV2ProductTdAttributes(t) {
|
|
386
346
|
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
387
347
|
return t;
|
|
388
|
-
const e = this.parser.parseFromString(
|
|
389
|
-
let
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
const m = _.getAttribute("style");
|
|
396
|
-
m && H(m) && (_.setAttribute("style", N(m)), _.setAttribute("width", "100%"), i = !0);
|
|
348
|
+
const e = this.parser.parseFromString(H(t), "text/html");
|
|
349
|
+
let a = !1;
|
|
350
|
+
return e.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
351
|
+
r.hasAttribute("width") && (r.removeAttribute("width"), a = !0), r.classList.contains("esd-container-frame") && (r.classList.remove("esd-container-frame"), a = !0), r.querySelectorAll("table.ins-product-wrapper").forEach((d) => {
|
|
352
|
+
d.hasAttribute("width") && d.getAttribute("width") !== "100%" && (d.setAttribute("width", "100%"), a = !0);
|
|
353
|
+
const l = d.getAttribute("style");
|
|
354
|
+
l && L(l) && (d.setAttribute("style", x(l)), d.setAttribute("width", "100%"), a = !0);
|
|
397
355
|
});
|
|
398
|
-
const
|
|
399
|
-
let
|
|
356
|
+
const u = r.getAttribute("esd-ext-config");
|
|
357
|
+
let c = null;
|
|
400
358
|
try {
|
|
401
|
-
|
|
359
|
+
c = u ? JSON.parse(u) : null;
|
|
402
360
|
} catch {
|
|
403
361
|
}
|
|
404
|
-
if (!
|
|
362
|
+
if (!c || (!r.getAttribute("data-nodup") && typeof c.priceHideDiscount == "boolean" && (r.setAttribute("data-nodup", String(c.priceHideDiscount)), a = !0), r.getAttribute("data-type")))
|
|
405
363
|
return;
|
|
406
|
-
const
|
|
407
|
-
if (!
|
|
364
|
+
const o = c.type || c.source;
|
|
365
|
+
if (!o)
|
|
408
366
|
return;
|
|
409
|
-
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
}),
|
|
367
|
+
r.setAttribute("data-type", o), a = !0;
|
|
368
|
+
const i = typeof c.itemsSelectValue == "string" ? c.itemsSelectValue.match(/\((\d+)\)/) : null;
|
|
369
|
+
i && r.getAttribute("data-number") !== i[1] && r.setAttribute("data-number", i[1]);
|
|
370
|
+
}), a ? $(e.documentElement.outerHTML) : t;
|
|
413
371
|
}
|
|
414
372
|
/**
|
|
415
373
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
@@ -430,22 +388,22 @@ class K {
|
|
|
430
388
|
* contains display condition Jinja scripts that should NOT be removed.
|
|
431
389
|
*/
|
|
432
390
|
removeJinjaConditionals(t) {
|
|
433
|
-
const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__",
|
|
434
|
-
let
|
|
435
|
-
return
|
|
391
|
+
const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", a = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
392
|
+
let r = a ? t.replace(a[0], e) : t;
|
|
393
|
+
return r = r.replace(
|
|
436
394
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
437
395
|
""
|
|
438
|
-
),
|
|
396
|
+
), r = r.replace(
|
|
439
397
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
440
398
|
""
|
|
441
|
-
),
|
|
399
|
+
), r = r.replace(/\{%\s*endif\s*%\}/g, ""), a && (r = r.replace(e, a[0])), r = r.replace(/\n\s*\n\s*\n/g, `
|
|
442
400
|
|
|
443
|
-
`),
|
|
401
|
+
`), r;
|
|
444
402
|
}
|
|
445
403
|
}
|
|
446
|
-
function
|
|
447
|
-
return new
|
|
404
|
+
function X(n) {
|
|
405
|
+
return new z().migrate(n);
|
|
448
406
|
}
|
|
449
407
|
export {
|
|
450
|
-
|
|
408
|
+
X as migrateItemsBlock
|
|
451
409
|
};
|
package/dist/package.json.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const o = "3.27.0-beta.
|
|
1
|
+
const o = "3.27.0-beta.b57163d", s = { stripo: { version: "2.83.1" } }, t = {
|
|
2
2
|
version: o,
|
|
3
3
|
guido: s
|
|
4
4
|
};
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
t as default,
|
|
7
7
|
s as guido,
|
|
8
8
|
o as version
|
|
9
9
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.27.0-beta.
|
|
3
|
+
"version": "3.27.0-beta.b57163d",
|
|
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",
|