@useinsider/guido 3.9.0-beta.1a5491e → 3.9.0-beta.3476244
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/compiler/utils/recommendationCompilerUtils.js +118 -88
- package/dist/config/migrator/itemsBlockMigrator.js +114 -159
- package/dist/extensions/Blocks/Items/block.js +37 -57
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +78 -67
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +9 -13
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +14 -26
- package/dist/extensions/Blocks/Items/template.js +247 -245
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +45 -53
- package/dist/src/extensions/Blocks/Items/block.d.ts +0 -9
- package/dist/src/extensions/Blocks/Items/template.d.ts +0 -7
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +0 -12
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var M = (
|
|
4
|
-
import { BLOCK_ID as
|
|
1
|
+
var B = Object.defineProperty;
|
|
2
|
+
var v = (r, t, o) => t in r ? B(r, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[t] = o;
|
|
3
|
+
var M = (r, t, o) => v(r, typeof t != "symbol" ? t + "" : t, o);
|
|
4
|
+
import { BLOCK_ID as U } from "../../extensions/Blocks/Items/block.js";
|
|
5
5
|
import { productPairs as K } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
-
import { ItemInCartOptions as
|
|
7
|
-
import { getDefaultTemplate as
|
|
8
|
-
import { useTemplateStore as
|
|
9
|
-
const
|
|
6
|
+
import { ItemInCartOptions as T, DefaultConfigValues as g, SETTINGS_ENUMS as s } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
7
|
+
import { getDefaultTemplate as w } from "../../extensions/Blocks/Items/template.js";
|
|
8
|
+
import { useTemplateStore as F } from "../../stores/template.js";
|
|
9
|
+
const q = {
|
|
10
10
|
img: {
|
|
11
11
|
pairsKey: "imageSrc",
|
|
12
12
|
defaultKey: "DEFAULT",
|
|
@@ -76,77 +76,77 @@ const x = {
|
|
|
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) {
|
|
80
|
+
return r ? {
|
|
81
|
+
CartItems: s.ITEMS_TYPE.CART_ITEMS,
|
|
82
|
+
BrowsedItems: s.ITEMS_TYPE.BROWSED_ITEMS,
|
|
83
|
+
PurchasedItems: s.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
84
|
+
CART_ITEMS: s.ITEMS_TYPE.CART_ITEMS,
|
|
85
|
+
BROWSED_ITEMS: s.ITEMS_TYPE.BROWSED_ITEMS,
|
|
86
|
+
PURCHASED_ITEMS: s.ITEMS_TYPE.PURCHASED_ITEMS
|
|
87
|
+
}[r] || s.ITEMS_TYPE.CART_ITEMS : s.ITEMS_TYPE.CART_ITEMS;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function R(r) {
|
|
90
90
|
var e;
|
|
91
|
-
const t = (c,
|
|
92
|
-
let
|
|
93
|
-
if (
|
|
94
|
-
const c = parseInt(
|
|
95
|
-
|
|
91
|
+
const t = (c, _) => c == null ? _ : c === "1" || c === "true", o = (c, _) => c || _, l = r["data-type"] || r["data-source"], a = $(l), n = T[a];
|
|
92
|
+
let i = r["data-cart_items_select_control_value"] || ((e = n == null ? void 0 : n[0]) == null ? void 0 : e.value) || g.cartItemsSelectControlValue;
|
|
93
|
+
if (i && !i.includes("{{") && /^\d+$/.test(i)) {
|
|
94
|
+
const c = parseInt(i) - 1, _ = T[a];
|
|
95
|
+
_ && _[c] && (i = _[c].value);
|
|
96
96
|
}
|
|
97
97
|
return {
|
|
98
98
|
initialized: !0,
|
|
99
|
-
blockInstanceId: r
|
|
99
|
+
blockInstanceId: o(r["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: i,
|
|
103
|
+
orientation: r["data-card_orientation_control_value"] || s.ORIENTATION.VERTICAL,
|
|
104
|
+
nameTrimming: t(r["data-product_name_control_trim"], !0),
|
|
105
|
+
priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
|
|
106
|
+
priceFormatted: t(r["data-product_price_control_formated"], !0),
|
|
107
|
+
priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
|
|
108
|
+
priceCurrencySymbol: o(
|
|
109
|
+
r["data-product_price_control_currency_symbol"],
|
|
110
110
|
g.productPriceCurrencySymbolControlValue
|
|
111
111
|
),
|
|
112
|
-
priceCurrencyLocation:
|
|
113
|
-
|
|
112
|
+
priceCurrencyLocation: o(
|
|
113
|
+
r["data-product_price_currency_location"],
|
|
114
114
|
g.productPriceCurrencyLocationControlValue
|
|
115
115
|
),
|
|
116
|
-
priceOrientation:
|
|
117
|
-
quantityControlEnabled: t(
|
|
118
|
-
buttonLink: r
|
|
119
|
-
imageLink: r
|
|
120
|
-
buttonLabel: r
|
|
121
|
-
buttonFullWidth: t(
|
|
122
|
-
imageVisible: t(
|
|
123
|
-
nameVisible: t(
|
|
124
|
-
quantityVisible: t(
|
|
125
|
-
priceVisible: t(
|
|
126
|
-
originalPriceVisible: t(
|
|
127
|
-
buttonVisible: t(
|
|
116
|
+
priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
|
|
117
|
+
quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
|
|
118
|
+
buttonLink: o(r["data-product_button_link"], g.productButtonLinkControlValue),
|
|
119
|
+
imageLink: o(r["data-product_image_link"], g.productImageLinkControlValue),
|
|
120
|
+
buttonLabel: o(r["data-product_button_control_label"], "Buy"),
|
|
121
|
+
buttonFullWidth: t(r["data-product_button_control_atw"], !0),
|
|
122
|
+
imageVisible: t(r["data-product_image_control_enabled"], !0),
|
|
123
|
+
nameVisible: t(r["data-product_name_control_enabled"], !0),
|
|
124
|
+
quantityVisible: t(r["data-product_quantity_control_enabled"], !0),
|
|
125
|
+
priceVisible: t(r["data-product_price_control_enabled"], !0),
|
|
126
|
+
originalPriceVisible: t(r["data-product_original_price_control_enabled"], !0),
|
|
127
|
+
buttonVisible: t(r["data-product_button_control_enabled"], !0)
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
const
|
|
130
|
+
const x = {
|
|
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 V(r, t) {
|
|
136
|
+
const o = {
|
|
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 r
|
|
141
|
+
return o[r] || o.CART_ITEMS;
|
|
142
142
|
}
|
|
143
|
-
function N(
|
|
144
|
-
const
|
|
143
|
+
function N(r, t) {
|
|
144
|
+
const o = {
|
|
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 r
|
|
149
|
+
return o[r] || o.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
|
|
160
|
-
let
|
|
161
|
-
|
|
162
|
-
const l = this.parser.parseFromString(
|
|
159
|
+
return t;
|
|
160
|
+
let o = this.removeJinjaConditionals(t);
|
|
161
|
+
o = this.replaceTemplateVariables(o);
|
|
162
|
+
const l = this.parser.parseFromString(o, "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 F().$patch((i) => {
|
|
166
|
+
i.migrations = { ...i.migrations, [U]: a.length };
|
|
167
|
+
}), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), o) : (a.forEach((i) => {
|
|
168
|
+
const e = this.extractConfiguration(i), c = w({
|
|
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: R(e.configBlockAttributes)
|
|
183
|
+
}), u = 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 (u && i.parentNode) {
|
|
188
|
+
const p = R(e.configBlockAttributes);
|
|
189
|
+
u.setAttribute("esd-ext-config", JSON.stringify(p));
|
|
190
|
+
const d = u.querySelector("esd-config-block");
|
|
191
|
+
d && d.remove(), i.parentNode.replaceChild(u, i);
|
|
192
192
|
}
|
|
193
193
|
}), l.documentElement.outerHTML);
|
|
194
|
-
} catch (
|
|
195
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
194
|
+
} catch (o) {
|
|
195
|
+
return console.error("ItemsBlockMigrator failed:", o), t;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
@@ -203,25 +203,23 @@ class z {
|
|
|
203
203
|
*/
|
|
204
204
|
extractConfiguration(t) {
|
|
205
205
|
var C, D, P;
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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, R = (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;
|
|
206
|
+
const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", u = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, o, l), S = d["data-card_orientation_control_value"];
|
|
207
|
+
let b;
|
|
208
|
+
S ? b = S === "horizontal" ? "horizontal" : "vertical" : b = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
209
|
+
const y = t.querySelector('a[product-attr="name"]'), I = (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, k = (e == null ? void 0 : e.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), h = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0;
|
|
212
210
|
return {
|
|
213
|
-
orientation:
|
|
214
|
-
itemsType:
|
|
215
|
-
itemId:
|
|
211
|
+
orientation: b,
|
|
212
|
+
itemsType: o,
|
|
213
|
+
itemId: i,
|
|
216
214
|
currencySymbol: c,
|
|
217
|
-
currencyLocation:
|
|
218
|
-
formattedPrice:
|
|
215
|
+
currencyLocation: u,
|
|
216
|
+
formattedPrice: p,
|
|
219
217
|
configBlockAttributes: d,
|
|
220
|
-
nameStyles:
|
|
218
|
+
nameStyles: I,
|
|
221
219
|
buttonStyles: m,
|
|
222
|
-
priceStyles:
|
|
223
|
-
originalPriceStyles:
|
|
224
|
-
quantityStyles:
|
|
220
|
+
priceStyles: k,
|
|
221
|
+
originalPriceStyles: h,
|
|
222
|
+
quantityStyles: L
|
|
225
223
|
};
|
|
226
224
|
}
|
|
227
225
|
/**
|
|
@@ -231,27 +229,27 @@ class z {
|
|
|
231
229
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
232
230
|
* @param itemNumber - The item number (1-based index)
|
|
233
231
|
*/
|
|
234
|
-
extractConfigBlockAttributes(t,
|
|
235
|
-
const a = t.querySelector("esd-config-block"),
|
|
232
|
+
extractConfigBlockAttributes(t, o, l) {
|
|
233
|
+
const a = t.querySelector("esd-config-block"), n = {};
|
|
236
234
|
if (!a)
|
|
237
235
|
return this.getDefaultConfigBlockAttributes();
|
|
238
236
|
if (Array.from(a.attributes).forEach((e) => {
|
|
239
|
-
e.name.startsWith("data-") && (
|
|
240
|
-
}),
|
|
241
|
-
const e =
|
|
237
|
+
e.name.startsWith("data-") && (n[e.name] = e.value);
|
|
238
|
+
}), n["data-cart_items_select_control_value"]) {
|
|
239
|
+
const e = n["data-cart_items_select_control_value"];
|
|
242
240
|
if (/^\d+$/.test(e)) {
|
|
243
|
-
const c = parseInt(e) - 1,
|
|
244
|
-
|
|
241
|
+
const c = parseInt(e) - 1, _ = T[o];
|
|
242
|
+
_ && _[c] && (n["data-cart_items_select_control_value"] = _[c].value);
|
|
245
243
|
}
|
|
246
244
|
}
|
|
247
|
-
if (
|
|
248
|
-
const e =
|
|
245
|
+
if (n["data-product_price_control_curency"]) {
|
|
246
|
+
const e = n["data-product_price_control_curency"];
|
|
249
247
|
let c = e;
|
|
250
|
-
e === "before" ? c = "0" : e === "after" && (c = "1"),
|
|
248
|
+
e === "before" ? c = "0" : e === "after" && (c = "1"), n["data-product_price_control_curency"] = c, n["data-product_price_currency_location"] = c;
|
|
251
249
|
}
|
|
252
|
-
(!
|
|
253
|
-
const
|
|
254
|
-
return
|
|
250
|
+
(!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
|
|
251
|
+
const i = { ...this.getDefaultConfigBlockAttributes(), ...n };
|
|
252
|
+
return i["data-type"] = o, i["data-source"] = o, i["data-product_image_link"] = V(o, l), i["data-product_button_link"] = N(o, l), i;
|
|
255
253
|
}
|
|
256
254
|
/**
|
|
257
255
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -300,49 +298,6 @@ class z {
|
|
|
300
298
|
"data-product_button_link": "{{Abandoned Cart Item (1) Url}}"
|
|
301
299
|
};
|
|
302
300
|
}
|
|
303
|
-
/**
|
|
304
|
-
* Backfills data-type (and data-number) onto v2 `.ins-product-td` elements
|
|
305
|
-
* from their persisted `esd-ext-config` nodeConfig, and strips the legacy
|
|
306
|
-
* static `width` that older builds baked onto the product-td.
|
|
307
|
-
*
|
|
308
|
-
* Why (data-type): templates migrated and saved by an older build can carry the
|
|
309
|
-
* correct product type in `esd-ext-config` while the `.ins-product-td` is missing
|
|
310
|
-
* the `data-type` DOM attribute. Stripo strips `esd-*` attributes during compile,
|
|
311
|
-
* so by save time only `data-type` survives for `pairProductVariables` to read
|
|
312
|
-
* when choosing the merge-tag namespace. Restoring it here (at load, before the
|
|
313
|
-
* editor compiles) makes the namespace resolve to the real source
|
|
314
|
-
* (browsed_item_ / purchased_item_) instead of defaulting to ins_apr_ (Cart).
|
|
315
|
-
*
|
|
316
|
-
* Why (width): the migrate output used to hardcode `width="560"` on the product-td,
|
|
317
|
-
* which made the block overflow narrow (33%/50%) columns and wrap. The generator
|
|
318
|
-
* no longer emits it; here we heal already-saved templates by removing it so the
|
|
319
|
-
* cell inherits its column width. width="560" was only ever written alongside
|
|
320
|
-
* esd-ext-config, so the guard below still catches every affected template.
|
|
321
|
-
*
|
|
322
|
-
* Only re-serializes when something actually changed, so healthy templates
|
|
323
|
-
* (data-type present, no static width) pass through byte-for-byte.
|
|
324
|
-
*/
|
|
325
|
-
backfillV2ProductTdAttributes(t) {
|
|
326
|
-
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
327
|
-
return t;
|
|
328
|
-
const r = this.parser.parseFromString(t, "text/html");
|
|
329
|
-
let l = !1;
|
|
330
|
-
return r.querySelectorAll(".ins-product-td").forEach((a) => {
|
|
331
|
-
if (a.hasAttribute("width") && (a.removeAttribute("width"), l = !0), a.getAttribute("data-type"))
|
|
332
|
-
return;
|
|
333
|
-
const i = a.getAttribute("esd-ext-config");
|
|
334
|
-
if (i)
|
|
335
|
-
try {
|
|
336
|
-
const n = JSON.parse(i), e = n.type || n.source;
|
|
337
|
-
if (!e)
|
|
338
|
-
return;
|
|
339
|
-
a.setAttribute("data-type", e), l = !0;
|
|
340
|
-
const c = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
|
|
341
|
-
c && a.getAttribute("data-number") !== c[1] && a.setAttribute("data-number", c[1]);
|
|
342
|
-
} catch {
|
|
343
|
-
}
|
|
344
|
-
}), l ? r.documentElement.outerHTML : t;
|
|
345
|
-
}
|
|
346
301
|
/**
|
|
347
302
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
348
303
|
* in the raw HTML. Used to gate the migration pipeline so non-items templates
|
|
@@ -362,15 +317,15 @@ class z {
|
|
|
362
317
|
* contains display condition Jinja scripts that should NOT be removed.
|
|
363
318
|
*/
|
|
364
319
|
removeJinjaConditionals(t) {
|
|
365
|
-
const
|
|
366
|
-
let a = l ? t.replace(l[0],
|
|
320
|
+
const o = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", l = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
321
|
+
let a = l ? t.replace(l[0], o) : t;
|
|
367
322
|
return a = a.replace(
|
|
368
323
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
369
324
|
""
|
|
370
325
|
), a = a.replace(
|
|
371
326
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
372
327
|
""
|
|
373
|
-
), a = a.replace(/\{%\s*endif\s*%\}/g, ""), l && (a = a.replace(
|
|
328
|
+
), a = a.replace(/\{%\s*endif\s*%\}/g, ""), l && (a = a.replace(o, l[0])), a = a.replace(/\n\s*\n\s*\n/g, `
|
|
374
329
|
|
|
375
330
|
`), a;
|
|
376
331
|
}
|
|
@@ -384,31 +339,31 @@ class z {
|
|
|
384
339
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
385
340
|
*/
|
|
386
341
|
replaceTemplateVariables(t) {
|
|
387
|
-
const { PAIRS_FOR_EXTENSION:
|
|
342
|
+
const { PAIRS_FOR_EXTENSION: o } = K;
|
|
388
343
|
return t.replace(/{{([^}]+)}}/g, (l, a) => {
|
|
389
|
-
const
|
|
390
|
-
if (!
|
|
344
|
+
const n = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
345
|
+
if (!n)
|
|
391
346
|
return l;
|
|
392
|
-
const [,
|
|
347
|
+
const [, i, e, c] = n, _ = x[i];
|
|
348
|
+
if (!_)
|
|
349
|
+
return console.warn(`Unknown variable prefix: ${i}`), l;
|
|
350
|
+
const u = q[e];
|
|
393
351
|
if (!u)
|
|
394
|
-
return console.warn(`Unknown variable prefix: ${n}`), l;
|
|
395
|
-
const s = x[e];
|
|
396
|
-
if (!s)
|
|
397
352
|
return console.warn(`Unknown variable suffix mapping for: ${e}`), l;
|
|
398
|
-
const { pairsKey:
|
|
353
|
+
const { pairsKey: p, defaultKey: d, isArray: S } = u, y = o[p][_];
|
|
399
354
|
if (!y)
|
|
400
|
-
return console.warn(`No data found for: ${
|
|
401
|
-
if (
|
|
355
|
+
return console.warn(`No data found for: ${p}.${_}`), l;
|
|
356
|
+
if (S) {
|
|
402
357
|
const f = parseInt(c) - 1, m = y[d];
|
|
403
|
-
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${
|
|
358
|
+
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${d}[${f}]`), l);
|
|
404
359
|
}
|
|
405
|
-
const
|
|
406
|
-
return
|
|
360
|
+
const I = y[d];
|
|
361
|
+
return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${d}`), l);
|
|
407
362
|
});
|
|
408
363
|
}
|
|
409
364
|
}
|
|
410
|
-
function Q(
|
|
411
|
-
return new z().migrate(
|
|
365
|
+
function Q(r) {
|
|
366
|
+
return new z().migrate(r);
|
|
412
367
|
}
|
|
413
368
|
export {
|
|
414
369
|
Q as migrateItemsBlock
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { BlockId as
|
|
1
|
+
import { BlockId as u } from "../../../enums/block.js";
|
|
2
2
|
import { useOnboardingStore as p } from "../../../stores/onboarding.js";
|
|
3
|
-
import { getMigrationBannerHtml as
|
|
4
|
-
import { Block as I, BlockCompositionType as
|
|
5
|
-
import { SETTINGS_ENUMS as
|
|
6
|
-
import { getDefaultTemplate as
|
|
7
|
-
import { getItemsBlockContainer as
|
|
8
|
-
const
|
|
9
|
-
class
|
|
3
|
+
import { getMigrationBannerHtml as C } from "../../../utils/migrationBannerHtml.js";
|
|
4
|
+
import { Block as I, BlockCompositionType as y, ModificationDescription as s } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { SETTINGS_ENUMS as c, DefaultConfigValues as a } from "./enums/settingsEnums.js";
|
|
6
|
+
import { getDefaultTemplate as h } from "./template.js";
|
|
7
|
+
import { getItemsBlockContainer as l, getItemsBlockConfig as m, getDefaultItemsBlockConfig as b } from "./utils/nodeConfigUtils.js";
|
|
8
|
+
const d = u.Items;
|
|
9
|
+
class E extends I {
|
|
10
10
|
getId() {
|
|
11
|
-
return
|
|
11
|
+
return d;
|
|
12
12
|
}
|
|
13
13
|
getIcon() {
|
|
14
14
|
return "items-icon";
|
|
15
15
|
}
|
|
16
16
|
getBlockCompositionType() {
|
|
17
|
-
return
|
|
17
|
+
return y.CONTAINER;
|
|
18
18
|
}
|
|
19
19
|
getName() {
|
|
20
20
|
return this.api.translate("Items");
|
|
@@ -23,20 +23,20 @@ class P 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 C(
|
|
27
|
+
d,
|
|
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 h({
|
|
34
|
+
orientation: c.ORIENTATION.VERTICAL,
|
|
35
|
+
itemsType: c.ITEMS_TYPE.CART_ITEMS,
|
|
36
36
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
37
|
-
currencySymbol:
|
|
38
|
-
currencyLocation:
|
|
39
|
-
formattedPrice:
|
|
37
|
+
currencySymbol: a.productPriceCurrencySymbolControlValue,
|
|
38
|
+
currencyLocation: a.productPriceCurrencyLocationControlValue,
|
|
39
|
+
formattedPrice: a.productPriceFormattedControlValue === "1"
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
allowInnerBlocksDND() {
|
|
@@ -45,23 +45,18 @@ class P extends I {
|
|
|
45
45
|
canBeSavedAsModule() {
|
|
46
46
|
return !0;
|
|
47
47
|
}
|
|
48
|
-
onCreated(
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
48
|
+
onCreated(i) {
|
|
49
|
+
const n = this.api.getDocumentModifier(), r = this.api.getDocumentRootCssNode();
|
|
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)
|
|
53
53
|
return;
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
n.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...n, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
|
|
58
|
-
else {
|
|
59
|
-
const a = this.api.getDocumentModifier();
|
|
60
|
-
a.modifyHtml(e).setNodeConfig(n), this._stampProductTdDomAttributes(e, n, a), a.apply(new c("Migrate legacy config to nodeConfig"));
|
|
61
|
-
}
|
|
54
|
+
const e = t.getNodeConfig(), g = e && Object.keys(e).length > 0, o = m(i);
|
|
55
|
+
if (o != null && o.initialized)
|
|
56
|
+
g ? o.blockInstanceId || this.api.getDocumentModifier().modifyHtml(t).setNodeConfig({ ...o, blockInstanceId: String(Date.now()) }).apply(new s("Assign block instance ID to block")) : this.api.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new s("Migrate legacy config to nodeConfig"));
|
|
62
57
|
else {
|
|
63
|
-
const
|
|
64
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
58
|
+
const f = b();
|
|
59
|
+
this.api.getDocumentModifier().modifyHtml(t).setNodeConfig(f).apply(new s("Initialize Items block with default configuration")), p().startOnboarding("itemsOnboarding");
|
|
65
60
|
}
|
|
66
61
|
}
|
|
67
62
|
/**
|
|
@@ -70,33 +65,18 @@ class P extends I {
|
|
|
70
65
|
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
71
66
|
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
72
67
|
*/
|
|
73
|
-
onDocumentChanged(
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
76
|
-
return;
|
|
77
|
-
const i = t.getNodeConfig();
|
|
78
|
-
if (i && Object.keys(i).length > 0)
|
|
68
|
+
onDocumentChanged(i) {
|
|
69
|
+
const n = l(i);
|
|
70
|
+
if (!n)
|
|
79
71
|
return;
|
|
80
|
-
const r =
|
|
81
|
-
if (
|
|
72
|
+
const r = n.getNodeConfig();
|
|
73
|
+
if (r && Object.keys(r).length > 0)
|
|
82
74
|
return;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`) onto the
|
|
88
|
-
* `.ins-product-td` container from the recovered config. Required for saved modules:
|
|
89
|
-
* `migrate()` (which backfills these) only runs at template load — never when a module
|
|
90
|
-
* is dropped into a live editor — so this is the one place the namespace + index get
|
|
91
|
-
* restored before export. The name `<a>` carries no data-type/data-number of its own and
|
|
92
|
-
* relies on this td-level fallback in pairProductVariables.
|
|
93
|
-
*/
|
|
94
|
-
_stampProductTdDomAttributes(o, t, i) {
|
|
95
|
-
const e = h(t.itemsSelectValue, t.type);
|
|
96
|
-
i.modifyHtml(o).setAttribute("data-type", t.type), i.modifyHtml(o).setAttribute("data-number", e);
|
|
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"));
|
|
97
77
|
}
|
|
98
78
|
}
|
|
99
79
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
80
|
+
d as BLOCK_ID,
|
|
81
|
+
E as ItemsBlock
|
|
102
82
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
1
|
+
import { ModificationDescription as s, UIElementType as a, UEAttr as T } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as d } from "../../../common-control.js";
|
|
3
3
|
import { ItemsBlockControlId as l } from "../../enums/controlEnums.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { SETTINGS_ENUMS as h } from "../../enums/settingsEnums.js";
|
|
5
|
+
import { getItemsBlockConfig as r, setItemsBlockConfig as c } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const I = l.NAME_TRIMMING, n = {
|
|
6
7
|
TRIMMING: "trimming"
|
|
7
8
|
};
|
|
8
|
-
class
|
|
9
|
+
class S extends d {
|
|
9
10
|
getId() {
|
|
10
|
-
return
|
|
11
|
+
return I;
|
|
11
12
|
}
|
|
12
13
|
getTemplate() {
|
|
13
14
|
return `
|
|
@@ -17,41 +18,41 @@ class y extends T {
|
|
|
17
18
|
`;
|
|
18
19
|
}
|
|
19
20
|
onRender() {
|
|
20
|
-
const e =
|
|
21
|
-
this.api.updateValues({ [
|
|
21
|
+
const e = r(this.currentNode);
|
|
22
|
+
this.api.updateValues({ [n.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(n.TRIMMING, (t) => {
|
|
22
23
|
this._onTrimmingChange(t);
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
onTemplateNodeUpdated(e) {
|
|
26
27
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
27
|
-
const t =
|
|
28
|
-
this.api.updateValues({ [
|
|
28
|
+
const t = r(this.currentNode);
|
|
29
|
+
this.api.updateValues({ [n.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
_onTrimmingChange(e) {
|
|
32
|
-
c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [
|
|
33
|
+
c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [n.TRIMMING]: e }), this._applyTrimmingStyles(e);
|
|
33
34
|
}
|
|
34
35
|
_applyTrimmingStyles(e) {
|
|
35
36
|
var m;
|
|
36
37
|
const t = (m = this.currentNode) == null ? void 0 : m.querySelector("p > a");
|
|
37
38
|
if (!t)
|
|
38
39
|
return;
|
|
39
|
-
const
|
|
40
|
-
|
|
40
|
+
const i = r(this.currentNode), p = e !== void 0 ? e : (i == null ? void 0 : i.nameTrimming) ?? !0, o = (i == null ? void 0 : i.orientation) === h.ORIENTATION.VERTICAL;
|
|
41
|
+
p ? this.api.getDocumentModifier().modifyHtml(t).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", o ? "130px" : "520px").apply(new s("Text Trimming Enabled")) : this.api.getDocumentModifier().modifyHtml(t).removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow").removeStyle("max-width").setStyle("max-width", o ? "130px" : "520px").apply(new s("Text Trimming Disabled"));
|
|
41
42
|
}
|
|
42
43
|
_getTextTrimming() {
|
|
43
44
|
return `
|
|
44
45
|
<div class="display-flex align-items-center justify-content-between">
|
|
45
46
|
<${a.LABEL}
|
|
46
|
-
${
|
|
47
|
+
${T.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
47
48
|
>
|
|
48
49
|
</${a.LABEL}>
|
|
49
|
-
${this._GuToggle(
|
|
50
|
+
${this._GuToggle(n.TRIMMING)}
|
|
50
51
|
</div>
|
|
51
52
|
`;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
I as CONTROL_BLOCK_ID,
|
|
57
|
+
S as NameTrimmingControl
|
|
57
58
|
};
|