@useinsider/guido 2.1.0-beta.683dbc0 → 2.1.0-beta.784167c
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,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var M = (r, t,
|
|
4
|
-
import { productPairs as
|
|
1
|
+
var v = Object.defineProperty;
|
|
2
|
+
var B = (r, t, o) => t in r ? v(r, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[t] = o;
|
|
3
|
+
var M = (r, t, o) => B(r, typeof t != "symbol" ? t + "" : t, o);
|
|
4
|
+
import { productPairs as U } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
5
5
|
import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as d } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
6
6
|
import { getDefaultTemplate as K } from "../../extensions/Blocks/Items/template.js";
|
|
7
7
|
const w = {
|
|
@@ -85,36 +85,36 @@ function q(r) {
|
|
|
85
85
|
}[r] || d.ITEMS_TYPE.CART_ITEMS : d.ITEMS_TYPE.CART_ITEMS;
|
|
86
86
|
}
|
|
87
87
|
function R(r) {
|
|
88
|
-
const t = (a,
|
|
88
|
+
const t = (a, e) => a == null ? e : a === "1" || a === "true", o = (a, e) => a || e, c = r["data-type"] || r["data-source"], i = q(c);
|
|
89
89
|
let n = r["data-cart_items_select_control_value"] || g.cartItemsSelectControlValue;
|
|
90
90
|
if (n && !n.includes("{{") && /^\d+$/.test(n)) {
|
|
91
|
-
const a = parseInt(n) - 1,
|
|
92
|
-
|
|
91
|
+
const a = parseInt(n) - 1, e = E[i];
|
|
92
|
+
e && e[a] && (n = e[a].value);
|
|
93
93
|
}
|
|
94
94
|
return {
|
|
95
95
|
initialized: !0,
|
|
96
|
-
blockInstanceId:
|
|
97
|
-
source:
|
|
98
|
-
type:
|
|
96
|
+
blockInstanceId: o(r["data-block-instance-id"], F()),
|
|
97
|
+
source: i,
|
|
98
|
+
type: i,
|
|
99
99
|
itemsSelectValue: n,
|
|
100
100
|
orientation: r["data-card_orientation_control_value"] || d.ORIENTATION.VERTICAL,
|
|
101
101
|
nameTrimming: t(r["data-product_name_control_trim"], !0),
|
|
102
102
|
priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
|
|
103
103
|
priceFormatted: t(r["data-product_price_control_formated"], !0),
|
|
104
104
|
priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
|
|
105
|
-
priceCurrencySymbol:
|
|
105
|
+
priceCurrencySymbol: o(
|
|
106
106
|
r["data-product_price_control_currency_symbol"],
|
|
107
107
|
g.productPriceCurrencySymbolControlValue
|
|
108
108
|
),
|
|
109
|
-
priceCurrencyLocation:
|
|
109
|
+
priceCurrencyLocation: o(
|
|
110
110
|
r["data-product_price_currency_location"],
|
|
111
111
|
g.productPriceCurrencyLocationControlValue
|
|
112
112
|
),
|
|
113
113
|
priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
|
|
114
114
|
quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
|
|
115
|
-
buttonLink:
|
|
116
|
-
imageLink:
|
|
117
|
-
buttonLabel:
|
|
115
|
+
buttonLink: o(r["data-product_button_link"], g.productButtonLinkControlValue),
|
|
116
|
+
imageLink: o(r["data-product_image_link"], g.productImageLinkControlValue),
|
|
117
|
+
buttonLabel: o(r["data-product_button_control_label"], "Buy"),
|
|
118
118
|
buttonFullWidth: t(r["data-product_button_control_atw"], !0),
|
|
119
119
|
imageVisible: t(r["data-product_image_control_enabled"], !0),
|
|
120
120
|
nameVisible: t(r["data-product_name_control_enabled"], !0),
|
|
@@ -130,20 +130,20 @@ const $ = {
|
|
|
130
130
|
purchased_item: "PURCHASED_ITEMS"
|
|
131
131
|
};
|
|
132
132
|
function x(r, t) {
|
|
133
|
-
const
|
|
133
|
+
const o = {
|
|
134
134
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
135
135
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
136
136
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
137
137
|
};
|
|
138
|
-
return
|
|
138
|
+
return o[r] || o.CART_ITEMS;
|
|
139
139
|
}
|
|
140
140
|
function O(r, t) {
|
|
141
|
-
const
|
|
141
|
+
const o = {
|
|
142
142
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
143
143
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
144
144
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
145
145
|
};
|
|
146
|
-
return
|
|
146
|
+
return o[r] || o.CART_ITEMS;
|
|
147
147
|
}
|
|
148
148
|
class V {
|
|
149
149
|
constructor() {
|
|
@@ -152,13 +152,13 @@ class V {
|
|
|
152
152
|
}
|
|
153
153
|
migrate(t) {
|
|
154
154
|
try {
|
|
155
|
-
let
|
|
156
|
-
|
|
157
|
-
const
|
|
155
|
+
let o = this.removeJinjaConditionals(t);
|
|
156
|
+
o = this.replaceTemplateVariables(o);
|
|
157
|
+
const c = this.parser.parseFromString(o, "text/html"), i = c.querySelectorAll(
|
|
158
158
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
159
159
|
);
|
|
160
|
-
return
|
|
161
|
-
const a = this.extractConfiguration(n),
|
|
160
|
+
return i.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), o) : (i.forEach((n) => {
|
|
161
|
+
const a = this.extractConfiguration(n), e = K({
|
|
162
162
|
orientation: a.orientation,
|
|
163
163
|
itemsType: a.itemsType,
|
|
164
164
|
itemId: a.itemId,
|
|
@@ -173,19 +173,19 @@ class V {
|
|
|
173
173
|
originalPriceStyles: a.originalPriceStyles,
|
|
174
174
|
quantityStyles: a.quantityStyles,
|
|
175
175
|
nodeConfig: R(a.configBlockAttributes)
|
|
176
|
-
}),
|
|
177
|
-
`<table><tbody><tr>${
|
|
176
|
+
}), u = this.parser.parseFromString(
|
|
177
|
+
`<table><tbody><tr>${e}</tr></tbody></table>`,
|
|
178
178
|
"text/html"
|
|
179
179
|
).querySelector("td");
|
|
180
|
-
if (
|
|
180
|
+
if (u && n.parentNode) {
|
|
181
181
|
const f = R(a.configBlockAttributes);
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
182
|
+
u.setAttribute("esd-ext-config", JSON.stringify(f));
|
|
183
|
+
const _ = u.querySelector("esd-config-block");
|
|
184
|
+
_ && _.remove(), n.parentNode.replaceChild(u, n);
|
|
185
185
|
}
|
|
186
|
-
}),
|
|
187
|
-
} catch (
|
|
188
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
186
|
+
}), c.documentElement.outerHTML);
|
|
187
|
+
} catch (o) {
|
|
188
|
+
return console.error("ItemsBlockMigrator failed:", o), t;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
@@ -195,23 +195,23 @@ class V {
|
|
|
195
195
|
* - UI styles from product elements (name, price, button, quantity, etc.)
|
|
196
196
|
*/
|
|
197
197
|
extractConfiguration(t) {
|
|
198
|
-
var C,
|
|
199
|
-
const
|
|
198
|
+
var C, P, D;
|
|
199
|
+
const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", c = ((P = t.querySelector("[data-number]")) == null ? void 0 : P.getAttribute("data-number")) || "1", i = parseInt(c) - 1, n = E[o], a = ((D = n == null ? void 0 : n[i]) == null ? void 0 : D.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), l = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", f = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", _ = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", s = this.extractConfigBlockAttributes(t, o, c), b = s["data-card_orientation_control_value"];
|
|
200
200
|
let S;
|
|
201
201
|
b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
202
|
-
const p = t.querySelector('a[product-attr="name"]'), T = (p == null ? void 0 : p.getAttribute("style")) || void 0, y = t.querySelector('a[product-attr="button"]'), m = (y == null ? void 0 : y.getAttribute("style")) || void 0,
|
|
202
|
+
const p = t.querySelector('a[product-attr="name"]'), T = (p == null ? void 0 : p.getAttribute("style")) || void 0, y = t.querySelector('a[product-attr="button"]'), m = (y == null ? void 0 : y.getAttribute("style")) || void 0, h = (e == null ? void 0 : e.getAttribute("style")) || void 0, I = t.querySelector("p.original-price"), k = (I == null ? void 0 : I.getAttribute("style")) || void 0, A = t.querySelector('[product-attr="quantity"]'), L = (A == null ? void 0 : A.getAttribute("style")) || void 0;
|
|
203
203
|
return {
|
|
204
204
|
orientation: S,
|
|
205
|
-
itemsType:
|
|
205
|
+
itemsType: o,
|
|
206
206
|
itemId: a,
|
|
207
|
-
currencySymbol:
|
|
207
|
+
currencySymbol: l,
|
|
208
208
|
currencyLocation: f,
|
|
209
|
-
formattedPrice:
|
|
209
|
+
formattedPrice: _,
|
|
210
210
|
configBlockAttributes: s,
|
|
211
211
|
nameStyles: T,
|
|
212
212
|
buttonStyles: m,
|
|
213
|
-
priceStyles:
|
|
214
|
-
originalPriceStyles:
|
|
213
|
+
priceStyles: h,
|
|
214
|
+
originalPriceStyles: k,
|
|
215
215
|
quantityStyles: L
|
|
216
216
|
};
|
|
217
217
|
}
|
|
@@ -222,27 +222,27 @@ class V {
|
|
|
222
222
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
223
223
|
* @param itemNumber - The item number (1-based index)
|
|
224
224
|
*/
|
|
225
|
-
extractConfigBlockAttributes(t,
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
225
|
+
extractConfigBlockAttributes(t, o, c) {
|
|
226
|
+
const i = t.querySelector("esd-config-block"), n = {};
|
|
227
|
+
if (!i)
|
|
228
228
|
return this.getDefaultConfigBlockAttributes();
|
|
229
|
-
if (Array.from(
|
|
230
|
-
|
|
229
|
+
if (Array.from(i.attributes).forEach((e) => {
|
|
230
|
+
e.name.startsWith("data-") && (n[e.name] = e.value);
|
|
231
231
|
}), n["data-cart_items_select_control_value"]) {
|
|
232
|
-
const
|
|
233
|
-
if (/^\d+$/.test(
|
|
234
|
-
const
|
|
235
|
-
|
|
232
|
+
const e = n["data-cart_items_select_control_value"];
|
|
233
|
+
if (/^\d+$/.test(e)) {
|
|
234
|
+
const l = parseInt(e) - 1, u = E[o];
|
|
235
|
+
u && u[l] && (n["data-cart_items_select_control_value"] = u[l].value);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
if (n["data-product_price_control_curency"]) {
|
|
239
|
-
const
|
|
240
|
-
let
|
|
241
|
-
|
|
239
|
+
const e = n["data-product_price_control_curency"];
|
|
240
|
+
let l = e;
|
|
241
|
+
e === "before" ? l = "0" : e === "after" && (l = "1"), n["data-product_price_control_curency"] = l, n["data-product_price_currency_location"] = l;
|
|
242
242
|
}
|
|
243
243
|
(!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
|
|
244
244
|
const a = { ...this.getDefaultConfigBlockAttributes(), ...n };
|
|
245
|
-
return a["data-type"] =
|
|
245
|
+
return a["data-type"] = o, a["data-source"] = o, a["data-product_image_link"] = x(o, c), a["data-product_button_link"] = O(o, c), a;
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
248
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -299,14 +299,12 @@ class V {
|
|
|
299
299
|
* - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
|
|
300
300
|
*/
|
|
301
301
|
removeJinjaConditionals(t) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
)
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
""
|
|
309
|
-
), e = e.replace(/\{%\s*endif\s*%\}/g, ""), e = e.replace(/\n\s*\n\s*\n/g, `
|
|
302
|
+
const o = /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g, c = /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g, i = t.match(o) || [], n = t.match(c) || [], a = i.length + n.length;
|
|
303
|
+
let e = t.replace(o, "");
|
|
304
|
+
e = e.replace(c, "");
|
|
305
|
+
for (let l = 0; l < a; l++)
|
|
306
|
+
e = e.replace(/\{%\s*endif\s*%\}/, "");
|
|
307
|
+
return e = e.replace(/\n\s*\n\s*\n/g, `
|
|
310
308
|
|
|
311
309
|
`), e;
|
|
312
310
|
}
|
|
@@ -320,26 +318,26 @@ class V {
|
|
|
320
318
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
321
319
|
*/
|
|
322
320
|
replaceTemplateVariables(t) {
|
|
323
|
-
const { PAIRS_FOR_EXTENSION:
|
|
324
|
-
return t.replace(/{{([^}]+)}}/g, (
|
|
325
|
-
const n =
|
|
321
|
+
const { PAIRS_FOR_EXTENSION: o } = U;
|
|
322
|
+
return t.replace(/{{([^}]+)}}/g, (c, i) => {
|
|
323
|
+
const n = i.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
326
324
|
if (!n)
|
|
327
|
-
return
|
|
328
|
-
const [, a,
|
|
329
|
-
if (!
|
|
330
|
-
return console.warn(`Unknown variable prefix: ${a}`),
|
|
331
|
-
const f = w[
|
|
325
|
+
return c;
|
|
326
|
+
const [, a, e, l] = n, u = $[a];
|
|
327
|
+
if (!u)
|
|
328
|
+
return console.warn(`Unknown variable prefix: ${a}`), c;
|
|
329
|
+
const f = w[e];
|
|
332
330
|
if (!f)
|
|
333
|
-
return console.warn(`Unknown variable suffix mapping for: ${
|
|
334
|
-
const { pairsKey:
|
|
331
|
+
return console.warn(`Unknown variable suffix mapping for: ${e}`), c;
|
|
332
|
+
const { pairsKey: _, defaultKey: s, isArray: b } = f, p = o[_][u];
|
|
335
333
|
if (!p)
|
|
336
|
-
return console.warn(`No data found for: ${
|
|
334
|
+
return console.warn(`No data found for: ${_}.${u}`), c;
|
|
337
335
|
if (b) {
|
|
338
|
-
const y = parseInt(
|
|
339
|
-
return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${
|
|
336
|
+
const y = parseInt(l) - 1, m = p[s];
|
|
337
|
+
return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${_}.${u}.${s}[${y}]`), c);
|
|
340
338
|
}
|
|
341
339
|
const T = p[s];
|
|
342
|
-
return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${
|
|
340
|
+
return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${_}.${u}.${s}`), c);
|
|
343
341
|
});
|
|
344
342
|
}
|
|
345
343
|
}
|
|
@@ -133,21 +133,6 @@ ue-label.accent-dot:after {
|
|
|
133
133
|
font-size: 13px;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
.e2e-container-video-size {
|
|
137
|
-
grid-template-columns: 1fr !important;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.e2e-container-video-size .control-shadow-wrapper:not(ue-button) {
|
|
141
|
-
display: flex;
|
|
142
|
-
width: 100%;
|
|
143
|
-
justify-content: flex-end;
|
|
144
|
-
background-color: transparent !important;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.e2e-container-video-size .control-shadow-wrapper input {
|
|
148
|
-
background-color: var(--guido-color-gray-0);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
136
|
.e2e-size,
|
|
152
137
|
.e2e-timer-size {
|
|
153
138
|
grid-auto-flow: row;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.784167c",
|
|
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",
|