@useinsider/guido 3.8.1-beta.6c331cf → 3.8.1-beta.7e47cd7
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/dist/config/migrator/itemsBlockMigrator.js +154 -115
- package/dist/extensions/Blocks/Items/block.js +29 -48
- package/dist/extensions/Blocks/Items/template.js +26 -27
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +45 -62
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +10 -10
- package/dist/src/extensions/Blocks/Items/block.d.ts +0 -8
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var M = (
|
|
4
|
-
import { BLOCK_ID as
|
|
5
|
-
import { productPairs as
|
|
6
|
-
import { ItemInCartOptions as
|
|
7
|
-
import { getDefaultTemplate as
|
|
8
|
-
import { useTemplateStore as
|
|
9
|
-
const
|
|
1
|
+
var v = Object.defineProperty;
|
|
2
|
+
var U = (o, t, r) => t in o ? v(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r;
|
|
3
|
+
var M = (o, t, r) => U(o, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { BLOCK_ID as K } from "../../extensions/Blocks/Items/block.js";
|
|
5
|
+
import { productPairs as w } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { ItemInCartOptions as I, DefaultConfigValues as g, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
7
|
+
import { getDefaultTemplate as F } from "../../extensions/Blocks/Items/template.js";
|
|
8
|
+
import { useTemplateStore as q } from "../../stores/template.js";
|
|
9
|
+
const x = {
|
|
10
10
|
img: {
|
|
11
11
|
pairsKey: "imageSrc",
|
|
12
12
|
defaultKey: "DEFAULT",
|
|
@@ -76,77 +76,77 @@ const q = {
|
|
|
76
76
|
function O() {
|
|
77
77
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
81
|
-
CartItems:
|
|
82
|
-
BrowsedItems:
|
|
83
|
-
PurchasedItems:
|
|
84
|
-
CART_ITEMS:
|
|
85
|
-
BROWSED_ITEMS:
|
|
86
|
-
PURCHASED_ITEMS:
|
|
87
|
-
}[
|
|
79
|
+
function R(o) {
|
|
80
|
+
return o ? {
|
|
81
|
+
CartItems: p.ITEMS_TYPE.CART_ITEMS,
|
|
82
|
+
BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
|
|
83
|
+
PurchasedItems: p.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
84
|
+
CART_ITEMS: p.ITEMS_TYPE.CART_ITEMS,
|
|
85
|
+
BROWSED_ITEMS: p.ITEMS_TYPE.BROWSED_ITEMS,
|
|
86
|
+
PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
|
|
87
|
+
}[o] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function k(o) {
|
|
90
90
|
var e;
|
|
91
|
-
const t = (c,
|
|
92
|
-
let
|
|
93
|
-
if (
|
|
94
|
-
const c = parseInt(
|
|
95
|
-
|
|
91
|
+
const t = (c, u) => c == null ? u : c === "1" || c === "true", r = (c, u) => c || u, l = o["data-type"] || o["data-source"], a = R(l), i = I[a];
|
|
92
|
+
let n = o["data-cart_items_select_control_value"] || ((e = i == null ? void 0 : i[0]) == null ? void 0 : e.value) || g.cartItemsSelectControlValue;
|
|
93
|
+
if (n && !n.includes("{{") && /^\d+$/.test(n)) {
|
|
94
|
+
const c = parseInt(n) - 1, u = I[a];
|
|
95
|
+
u && u[c] && (n = u[c].value);
|
|
96
96
|
}
|
|
97
97
|
return {
|
|
98
98
|
initialized: !0,
|
|
99
|
-
blockInstanceId: o
|
|
99
|
+
blockInstanceId: r(o["data-block-instance-id"], O()),
|
|
100
100
|
source: a,
|
|
101
101
|
type: a,
|
|
102
|
-
itemsSelectValue:
|
|
103
|
-
orientation:
|
|
104
|
-
nameTrimming: t(
|
|
105
|
-
priceHideDiscount: t(
|
|
106
|
-
priceFormatted: t(
|
|
107
|
-
priceSinglePrice: t(
|
|
108
|
-
priceCurrencySymbol:
|
|
109
|
-
|
|
102
|
+
itemsSelectValue: n,
|
|
103
|
+
orientation: o["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
|
|
104
|
+
nameTrimming: t(o["data-product_name_control_trim"], !0),
|
|
105
|
+
priceHideDiscount: t(o["data-product_price_control_nodup"], !0),
|
|
106
|
+
priceFormatted: t(o["data-product_price_control_formated"], !0),
|
|
107
|
+
priceSinglePrice: t(o["data-product_price_control_single_price"], !1),
|
|
108
|
+
priceCurrencySymbol: r(
|
|
109
|
+
o["data-product_price_control_currency_symbol"],
|
|
110
110
|
g.productPriceCurrencySymbolControlValue
|
|
111
111
|
),
|
|
112
|
-
priceCurrencyLocation:
|
|
113
|
-
|
|
112
|
+
priceCurrencyLocation: r(
|
|
113
|
+
o["data-product_price_currency_location"],
|
|
114
114
|
g.productPriceCurrencyLocationControlValue
|
|
115
115
|
),
|
|
116
|
-
priceOrientation:
|
|
117
|
-
quantityControlEnabled: t(
|
|
118
|
-
buttonLink: o
|
|
119
|
-
imageLink: o
|
|
120
|
-
buttonLabel: o
|
|
121
|
-
buttonFullWidth: t(
|
|
122
|
-
imageVisible: t(
|
|
123
|
-
nameVisible: t(
|
|
124
|
-
quantityVisible: t(
|
|
125
|
-
priceVisible: t(
|
|
126
|
-
originalPriceVisible: t(
|
|
127
|
-
buttonVisible: t(
|
|
116
|
+
priceOrientation: o["data-product_original_price_control_orientation"] || "horizontal",
|
|
117
|
+
quantityControlEnabled: t(o["data-product_quantity_control_enabled"], !0),
|
|
118
|
+
buttonLink: r(o["data-product_button_link"], g.productButtonLinkControlValue),
|
|
119
|
+
imageLink: r(o["data-product_image_link"], g.productImageLinkControlValue),
|
|
120
|
+
buttonLabel: r(o["data-product_button_control_label"], "Buy"),
|
|
121
|
+
buttonFullWidth: t(o["data-product_button_control_atw"], !0),
|
|
122
|
+
imageVisible: t(o["data-product_image_control_enabled"], !0),
|
|
123
|
+
nameVisible: t(o["data-product_name_control_enabled"], !0),
|
|
124
|
+
quantityVisible: t(o["data-product_quantity_control_enabled"], !0),
|
|
125
|
+
priceVisible: t(o["data-product_price_control_enabled"], !0),
|
|
126
|
+
originalPriceVisible: t(o["data-product_original_price_control_enabled"], !0),
|
|
127
|
+
buttonVisible: t(o["data-product_button_control_enabled"], !0)
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
const
|
|
130
|
+
const V = {
|
|
131
131
|
ins_apr: "CART_ITEMS",
|
|
132
132
|
browsed_item: "BROWSED_ITEMS",
|
|
133
133
|
purchased_item: "PURCHASED_ITEMS"
|
|
134
134
|
};
|
|
135
|
-
function
|
|
136
|
-
const
|
|
135
|
+
function $(o, t) {
|
|
136
|
+
const r = {
|
|
137
137
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
138
138
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
139
139
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
140
140
|
};
|
|
141
|
-
return o
|
|
141
|
+
return r[o] || r.CART_ITEMS;
|
|
142
142
|
}
|
|
143
|
-
function N(
|
|
144
|
-
const
|
|
143
|
+
function N(o, t) {
|
|
144
|
+
const r = {
|
|
145
145
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
146
146
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
147
147
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
148
148
|
};
|
|
149
|
-
return o
|
|
149
|
+
return r[o] || r.CART_ITEMS;
|
|
150
150
|
}
|
|
151
151
|
class z {
|
|
152
152
|
constructor() {
|
|
@@ -156,16 +156,16 @@ class z {
|
|
|
156
156
|
migrate(t) {
|
|
157
157
|
try {
|
|
158
158
|
if (!this.containsItemsBlock(t))
|
|
159
|
-
return t;
|
|
160
|
-
let
|
|
161
|
-
|
|
162
|
-
const l = this.parser.parseFromString(
|
|
159
|
+
return this.backfillV2ProductTdAttributes(t);
|
|
160
|
+
let r = this.removeJinjaConditionals(t);
|
|
161
|
+
r = this.replaceTemplateVariables(r);
|
|
162
|
+
const l = this.parser.parseFromString(r, "text/html"), a = l.querySelectorAll(
|
|
163
163
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
164
164
|
);
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
}), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"),
|
|
168
|
-
const e = this.extractConfiguration(
|
|
165
|
+
return q().$patch((n) => {
|
|
166
|
+
n.migrations = { ...n.migrations, [K]: a.length };
|
|
167
|
+
}), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (a.forEach((n) => {
|
|
168
|
+
const e = this.extractConfiguration(n), c = F({
|
|
169
169
|
orientation: e.orientation,
|
|
170
170
|
itemsType: e.itemsType,
|
|
171
171
|
itemId: e.itemId,
|
|
@@ -179,20 +179,20 @@ class z {
|
|
|
179
179
|
priceStyles: e.priceStyles,
|
|
180
180
|
originalPriceStyles: e.originalPriceStyles,
|
|
181
181
|
quantityStyles: e.quantityStyles,
|
|
182
|
-
nodeConfig:
|
|
183
|
-
}),
|
|
182
|
+
nodeConfig: k(e.configBlockAttributes)
|
|
183
|
+
}), s = this.parser.parseFromString(
|
|
184
184
|
`<table><tbody><tr>${c}</tr></tbody></table>`,
|
|
185
185
|
"text/html"
|
|
186
186
|
).querySelector("td");
|
|
187
|
-
if (
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
const d =
|
|
191
|
-
d && d.remove(),
|
|
187
|
+
if (s && n.parentNode) {
|
|
188
|
+
const _ = k(e.configBlockAttributes);
|
|
189
|
+
s.setAttribute("esd-ext-config", JSON.stringify(_)), s.setAttribute("data-type", _.type);
|
|
190
|
+
const d = s.querySelector("esd-config-block");
|
|
191
|
+
d && d.remove(), n.parentNode.replaceChild(s, n);
|
|
192
192
|
}
|
|
193
193
|
}), l.documentElement.outerHTML);
|
|
194
|
-
} catch (
|
|
195
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
194
|
+
} catch (r) {
|
|
195
|
+
return console.error("ItemsBlockMigrator failed:", r), t;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
@@ -203,23 +203,25 @@ class z {
|
|
|
203
203
|
*/
|
|
204
204
|
extractConfiguration(t) {
|
|
205
205
|
var C, D, P;
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
const r = R(
|
|
207
|
+
((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) ?? null
|
|
208
|
+
), l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, i = I[r], n = ((P = i == null ? void 0 : i[a]) == null ? void 0 : P.value) || i[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", s = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", _ = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, r, l), b = d["data-card_orientation_control_value"];
|
|
209
|
+
let S;
|
|
210
|
+
b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
211
|
+
const y = t.querySelector('a[product-attr="name"]'), A = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, h = (e == null ? void 0 : e.getAttribute("style")) || void 0, T = t.querySelector("p.original-price"), L = (T == null ? void 0 : T.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), B = (E == null ? void 0 : E.getAttribute("style")) || void 0;
|
|
210
212
|
return {
|
|
211
|
-
orientation:
|
|
212
|
-
itemsType:
|
|
213
|
-
itemId:
|
|
213
|
+
orientation: S,
|
|
214
|
+
itemsType: r,
|
|
215
|
+
itemId: n,
|
|
214
216
|
currencySymbol: c,
|
|
215
|
-
currencyLocation:
|
|
216
|
-
formattedPrice:
|
|
217
|
+
currencyLocation: s,
|
|
218
|
+
formattedPrice: _,
|
|
217
219
|
configBlockAttributes: d,
|
|
218
|
-
nameStyles:
|
|
220
|
+
nameStyles: A,
|
|
219
221
|
buttonStyles: m,
|
|
220
|
-
priceStyles:
|
|
221
|
-
originalPriceStyles:
|
|
222
|
-
quantityStyles:
|
|
222
|
+
priceStyles: h,
|
|
223
|
+
originalPriceStyles: L,
|
|
224
|
+
quantityStyles: B
|
|
223
225
|
};
|
|
224
226
|
}
|
|
225
227
|
/**
|
|
@@ -229,27 +231,27 @@ class z {
|
|
|
229
231
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
230
232
|
* @param itemNumber - The item number (1-based index)
|
|
231
233
|
*/
|
|
232
|
-
extractConfigBlockAttributes(t,
|
|
233
|
-
const a = t.querySelector("esd-config-block"),
|
|
234
|
+
extractConfigBlockAttributes(t, r, l) {
|
|
235
|
+
const a = t.querySelector("esd-config-block"), i = {};
|
|
234
236
|
if (!a)
|
|
235
237
|
return this.getDefaultConfigBlockAttributes();
|
|
236
238
|
if (Array.from(a.attributes).forEach((e) => {
|
|
237
|
-
e.name.startsWith("data-") && (
|
|
238
|
-
}),
|
|
239
|
-
const e =
|
|
239
|
+
e.name.startsWith("data-") && (i[e.name] = e.value);
|
|
240
|
+
}), i["data-cart_items_select_control_value"]) {
|
|
241
|
+
const e = i["data-cart_items_select_control_value"];
|
|
240
242
|
if (/^\d+$/.test(e)) {
|
|
241
|
-
const c = parseInt(e) - 1,
|
|
242
|
-
|
|
243
|
+
const c = parseInt(e) - 1, u = I[r];
|
|
244
|
+
u && u[c] && (i["data-cart_items_select_control_value"] = u[c].value);
|
|
243
245
|
}
|
|
244
246
|
}
|
|
245
|
-
if (
|
|
246
|
-
const e =
|
|
247
|
+
if (i["data-product_price_control_curency"]) {
|
|
248
|
+
const e = i["data-product_price_control_curency"];
|
|
247
249
|
let c = e;
|
|
248
|
-
e === "before" ? c = "0" : e === "after" && (c = "1"),
|
|
250
|
+
e === "before" ? c = "0" : e === "after" && (c = "1"), i["data-product_price_control_curency"] = c, i["data-product_price_currency_location"] = c;
|
|
249
251
|
}
|
|
250
|
-
(!
|
|
251
|
-
const
|
|
252
|
-
return
|
|
252
|
+
(!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
|
|
253
|
+
const n = { ...this.getDefaultConfigBlockAttributes(), ...i };
|
|
254
|
+
return n["data-type"] = r, n["data-source"] = r, n["data-product_image_link"] = $(r, l), n["data-product_button_link"] = N(r, l), n;
|
|
253
255
|
}
|
|
254
256
|
/**
|
|
255
257
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -298,6 +300,43 @@ class z {
|
|
|
298
300
|
"data-product_button_link": "{{Abandoned Cart Item (1) Url}}"
|
|
299
301
|
};
|
|
300
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Backfills data-type (and data-number) onto v2 `.ins-product-td` elements
|
|
305
|
+
* from their persisted `esd-ext-config` nodeConfig.
|
|
306
|
+
*
|
|
307
|
+
* Why: templates migrated and saved by an older build can carry the correct
|
|
308
|
+
* product type in `esd-ext-config` while the `.ins-product-td` is missing the
|
|
309
|
+
* `data-type` DOM attribute. Stripo strips `esd-*` attributes during compile,
|
|
310
|
+
* so by save time only `data-type` survives for `pairProductVariables` to read
|
|
311
|
+
* when choosing the merge-tag namespace. Restoring it here (at load, before the
|
|
312
|
+
* editor compiles) makes the namespace resolve to the real source
|
|
313
|
+
* (browsed_item_ / purchased_item_) instead of defaulting to ins_apr_ (Cart).
|
|
314
|
+
*
|
|
315
|
+
* Only re-serializes when something actually changed, so healthy templates
|
|
316
|
+
* (every product-td already has data-type) pass through byte-for-byte.
|
|
317
|
+
*/
|
|
318
|
+
backfillV2ProductTdAttributes(t) {
|
|
319
|
+
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
320
|
+
return t;
|
|
321
|
+
const r = this.parser.parseFromString(t, "text/html");
|
|
322
|
+
let l = !1;
|
|
323
|
+
return r.querySelectorAll(".ins-product-td").forEach((a) => {
|
|
324
|
+
if (a.getAttribute("data-type"))
|
|
325
|
+
return;
|
|
326
|
+
const i = a.getAttribute("esd-ext-config");
|
|
327
|
+
if (i)
|
|
328
|
+
try {
|
|
329
|
+
const n = JSON.parse(i), e = n.type || n.source;
|
|
330
|
+
if (!e)
|
|
331
|
+
return;
|
|
332
|
+
if (a.setAttribute("data-type", e), l = !0, !a.getAttribute("data-number")) {
|
|
333
|
+
const c = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
|
|
334
|
+
c && a.setAttribute("data-number", c[1]);
|
|
335
|
+
}
|
|
336
|
+
} catch {
|
|
337
|
+
}
|
|
338
|
+
}), l ? r.documentElement.outerHTML : t;
|
|
339
|
+
}
|
|
301
340
|
/**
|
|
302
341
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
303
342
|
* in the raw HTML. Used to gate the migration pipeline so non-items templates
|
|
@@ -317,15 +356,15 @@ class z {
|
|
|
317
356
|
* contains display condition Jinja scripts that should NOT be removed.
|
|
318
357
|
*/
|
|
319
358
|
removeJinjaConditionals(t) {
|
|
320
|
-
const
|
|
321
|
-
let a = l ? t.replace(l[0],
|
|
359
|
+
const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", l = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
360
|
+
let a = l ? t.replace(l[0], r) : t;
|
|
322
361
|
return a = a.replace(
|
|
323
362
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
324
363
|
""
|
|
325
364
|
), a = a.replace(
|
|
326
365
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
327
366
|
""
|
|
328
|
-
), a = a.replace(/\{%\s*endif\s*%\}/g, ""), l && (a = a.replace(
|
|
367
|
+
), a = a.replace(/\{%\s*endif\s*%\}/g, ""), l && (a = a.replace(r, l[0])), a = a.replace(/\n\s*\n\s*\n/g, `
|
|
329
368
|
|
|
330
369
|
`), a;
|
|
331
370
|
}
|
|
@@ -339,31 +378,31 @@ class z {
|
|
|
339
378
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
340
379
|
*/
|
|
341
380
|
replaceTemplateVariables(t) {
|
|
342
|
-
const { PAIRS_FOR_EXTENSION:
|
|
381
|
+
const { PAIRS_FOR_EXTENSION: r } = w;
|
|
343
382
|
return t.replace(/{{([^}]+)}}/g, (l, a) => {
|
|
344
|
-
const
|
|
345
|
-
if (!
|
|
383
|
+
const i = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
384
|
+
if (!i)
|
|
346
385
|
return l;
|
|
347
|
-
const [,
|
|
348
|
-
if (!_)
|
|
349
|
-
return console.warn(`Unknown variable prefix: ${i}`), l;
|
|
350
|
-
const u = q[e];
|
|
386
|
+
const [, n, e, c] = i, u = V[n];
|
|
351
387
|
if (!u)
|
|
388
|
+
return console.warn(`Unknown variable prefix: ${n}`), l;
|
|
389
|
+
const s = x[e];
|
|
390
|
+
if (!s)
|
|
352
391
|
return console.warn(`Unknown variable suffix mapping for: ${e}`), l;
|
|
353
|
-
const { pairsKey:
|
|
392
|
+
const { pairsKey: _, defaultKey: d, isArray: b } = s, y = r[_][u];
|
|
354
393
|
if (!y)
|
|
355
|
-
return console.warn(`No data found for: ${
|
|
356
|
-
if (
|
|
394
|
+
return console.warn(`No data found for: ${_}.${u}`), l;
|
|
395
|
+
if (b) {
|
|
357
396
|
const f = parseInt(c) - 1, m = y[d];
|
|
358
|
-
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${
|
|
397
|
+
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), l);
|
|
359
398
|
}
|
|
360
|
-
const
|
|
361
|
-
return
|
|
399
|
+
const A = y[d];
|
|
400
|
+
return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), l);
|
|
362
401
|
});
|
|
363
402
|
}
|
|
364
403
|
}
|
|
365
|
-
function Q(
|
|
366
|
-
return new z().migrate(
|
|
404
|
+
function Q(o) {
|
|
405
|
+
return new z().migrate(o);
|
|
367
406
|
}
|
|
368
407
|
export {
|
|
369
408
|
Q as migrateItemsBlock
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { BlockId as
|
|
1
|
+
import { BlockId as g } from "../../../enums/block.js";
|
|
2
2
|
import { useOnboardingStore as p } from "../../../stores/onboarding.js";
|
|
3
|
-
import { getMigrationBannerHtml as
|
|
4
|
-
import { Block as
|
|
5
|
-
import { SETTINGS_ENUMS as
|
|
6
|
-
import { getDefaultTemplate as
|
|
7
|
-
import { getItemsBlockContainer as
|
|
8
|
-
const
|
|
9
|
-
class E extends
|
|
3
|
+
import { getMigrationBannerHtml as f } from "../../../utils/migrationBannerHtml.js";
|
|
4
|
+
import { Block as u, BlockCompositionType as I, ModificationDescription as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { SETTINGS_ENUMS as a, DefaultConfigValues as i } from "./enums/settingsEnums.js";
|
|
6
|
+
import { getDefaultTemplate as C } from "./template.js";
|
|
7
|
+
import { getItemsBlockContainer as y, getItemsBlockConfig as b, getDefaultItemsBlockConfig as h } from "./utils/nodeConfigUtils.js";
|
|
8
|
+
const c = g.Items;
|
|
9
|
+
class E extends u {
|
|
10
10
|
getId() {
|
|
11
|
-
return
|
|
11
|
+
return c;
|
|
12
12
|
}
|
|
13
13
|
getIcon() {
|
|
14
14
|
return "items-icon";
|
|
15
15
|
}
|
|
16
16
|
getBlockCompositionType() {
|
|
17
|
-
return
|
|
17
|
+
return I.CONTAINER;
|
|
18
18
|
}
|
|
19
19
|
getName() {
|
|
20
20
|
return this.api.translate("Items");
|
|
@@ -23,60 +23,41 @@ class E extends I {
|
|
|
23
23
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
24
24
|
}
|
|
25
25
|
getSettingsPanelTitleHtml() {
|
|
26
|
-
return
|
|
27
|
-
|
|
26
|
+
return f(
|
|
27
|
+
c,
|
|
28
28
|
this.api.translate("Items"),
|
|
29
29
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
getTemplate() {
|
|
33
|
-
return
|
|
34
|
-
orientation:
|
|
35
|
-
itemsType:
|
|
33
|
+
return C({
|
|
34
|
+
orientation: a.ORIENTATION.VERTICAL,
|
|
35
|
+
itemsType: a.ITEMS_TYPE.CART_ITEMS,
|
|
36
36
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
37
|
-
currencySymbol:
|
|
38
|
-
currencyLocation:
|
|
39
|
-
formattedPrice:
|
|
37
|
+
currencySymbol: i.productPriceCurrencySymbolControlValue,
|
|
38
|
+
currencyLocation: i.productPriceCurrencyLocationControlValue,
|
|
39
|
+
formattedPrice: i.productPriceFormattedControlValue === "1"
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
allowInnerBlocksDND() {
|
|
43
43
|
return !1;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
r.querySelector('[product-attr="imageSrc"] img') || n.modifyCss(r).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
51
|
-
const t = l(i);
|
|
52
|
-
if (!t)
|
|
45
|
+
onCreated(n) {
|
|
46
|
+
const l = this.api.getDocumentModifier(), r = this.api.getDocumentRootCssNode();
|
|
47
|
+
r.querySelector('[product-attr="imageSrc"] img') || l.modifyCss(r).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
48
|
+
const e = y(n);
|
|
49
|
+
if (!e)
|
|
53
50
|
return;
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
|
|
51
|
+
const s = e.getNodeConfig(), m = s && Object.keys(s).length > 0, t = b(n);
|
|
52
|
+
if (t != null && t.initialized)
|
|
53
|
+
m ? t.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...t, blockInstanceId: String(Date.now()) }).apply(new o("Assign block instance ID to block")) : this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(t).apply(new o("Migrate legacy config to nodeConfig"));
|
|
57
54
|
else {
|
|
58
|
-
const
|
|
59
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
55
|
+
const d = h();
|
|
56
|
+
this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(d).apply(new o("Initialize Items block with default configuration")), p().startOnboarding("itemsOnboarding");
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
64
|
-
* surfaces via document load. Stripo strips esd-ext-config and never restores it
|
|
65
|
-
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
66
|
-
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
67
|
-
*/
|
|
68
|
-
onDocumentChanged(i) {
|
|
69
|
-
const n = l(i);
|
|
70
|
-
if (!n)
|
|
71
|
-
return;
|
|
72
|
-
const r = n.getNodeConfig();
|
|
73
|
-
if (r && Object.keys(r).length > 0)
|
|
74
|
-
return;
|
|
75
|
-
const e = m(i);
|
|
76
|
-
e != null && e.initialized && this.api.getDocumentModifier().modifyHtml(n).setNodeConfig(e).apply(new s("Recover Items block config from saved module"));
|
|
77
|
-
}
|
|
78
59
|
}
|
|
79
60
|
export {
|
|
80
|
-
|
|
61
|
+
c as BLOCK_ID,
|
|
81
62
|
E as ItemsBlock
|
|
82
63
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BlockType as b, BlockAttr as N } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { ItemsBlockId as O } from "./enums/controlEnums.js";
|
|
3
|
-
import { productPairs as A, templateFirstLine as
|
|
4
|
-
import { ItemInCartOptions as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import { productPairs as A, templateFirstLine as Q } from "./enums/productEnums.js";
|
|
4
|
+
import { ItemInCartOptions as C, SETTINGS_ENUMS as x, DefaultConfigValues as D } from "./enums/settingsEnums.js";
|
|
5
|
+
import Y from "./layouts/horizontal.html.js";
|
|
6
|
+
import j from "./layouts/vertical.html.js";
|
|
7
7
|
import { escapeReplacement as V } from "./utils/nodeConfigUtils.js";
|
|
8
8
|
let [g] = A.PAIRS_FOR_EXTENSION.imageSrc.CART_ITEMS.DEFAULT, [L] = A.PAIRS_FOR_EXTENSION.name.CART_ITEMS.DEFAULT, [m] = A.PAIRS_FOR_EXTENSION.price.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [S] = A.PAIRS_FOR_EXTENSION.originalPrice.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [M] = A.PAIRS_FOR_EXTENSION.quantity.CART_ITEMS.DEFAULT;
|
|
9
9
|
const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCase().startsWith(e.toLowerCase())).join("; ").replace(/;\s*$/, ""), F = (s) => U(s, "text-align"), w = (s, e) => {
|
|
@@ -12,7 +12,7 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
|
|
|
12
12
|
}, v = (s, e, r) => new RegExp(`(${e}\\s*:\\s*)[^;]+`, "gi").test(s) ? s.replace(
|
|
13
13
|
new RegExp(`(${e}\\s*:\\s*)[^;]+`, "gi"),
|
|
14
14
|
`$1${r}`
|
|
15
|
-
) : s,
|
|
15
|
+
) : s, q = (s, e, r, a) => {
|
|
16
16
|
const i = r || D.productImageHeight, n = (a == null ? void 0 : a.imageVisible) === !1 ? "display: none; " : "";
|
|
17
17
|
return `
|
|
18
18
|
<td class="esd-block-image document-node-component default-block-component selectable ng-star-inserted"
|
|
@@ -35,7 +35,7 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
|
|
|
35
35
|
</a>
|
|
36
36
|
</td>
|
|
37
37
|
`;
|
|
38
|
-
},
|
|
38
|
+
}, Z = (s, e) => `
|
|
39
39
|
<${b.BLOCK_IMAGE}
|
|
40
40
|
${N.BLOCK_IMAGE.src}="${g}"
|
|
41
41
|
${N.BLOCK_IMAGE.alt}="${L}"
|
|
@@ -48,7 +48,7 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
|
|
|
48
48
|
data-type="${s}"
|
|
49
49
|
data-number="${e}"
|
|
50
50
|
/>
|
|
51
|
-
`,
|
|
51
|
+
`, J = (s, e, r, a, i) => {
|
|
52
52
|
const o = `
|
|
53
53
|
text-decoration:none;
|
|
54
54
|
font-size: inherit;
|
|
@@ -129,7 +129,7 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
|
|
|
129
129
|
</p>
|
|
130
130
|
</${b.BLOCK_TEXT}>
|
|
131
131
|
`;
|
|
132
|
-
},
|
|
132
|
+
}, tt = (s, e, r, a, i, n, o, c, l, $) => {
|
|
133
133
|
let t = m;
|
|
134
134
|
if (a && a.trim()) {
|
|
135
135
|
const T = `${a.trim()}`;
|
|
@@ -180,7 +180,7 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
|
|
|
180
180
|
</p>
|
|
181
181
|
</${b.BLOCK_TEXT}>
|
|
182
182
|
`;
|
|
183
|
-
},
|
|
183
|
+
}, et = (s, e, r, a, i, n, o = !0, c, l, $) => {
|
|
184
184
|
let t = S;
|
|
185
185
|
if (a && a.trim()) {
|
|
186
186
|
const T = `${a.trim()}`;
|
|
@@ -234,7 +234,7 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
|
|
|
234
234
|
</p>
|
|
235
235
|
</${b.BLOCK_TEXT}>
|
|
236
236
|
`;
|
|
237
|
-
},
|
|
237
|
+
}, at = (s = !0, e, r) => {
|
|
238
238
|
const a = s ? "" : 'style="display: none;"';
|
|
239
239
|
if (e) {
|
|
240
240
|
const i = "font-size: 14px;", n = w(r || "", "text-align") || "center", o = F(r || i);
|
|
@@ -270,7 +270,7 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
|
|
|
270
270
|
</p>
|
|
271
271
|
</${b.BLOCK_TEXT}>
|
|
272
272
|
`;
|
|
273
|
-
},
|
|
273
|
+
}, st = (s, e, r = "Buy", a, i, n = !0, o = !0) => {
|
|
274
274
|
if (a) {
|
|
275
275
|
const c = w(i || "", "background") || w(i || "", "background-color"), l = c ? `border-width: 0px; background: ${c};` : "border-width: 0px;", $ = n ? "es-fw" : "es-il", t = (i || "").replace("border-width: 0;", "");
|
|
276
276
|
return `
|
|
@@ -305,7 +305,7 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
|
|
|
305
305
|
>${r}
|
|
306
306
|
</${b.BLOCK_BUTTON}>
|
|
307
307
|
`;
|
|
308
|
-
},
|
|
308
|
+
}, lt = (s, e, r, a = !0, i = !0) => {
|
|
309
309
|
const n = e === x.ORIENTATION.VERTICAL, o = r === "horizontal";
|
|
310
310
|
if (n) {
|
|
311
311
|
const c = !o, l = c || !i ? "100%" : "50%", $ = c || !a ? "100%" : "50%";
|
|
@@ -325,16 +325,12 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
|
|
|
325
325
|
/<td\s+[^>]*class="[^"]*vertical-price[^"]*"[^>]*>/gi,
|
|
326
326
|
(c) => c.replace(/display:\s*none;?/gi, "display: table-cell;")
|
|
327
327
|
);
|
|
328
|
-
},
|
|
328
|
+
}, rt = (s) => s ? `<td align="center"
|
|
329
329
|
esd-extension-block-id="items-block" width="560"
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
const h = `${`data-type="${e}" data-number="${r}"`} data-orientation="${a}"`, y = s.replace(
|
|
333
|
-
/<td([^>]*class="[^"]*ins-product-td[^"]*"[^>]*)>/,
|
|
334
|
-
`<td$1 ${h}>`
|
|
335
|
-
), X = l == null ? void 0 : l["data-product_image_control_image-height"], G = n ? Z(e, r, X, t) : J(e, r), K = (t == null ? void 0 : t.buttonLabel) || "Buy", B = (t == null ? void 0 : t.buttonFullWidth) !== void 0 ? t.buttonFullWidth : !0, W = e === x.ITEMS_TYPE.BROWSED_ITEMS ? !1 : t == null ? void 0 : t.quantityControlEnabled, Q = (t == null ? void 0 : t.buttonVisible) !== void 0 ? t.buttonVisible : (l == null ? void 0 : l["data-product_button_control_enabled"]) !== "false", k = (t == null ? void 0 : t.priceVisible) !== void 0 ? t.priceVisible : (l == null ? void 0 : l["data-product_price_control_enabled"]) !== "false", f = (t == null ? void 0 : t.originalPriceVisible) !== void 0 ? t.originalPriceVisible : (l == null ? void 0 : l["data-product_original_price_control_enabled"]) !== "false", H = y.replace("{-{-TEMPLATE_FIRST_LINE-}-}", it(n)).replace("{-{-PRODUCT_IMAGE-}-}", G).replace("{-{-PRODUCT_NAME-}-}", tt(e, n, a, E, t)).replaceAll(
|
|
330
|
+
class="ins-product-td items-block items-block-v2 esd-items-block esd-extension-block esd-container-frame">` : Q, z = (s, e, r, a, i, n, o, c, l, $, t, E, _, u = "horizontal", P, p, R, d) => {
|
|
331
|
+
const h = `${`data-type="${e}" data-number="${r}"`} data-orientation="${a}"`, y = l == null ? void 0 : l["data-product_image_control_image-height"], X = n ? q(e, r, y, t) : Z(e, r), G = (t == null ? void 0 : t.buttonLabel) || "Buy", K = (t == null ? void 0 : t.buttonFullWidth) !== void 0 ? t.buttonFullWidth : !0, B = e === x.ITEMS_TYPE.BROWSED_ITEMS ? !1 : t == null ? void 0 : t.quantityControlEnabled, W = (t == null ? void 0 : t.buttonVisible) !== void 0 ? t.buttonVisible : (l == null ? void 0 : l["data-product_button_control_enabled"]) !== "false", k = (t == null ? void 0 : t.priceVisible) !== void 0 ? t.priceVisible : (l == null ? void 0 : l["data-product_price_control_enabled"]) !== "false", f = (t == null ? void 0 : t.originalPriceVisible) !== void 0 ? t.originalPriceVisible : (l == null ? void 0 : l["data-product_original_price_control_enabled"]) !== "false", H = s.replace("{-{-TEMPLATE_FIRST_LINE-}-}", rt(n)).replace("{-{-PRODUCT_IMAGE-}-}", X).replace("{-{-PRODUCT_NAME-}-}", J(e, n, a, E, t)).replaceAll(
|
|
336
332
|
"{-{-PRODUCT_PRICE-}-}",
|
|
337
|
-
V(
|
|
333
|
+
V(tt(
|
|
338
334
|
e,
|
|
339
335
|
r,
|
|
340
336
|
i,
|
|
@@ -348,7 +344,7 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
|
|
|
348
344
|
))
|
|
349
345
|
).replaceAll(
|
|
350
346
|
"{-{-PRODUCT_ORIGINAL_PRICE-}-}",
|
|
351
|
-
V(
|
|
347
|
+
V(et(
|
|
352
348
|
e,
|
|
353
349
|
r,
|
|
354
350
|
i,
|
|
@@ -360,11 +356,14 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
|
|
|
360
356
|
d,
|
|
361
357
|
a
|
|
362
358
|
))
|
|
363
|
-
).replace("{-{-PRODUCT_QUANTITY-}-}",
|
|
359
|
+
).replace("{-{-PRODUCT_QUANTITY-}-}", at(B, n, R)).replace(
|
|
364
360
|
"{-{-PRODUCT_BUTTON-}-}",
|
|
365
|
-
|
|
361
|
+
st(e, r, G, n, _, K, W)
|
|
362
|
+
).replace(
|
|
363
|
+
/<td([^>]*class="[^"]*ins-product-td[^"]*"[^>]*)>/,
|
|
364
|
+
`<td$1 ${h}>`
|
|
366
365
|
);
|
|
367
|
-
return
|
|
366
|
+
return lt(
|
|
368
367
|
H,
|
|
369
368
|
a,
|
|
370
369
|
u,
|
|
@@ -389,7 +388,7 @@ function Tt({
|
|
|
389
388
|
quantityStyles: u,
|
|
390
389
|
priceOrientation: P
|
|
391
390
|
}) {
|
|
392
|
-
const p =
|
|
391
|
+
const p = C[e].findIndex((y) => y.value === r);
|
|
393
392
|
let R = "1";
|
|
394
393
|
if (p >= 0)
|
|
395
394
|
R = String(p + 1);
|
|
@@ -403,7 +402,7 @@ function Tt({
|
|
|
403
402
|
d ? (m = o ? T.DEFAULT_SINGLE_PRICE_FORMATTED : T.DEFAULT_SINGLE_PRICE, S = o ? I.DEFAULT_SINGLE_PRICE_FORMATTED : I.DEFAULT_SINGLE_PRICE) : (m = o ? T.DEFAULT_PRICE_FORMATTED : T.DEFAULT_PRICE, S = o ? I.DEFAULT_PRICE_FORMATTED : I.DEFAULT_PRICE), M = A.PAIRS_FOR_EXTENSION.quantity[e].DEFAULT;
|
|
404
403
|
const h = P || (l == null ? void 0 : l.priceOrientation) || "horizontal";
|
|
405
404
|
return s === x.ORIENTATION.VERTICAL ? z(
|
|
406
|
-
|
|
405
|
+
j,
|
|
407
406
|
e,
|
|
408
407
|
R,
|
|
409
408
|
s,
|
|
@@ -423,7 +422,7 @@ function Tt({
|
|
|
423
422
|
u,
|
|
424
423
|
d
|
|
425
424
|
) : z(
|
|
426
|
-
|
|
425
|
+
Y,
|
|
427
426
|
e,
|
|
428
427
|
R,
|
|
429
428
|
s,
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { ModificationDescription as b } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
import { DefaultConfigValues as
|
|
2
|
+
import { DefaultConfigValues as o, SETTINGS_ENUMS as n, ItemInCartOptions as g } from "../enums/settingsEnums.js";
|
|
3
3
|
function _() {
|
|
4
4
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
5
5
|
}
|
|
6
6
|
const E = (r) => r.replace(/\$/g, "$$$$");
|
|
7
|
-
function
|
|
7
|
+
function S() {
|
|
8
8
|
return {
|
|
9
9
|
initialized: !0,
|
|
10
10
|
blockInstanceId: _(),
|
|
11
11
|
source: n.ITEMS_TYPE.CART_ITEMS,
|
|
12
12
|
type: n.ITEMS_TYPE.CART_ITEMS,
|
|
13
|
-
itemsSelectValue:
|
|
13
|
+
itemsSelectValue: o.cartItemsSelectControlValue,
|
|
14
14
|
orientation: n.ORIENTATION.VERTICAL,
|
|
15
|
-
nameTrimming:
|
|
16
|
-
priceHideDiscount:
|
|
17
|
-
priceFormatted:
|
|
15
|
+
nameTrimming: o.productNameTrimmingControlValue === "1",
|
|
16
|
+
priceHideDiscount: o.productPriceHideDiscountControlValue === "1",
|
|
17
|
+
priceFormatted: o.productPriceFormattedControlValue === "1",
|
|
18
18
|
priceSinglePrice: !1,
|
|
19
|
-
priceCurrencySymbol:
|
|
20
|
-
priceCurrencyLocation:
|
|
19
|
+
priceCurrencySymbol: o.productPriceCurrencySymbolControlValue,
|
|
20
|
+
priceCurrencyLocation: o.productPriceCurrencyLocationControlValue,
|
|
21
21
|
priceOrientation: "horizontal",
|
|
22
|
-
quantityControlEnabled:
|
|
23
|
-
buttonLink:
|
|
24
|
-
imageLink:
|
|
22
|
+
quantityControlEnabled: o.productQuantityControlEnabled === "1",
|
|
23
|
+
buttonLink: o.productButtonLinkControlValue,
|
|
24
|
+
imageLink: o.productImageLinkControlValue,
|
|
25
25
|
buttonLabel: "Buy",
|
|
26
26
|
buttonFullWidth: !0,
|
|
27
27
|
// Default to full width (es-fw class)
|
|
28
|
-
imageVisible:
|
|
29
|
-
nameVisible:
|
|
30
|
-
quantityVisible:
|
|
31
|
-
priceVisible:
|
|
32
|
-
originalPriceVisible:
|
|
33
|
-
buttonVisible:
|
|
28
|
+
imageVisible: o.productImageVisible === "1",
|
|
29
|
+
nameVisible: o.productNameVisible === "1",
|
|
30
|
+
quantityVisible: o.productQuantityVisible === "1",
|
|
31
|
+
priceVisible: o.productPriceVisible === "1",
|
|
32
|
+
originalPriceVisible: o.productOriginalPriceVisible === "1",
|
|
33
|
+
buttonVisible: o.productButtonVisible === "1"
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
function p(r) {
|
|
@@ -50,26 +50,26 @@ function m(r) {
|
|
|
50
50
|
PURCHASED_ITEMS: n.ITEMS_TYPE.PURCHASED_ITEMS
|
|
51
51
|
}[r] || n.ITEMS_TYPE.CART_ITEMS : n.ITEMS_TYPE.CART_ITEMS;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function I(r, t) {
|
|
54
54
|
if (!r)
|
|
55
|
-
return
|
|
55
|
+
return o.cartItemsSelectControlValue;
|
|
56
56
|
if (r.includes("{{"))
|
|
57
57
|
return r;
|
|
58
58
|
if (/^\d+$/.test(r)) {
|
|
59
|
-
const e = parseInt(r) - 1,
|
|
60
|
-
if (
|
|
61
|
-
return
|
|
59
|
+
const e = parseInt(r) - 1, i = g[t];
|
|
60
|
+
if (i && i[e])
|
|
61
|
+
return i[e].value;
|
|
62
62
|
}
|
|
63
|
-
return
|
|
63
|
+
return o.cartItemsSelectControlValue;
|
|
64
64
|
}
|
|
65
65
|
function C(r) {
|
|
66
66
|
const t = r.querySelector("esd-config-block");
|
|
67
67
|
if (!t)
|
|
68
68
|
return null;
|
|
69
|
-
const e = (
|
|
69
|
+
const e = (c, s) => c == null ? s : c === "1" || c === "true", i = (c, s) => c || s, u = t.getAttribute("data-type"), a = m(u), d = t.getAttribute("data-cart_items_select_control_value"), l = I(d, a);
|
|
70
70
|
return {
|
|
71
71
|
initialized: e(t.getAttribute("data-initialized"), !1),
|
|
72
|
-
blockInstanceId:
|
|
72
|
+
blockInstanceId: i(
|
|
73
73
|
t.getAttribute("data-block-instance-id"),
|
|
74
74
|
_()
|
|
75
75
|
),
|
|
@@ -93,28 +93,28 @@ function C(r) {
|
|
|
93
93
|
t.getAttribute("data-product_price_control_single_price"),
|
|
94
94
|
!1
|
|
95
95
|
),
|
|
96
|
-
priceCurrencySymbol:
|
|
96
|
+
priceCurrencySymbol: i(
|
|
97
97
|
t.getAttribute("data-product_price_control_currency_symbol"),
|
|
98
|
-
|
|
98
|
+
o.productPriceCurrencySymbolControlValue
|
|
99
99
|
),
|
|
100
|
-
priceCurrencyLocation:
|
|
100
|
+
priceCurrencyLocation: i(
|
|
101
101
|
t.getAttribute("data-product_price_currency_location"),
|
|
102
|
-
|
|
102
|
+
o.productPriceCurrencyLocationControlValue
|
|
103
103
|
),
|
|
104
104
|
priceOrientation: t.getAttribute("data-product_original_price_control_orientation") || "horizontal",
|
|
105
105
|
quantityControlEnabled: e(
|
|
106
106
|
t.getAttribute("data-product_quantity_control_enabled"),
|
|
107
107
|
!0
|
|
108
108
|
),
|
|
109
|
-
buttonLink:
|
|
109
|
+
buttonLink: i(
|
|
110
110
|
t.getAttribute("data-product_button_link"),
|
|
111
|
-
|
|
111
|
+
o.productButtonLinkControlValue
|
|
112
112
|
),
|
|
113
|
-
imageLink:
|
|
113
|
+
imageLink: i(
|
|
114
114
|
t.getAttribute("data-product_image_link"),
|
|
115
|
-
|
|
115
|
+
o.productImageLinkControlValue
|
|
116
116
|
),
|
|
117
|
-
buttonLabel:
|
|
117
|
+
buttonLabel: i(
|
|
118
118
|
t.getAttribute("data-product_button_control_label"),
|
|
119
119
|
"Buy"
|
|
120
120
|
),
|
|
@@ -149,45 +149,28 @@ function C(r) {
|
|
|
149
149
|
)
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
if (typeof r.getAttribute != "function")
|
|
154
|
-
return null;
|
|
155
|
-
const t = r.getAttribute("esd-ext-config");
|
|
156
|
-
if (!t)
|
|
157
|
-
return null;
|
|
158
|
-
try {
|
|
159
|
-
const e = JSON.parse(t);
|
|
160
|
-
if (e && e.initialized)
|
|
161
|
-
return e;
|
|
162
|
-
} catch {
|
|
163
|
-
}
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
function A(r) {
|
|
152
|
+
function y(r) {
|
|
167
153
|
const t = p(r);
|
|
168
154
|
if (!t)
|
|
169
155
|
return null;
|
|
170
156
|
const e = t.getNodeConfig();
|
|
171
157
|
if (e && e.initialized)
|
|
172
158
|
return e;
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
return o;
|
|
176
|
-
const c = C(t);
|
|
177
|
-
return c || null;
|
|
159
|
+
const i = C(t);
|
|
160
|
+
return i || null;
|
|
178
161
|
}
|
|
179
|
-
function
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
162
|
+
function A(r, t, e, i) {
|
|
163
|
+
const u = p(r);
|
|
164
|
+
if (!u)
|
|
182
165
|
return;
|
|
183
|
-
const d = { ...
|
|
184
|
-
l.modifyHtml(
|
|
166
|
+
const d = { ...u.getNodeConfig() || {}, ...e }, l = i ?? t.getDocumentModifier();
|
|
167
|
+
l.modifyHtml(u).setNodeConfig(d), i || l.apply(new b("Update Items block configuration"));
|
|
185
168
|
}
|
|
186
169
|
export {
|
|
187
170
|
E as escapeReplacement,
|
|
188
171
|
_ as generateBlockInstanceId,
|
|
189
|
-
|
|
190
|
-
|
|
172
|
+
S as getDefaultItemsBlockConfig,
|
|
173
|
+
y as getItemsBlockConfig,
|
|
191
174
|
p as getItemsBlockContainer,
|
|
192
|
-
|
|
175
|
+
A as setItemsBlockConfig
|
|
193
176
|
};
|
|
@@ -93,8 +93,8 @@ function $(e, t = {}) {
|
|
|
93
93
|
productsPerRow: c.mobileCardsInRow,
|
|
94
94
|
composition: d,
|
|
95
95
|
filterList: l.filterList,
|
|
96
|
-
//
|
|
97
|
-
cellPadding:
|
|
96
|
+
// Match the initial render's gutter so a regeneration never changes block height (SD-143023).
|
|
97
|
+
cellPadding: U(c.mobileColumnSpacing),
|
|
98
98
|
rowSpacingPx: c.mobileRowSpacing,
|
|
99
99
|
...t
|
|
100
100
|
})}</table></td>`, E = n.querySelector(N);
|
|
@@ -120,8 +120,8 @@ function ee(e, t = {}) {
|
|
|
120
120
|
productsPerRow: a,
|
|
121
121
|
composition: d,
|
|
122
122
|
filterList: c.filterList,
|
|
123
|
-
//
|
|
124
|
-
cellPadding:
|
|
123
|
+
// Match the initial render's gutter so a regeneration never changes block height (SD-143023).
|
|
124
|
+
cellPadding: U(p.columnSpacing),
|
|
125
125
|
rowSpacingPx: p.rowSpacing,
|
|
126
126
|
...t
|
|
127
127
|
});
|
|
@@ -277,7 +277,7 @@ function re(e, t, n) {
|
|
|
277
277
|
});
|
|
278
278
|
}), s;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function h(e, t, n) {
|
|
281
281
|
if (!("querySelectorAll" in e))
|
|
282
282
|
return !1;
|
|
283
283
|
const o = e.querySelectorAll(
|
|
@@ -321,12 +321,12 @@ function ge(e) {
|
|
|
321
321
|
`[esd-extension-block-id="${m.IMAGE}"]`
|
|
322
322
|
).length !== o.length)
|
|
323
323
|
return !1;
|
|
324
|
-
let i =
|
|
324
|
+
let i = h(r, n, o);
|
|
325
325
|
const u = C(t), c = S.getConfig(t);
|
|
326
326
|
if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
|
|
327
327
|
const l = t.querySelector(O);
|
|
328
328
|
if (l) {
|
|
329
|
-
const a =
|
|
329
|
+
const a = h(
|
|
330
330
|
l,
|
|
331
331
|
n,
|
|
332
332
|
o
|
|
@@ -336,7 +336,7 @@ function ge(e) {
|
|
|
336
336
|
}
|
|
337
337
|
return i && n.apply(new g("Updated product content in-place")), !0;
|
|
338
338
|
}
|
|
339
|
-
function
|
|
339
|
+
function I(e, t, n) {
|
|
340
340
|
if (!("querySelectorAll" in e))
|
|
341
341
|
return !1;
|
|
342
342
|
const o = e.querySelectorAll(
|
|
@@ -370,12 +370,12 @@ function Se(e) {
|
|
|
370
370
|
if (r.length === 0)
|
|
371
371
|
return !1;
|
|
372
372
|
const s = j(t);
|
|
373
|
-
let i =
|
|
373
|
+
let i = I(s, n, r);
|
|
374
374
|
const u = C(t), c = S.getConfig(t);
|
|
375
375
|
if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
|
|
376
376
|
const l = t.querySelector(O);
|
|
377
377
|
if (l) {
|
|
378
|
-
const a =
|
|
378
|
+
const a = I(l, n, r);
|
|
379
379
|
i = i || a;
|
|
380
380
|
}
|
|
381
381
|
}
|
|
@@ -24,13 +24,5 @@ export declare class ItemsBlock extends Block {
|
|
|
24
24
|
getSettingsPanelTitleHtml(): string;
|
|
25
25
|
getTemplate(): string;
|
|
26
26
|
allowInnerBlocksDND(): boolean;
|
|
27
|
-
canBeSavedAsModule(): boolean;
|
|
28
27
|
onCreated(node: ImmutableHtmlNode): void;
|
|
29
|
-
/**
|
|
30
|
-
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
31
|
-
* surfaces via document load. Stripo strips esd-ext-config and never restores it
|
|
32
|
-
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
33
|
-
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
34
|
-
*/
|
|
35
|
-
onDocumentChanged(node: ImmutableHtmlNode): void;
|
|
36
28
|
}
|
|
@@ -55,7 +55,7 @@ export declare function getItemsBlockContainer(currentNode: ImmutableHtmlNode |
|
|
|
55
55
|
/**
|
|
56
56
|
* Gets the node configuration from the Items block.
|
|
57
57
|
* Uses Stripo V2's getNodeConfig() API.
|
|
58
|
-
* Falls back to
|
|
58
|
+
* Falls back to migrating from legacy config block if nodeConfig is empty.
|
|
59
59
|
* @param currentNode - The current node from the control
|
|
60
60
|
* @returns The ItemsBlockConfig object or null if not found
|
|
61
61
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.8.1-beta.
|
|
3
|
+
"version": "3.8.1-beta.7e47cd7",
|
|
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",
|