@useinsider/guido 3.27.0-beta.8bef749 → 3.27.0-beta.8f596fb
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,59 +1,63 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var M = (n, t, e) =>
|
|
4
|
-
import { BLOCK_ID as
|
|
5
|
-
import { hasZeroWidthDeclaration as
|
|
6
|
-
import { ItemInCartOptions as h, DefaultConfigValues as
|
|
7
|
-
import { getDefaultTemplate as
|
|
8
|
-
import { useTemplateStore as
|
|
9
|
-
import { protectLiquid as
|
|
10
|
-
|
|
1
|
+
var v = Object.defineProperty;
|
|
2
|
+
var L = (n, t, e) => t in n ? v(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var M = (n, t, e) => L(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { BLOCK_ID as x } from "../../extensions/Blocks/Items/block.js";
|
|
5
|
+
import { hasZeroWidthDeclaration as V, withoutZeroWidth as O } from "../../extensions/Blocks/Items/constants/cardWidth.js";
|
|
6
|
+
import { ItemInCartOptions as h, DefaultConfigValues as y, SETTINGS_ENUMS as s } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
7
|
+
import { getDefaultTemplate as H } from "../../extensions/Blocks/Items/template.js";
|
|
8
|
+
import { useTemplateStore as U } from "../../stores/template.js";
|
|
9
|
+
import { protectLiquid as P, restoreLiquid as D } from "../../utils/liquidProtection.js";
|
|
10
|
+
const $ = /\{%-?\s*(\w+)(?:(?!\{%)[\s\S])*?%\}/g, F = [
|
|
11
|
+
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/,
|
|
12
|
+
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/
|
|
13
|
+
], N = /esd-custom-display-conditions?="[^"]*"/g;
|
|
14
|
+
function Y() {
|
|
11
15
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
12
16
|
}
|
|
13
|
-
function
|
|
17
|
+
function w(n) {
|
|
14
18
|
return n ? {
|
|
15
|
-
CartItems:
|
|
16
|
-
BrowsedItems:
|
|
17
|
-
PurchasedItems:
|
|
18
|
-
CART_ITEMS:
|
|
19
|
-
BROWSED_ITEMS:
|
|
20
|
-
PURCHASED_ITEMS:
|
|
21
|
-
}[n] ||
|
|
19
|
+
CartItems: s.ITEMS_TYPE.CART_ITEMS,
|
|
20
|
+
BrowsedItems: s.ITEMS_TYPE.BROWSED_ITEMS,
|
|
21
|
+
PurchasedItems: s.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
22
|
+
CART_ITEMS: s.ITEMS_TYPE.CART_ITEMS,
|
|
23
|
+
BROWSED_ITEMS: s.ITEMS_TYPE.BROWSED_ITEMS,
|
|
24
|
+
PURCHASED_ITEMS: s.ITEMS_TYPE.PURCHASED_ITEMS
|
|
25
|
+
}[n] || s.ITEMS_TYPE.CART_ITEMS : s.ITEMS_TYPE.CART_ITEMS;
|
|
22
26
|
}
|
|
23
|
-
function
|
|
24
|
-
return n.classList.contains("esd-browsed-items-block") ?
|
|
27
|
+
function W(n) {
|
|
28
|
+
return n.classList.contains("esd-browsed-items-block") ? s.ITEMS_TYPE.BROWSED_ITEMS : n.classList.contains("esd-purchased-items-block") ? s.ITEMS_TYPE.PURCHASED_ITEMS : s.ITEMS_TYPE.CART_ITEMS;
|
|
25
29
|
}
|
|
26
|
-
function
|
|
27
|
-
var
|
|
28
|
-
const t = (i, d) => i == null ? d : i === "1" || i === "true", e = (i, d) => i || d,
|
|
29
|
-
let c = n["data-cart_items_select_control_value"] || ((
|
|
30
|
+
function k(n) {
|
|
31
|
+
var r;
|
|
32
|
+
const t = (i, d) => i == null ? d : i === "1" || i === "true", e = (i, d) => i || d, u = n["data-type"] || n["data-source"], o = w(u), a = h[o];
|
|
33
|
+
let c = n["data-cart_items_select_control_value"] || ((r = a == null ? void 0 : a[0]) == null ? void 0 : r.value) || y.cartItemsSelectControlValue;
|
|
30
34
|
if (c && !c.includes("{{") && /^\d+$/.test(c)) {
|
|
31
|
-
const i = parseInt(c) - 1, d = h[
|
|
35
|
+
const i = parseInt(c) - 1, d = h[o];
|
|
32
36
|
d && d[i] && (c = d[i].value);
|
|
33
37
|
}
|
|
34
38
|
return {
|
|
35
39
|
initialized: !0,
|
|
36
|
-
blockInstanceId: e(n["data-block-instance-id"],
|
|
37
|
-
source:
|
|
38
|
-
type:
|
|
40
|
+
blockInstanceId: e(n["data-block-instance-id"], Y()),
|
|
41
|
+
source: o,
|
|
42
|
+
type: o,
|
|
39
43
|
itemsSelectValue: c,
|
|
40
|
-
orientation: n["data-card_orientation_control_value"] ||
|
|
44
|
+
orientation: n["data-card_orientation_control_value"] || s.ORIENTATION.VERTICAL,
|
|
41
45
|
nameTrimming: t(n["data-product_name_control_trim"], !0),
|
|
42
46
|
priceHideDiscount: t(n["data-product_price_control_nodup"], !0),
|
|
43
47
|
priceFormatted: t(n["data-product_price_control_formated"], !0),
|
|
44
48
|
priceSinglePrice: t(n["data-product_price_control_single_price"], !1),
|
|
45
49
|
priceCurrencySymbol: e(
|
|
46
50
|
n["data-product_price_control_currency_symbol"],
|
|
47
|
-
|
|
51
|
+
y.productPriceCurrencySymbolControlValue
|
|
48
52
|
),
|
|
49
53
|
priceCurrencyLocation: e(
|
|
50
54
|
n["data-product_price_currency_location"],
|
|
51
|
-
|
|
55
|
+
y.productPriceCurrencyLocationControlValue
|
|
52
56
|
),
|
|
53
57
|
priceOrientation: n["data-product_original_price_control_orientation"] || "horizontal",
|
|
54
58
|
quantityControlEnabled: t(n["data-product_quantity_control_enabled"], !0),
|
|
55
|
-
buttonLink: e(n["data-product_button_link"],
|
|
56
|
-
imageLink: e(n["data-product_image_link"],
|
|
59
|
+
buttonLink: e(n["data-product_button_link"], y.productButtonLinkControlValue),
|
|
60
|
+
imageLink: e(n["data-product_image_link"], y.productImageLinkControlValue),
|
|
57
61
|
buttonLabel: e(n["data-product_button_control_label"], "Buy"),
|
|
58
62
|
buttonFullWidth: t(n["data-product_button_control_atw"], !0),
|
|
59
63
|
imageVisible: t(n["data-product_image_control_enabled"], !0),
|
|
@@ -64,7 +68,7 @@ function P(n) {
|
|
|
64
68
|
buttonVisible: t(n["data-product_button_control_enabled"], !0)
|
|
65
69
|
};
|
|
66
70
|
}
|
|
67
|
-
function
|
|
71
|
+
function z(n, t) {
|
|
68
72
|
const e = {
|
|
69
73
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
70
74
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
@@ -72,7 +76,7 @@ function Y(n, t) {
|
|
|
72
76
|
};
|
|
73
77
|
return e[n] || e.CART_ITEMS;
|
|
74
78
|
}
|
|
75
|
-
function
|
|
79
|
+
function G(n, t) {
|
|
76
80
|
const e = {
|
|
77
81
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
78
82
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
@@ -80,7 +84,7 @@ function W(n, t) {
|
|
|
80
84
|
};
|
|
81
85
|
return e[n] || e.CART_ITEMS;
|
|
82
86
|
}
|
|
83
|
-
class
|
|
87
|
+
class J {
|
|
84
88
|
constructor() {
|
|
85
89
|
M(this, "parser");
|
|
86
90
|
this.parser = new DOMParser();
|
|
@@ -89,38 +93,38 @@ class z {
|
|
|
89
93
|
try {
|
|
90
94
|
if (!this.containsItemsBlock(t))
|
|
91
95
|
return this.backfillV2ProductTdAttributes(t);
|
|
92
|
-
const e = this.removeJinjaConditionals(t),
|
|
96
|
+
const e = this.removeJinjaConditionals(t), u = this.parser.parseFromString(P(e), "text/html"), o = u.querySelectorAll(
|
|
93
97
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
94
98
|
);
|
|
95
|
-
return
|
|
96
|
-
c.migrations = { ...c.migrations, [
|
|
97
|
-
}),
|
|
98
|
-
const
|
|
99
|
-
orientation:
|
|
100
|
-
itemsType:
|
|
101
|
-
itemId:
|
|
102
|
-
currencySymbol:
|
|
103
|
-
currencyLocation:
|
|
104
|
-
formattedPrice:
|
|
105
|
-
configBlockAttributes:
|
|
99
|
+
return U().$patch((c) => {
|
|
100
|
+
c.migrations = { ...c.migrations, [x]: o.length };
|
|
101
|
+
}), o.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), this.backfillV2ProductTdAttributes(e)) : (o.forEach((c) => {
|
|
102
|
+
const r = this.extractConfiguration(c), i = H({
|
|
103
|
+
orientation: r.orientation,
|
|
104
|
+
itemsType: r.itemsType,
|
|
105
|
+
itemId: r.itemId,
|
|
106
|
+
currencySymbol: r.currencySymbol,
|
|
107
|
+
currencyLocation: r.currencyLocation,
|
|
108
|
+
formattedPrice: r.formattedPrice,
|
|
109
|
+
configBlockAttributes: r.configBlockAttributes,
|
|
106
110
|
migrate: !0,
|
|
107
|
-
nameStyles:
|
|
108
|
-
buttonStyles:
|
|
109
|
-
priceStyles:
|
|
110
|
-
originalPriceStyles:
|
|
111
|
-
quantityStyles:
|
|
112
|
-
nodeConfig:
|
|
111
|
+
nameStyles: r.nameStyles,
|
|
112
|
+
buttonStyles: r.buttonStyles,
|
|
113
|
+
priceStyles: r.priceStyles,
|
|
114
|
+
originalPriceStyles: r.originalPriceStyles,
|
|
115
|
+
quantityStyles: r.quantityStyles,
|
|
116
|
+
nodeConfig: k(r.configBlockAttributes)
|
|
113
117
|
}), l = this.parser.parseFromString(
|
|
114
118
|
`<table><tbody><tr>${i}</tr></tbody></table>`,
|
|
115
119
|
"text/html"
|
|
116
120
|
).querySelector("td");
|
|
117
121
|
if (l && c.parentNode) {
|
|
118
|
-
const
|
|
119
|
-
l.setAttribute("esd-ext-config", JSON.stringify(
|
|
122
|
+
const _ = k(r.configBlockAttributes);
|
|
123
|
+
l.setAttribute("esd-ext-config", JSON.stringify(_)), l.setAttribute("data-type", _.type);
|
|
120
124
|
const p = l.querySelector("esd-config-block");
|
|
121
125
|
p && p.remove(), c.parentNode.replaceChild(l, c);
|
|
122
126
|
}
|
|
123
|
-
}), this.backfillV2ProductTdAttributes(
|
|
127
|
+
}), this.backfillV2ProductTdAttributes(D(u.documentElement.outerHTML)));
|
|
124
128
|
} catch (e) {
|
|
125
129
|
return console.error("ItemsBlockMigrator failed:", e), t;
|
|
126
130
|
}
|
|
@@ -133,11 +137,11 @@ class z {
|
|
|
133
137
|
*/
|
|
134
138
|
extractConfiguration(t) {
|
|
135
139
|
var C;
|
|
136
|
-
const e =
|
|
137
|
-
this.readSelfOrDescendantAttribute(t, "data-type") ||
|
|
138
|
-
),
|
|
139
|
-
this.applyDomFallbacks(t,
|
|
140
|
-
const i = t.querySelector('[product-attr="price"]'), d =
|
|
140
|
+
const e = w(
|
|
141
|
+
this.readSelfOrDescendantAttribute(t, "data-type") || W(t)
|
|
142
|
+
), u = this.readSelfOrDescendantAttribute(t, "data-number") || "1", o = parseInt(u) - 1, a = h[e], c = ((C = a == null ? void 0 : a[o]) == null ? void 0 : C.value) || a[0].value, r = this.extractConfigBlockAttributes(t, e, u);
|
|
143
|
+
this.applyDomFallbacks(t, r);
|
|
144
|
+
const i = t.querySelector('[product-attr="price"]'), d = r["data-product_price_control_currency_symbol"], l = r["data-product_price_currency_location"] || "0", _ = r["data-product_price_control_formated"], p = _ !== "false" && _ !== "0", S = r["data-card_orientation_control_value"] === "horizontal" ? "horizontal" : "vertical", g = t.querySelector('a[product-attr="name"]'), b = (g == null ? void 0 : g.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), I = (f == null ? void 0 : f.getAttribute("style")) || void 0, q = (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, R = (A == null ? void 0 : A.getAttribute("style")) || void 0, T = t.querySelector('[product-attr="quantity"]'), B = (T == null ? void 0 : T.getAttribute("style")) || void 0;
|
|
141
145
|
return {
|
|
142
146
|
orientation: S,
|
|
143
147
|
itemsType: e,
|
|
@@ -145,12 +149,12 @@ class z {
|
|
|
145
149
|
currencySymbol: d,
|
|
146
150
|
currencyLocation: l,
|
|
147
151
|
formattedPrice: p,
|
|
148
|
-
configBlockAttributes:
|
|
149
|
-
nameStyles:
|
|
152
|
+
configBlockAttributes: r,
|
|
153
|
+
nameStyles: b,
|
|
150
154
|
buttonStyles: I,
|
|
151
|
-
priceStyles:
|
|
152
|
-
originalPriceStyles:
|
|
153
|
-
quantityStyles:
|
|
155
|
+
priceStyles: q,
|
|
156
|
+
originalPriceStyles: R,
|
|
157
|
+
quantityStyles: B
|
|
154
158
|
};
|
|
155
159
|
}
|
|
156
160
|
/**
|
|
@@ -161,8 +165,8 @@ class z {
|
|
|
161
165
|
* card migrates with the boilerplate defaults: caption "Buy", USD, full-width button.
|
|
162
166
|
*/
|
|
163
167
|
applyDomFallbacks(t, e) {
|
|
164
|
-
var S,
|
|
165
|
-
const
|
|
168
|
+
var S, g;
|
|
169
|
+
const u = t.querySelector("esd-config-block"), o = (...b) => !u || b.every((f) => !(u.getAttribute(f) ?? "").trim());
|
|
166
170
|
Object.entries({
|
|
167
171
|
image: '[product-attr="imageSrc"]',
|
|
168
172
|
name: '[product-attr="name"]',
|
|
@@ -170,18 +174,18 @@ class z {
|
|
|
170
174
|
original_price: '[product-attr="originalPrice"], p.original-price',
|
|
171
175
|
quantity: '[product-attr="quantity"]',
|
|
172
176
|
button: '[product-attr="button"]'
|
|
173
|
-
}).forEach(([
|
|
174
|
-
const I = `data-product_${
|
|
175
|
-
|
|
176
|
-
}),
|
|
177
|
-
const c = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'),
|
|
178
|
-
|
|
177
|
+
}).forEach(([b, f]) => {
|
|
178
|
+
const I = `data-product_${b}_control_enabled`;
|
|
179
|
+
o(I) && (e[I] = t.querySelector(f) ? "true" : "false");
|
|
180
|
+
}), o("data-card_orientation_control_value") && (e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal");
|
|
181
|
+
const c = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), r = (S = c == null ? void 0 : c.textContent) == null ? void 0 : S.replace(/\s+/g, " ").trim();
|
|
182
|
+
r && o("data-product_button_control_label") && (e["data-product_button_control_label"] = r);
|
|
179
183
|
const i = (c == null ? void 0 : c.getAttribute("style")) || "";
|
|
180
|
-
|
|
181
|
-
const d = t.querySelector('[product-attr="imageSrc"]'), l = d ? this.readImageSize(d) : null,
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
184
|
+
o("data-product_button_control_atw") && /display:\s*inline/.test(i) && !/(?:^|;)\s*width\s*:\s*100%/.test(i) && (e["data-product_button_control_atw"] = "false");
|
|
185
|
+
const d = t.querySelector('[product-attr="imageSrc"]'), l = d ? this.readImageSize(d) : null, _ = (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);
|
|
186
|
+
_ && o("data-product_image_control_image-height") && (e["data-product_image_control_image-height"] = _), p && o("data-product_image_control_image-width") && (e["data-product_image_control_image-width"] = p), this.applyPriceDomFallbacks(t, e, o);
|
|
187
|
+
const E = ((g = t.querySelector('[product-attr="name"]')) == null ? void 0 : g.getAttribute("style")) || "";
|
|
188
|
+
o("data-product_name_control_trim") && /white-space:\s*normal/.test(E) && (e["data-product_name_control_trim"] = "0");
|
|
185
189
|
}
|
|
186
190
|
/**
|
|
187
191
|
* Carries the price cell's own currency/format attributes into the config attributes when
|
|
@@ -190,22 +194,22 @@ class z {
|
|
|
190
194
|
* ₺ but reporting USD/before to the settings panel, and the first unrelated price edit wrote
|
|
191
195
|
* the default back over the real value.
|
|
192
196
|
*/
|
|
193
|
-
applyPriceDomFallbacks(t, e,
|
|
197
|
+
applyPriceDomFallbacks(t, e, u) {
|
|
194
198
|
var d;
|
|
195
|
-
const
|
|
196
|
-
if (!
|
|
199
|
+
const o = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
|
|
200
|
+
if (!o)
|
|
197
201
|
return;
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
const c =
|
|
201
|
-
if (c &&
|
|
202
|
+
const a = (d = o.getAttribute("data-currency_symbol")) == null ? void 0 : d.trim();
|
|
203
|
+
a && u("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = a);
|
|
204
|
+
const c = o.getAttribute("data-curency");
|
|
205
|
+
if (c && u("data-product_price_currency_location", "data-product_price_control_curency")) {
|
|
202
206
|
const l = c === "after" ? "1" : "0";
|
|
203
207
|
e["data-product_price_currency_location"] = l, e["data-product_price_control_curency"] = l;
|
|
204
208
|
}
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
const i =
|
|
208
|
-
i &&
|
|
209
|
+
const r = o.getAttribute("data-formated");
|
|
210
|
+
r && u("data-product_price_control_formated") && (e["data-product_price_control_formated"] = r);
|
|
211
|
+
const i = o.getAttribute("data-single_price");
|
|
212
|
+
i && u("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = i);
|
|
209
213
|
}
|
|
210
214
|
/**
|
|
211
215
|
* Reads an attribute from the block element itself before falling back to a descendant.
|
|
@@ -213,8 +217,8 @@ class z {
|
|
|
213
217
|
* esd-config-block; when an author deletes the config block only the td's copy survives.
|
|
214
218
|
*/
|
|
215
219
|
readSelfOrDescendantAttribute(t, e) {
|
|
216
|
-
var
|
|
217
|
-
return t.getAttribute(e) || ((
|
|
220
|
+
var u;
|
|
221
|
+
return t.getAttribute(e) || ((u = t.querySelector(`[${e}]`)) == null ? void 0 : u.getAttribute(e)) || null;
|
|
218
222
|
}
|
|
219
223
|
/**
|
|
220
224
|
* Reads the product image's pixel size — `width`/`height` attributes first, then px values
|
|
@@ -235,14 +239,14 @@ class z {
|
|
|
235
239
|
*/
|
|
236
240
|
readImageDimension(t, e) {
|
|
237
241
|
var d;
|
|
238
|
-
const
|
|
239
|
-
const
|
|
242
|
+
const u = (l) => {
|
|
243
|
+
const _ = (l ?? "").trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i), p = _ ? Math.floor(parseFloat(_[1])) : 0;
|
|
240
244
|
return p > 0 ? String(p) : null;
|
|
241
|
-
},
|
|
242
|
-
if (
|
|
243
|
-
return
|
|
244
|
-
const
|
|
245
|
-
return
|
|
245
|
+
}, o = u((d = t.getAttribute(e)) == null ? void 0 : d.trim());
|
|
246
|
+
if (o)
|
|
247
|
+
return o;
|
|
248
|
+
const a = t.getAttribute("style") || "", c = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+(?:\\.\\d+)?)px`), r = new RegExp(`max-${e}:\\s*(\\d+(?:\\.\\d+)?)px`), i = a.match(c) || a.match(r);
|
|
249
|
+
return u(i == null ? void 0 : i[1]);
|
|
246
250
|
}
|
|
247
251
|
/**
|
|
248
252
|
* Extracts all data-* attributes from the esd-config-block element
|
|
@@ -251,27 +255,27 @@ class z {
|
|
|
251
255
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
252
256
|
* @param itemNumber - The item number (1-based index)
|
|
253
257
|
*/
|
|
254
|
-
extractConfigBlockAttributes(t, e,
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
if (Array.from(
|
|
258
|
-
|
|
259
|
-
}),
|
|
260
|
-
const
|
|
261
|
-
if (/^\d+$/.test(
|
|
262
|
-
const i = parseInt(
|
|
263
|
-
d && d[i] && (
|
|
258
|
+
extractConfigBlockAttributes(t, e, u) {
|
|
259
|
+
const o = t.querySelector("esd-config-block"), a = {};
|
|
260
|
+
if (o) {
|
|
261
|
+
if (Array.from(o.attributes).forEach((r) => {
|
|
262
|
+
r.name.startsWith("data-") && (a[r.name] = r.value);
|
|
263
|
+
}), a["data-cart_items_select_control_value"]) {
|
|
264
|
+
const r = a["data-cart_items_select_control_value"];
|
|
265
|
+
if (/^\d+$/.test(r)) {
|
|
266
|
+
const i = parseInt(r) - 1, d = h[e];
|
|
267
|
+
d && d[i] && (a["data-cart_items_select_control_value"] = d[i].value);
|
|
264
268
|
}
|
|
265
269
|
}
|
|
266
|
-
if (
|
|
267
|
-
const
|
|
268
|
-
let i =
|
|
269
|
-
|
|
270
|
+
if (a["data-product_price_control_curency"]) {
|
|
271
|
+
const r = a["data-product_price_control_curency"];
|
|
272
|
+
let i = r;
|
|
273
|
+
r === "before" ? i = "0" : r === "after" && (i = "1"), a["data-product_price_control_curency"] = i, a["data-product_price_currency_location"] = i;
|
|
270
274
|
}
|
|
271
|
-
(!
|
|
275
|
+
(!a["data-product_price_control_currency_symbol"] || a["data-product_price_control_currency_symbol"].trim() === "") && (a["data-product_price_control_currency_symbol"] = "USD");
|
|
272
276
|
}
|
|
273
|
-
const c = { ...this.getDefaultConfigBlockAttributes(), ...
|
|
274
|
-
return c["data-type"] = e, c["data-source"] = e, c["data-product_image_link"] =
|
|
277
|
+
const c = { ...this.getDefaultConfigBlockAttributes(), ...a };
|
|
278
|
+
return c["data-type"] = e, c["data-source"] = e, c["data-product_image_link"] = z(e, u), c["data-product_button_link"] = G(e, u), c;
|
|
275
279
|
}
|
|
276
280
|
/**
|
|
277
281
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -345,29 +349,29 @@ class z {
|
|
|
345
349
|
backfillV2ProductTdAttributes(t) {
|
|
346
350
|
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
347
351
|
return t;
|
|
348
|
-
const e = this.parser.parseFromString(
|
|
349
|
-
let
|
|
350
|
-
return e.querySelectorAll(".ins-product-td").forEach((
|
|
351
|
-
|
|
352
|
-
d.hasAttribute("width") && d.getAttribute("width") !== "100%" && (d.setAttribute("width", "100%"),
|
|
352
|
+
const e = this.parser.parseFromString(P(t), "text/html");
|
|
353
|
+
let u = !1;
|
|
354
|
+
return e.querySelectorAll(".ins-product-td").forEach((o) => {
|
|
355
|
+
o.hasAttribute("width") && (o.removeAttribute("width"), u = !0), o.classList.contains("esd-container-frame") && (o.classList.remove("esd-container-frame"), u = !0), o.querySelectorAll("table.ins-product-wrapper").forEach((d) => {
|
|
356
|
+
d.hasAttribute("width") && d.getAttribute("width") !== "100%" && (d.setAttribute("width", "100%"), u = !0);
|
|
353
357
|
const l = d.getAttribute("style");
|
|
354
|
-
l &&
|
|
358
|
+
l && V(l) && (d.setAttribute("style", O(l)), d.setAttribute("width", "100%"), u = !0);
|
|
355
359
|
});
|
|
356
|
-
const
|
|
360
|
+
const a = o.getAttribute("esd-ext-config");
|
|
357
361
|
let c = null;
|
|
358
362
|
try {
|
|
359
|
-
c =
|
|
363
|
+
c = a ? JSON.parse(a) : null;
|
|
360
364
|
} catch {
|
|
361
365
|
}
|
|
362
|
-
if (!c || (!
|
|
366
|
+
if (!c || (!o.getAttribute("data-nodup") && typeof c.priceHideDiscount == "boolean" && (o.setAttribute("data-nodup", String(c.priceHideDiscount)), u = !0), o.getAttribute("data-type")))
|
|
363
367
|
return;
|
|
364
|
-
const
|
|
365
|
-
if (!
|
|
368
|
+
const r = c.type || c.source;
|
|
369
|
+
if (!r)
|
|
366
370
|
return;
|
|
367
|
-
|
|
371
|
+
o.setAttribute("data-type", r), u = !0;
|
|
368
372
|
const i = typeof c.itemsSelectValue == "string" ? c.itemsSelectValue.match(/\((\d+)\)/) : null;
|
|
369
|
-
i &&
|
|
370
|
-
}),
|
|
373
|
+
i && o.getAttribute("data-number") !== i[1] && o.setAttribute("data-number", i[1]);
|
|
374
|
+
}), u ? D(e.documentElement.outerHTML) : t;
|
|
371
375
|
}
|
|
372
376
|
/**
|
|
373
377
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
@@ -378,32 +382,28 @@ class z {
|
|
|
378
382
|
return t.includes("esd-cart-items-block") || t.includes("esd-browsed-items-block") || t.includes("esd-purchased-items-block");
|
|
379
383
|
}
|
|
380
384
|
/**
|
|
381
|
-
* Removes
|
|
382
|
-
*
|
|
383
|
-
* - Cart Items: ins_apr_total_product_kind, ins_apr_price_N, ins_apr_originalprice_N
|
|
384
|
-
* - Browsed Items: browsed_item_total_product_kind, browsed_item_price_N, browsed_item_originalprice_N
|
|
385
|
-
* - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
|
|
386
|
-
*
|
|
387
|
-
* IMPORTANT: Preserves the esd-custom-display-conditions attribute on <body> which
|
|
388
|
-
* contains display condition Jinja scripts that should NOT be removed.
|
|
385
|
+
* Removes each Items guard opener together with the endif that closes it, and no other tag.
|
|
386
|
+
* Liquid inside esd-custom-display-condition(s) attribute values is skipped.
|
|
389
387
|
*/
|
|
390
388
|
removeJinjaConditionals(t) {
|
|
391
|
-
const e =
|
|
392
|
-
let
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
""
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
389
|
+
const e = [...t.matchAll(N)].map((a) => ({ start: a.index, end: a.index + a[0].length })), u = [];
|
|
390
|
+
let o = t.replace($, (a, c, r) => {
|
|
391
|
+
if (e.some(({ start: i, end: d }) => r >= i && r < d))
|
|
392
|
+
return a;
|
|
393
|
+
if (c === "if") {
|
|
394
|
+
const i = F.some((d) => d.test(a));
|
|
395
|
+
return u.push(i), i ? "" : a;
|
|
396
|
+
}
|
|
397
|
+
return c === "endif" && u.pop() ? "" : a;
|
|
398
|
+
});
|
|
399
|
+
return o = o.replace(/\n\s*\n\s*\n/g, `
|
|
400
400
|
|
|
401
|
-
`),
|
|
401
|
+
`), o;
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
-
function
|
|
405
|
-
return new
|
|
404
|
+
function rt(n) {
|
|
405
|
+
return new J().migrate(n);
|
|
406
406
|
}
|
|
407
407
|
export {
|
|
408
|
-
|
|
408
|
+
rt as migrateItemsBlock
|
|
409
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.8f596fb", 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.8f596fb",
|
|
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",
|