@useinsider/guido 2.1.0-beta.411f2a9 → 2.1.0-beta.425dfd0
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 +123 -140
- package/dist/extensions/Blocks/Items/block.js +28 -19
- package/dist/extensions/Blocks/Items/controls/button/link.js +31 -19
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +81 -97
- package/dist/extensions/Blocks/Items/controls/image/link.js +31 -19
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +40 -28
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +46 -34
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +50 -45
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +51 -40
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +35 -23
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +57 -45
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +62 -42
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +191 -184
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -0
- package/dist/extensions/Blocks/Items/extension.js +9 -8
- package/dist/extensions/Blocks/Items/store/items-block.js +79 -0
- package/dist/extensions/Blocks/Items/template.js +175 -181
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +3 -3
- package/dist/extensions/Blocks/common-control.js +92 -91
- package/dist/src/extensions/Blocks/Items/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +12 -10
- package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +45 -0
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -2
- package/dist/src/extensions/Blocks/common-control.d.ts +5 -4
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { productPairs as
|
|
5
|
-
import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as
|
|
6
|
-
import { getDefaultTemplate as
|
|
1
|
+
var L = Object.defineProperty;
|
|
2
|
+
var K = (o, t, r) => t in o ? L(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r;
|
|
3
|
+
var R = (o, t, r) => K(o, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { productPairs as B } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
5
|
+
import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as _ } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
6
|
+
import { getDefaultTemplate as U } from "../../extensions/Blocks/Items/template.js";
|
|
7
7
|
const w = {
|
|
8
8
|
img: {
|
|
9
9
|
pairsKey: "imageSrc",
|
|
@@ -74,118 +74,102 @@ const w = {
|
|
|
74
74
|
function F() {
|
|
75
75
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
76
76
|
}
|
|
77
|
-
function q(
|
|
78
|
-
return
|
|
79
|
-
CartItems:
|
|
80
|
-
BrowsedItems:
|
|
81
|
-
PurchasedItems:
|
|
82
|
-
CART_ITEMS:
|
|
83
|
-
BROWSED_ITEMS:
|
|
84
|
-
PURCHASED_ITEMS:
|
|
85
|
-
}[
|
|
77
|
+
function q(o) {
|
|
78
|
+
return o ? {
|
|
79
|
+
CartItems: _.ITEMS_TYPE.CART_ITEMS,
|
|
80
|
+
BrowsedItems: _.ITEMS_TYPE.BROWSED_ITEMS,
|
|
81
|
+
PurchasedItems: _.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
82
|
+
CART_ITEMS: _.ITEMS_TYPE.CART_ITEMS,
|
|
83
|
+
BROWSED_ITEMS: _.ITEMS_TYPE.BROWSED_ITEMS,
|
|
84
|
+
PURCHASED_ITEMS: _.ITEMS_TYPE.PURCHASED_ITEMS
|
|
85
|
+
}[o] || _.ITEMS_TYPE.CART_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
const t = (
|
|
89
|
-
let
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
|
|
87
|
+
function M(o) {
|
|
88
|
+
const t = (e, a) => e == null ? a : e === "1" || e === "true", r = (e, a) => e || a, c = o["data-type"] || o["data-source"], n = q(c);
|
|
89
|
+
let i = o["data-cart_items_select_control_value"] || g.cartItemsSelectControlValue;
|
|
90
|
+
if (i && !i.includes("{{") && /^\d+$/.test(i)) {
|
|
91
|
+
const e = parseInt(i) - 1, a = E[n];
|
|
92
|
+
a && a[e] && (i = a[e].value);
|
|
93
93
|
}
|
|
94
94
|
return {
|
|
95
95
|
initialized: !0,
|
|
96
|
-
blockInstanceId:
|
|
97
|
-
source:
|
|
98
|
-
type:
|
|
99
|
-
itemsSelectValue:
|
|
100
|
-
orientation:
|
|
101
|
-
nameTrimming: t(
|
|
102
|
-
priceHideDiscount: t(
|
|
103
|
-
priceFormatted: t(
|
|
104
|
-
priceSinglePrice: t(
|
|
105
|
-
priceCurrencySymbol:
|
|
106
|
-
|
|
96
|
+
blockInstanceId: r(o["data-block-instance-id"], F()),
|
|
97
|
+
source: n,
|
|
98
|
+
type: n,
|
|
99
|
+
itemsSelectValue: i,
|
|
100
|
+
orientation: o["data-card_orientation_control_value"] || _.ORIENTATION.VERTICAL,
|
|
101
|
+
nameTrimming: t(o["data-product_name_control_trim"], !0),
|
|
102
|
+
priceHideDiscount: t(o["data-product_price_control_nodup"], !0),
|
|
103
|
+
priceFormatted: t(o["data-product_price_control_formated"], !0),
|
|
104
|
+
priceSinglePrice: t(o["data-product_price_control_single_price"], !1),
|
|
105
|
+
priceCurrencySymbol: r(
|
|
106
|
+
o["data-product_price_currency_symbol"],
|
|
107
107
|
g.productPriceCurrencySymbolControlValue
|
|
108
108
|
),
|
|
109
|
-
priceCurrencyLocation:
|
|
110
|
-
|
|
109
|
+
priceCurrencyLocation: r(
|
|
110
|
+
o["data-product_price_currency_location"],
|
|
111
111
|
g.productPriceCurrencyLocationControlValue
|
|
112
112
|
),
|
|
113
|
-
priceOrientation:
|
|
114
|
-
quantityControlEnabled: t(
|
|
115
|
-
buttonLink:
|
|
116
|
-
imageLink:
|
|
117
|
-
buttonLabel:
|
|
118
|
-
buttonFullWidth: t(
|
|
119
|
-
imageVisible: t(
|
|
120
|
-
nameVisible: t(
|
|
121
|
-
quantityVisible: t(
|
|
122
|
-
priceVisible: t(
|
|
123
|
-
originalPriceVisible: t(
|
|
124
|
-
buttonVisible: t(
|
|
113
|
+
priceOrientation: o["data-product_original_price_control_orientation"] || "horizontal",
|
|
114
|
+
quantityControlEnabled: t(o["data-product_quantity_control_enabled"], !0),
|
|
115
|
+
buttonLink: r(o["data-product_button_link"], g.productButtonLinkControlValue),
|
|
116
|
+
imageLink: r(o["data-product_image_link"], g.productImageLinkControlValue),
|
|
117
|
+
buttonLabel: r(o["data-product_button_control_label"], "Buy"),
|
|
118
|
+
buttonFullWidth: t(o["data-product_button_control_atw"], !0),
|
|
119
|
+
imageVisible: t(o["data-product_image_control_enabled"], !0),
|
|
120
|
+
nameVisible: t(o["data-product_name_control_enabled"], !0),
|
|
121
|
+
quantityVisible: t(o["data-product_quantity_control_enabled"], !0),
|
|
122
|
+
priceVisible: t(o["data-product_price_control_enabled"], !0),
|
|
123
|
+
originalPriceVisible: t(o["data-product_original_price_control_enabled"], !0),
|
|
124
|
+
buttonVisible: t(o["data-product_button_control_enabled"], !0)
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
const
|
|
127
|
+
const x = {
|
|
128
128
|
ins_apr: "CART_ITEMS",
|
|
129
129
|
browsed_item: "BROWSED_ITEMS",
|
|
130
130
|
purchased_item: "PURCHASED_ITEMS"
|
|
131
131
|
};
|
|
132
|
-
|
|
133
|
-
const e = {
|
|
134
|
-
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
135
|
-
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
136
|
-
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
137
|
-
};
|
|
138
|
-
return e[r] || e.CART_ITEMS;
|
|
139
|
-
}
|
|
140
|
-
function O(r, t) {
|
|
141
|
-
const e = {
|
|
142
|
-
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
143
|
-
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
144
|
-
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
145
|
-
};
|
|
146
|
-
return e[r] || e.CART_ITEMS;
|
|
147
|
-
}
|
|
148
|
-
class V {
|
|
132
|
+
class N {
|
|
149
133
|
constructor() {
|
|
150
|
-
|
|
134
|
+
R(this, "parser");
|
|
151
135
|
this.parser = new DOMParser();
|
|
152
136
|
}
|
|
153
137
|
migrate(t) {
|
|
154
138
|
try {
|
|
155
|
-
let
|
|
156
|
-
|
|
157
|
-
const
|
|
139
|
+
let r = this.removeJinjaConditionals(t);
|
|
140
|
+
r = this.replaceTemplateVariables(r);
|
|
141
|
+
const c = this.parser.parseFromString(r, "text/html"), n = c.querySelectorAll(
|
|
158
142
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
159
143
|
);
|
|
160
|
-
return
|
|
161
|
-
const
|
|
162
|
-
orientation:
|
|
163
|
-
itemsType:
|
|
164
|
-
itemId:
|
|
165
|
-
currencySymbol:
|
|
166
|
-
currencyLocation:
|
|
167
|
-
formattedPrice:
|
|
168
|
-
configBlockAttributes:
|
|
144
|
+
return n.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (n.forEach((i) => {
|
|
145
|
+
const e = this.extractConfiguration(i), a = U({
|
|
146
|
+
orientation: e.orientation,
|
|
147
|
+
itemsType: e.itemsType,
|
|
148
|
+
itemId: e.itemId,
|
|
149
|
+
currencySymbol: e.currencySymbol,
|
|
150
|
+
currencyLocation: e.currencyLocation,
|
|
151
|
+
formattedPrice: e.formattedPrice,
|
|
152
|
+
configBlockAttributes: e.configBlockAttributes,
|
|
169
153
|
migrate: !0,
|
|
170
|
-
nameStyles:
|
|
171
|
-
buttonStyles:
|
|
172
|
-
priceStyles:
|
|
173
|
-
originalPriceStyles:
|
|
174
|
-
quantityStyles:
|
|
175
|
-
nodeConfig:
|
|
176
|
-
}),
|
|
177
|
-
`<table><tbody><tr>${
|
|
154
|
+
nameStyles: e.nameStyles,
|
|
155
|
+
buttonStyles: e.buttonStyles,
|
|
156
|
+
priceStyles: e.priceStyles,
|
|
157
|
+
originalPriceStyles: e.originalPriceStyles,
|
|
158
|
+
quantityStyles: e.quantityStyles,
|
|
159
|
+
nodeConfig: M(e.configBlockAttributes)
|
|
160
|
+
}), l = this.parser.parseFromString(
|
|
161
|
+
`<table><tbody><tr>${a}</tr></tbody></table>`,
|
|
178
162
|
"text/html"
|
|
179
163
|
).querySelector("td");
|
|
180
|
-
if (
|
|
181
|
-
const f =
|
|
182
|
-
|
|
183
|
-
const u =
|
|
184
|
-
u && u.remove(),
|
|
164
|
+
if (l && i.parentNode) {
|
|
165
|
+
const f = M(e.configBlockAttributes);
|
|
166
|
+
l.setAttribute("esd-ext-config", JSON.stringify(f));
|
|
167
|
+
const u = l.querySelector("esd-config-block");
|
|
168
|
+
u && u.remove(), i.parentNode.replaceChild(l, i);
|
|
185
169
|
}
|
|
186
|
-
}),
|
|
187
|
-
} catch (
|
|
188
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
170
|
+
}), c.documentElement.outerHTML);
|
|
171
|
+
} catch (r) {
|
|
172
|
+
return console.error("ItemsBlockMigrator failed:", r), t;
|
|
189
173
|
}
|
|
190
174
|
}
|
|
191
175
|
/**
|
|
@@ -196,23 +180,23 @@ class V {
|
|
|
196
180
|
*/
|
|
197
181
|
extractConfiguration(t) {
|
|
198
182
|
var C, D, P;
|
|
199
|
-
const
|
|
183
|
+
const r = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", n = parseInt(c) - 1, i = E[r], e = ((P = i == null ? void 0 : i[n]) == null ? void 0 : P.value) || i[0].value, a = t.querySelector('[product-attr="price"]'), d = (a == null ? void 0 : a.getAttribute("data-currency_symbol")) || "USD", f = ((a == null ? void 0 : a.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", u = (a == null ? void 0 : a.getAttribute("data-formated")) !== "false", s = this.extractConfigBlockAttributes(t, r), b = s["data-card_orientation_control_value"];
|
|
200
184
|
let S;
|
|
201
185
|
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,
|
|
186
|
+
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 = (a == null ? void 0 : a.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), k = (A == null ? void 0 : A.getAttribute("style")) || void 0, I = t.querySelector('[product-attr="quantity"]'), v = (I == null ? void 0 : I.getAttribute("style")) || void 0;
|
|
203
187
|
return {
|
|
204
188
|
orientation: S,
|
|
205
|
-
itemsType:
|
|
206
|
-
itemId:
|
|
207
|
-
currencySymbol:
|
|
189
|
+
itemsType: r,
|
|
190
|
+
itemId: e,
|
|
191
|
+
currencySymbol: d,
|
|
208
192
|
currencyLocation: f,
|
|
209
193
|
formattedPrice: u,
|
|
210
194
|
configBlockAttributes: s,
|
|
211
195
|
nameStyles: T,
|
|
212
196
|
buttonStyles: m,
|
|
213
|
-
priceStyles:
|
|
214
|
-
originalPriceStyles:
|
|
215
|
-
quantityStyles:
|
|
197
|
+
priceStyles: h,
|
|
198
|
+
originalPriceStyles: k,
|
|
199
|
+
quantityStyles: v
|
|
216
200
|
};
|
|
217
201
|
}
|
|
218
202
|
/**
|
|
@@ -220,29 +204,28 @@ class V {
|
|
|
220
204
|
* Returns a key-value mapping of all configuration attributes
|
|
221
205
|
* @param block - The block element containing the esd-config-block
|
|
222
206
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
223
|
-
* @param itemNumber - The item number (1-based index)
|
|
224
207
|
*/
|
|
225
|
-
extractConfigBlockAttributes(t,
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
208
|
+
extractConfigBlockAttributes(t, r) {
|
|
209
|
+
const c = t.querySelector("esd-config-block"), n = {};
|
|
210
|
+
if (!c)
|
|
228
211
|
return this.getDefaultConfigBlockAttributes();
|
|
229
|
-
if (Array.from(
|
|
230
|
-
|
|
212
|
+
if (Array.from(c.attributes).forEach((e) => {
|
|
213
|
+
e.name.startsWith("data-") && (n[e.name] = e.value);
|
|
231
214
|
}), n["data-cart_items_select_control_value"]) {
|
|
232
|
-
const
|
|
233
|
-
if (/^\d+$/.test(
|
|
234
|
-
const
|
|
235
|
-
|
|
215
|
+
const e = n["data-cart_items_select_control_value"];
|
|
216
|
+
if (/^\d+$/.test(e)) {
|
|
217
|
+
const a = parseInt(e) - 1, d = E[r];
|
|
218
|
+
d && d[a] && (n["data-cart_items_select_control_value"] = d[a].value);
|
|
236
219
|
}
|
|
237
220
|
}
|
|
238
221
|
if (n["data-product_price_control_curency"]) {
|
|
239
|
-
const
|
|
240
|
-
let
|
|
241
|
-
|
|
222
|
+
const e = n["data-product_price_control_curency"];
|
|
223
|
+
let a = e;
|
|
224
|
+
e === "before" ? a = "0" : e === "after" && (a = "1"), n["data-product_price_control_curency"] = a, n["data-product_price_currency_location"] = a;
|
|
242
225
|
}
|
|
243
|
-
(!n["data-
|
|
244
|
-
const
|
|
245
|
-
return
|
|
226
|
+
(!n["data-product_price_currency_symbol"] || n["data-product_price_currency_symbol"].trim() === "") && (n["data-product_price_currency_symbol"] = "USD");
|
|
227
|
+
const i = { ...this.getDefaultConfigBlockAttributes(), ...n };
|
|
228
|
+
return i["data-type"] = r, i["data-source"] = r, i;
|
|
246
229
|
}
|
|
247
230
|
/**
|
|
248
231
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -271,7 +254,7 @@ class V {
|
|
|
271
254
|
"data-product_price_control_color": "#060606",
|
|
272
255
|
"data-product_price_control_curency": "0",
|
|
273
256
|
"data-product_price_currency_location": "0",
|
|
274
|
-
"data-
|
|
257
|
+
"data-product_price_currency_symbol": "USD",
|
|
275
258
|
"data-product_price_control_formated": "1",
|
|
276
259
|
"data-product_price_control_nodup": "1",
|
|
277
260
|
"data-product_price_control_single_price": "false",
|
|
@@ -299,16 +282,16 @@ class V {
|
|
|
299
282
|
* - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
|
|
300
283
|
*/
|
|
301
284
|
removeJinjaConditionals(t) {
|
|
302
|
-
let
|
|
285
|
+
let r = t.replace(
|
|
303
286
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
304
287
|
""
|
|
305
288
|
);
|
|
306
|
-
return
|
|
289
|
+
return r = r.replace(
|
|
307
290
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
308
291
|
""
|
|
309
|
-
),
|
|
292
|
+
), r = r.replace(/\{%\s*endif\s*%\}/g, ""), r = r.replace(/\n\s*\n\s*\n/g, `
|
|
310
293
|
|
|
311
|
-
`),
|
|
294
|
+
`), r;
|
|
312
295
|
}
|
|
313
296
|
/**
|
|
314
297
|
* Replaces template variables with default values from productPairs
|
|
@@ -320,32 +303,32 @@ class V {
|
|
|
320
303
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
321
304
|
*/
|
|
322
305
|
replaceTemplateVariables(t) {
|
|
323
|
-
const { PAIRS_FOR_EXTENSION:
|
|
324
|
-
return t.replace(/{{([^}]+)}}/g, (
|
|
325
|
-
const
|
|
326
|
-
if (!
|
|
327
|
-
return
|
|
328
|
-
const [,
|
|
329
|
-
if (!
|
|
330
|
-
return console.warn(`Unknown variable prefix: ${
|
|
331
|
-
const f = w[
|
|
306
|
+
const { PAIRS_FOR_EXTENSION: r } = B;
|
|
307
|
+
return t.replace(/{{([^}]+)}}/g, (c, n) => {
|
|
308
|
+
const i = n.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
309
|
+
if (!i)
|
|
310
|
+
return c;
|
|
311
|
+
const [, e, a, d] = i, l = x[e];
|
|
312
|
+
if (!l)
|
|
313
|
+
return console.warn(`Unknown variable prefix: ${e}`), c;
|
|
314
|
+
const f = w[a];
|
|
332
315
|
if (!f)
|
|
333
|
-
return console.warn(`Unknown variable suffix mapping for: ${
|
|
334
|
-
const { pairsKey: u, defaultKey: s, isArray: b } = f, p =
|
|
316
|
+
return console.warn(`Unknown variable suffix mapping for: ${a}`), c;
|
|
317
|
+
const { pairsKey: u, defaultKey: s, isArray: b } = f, p = r[u][l];
|
|
335
318
|
if (!p)
|
|
336
|
-
return console.warn(`No data found for: ${u}.${
|
|
319
|
+
return console.warn(`No data found for: ${u}.${l}`), c;
|
|
337
320
|
if (b) {
|
|
338
|
-
const y = parseInt(
|
|
339
|
-
return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${u}.${
|
|
321
|
+
const y = parseInt(d) - 1, m = p[s];
|
|
322
|
+
return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${u}.${l}.${s}[${y}]`), c);
|
|
340
323
|
}
|
|
341
324
|
const T = p[s];
|
|
342
|
-
return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${
|
|
325
|
+
return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${l}.${s}`), c);
|
|
343
326
|
});
|
|
344
327
|
}
|
|
345
328
|
}
|
|
346
|
-
function
|
|
347
|
-
return new
|
|
329
|
+
function Y(o) {
|
|
330
|
+
return new N().migrate(o);
|
|
348
331
|
}
|
|
349
332
|
export {
|
|
350
|
-
|
|
333
|
+
Y as migrateItemsBlock
|
|
351
334
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { useOnboardingStore as
|
|
2
|
-
import { Block as
|
|
3
|
-
import { SETTINGS_ENUMS as c, DefaultConfigValues as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { useOnboardingStore as m } from "../../../stores/onboarding.js";
|
|
2
|
+
import { Block as u, BlockCompositionType as d, ModificationDescription as i } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
3
|
+
import { SETTINGS_ENUMS as c, DefaultConfigValues as o } from "./enums/settingsEnums.js";
|
|
4
|
+
import { useItemsBlockStore as p } from "./store/items-block.js";
|
|
5
|
+
import { getDefaultTemplate as f } from "./template.js";
|
|
6
|
+
import { getItemsBlockContainer as g, getItemsBlockConfig as a, getDefaultItemsBlockConfig as C } from "./utils/nodeConfigUtils.js";
|
|
6
7
|
const y = "items-block";
|
|
7
|
-
class B extends
|
|
8
|
+
class B extends u {
|
|
8
9
|
getId() {
|
|
9
10
|
return y;
|
|
10
11
|
}
|
|
@@ -12,7 +13,7 @@ class B extends g {
|
|
|
12
13
|
return "items-icon";
|
|
13
14
|
}
|
|
14
15
|
getBlockCompositionType() {
|
|
15
|
-
return
|
|
16
|
+
return d.CONTAINER;
|
|
16
17
|
}
|
|
17
18
|
getName() {
|
|
18
19
|
return this.api.translate("Items");
|
|
@@ -21,32 +22,40 @@ class B extends g {
|
|
|
21
22
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
22
23
|
}
|
|
23
24
|
getTemplate() {
|
|
24
|
-
return
|
|
25
|
+
return f({
|
|
25
26
|
orientation: c.ORIENTATION.VERTICAL,
|
|
26
27
|
itemsType: c.ITEMS_TYPE.CART_ITEMS,
|
|
27
28
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
28
|
-
currencySymbol:
|
|
29
|
-
currencyLocation:
|
|
30
|
-
formattedPrice:
|
|
29
|
+
currencySymbol: o.productPriceCurrencySymbolControlValue,
|
|
30
|
+
currencyLocation: o.productPriceCurrencyLocationControlValue,
|
|
31
|
+
formattedPrice: o.productPriceFormattedControlValue === "1"
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
allowInnerBlocksDND() {
|
|
34
35
|
return !1;
|
|
35
36
|
}
|
|
36
37
|
onCreated(n) {
|
|
37
|
-
const
|
|
38
|
-
r.querySelector('[product-attr="imageSrc"] img') || s.modifyCss(r).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
39
|
-
const e = u(n);
|
|
38
|
+
const e = g(n);
|
|
40
39
|
if (!e)
|
|
41
40
|
return;
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
l ?
|
|
41
|
+
const t = e.getNodeConfig(), l = t && Object.keys(t).length > 0, r = a(n);
|
|
42
|
+
if (r != null && r.initialized)
|
|
43
|
+
l ? r.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...r, blockInstanceId: String(Date.now()) }).apply(new i("Assign block instance ID to block")) : this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(r).apply(new i("Migrate legacy config to nodeConfig"));
|
|
45
44
|
else {
|
|
46
|
-
const
|
|
47
|
-
this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(
|
|
45
|
+
const s = C();
|
|
46
|
+
this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(s).apply(new i("Initialize Items block with default configuration")), m().startOnboarding("itemsOnboarding");
|
|
48
47
|
}
|
|
49
48
|
}
|
|
49
|
+
onSelect(n) {
|
|
50
|
+
const e = p(), t = a(n);
|
|
51
|
+
t && (e.setItemsType(t.type || o.itemsType), e.setItemIds(t.itemsSelectValue || o.cartItemsSelectControlValue), e.setOrientation(t.orientation || o.cardOrientationControlValue), e.setCurrencySymbol(
|
|
52
|
+
t.priceCurrencySymbol || o.productPriceCurrencySymbolControlValue
|
|
53
|
+
), e.setCurrencyLocation(
|
|
54
|
+
t.priceCurrencyLocation || o.productPriceCurrencyLocationControlValue
|
|
55
|
+
), e.setFormattedPrice(
|
|
56
|
+
t.priceFormatted ?? o.productPriceFormattedControlValue === "1"
|
|
57
|
+
));
|
|
58
|
+
}
|
|
50
59
|
}
|
|
51
60
|
export {
|
|
52
61
|
y as BLOCK_ID,
|
|
@@ -1,40 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var l = (e, t, n) => t in e ? a(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var i = (e, t, n) => l(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { CommonControl as u } from "../../../common-control.js";
|
|
5
|
+
import { ItemsBlockControlId as d } from "../../enums/controlEnums.js";
|
|
6
|
+
import { useItemsBlockStore as m } from "../../store/items-block.js";
|
|
7
|
+
import { getItemsBlockConfig as L } from "../../utils/nodeConfigUtils.js";
|
|
8
|
+
const r = d.BUTTON_LINK, s = {
|
|
5
9
|
LINK: "link"
|
|
6
10
|
};
|
|
7
|
-
class
|
|
11
|
+
class N extends u {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
i(this, "store", m());
|
|
15
|
+
}
|
|
8
16
|
getId() {
|
|
9
|
-
return
|
|
17
|
+
return r;
|
|
10
18
|
}
|
|
11
19
|
getTemplate() {
|
|
12
20
|
return `
|
|
13
|
-
<div class="container ${
|
|
21
|
+
<div class="container ${r}">
|
|
14
22
|
${this._getLink()}
|
|
15
23
|
</div>
|
|
16
24
|
`;
|
|
17
25
|
}
|
|
18
26
|
onRender() {
|
|
19
|
-
const t = o(this.currentNode);
|
|
20
27
|
this.api.updateValues({
|
|
21
|
-
[
|
|
28
|
+
[s.LINK]: this.store.buttonLink
|
|
22
29
|
});
|
|
23
30
|
}
|
|
24
|
-
onTemplateNodeUpdated(
|
|
25
|
-
super.onTemplateNodeUpdated(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
+
onTemplateNodeUpdated(n) {
|
|
32
|
+
super.onTemplateNodeUpdated(n), this.handleBlockInstanceChange(
|
|
33
|
+
() => {
|
|
34
|
+
const o = L(this.currentNode);
|
|
35
|
+
o != null && o.buttonLink && this.store.setButtonLink(o.buttonLink);
|
|
36
|
+
},
|
|
37
|
+
() => {
|
|
38
|
+
this.api.updateValues({
|
|
39
|
+
[s.LINK]: this.store.buttonLink
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
);
|
|
31
43
|
}
|
|
32
44
|
_getLink() {
|
|
33
45
|
return `
|
|
34
46
|
${this._GuOneColumn([
|
|
35
47
|
this._GuLabel({ text: "Link" }),
|
|
36
48
|
this._GuTextInput({
|
|
37
|
-
name:
|
|
49
|
+
name: s.LINK,
|
|
38
50
|
placeholder: "Enter Link",
|
|
39
51
|
className: "es-100",
|
|
40
52
|
disabled: !0
|
|
@@ -44,6 +56,6 @@ class m extends r {
|
|
|
44
56
|
}
|
|
45
57
|
}
|
|
46
58
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
N as ButtonLinkControl,
|
|
60
|
+
r as CONTROL_BLOCK_ID
|
|
49
61
|
};
|