@useinsider/guido 3.18.1-beta.11789dd → 3.18.1-beta.178a3ec
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 +225 -163
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
- package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
- package/dist/extensions/Blocks/Items/template.js +212 -201
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
- package/dist/utils/pairProductVariables.js +71 -71
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var v = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { BLOCK_ID as
|
|
5
|
-
import { productPairs as
|
|
6
|
-
import { ItemInCartOptions as I, DefaultConfigValues as
|
|
7
|
-
import { getDefaultTemplate as
|
|
8
|
-
import { useTemplateStore as
|
|
2
|
+
var B = (a, t, e) => t in a ? v(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
3
|
+
var P = (a, t, e) => B(a, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { BLOCK_ID as U } from "../../extensions/Blocks/Items/block.js";
|
|
5
|
+
import { productPairs as F } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { ItemInCartOptions as I, DefaultConfigValues as S, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
7
|
+
import { getDefaultTemplate as K } from "../../extensions/Blocks/Items/template.js";
|
|
8
|
+
import { useTemplateStore as O } from "../../stores/template.js";
|
|
9
9
|
const x = {
|
|
10
10
|
img: {
|
|
11
11
|
pairsKey: "imageSrc",
|
|
@@ -73,126 +73,129 @@ const x = {
|
|
|
73
73
|
isArray: !1
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
function
|
|
76
|
+
function $() {
|
|
77
77
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
79
|
+
function R(a) {
|
|
80
|
+
return a ? {
|
|
81
81
|
CartItems: p.ITEMS_TYPE.CART_ITEMS,
|
|
82
82
|
BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
|
|
83
83
|
PurchasedItems: p.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
84
84
|
CART_ITEMS: p.ITEMS_TYPE.CART_ITEMS,
|
|
85
85
|
BROWSED_ITEMS: p.ITEMS_TYPE.BROWSED_ITEMS,
|
|
86
86
|
PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
|
|
87
|
-
}[
|
|
87
|
+
}[a] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
function V(a) {
|
|
90
|
+
return a.classList.contains("esd-browsed-items-block") ? p.ITEMS_TYPE.BROWSED_ITEMS : a.classList.contains("esd-purchased-items-block") ? p.ITEMS_TYPE.PURCHASED_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
|
|
91
|
+
}
|
|
92
|
+
function M(a) {
|
|
93
|
+
var r;
|
|
94
|
+
const t = (s, c) => s == null ? c : s === "1" || s === "true", e = (s, c) => s || c, n = a["data-type"] || a["data-source"], o = R(n), i = I[o];
|
|
95
|
+
let l = a["data-cart_items_select_control_value"] || ((r = i == null ? void 0 : i[0]) == null ? void 0 : r.value) || S.cartItemsSelectControlValue;
|
|
96
|
+
if (l && !l.includes("{{") && /^\d+$/.test(l)) {
|
|
97
|
+
const s = parseInt(l) - 1, c = I[o];
|
|
98
|
+
c && c[s] && (l = c[s].value);
|
|
96
99
|
}
|
|
97
100
|
return {
|
|
98
101
|
initialized: !0,
|
|
99
|
-
blockInstanceId:
|
|
100
|
-
source:
|
|
101
|
-
type:
|
|
102
|
-
itemsSelectValue:
|
|
103
|
-
orientation:
|
|
104
|
-
nameTrimming: t(
|
|
105
|
-
priceHideDiscount: t(
|
|
106
|
-
priceFormatted: t(
|
|
107
|
-
priceSinglePrice: t(
|
|
108
|
-
priceCurrencySymbol:
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
blockInstanceId: e(a["data-block-instance-id"], $()),
|
|
103
|
+
source: o,
|
|
104
|
+
type: o,
|
|
105
|
+
itemsSelectValue: l,
|
|
106
|
+
orientation: a["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
|
|
107
|
+
nameTrimming: t(a["data-product_name_control_trim"], !0),
|
|
108
|
+
priceHideDiscount: t(a["data-product_price_control_nodup"], !0),
|
|
109
|
+
priceFormatted: t(a["data-product_price_control_formated"], !0),
|
|
110
|
+
priceSinglePrice: t(a["data-product_price_control_single_price"], !1),
|
|
111
|
+
priceCurrencySymbol: e(
|
|
112
|
+
a["data-product_price_control_currency_symbol"],
|
|
113
|
+
S.productPriceCurrencySymbolControlValue
|
|
111
114
|
),
|
|
112
|
-
priceCurrencyLocation:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
priceCurrencyLocation: e(
|
|
116
|
+
a["data-product_price_currency_location"],
|
|
117
|
+
S.productPriceCurrencyLocationControlValue
|
|
115
118
|
),
|
|
116
|
-
priceOrientation:
|
|
117
|
-
quantityControlEnabled: t(
|
|
118
|
-
buttonLink:
|
|
119
|
-
imageLink:
|
|
120
|
-
buttonLabel:
|
|
121
|
-
buttonFullWidth: t(
|
|
122
|
-
imageVisible: t(
|
|
123
|
-
nameVisible: t(
|
|
124
|
-
quantityVisible: t(
|
|
125
|
-
priceVisible: t(
|
|
126
|
-
originalPriceVisible: t(
|
|
127
|
-
buttonVisible: t(
|
|
119
|
+
priceOrientation: a["data-product_original_price_control_orientation"] || "horizontal",
|
|
120
|
+
quantityControlEnabled: t(a["data-product_quantity_control_enabled"], !0),
|
|
121
|
+
buttonLink: e(a["data-product_button_link"], S.productButtonLinkControlValue),
|
|
122
|
+
imageLink: e(a["data-product_image_link"], S.productImageLinkControlValue),
|
|
123
|
+
buttonLabel: e(a["data-product_button_control_label"], "Buy"),
|
|
124
|
+
buttonFullWidth: t(a["data-product_button_control_atw"], !0),
|
|
125
|
+
imageVisible: t(a["data-product_image_control_enabled"], !0),
|
|
126
|
+
nameVisible: t(a["data-product_name_control_enabled"], !0),
|
|
127
|
+
quantityVisible: t(a["data-product_quantity_control_enabled"], !0),
|
|
128
|
+
priceVisible: t(a["data-product_price_control_enabled"], !0),
|
|
129
|
+
originalPriceVisible: t(a["data-product_original_price_control_enabled"], !0),
|
|
130
|
+
buttonVisible: t(a["data-product_button_control_enabled"], !0)
|
|
128
131
|
};
|
|
129
132
|
}
|
|
130
|
-
const
|
|
133
|
+
const H = {
|
|
131
134
|
ins_apr: "CART_ITEMS",
|
|
132
135
|
browsed_item: "BROWSED_ITEMS",
|
|
133
136
|
purchased_item: "PURCHASED_ITEMS"
|
|
134
137
|
};
|
|
135
|
-
function
|
|
136
|
-
const
|
|
138
|
+
function N(a, t) {
|
|
139
|
+
const e = {
|
|
137
140
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
138
141
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
139
142
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
140
143
|
};
|
|
141
|
-
return
|
|
144
|
+
return e[a] || e.CART_ITEMS;
|
|
142
145
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
146
|
+
function z(a, t) {
|
|
147
|
+
const e = {
|
|
145
148
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
146
149
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
147
150
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
148
151
|
};
|
|
149
|
-
return
|
|
152
|
+
return e[a] || e.CART_ITEMS;
|
|
150
153
|
}
|
|
151
|
-
class
|
|
154
|
+
class Y {
|
|
152
155
|
constructor() {
|
|
153
|
-
|
|
156
|
+
P(this, "parser");
|
|
154
157
|
this.parser = new DOMParser();
|
|
155
158
|
}
|
|
156
159
|
migrate(t) {
|
|
157
160
|
try {
|
|
158
161
|
if (!this.containsItemsBlock(t))
|
|
159
162
|
return this.backfillV2ProductTdAttributes(t);
|
|
160
|
-
let
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
+
let e = this.removeJinjaConditionals(t);
|
|
164
|
+
e = this.replaceTemplateVariables(e);
|
|
165
|
+
const n = this.parser.parseFromString(e, "text/html"), o = n.querySelectorAll(
|
|
163
166
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
164
167
|
);
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
}),
|
|
168
|
-
const
|
|
169
|
-
orientation:
|
|
170
|
-
itemsType:
|
|
171
|
-
itemId:
|
|
172
|
-
currencySymbol:
|
|
173
|
-
currencyLocation:
|
|
174
|
-
formattedPrice:
|
|
175
|
-
configBlockAttributes:
|
|
168
|
+
return O().$patch((l) => {
|
|
169
|
+
l.migrations = { ...l.migrations, [U]: o.length };
|
|
170
|
+
}), o.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (o.forEach((l) => {
|
|
171
|
+
const r = this.extractConfiguration(l), s = K({
|
|
172
|
+
orientation: r.orientation,
|
|
173
|
+
itemsType: r.itemsType,
|
|
174
|
+
itemId: r.itemId,
|
|
175
|
+
currencySymbol: r.currencySymbol,
|
|
176
|
+
currencyLocation: r.currencyLocation,
|
|
177
|
+
formattedPrice: r.formattedPrice,
|
|
178
|
+
configBlockAttributes: r.configBlockAttributes,
|
|
176
179
|
migrate: !0,
|
|
177
|
-
nameStyles:
|
|
178
|
-
buttonStyles:
|
|
179
|
-
priceStyles:
|
|
180
|
-
originalPriceStyles:
|
|
181
|
-
quantityStyles:
|
|
182
|
-
nodeConfig:
|
|
183
|
-
}),
|
|
184
|
-
`<table><tbody><tr>${
|
|
180
|
+
nameStyles: r.nameStyles,
|
|
181
|
+
buttonStyles: r.buttonStyles,
|
|
182
|
+
priceStyles: r.priceStyles,
|
|
183
|
+
originalPriceStyles: r.originalPriceStyles,
|
|
184
|
+
quantityStyles: r.quantityStyles,
|
|
185
|
+
nodeConfig: M(r.configBlockAttributes)
|
|
186
|
+
}), d = this.parser.parseFromString(
|
|
187
|
+
`<table><tbody><tr>${s}</tr></tbody></table>`,
|
|
185
188
|
"text/html"
|
|
186
189
|
).querySelector("td");
|
|
187
|
-
if (
|
|
188
|
-
const _ =
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
190
|
+
if (d && l.parentNode) {
|
|
191
|
+
const _ = M(r.configBlockAttributes);
|
|
192
|
+
d.setAttribute("esd-ext-config", JSON.stringify(_)), d.setAttribute("data-type", _.type);
|
|
193
|
+
const u = d.querySelector("esd-config-block");
|
|
194
|
+
u && u.remove(), l.parentNode.replaceChild(d, l);
|
|
192
195
|
}
|
|
193
|
-
}),
|
|
194
|
-
} catch (
|
|
195
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
196
|
+
}), n.documentElement.outerHTML);
|
|
197
|
+
} catch (e) {
|
|
198
|
+
return console.error("ItemsBlockMigrator failed:", e), t;
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
201
|
/**
|
|
@@ -202,28 +205,85 @@ class H {
|
|
|
202
205
|
* - UI styles from product elements (name, price, button, quantity, etc.)
|
|
203
206
|
*/
|
|
204
207
|
extractConfiguration(t) {
|
|
205
|
-
var
|
|
206
|
-
const
|
|
207
|
-
(
|
|
208
|
-
),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
var D;
|
|
209
|
+
const e = R(
|
|
210
|
+
this.readSelfOrDescendantAttribute(t, "data-type") || V(t)
|
|
211
|
+
), n = this.readSelfOrDescendantAttribute(t, "data-number") || "1", o = parseInt(n) - 1, i = I[e], l = ((D = i == null ? void 0 : i[o]) == null ? void 0 : D.value) || i[0].value, r = this.extractConfigBlockAttributes(t, e, n);
|
|
212
|
+
this.applyDomFallbacks(t, r);
|
|
213
|
+
const s = t.querySelector('[product-attr="price"]'), c = s ?? t.querySelector('[product-attr="originalPrice"]'), d = (c == null ? void 0 : c.getAttribute("data-currency_symbol")) || r["data-product_price_control_currency_symbol"], _ = c == null ? void 0 : c.getAttribute("data-curency");
|
|
214
|
+
let u = r["data-product_price_currency_location"] || "0";
|
|
215
|
+
_ && (u = _ === "after" ? "1" : "0"), r["data-product_price_currency_location"] = u, r["data-product_price_control_currency_symbol"] = d;
|
|
216
|
+
const A = (c == null ? void 0 : c.getAttribute("data-formated")) ?? r["data-product_price_control_formated"], C = A !== "false" && A !== "0", m = r["data-card_orientation_control_value"];
|
|
217
|
+
let g;
|
|
218
|
+
m ? g = m === "horizontal" ? "horizontal" : "vertical" : g = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
219
|
+
const y = t.querySelector('a[product-attr="name"]'), b = (y == null ? void 0 : y.getAttribute("style")) || void 0, E = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0, w = (s == null ? void 0 : s.getAttribute("style")) || void 0, f = t.querySelector("p.original-price") ?? t.querySelector('[product-attr="originalPrice"]'), T = f != null && f.getAttribute("style") ? f : (f == null ? void 0 : f.closest("p")) ?? f, k = (T == null ? void 0 : T.getAttribute("style")) || void 0, h = t.querySelector('[product-attr="quantity"]'), q = (h == null ? void 0 : h.getAttribute("style")) || void 0;
|
|
212
220
|
return {
|
|
213
|
-
orientation:
|
|
214
|
-
itemsType:
|
|
215
|
-
itemId:
|
|
216
|
-
currencySymbol:
|
|
217
|
-
currencyLocation:
|
|
218
|
-
formattedPrice:
|
|
219
|
-
configBlockAttributes:
|
|
220
|
-
nameStyles:
|
|
221
|
-
buttonStyles:
|
|
222
|
-
priceStyles:
|
|
223
|
-
originalPriceStyles:
|
|
224
|
-
quantityStyles:
|
|
221
|
+
orientation: g,
|
|
222
|
+
itemsType: e,
|
|
223
|
+
itemId: l,
|
|
224
|
+
currencySymbol: d,
|
|
225
|
+
currencyLocation: u,
|
|
226
|
+
formattedPrice: C,
|
|
227
|
+
configBlockAttributes: r,
|
|
228
|
+
nameStyles: b,
|
|
229
|
+
buttonStyles: L,
|
|
230
|
+
priceStyles: w,
|
|
231
|
+
originalPriceStyles: k,
|
|
232
|
+
quantityStyles: q
|
|
225
233
|
};
|
|
226
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* DOM fallback for hand-edited templates whose esd-config-block was deleted. With no
|
|
237
|
+
* toggle record left, derive each field's enabled state from whether its product-attr
|
|
238
|
+
* element still exists and read the button label from the live caption — a deleted
|
|
239
|
+
* element means the field is off, not an all-ON default. A present config block stays
|
|
240
|
+
* authoritative (a missing flag there still means "default on"), so we no-op for it.
|
|
241
|
+
*/
|
|
242
|
+
applyDomFallbacks(t, e) {
|
|
243
|
+
var c;
|
|
244
|
+
const n = t.querySelector("esd-config-block");
|
|
245
|
+
if (Object.entries({
|
|
246
|
+
image: '[product-attr="imageSrc"]',
|
|
247
|
+
name: '[product-attr="name"]',
|
|
248
|
+
price: '[product-attr="price"]',
|
|
249
|
+
original_price: '[product-attr="originalPrice"], p.original-price',
|
|
250
|
+
quantity: '[product-attr="quantity"]',
|
|
251
|
+
button: '[product-attr="button"]'
|
|
252
|
+
}).forEach(([d, _]) => {
|
|
253
|
+
const u = `data-product_${d}_control_enabled`;
|
|
254
|
+
(!n || !n.hasAttribute(u)) && (e[u] = t.querySelector(_) ? "true" : "false");
|
|
255
|
+
}), n)
|
|
256
|
+
return;
|
|
257
|
+
e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal";
|
|
258
|
+
const i = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), l = (c = i == null ? void 0 : i.textContent) == null ? void 0 : c.replace(/\s+/g, " ").trim();
|
|
259
|
+
l && (e["data-product_button_control_label"] = l), /display:\s*inline/.test((i == null ? void 0 : i.getAttribute("style")) || "") && (e["data-product_button_control_atw"] = "false");
|
|
260
|
+
const r = t.querySelector('[product-attr="imageSrc"]'), s = r ? this.readImageDimension(r) : null;
|
|
261
|
+
s && (e["data-product_image_control_image-height"] = s, e["data-product_image_control_image-width"] = s);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Reads an attribute from the block element itself before falling back to a descendant.
|
|
265
|
+
* Real legacy markup carries data-type/data-number on the `.ins-product-td` AND on the
|
|
266
|
+
* esd-config-block; when an author deletes the config block only the td's copy survives.
|
|
267
|
+
*/
|
|
268
|
+
readSelfOrDescendantAttribute(t, e) {
|
|
269
|
+
var n;
|
|
270
|
+
return t.getAttribute(e) || ((n = t.querySelector(`[${e}]`)) == null ? void 0 : n.getAttribute(e)) || null;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Reads a pixel dimension for the product image from its DOM element — the legacy
|
|
274
|
+
* `width` attribute first, then a px value in the inline style. An explicit `width` wins
|
|
275
|
+
* over `max-width`, which is only an upper bound; `max-width` still covers the common
|
|
276
|
+
* `width: 100%` case, where no pixel size can be read from `width` itself.
|
|
277
|
+
* Returns null when no pixel size is present.
|
|
278
|
+
*/
|
|
279
|
+
readImageDimension(t) {
|
|
280
|
+
var i;
|
|
281
|
+
const e = (i = t.getAttribute("width")) == null ? void 0 : i.trim();
|
|
282
|
+
if (e && /^\d+$/.test(e))
|
|
283
|
+
return e;
|
|
284
|
+
const n = t.getAttribute("style") || "", o = n.match(/(?:^|;)\s*width:\s*(\d+)px/) || n.match(/max-width:\s*(\d+)px/);
|
|
285
|
+
return o ? o[1] : null;
|
|
286
|
+
}
|
|
227
287
|
/**
|
|
228
288
|
* Extracts all data-* attributes from the esd-config-block element
|
|
229
289
|
* Returns a key-value mapping of all configuration attributes
|
|
@@ -231,27 +291,27 @@ class H {
|
|
|
231
291
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
232
292
|
* @param itemNumber - The item number (1-based index)
|
|
233
293
|
*/
|
|
234
|
-
extractConfigBlockAttributes(t,
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
294
|
+
extractConfigBlockAttributes(t, e, n) {
|
|
295
|
+
const o = t.querySelector("esd-config-block"), i = {};
|
|
296
|
+
if (o) {
|
|
297
|
+
if (Array.from(o.attributes).forEach((r) => {
|
|
298
|
+
r.name.startsWith("data-") && (i[r.name] = r.value);
|
|
299
|
+
}), i["data-cart_items_select_control_value"]) {
|
|
300
|
+
const r = i["data-cart_items_select_control_value"];
|
|
301
|
+
if (/^\d+$/.test(r)) {
|
|
302
|
+
const s = parseInt(r) - 1, c = I[e];
|
|
303
|
+
c && c[s] && (i["data-cart_items_select_control_value"] = c[s].value);
|
|
304
|
+
}
|
|
245
305
|
}
|
|
306
|
+
if (i["data-product_price_control_curency"]) {
|
|
307
|
+
const r = i["data-product_price_control_curency"];
|
|
308
|
+
let s = r;
|
|
309
|
+
r === "before" ? s = "0" : r === "after" && (s = "1"), i["data-product_price_control_curency"] = s, i["data-product_price_currency_location"] = s;
|
|
310
|
+
}
|
|
311
|
+
(!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
|
|
246
312
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
let l = e;
|
|
250
|
-
e === "before" ? l = "0" : e === "after" && (l = "1"), i["data-product_price_control_curency"] = l, i["data-product_price_currency_location"] = l;
|
|
251
|
-
}
|
|
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, c), n["data-product_button_link"] = N(r, c), n;
|
|
313
|
+
const l = { ...this.getDefaultConfigBlockAttributes(), ...i };
|
|
314
|
+
return l["data-type"] = e, l["data-source"] = e, l["data-product_image_link"] = N(e, n), l["data-product_button_link"] = z(e, n), l;
|
|
255
315
|
}
|
|
256
316
|
/**
|
|
257
317
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -325,25 +385,27 @@ class H {
|
|
|
325
385
|
backfillV2ProductTdAttributes(t) {
|
|
326
386
|
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
327
387
|
return t;
|
|
328
|
-
const
|
|
329
|
-
let
|
|
330
|
-
return
|
|
331
|
-
|
|
332
|
-
const i =
|
|
333
|
-
|
|
388
|
+
const e = this.parser.parseFromString(t, "text/html");
|
|
389
|
+
let n = !1;
|
|
390
|
+
return e.querySelectorAll(".ins-product-td").forEach((o) => {
|
|
391
|
+
o.hasAttribute("width") && (o.removeAttribute("width"), n = !0), o.classList.contains("esd-container-frame") && (o.classList.remove("esd-container-frame"), n = !0);
|
|
392
|
+
const i = o.querySelector("table.ins-product-wrapper");
|
|
393
|
+
i != null && i.hasAttribute("width") && i.getAttribute("width") !== "100%" && (i.setAttribute("width", "100%"), n = !0);
|
|
394
|
+
const l = o.getAttribute("esd-ext-config");
|
|
395
|
+
let r = null;
|
|
334
396
|
try {
|
|
335
|
-
|
|
397
|
+
r = l ? JSON.parse(l) : null;
|
|
336
398
|
} catch {
|
|
337
399
|
}
|
|
338
|
-
if (!
|
|
400
|
+
if (!r || (!o.getAttribute("data-nodup") && typeof r.priceHideDiscount == "boolean" && (o.setAttribute("data-nodup", String(r.priceHideDiscount)), n = !0), o.getAttribute("data-type")))
|
|
339
401
|
return;
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
402
|
+
const s = r.type || r.source;
|
|
403
|
+
if (!s)
|
|
342
404
|
return;
|
|
343
|
-
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
}),
|
|
405
|
+
o.setAttribute("data-type", s), n = !0;
|
|
406
|
+
const c = typeof r.itemsSelectValue == "string" ? r.itemsSelectValue.match(/\((\d+)\)/) : null;
|
|
407
|
+
c && o.getAttribute("data-number") !== c[1] && o.setAttribute("data-number", c[1]);
|
|
408
|
+
}), n ? e.documentElement.outerHTML : t;
|
|
347
409
|
}
|
|
348
410
|
/**
|
|
349
411
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
@@ -364,17 +426,17 @@ class H {
|
|
|
364
426
|
* contains display condition Jinja scripts that should NOT be removed.
|
|
365
427
|
*/
|
|
366
428
|
removeJinjaConditionals(t) {
|
|
367
|
-
const
|
|
368
|
-
let
|
|
369
|
-
return
|
|
429
|
+
const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", n = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
430
|
+
let o = n ? t.replace(n[0], e) : t;
|
|
431
|
+
return o = o.replace(
|
|
370
432
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
371
433
|
""
|
|
372
|
-
),
|
|
434
|
+
), o = o.replace(
|
|
373
435
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
374
436
|
""
|
|
375
|
-
),
|
|
437
|
+
), o = o.replace(/\{%\s*endif\s*%\}/g, ""), n && (o = o.replace(e, n[0])), o = o.replace(/\n\s*\n\s*\n/g, `
|
|
376
438
|
|
|
377
|
-
`),
|
|
439
|
+
`), o;
|
|
378
440
|
}
|
|
379
441
|
/**
|
|
380
442
|
* Replaces template variables with default values from productPairs
|
|
@@ -386,32 +448,32 @@ class H {
|
|
|
386
448
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
387
449
|
*/
|
|
388
450
|
replaceTemplateVariables(t) {
|
|
389
|
-
const { PAIRS_FOR_EXTENSION:
|
|
390
|
-
return t.replace(/{{([^}]+)}}/g, (
|
|
391
|
-
const i =
|
|
451
|
+
const { PAIRS_FOR_EXTENSION: e } = F;
|
|
452
|
+
return t.replace(/{{([^}]+)}}/g, (n, o) => {
|
|
453
|
+
const i = o.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
392
454
|
if (!i)
|
|
393
|
-
return
|
|
394
|
-
const [,
|
|
395
|
-
if (!
|
|
396
|
-
return console.warn(`Unknown variable prefix: ${
|
|
397
|
-
const
|
|
398
|
-
if (!
|
|
399
|
-
return console.warn(`Unknown variable suffix mapping for: ${
|
|
400
|
-
const { pairsKey: _, defaultKey:
|
|
401
|
-
if (!
|
|
402
|
-
return console.warn(`No data found for: ${_}.${
|
|
403
|
-
if (
|
|
404
|
-
const
|
|
405
|
-
return Array.isArray(
|
|
455
|
+
return n;
|
|
456
|
+
const [, l, r, s] = i, c = H[l];
|
|
457
|
+
if (!c)
|
|
458
|
+
return console.warn(`Unknown variable prefix: ${l}`), n;
|
|
459
|
+
const d = x[r];
|
|
460
|
+
if (!d)
|
|
461
|
+
return console.warn(`Unknown variable suffix mapping for: ${r}`), n;
|
|
462
|
+
const { pairsKey: _, defaultKey: u, isArray: A } = d, m = e[_][c];
|
|
463
|
+
if (!m)
|
|
464
|
+
return console.warn(`No data found for: ${_}.${c}`), n;
|
|
465
|
+
if (A) {
|
|
466
|
+
const y = parseInt(s) - 1, b = m[u];
|
|
467
|
+
return Array.isArray(b) && b[y] ? b[y] : (console.warn(`Array value not found: ${_}.${c}.${u}[${y}]`), n);
|
|
406
468
|
}
|
|
407
|
-
const
|
|
408
|
-
return
|
|
469
|
+
const g = m[u];
|
|
470
|
+
return g !== void 0 ? String(g) : (console.warn(`Default value not found: ${_}.${c}.${u}`), n);
|
|
409
471
|
});
|
|
410
472
|
}
|
|
411
473
|
}
|
|
412
|
-
function
|
|
413
|
-
return new
|
|
474
|
+
function tt(a) {
|
|
475
|
+
return new Y().migrate(a);
|
|
414
476
|
}
|
|
415
477
|
export {
|
|
416
|
-
|
|
478
|
+
tt as migrateItemsBlock
|
|
417
479
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SETTINGS_ENUMS as r } from "../enums/settingsEnums.js";
|
|
2
|
+
const I = "130px", L = "100%", R = (e) => e === r.ORIENTATION.HORIZONTAL ? I : L, n = {
|
|
3
|
+
VERTICAL: "es-p5b es-p5t",
|
|
4
|
+
HORIZONTAL: "es-p5l es-p5r"
|
|
5
|
+
}, o = "data-items-cell-pad", d = (e) => `${o}="${e ? "v" : "h"}"`, t = (e) => e ? ` ${n.VERTICAL}` : ` ${n.HORIZONTAL}`, E = (e, A) => {
|
|
6
|
+
if (!e.includes(o))
|
|
7
|
+
return e;
|
|
8
|
+
const T = A ? n.HORIZONTAL : n.VERTICAL, s = A ? n.VERTICAL : n.HORIZONTAL, c = A ? "v" : "h";
|
|
9
|
+
return e.includes(T) ? e.replace(T, s).replace(new RegExp(`${o}="[hv]"`), `${o}="${c}"`) : e;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
n as BLOCK_CELL_PADDING,
|
|
13
|
+
o as BLOCK_CELL_PAD_ATTR,
|
|
14
|
+
I as NAME_HORIZONTAL_MAX_WIDTH,
|
|
15
|
+
L as NAME_VERTICAL_MAX_WIDTH,
|
|
16
|
+
d as blockCellPadMarker,
|
|
17
|
+
t as blockCellPaddingFor,
|
|
18
|
+
R as nameMaxWidthFor,
|
|
19
|
+
E as reorientBlockCellPadding
|
|
20
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
1
|
+
import { ModificationDescription as d, UIElementType as s, UEAttr as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as T } from "../../../common-control.js";
|
|
3
|
+
import { nameMaxWidthFor as h } from "../../constants/cardLayout.js";
|
|
3
4
|
import { ItemsBlockControlId as a } from "../../enums/controlEnums.js";
|
|
4
|
-
import { findNameTextNode as
|
|
5
|
-
import { getItemsBlockConfig as r, setItemsBlockConfig as
|
|
6
|
-
const
|
|
5
|
+
import { findNameTextNode as c } from "../../utils/nameNode.js";
|
|
6
|
+
import { getItemsBlockConfig as r, setItemsBlockConfig as g } from "../../utils/nodeConfigUtils.js";
|
|
7
|
+
const I = a.NAME_TRIMMING, n = {
|
|
7
8
|
TRIMMING: "trimming"
|
|
8
9
|
};
|
|
9
|
-
class
|
|
10
|
+
class E extends T {
|
|
10
11
|
getId() {
|
|
11
|
-
return
|
|
12
|
+
return I;
|
|
12
13
|
}
|
|
13
14
|
getTemplate() {
|
|
14
15
|
return `
|
|
@@ -19,39 +20,39 @@ class y extends p {
|
|
|
19
20
|
}
|
|
20
21
|
onRender() {
|
|
21
22
|
const e = r(this.currentNode);
|
|
22
|
-
this.api.updateValues({ [
|
|
23
|
+
this.api.updateValues({ [n.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(n.TRIMMING, (t) => {
|
|
23
24
|
this._onTrimmingChange(t);
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
onTemplateNodeUpdated(e) {
|
|
27
28
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
28
29
|
const t = r(this.currentNode);
|
|
29
|
-
this.api.updateValues({ [
|
|
30
|
+
this.api.updateValues({ [n.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
_onTrimmingChange(e) {
|
|
33
|
-
|
|
34
|
+
g(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [n.TRIMMING]: e }), this._applyTrimmingStyles(e);
|
|
34
35
|
}
|
|
35
36
|
_applyTrimmingStyles(e) {
|
|
36
|
-
const t =
|
|
37
|
+
const t = c(this.currentNode);
|
|
37
38
|
if (!t)
|
|
38
39
|
return;
|
|
39
|
-
const
|
|
40
|
-
m ? o.setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis") : o.removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow"), o.setStyle("max-width",
|
|
40
|
+
const i = r(this.currentNode), m = e !== void 0 ? e : (i == null ? void 0 : i.nameTrimming) ?? !0, l = h(i == null ? void 0 : i.orientation), o = this.api.getDocumentModifier().modifyHtml(t);
|
|
41
|
+
m ? o.setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis") : o.removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow"), o.setStyle("max-width", l).apply(new d(`Text Trimming ${m ? "Enabled" : "Disabled"}`));
|
|
41
42
|
}
|
|
42
43
|
_getTextTrimming() {
|
|
43
44
|
return `
|
|
44
45
|
<div class="display-flex align-items-center justify-content-between">
|
|
45
46
|
<${s.LABEL}
|
|
46
|
-
${
|
|
47
|
+
${p.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
47
48
|
>
|
|
48
49
|
</${s.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
|
+
E as NameTrimmingControl
|
|
57
58
|
};
|