@useinsider/guido 3.8.0 → 3.8.1-beta.0fbf78a
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/composables/useHtmlValidator.js +180 -133
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -69
- package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
- package/dist/config/migrator/itemsBlockMigrator.js +154 -115
- package/dist/config/migrator/recommendation/extractors.js +44 -22
- package/dist/config/migrator/recommendation/htmlBuilder.js +175 -169
- package/dist/config/migrator/recommendationMigrator.js +30 -31
- package/dist/extensions/Blocks/Items/template.js +26 -27
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +22 -15
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +55 -41
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +42 -43
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +48 -45
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +64 -60
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +294 -335
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
- package/dist/extensions/Blocks/Recommendation/extension.js +7 -5
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +4 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -2
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +142 -173
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +56 -29
- package/dist/extensions/Blocks/Recommendation/templates/index.js +30 -8
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +132 -105
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +44 -23
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +112 -64
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +219 -0
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +24 -19
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +30 -22
- package/dist/extensions/Blocks/Unsubscribe/block.js +1 -1
- package/dist/extensions/Blocks/controlFactories.js +159 -133
- package/dist/src/composables/useHtmlValidator.d.ts +27 -0
- package/dist/src/composables/useHtmlValidator.test.d.ts +1 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +23 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +7 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +29 -47
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +165 -11
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +78 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +29 -9
- package/dist/src/extensions/Blocks/controlFactories.d.ts +11 -1
- package/package.json +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
|
@@ -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,27 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { CURRENCY_ATTR as n, CSS_CLASS_SKIP_COMPILE as c } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
const a = "You May Also Like!";
|
|
3
|
+
function l(t) {
|
|
4
|
+
var o;
|
|
5
|
+
const r = t.querySelector(".ext-recommendation-title");
|
|
6
|
+
if (!r)
|
|
7
|
+
return a;
|
|
8
|
+
const e = (o = r.textContent) == null ? void 0 : o.trim();
|
|
9
|
+
return e && e.length > 0 ? e : a;
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
...Array.from(
|
|
11
|
+
function m(t) {
|
|
12
|
+
const r = [
|
|
13
|
+
t,
|
|
14
|
+
...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
14
15
|
];
|
|
15
|
-
let
|
|
16
|
-
return
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
}),
|
|
16
|
+
let e = "";
|
|
17
|
+
return r.some((o) => {
|
|
18
|
+
const i = o.getAttribute("bgcolor");
|
|
19
|
+
if (i && i.trim())
|
|
20
|
+
return e = i.trim(), !0;
|
|
21
|
+
const u = (o.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
|
|
22
|
+
return u && u[1] ? (e = u[1].trim(), !0) : !1;
|
|
23
|
+
}), e;
|
|
24
|
+
}
|
|
25
|
+
function C(t) {
|
|
26
|
+
const r = t.getAttribute(n.CURRENCY);
|
|
27
|
+
if (!r)
|
|
28
|
+
return;
|
|
29
|
+
const e = t.getAttribute(n.SYMBOL);
|
|
30
|
+
return {
|
|
31
|
+
value: r,
|
|
32
|
+
// An empty `currency-symbol` is omitted so `mapCurrency` falls back to
|
|
33
|
+
// the currency code as the symbol.
|
|
34
|
+
...e ? { symbol: e } : {},
|
|
35
|
+
alignment: t.getAttribute(n.ALIGNMENT) ?? "",
|
|
36
|
+
decimalCount: t.getAttribute(n.DECIMAL_COUNT) ?? "",
|
|
37
|
+
decimalSeparator: t.getAttribute(n.DECIMAL_SEPARATOR) ?? "",
|
|
38
|
+
thousandSeparator: t.getAttribute(n.THOUSAND_SEPARATOR) ?? ""
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function d(t) {
|
|
42
|
+
return t.classList.contains(c);
|
|
23
43
|
}
|
|
24
44
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
45
|
+
m as extractCardBgColor,
|
|
46
|
+
C as extractCurrencyFromBlock,
|
|
47
|
+
l as extractTitleText,
|
|
48
|
+
d as isPartnerManagedBlock
|
|
27
49
|
};
|