@useinsider/guido 3.18.2-beta.fc246a7 → 3.18.2-beta.ff43aaa
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/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +34 -34
- package/dist/composables/useHttp.js +24 -22
- package/dist/config/migrator/itemsBlockMigrator.js +167 -257
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +17 -18
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +105 -114
- package/dist/extensions/Blocks/Items/enums/productEnums.js +9 -14
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +9 -11
- package/dist/extensions/Blocks/Items/template.js +204 -219
- package/dist/services/templateLibraryApi.js +17 -14
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +0 -3
- package/dist/src/extensions/Blocks/Items/template.d.ts +0 -19
- package/dist/src/utils/genericUtil.d.ts +6 -0
- package/dist/src/utils/liquidDynamicContent.d.ts +20 -0
- package/dist/utils/genericUtil.js +63 -54
- package/dist/utils/liquidDynamicContent.js +15 -0
- package/dist/utils/pairProductVariables.js +71 -71
- package/dist/utils/templatePreparation.js +37 -36
- package/package.json +1 -1
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +0 -20
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +0 -44
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { BLOCK_ID as
|
|
5
|
-
import { productPairs as
|
|
6
|
-
import { ItemInCartOptions as
|
|
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 w } from "../../extensions/Blocks/Items/block.js";
|
|
5
|
+
import { productPairs as K } 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
7
|
import { getDefaultTemplate as F } from "../../extensions/Blocks/Items/template.js";
|
|
8
|
-
import { useTemplateStore as
|
|
9
|
-
const
|
|
8
|
+
import { useTemplateStore as q } from "../../stores/template.js";
|
|
9
|
+
const x = {
|
|
10
10
|
img: {
|
|
11
11
|
pairsKey: "imageSrc",
|
|
12
12
|
defaultKey: "DEFAULT",
|
|
@@ -73,129 +73,126 @@ const K = {
|
|
|
73
73
|
isArray: !1
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
function
|
|
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 k(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
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (i && !i.includes("{{") && /^\d+$/.test(i)) {
|
|
97
|
-
const u = parseInt(i) - 1, n = E[r];
|
|
98
|
-
n && n[u] && (i = n[u].value);
|
|
89
|
+
function h(o) {
|
|
90
|
+
var e;
|
|
91
|
+
const t = (l, u) => l == null ? u : l === "1" || l === "true", r = (l, u) => l || u, c = o["data-type"] || o["data-source"], a = k(c), 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 l = parseInt(n) - 1, u = I[a];
|
|
95
|
+
u && u[l] && (n = u[l].value);
|
|
99
96
|
}
|
|
100
97
|
return {
|
|
101
98
|
initialized: !0,
|
|
102
|
-
blockInstanceId:
|
|
103
|
-
source:
|
|
104
|
-
type:
|
|
105
|
-
itemsSelectValue:
|
|
106
|
-
orientation:
|
|
107
|
-
nameTrimming: t(
|
|
108
|
-
priceHideDiscount: t(
|
|
109
|
-
priceFormatted: t(
|
|
110
|
-
priceSinglePrice: t(
|
|
111
|
-
priceCurrencySymbol:
|
|
112
|
-
|
|
113
|
-
|
|
99
|
+
blockInstanceId: r(o["data-block-instance-id"], O()),
|
|
100
|
+
source: a,
|
|
101
|
+
type: a,
|
|
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
|
+
g.productPriceCurrencySymbolControlValue
|
|
114
111
|
),
|
|
115
|
-
priceCurrencyLocation:
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
priceCurrencyLocation: r(
|
|
113
|
+
o["data-product_price_currency_location"],
|
|
114
|
+
g.productPriceCurrencyLocationControlValue
|
|
118
115
|
),
|
|
119
|
-
priceOrientation:
|
|
120
|
-
quantityControlEnabled: t(
|
|
121
|
-
buttonLink:
|
|
122
|
-
imageLink:
|
|
123
|
-
buttonLabel:
|
|
124
|
-
buttonFullWidth: t(
|
|
125
|
-
imageVisible: t(
|
|
126
|
-
nameVisible: t(
|
|
127
|
-
quantityVisible: t(
|
|
128
|
-
priceVisible: t(
|
|
129
|
-
originalPriceVisible: t(
|
|
130
|
-
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)
|
|
131
128
|
};
|
|
132
129
|
}
|
|
133
|
-
const
|
|
130
|
+
const V = {
|
|
134
131
|
ins_apr: "CART_ITEMS",
|
|
135
132
|
browsed_item: "BROWSED_ITEMS",
|
|
136
133
|
purchased_item: "PURCHASED_ITEMS"
|
|
137
134
|
};
|
|
138
|
-
function
|
|
139
|
-
const
|
|
135
|
+
function $(o, t) {
|
|
136
|
+
const r = {
|
|
140
137
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
141
138
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
142
139
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
143
140
|
};
|
|
144
|
-
return
|
|
141
|
+
return r[o] || r.CART_ITEMS;
|
|
145
142
|
}
|
|
146
|
-
function
|
|
147
|
-
const
|
|
143
|
+
function N(o, t) {
|
|
144
|
+
const r = {
|
|
148
145
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
149
146
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
150
147
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
151
148
|
};
|
|
152
|
-
return
|
|
149
|
+
return r[o] || r.CART_ITEMS;
|
|
153
150
|
}
|
|
154
|
-
class
|
|
151
|
+
class H {
|
|
155
152
|
constructor() {
|
|
156
|
-
|
|
153
|
+
M(this, "parser");
|
|
157
154
|
this.parser = new DOMParser();
|
|
158
155
|
}
|
|
159
156
|
migrate(t) {
|
|
160
157
|
try {
|
|
161
158
|
if (!this.containsItemsBlock(t))
|
|
162
159
|
return this.backfillV2ProductTdAttributes(t);
|
|
163
|
-
let
|
|
164
|
-
|
|
165
|
-
const
|
|
160
|
+
let r = this.removeJinjaConditionals(t);
|
|
161
|
+
r = this.replaceTemplateVariables(r);
|
|
162
|
+
const c = this.parser.parseFromString(r, "text/html"), a = c.querySelectorAll(
|
|
166
163
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
167
164
|
);
|
|
168
|
-
return
|
|
169
|
-
|
|
170
|
-
}),
|
|
171
|
-
const
|
|
172
|
-
orientation:
|
|
173
|
-
itemsType:
|
|
174
|
-
itemId:
|
|
175
|
-
currencySymbol:
|
|
176
|
-
currencyLocation:
|
|
177
|
-
formattedPrice:
|
|
178
|
-
configBlockAttributes:
|
|
165
|
+
return q().$patch((n) => {
|
|
166
|
+
n.migrations = { ...n.migrations, [w]: 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), l = F({
|
|
169
|
+
orientation: e.orientation,
|
|
170
|
+
itemsType: e.itemsType,
|
|
171
|
+
itemId: e.itemId,
|
|
172
|
+
currencySymbol: e.currencySymbol,
|
|
173
|
+
currencyLocation: e.currencyLocation,
|
|
174
|
+
formattedPrice: e.formattedPrice,
|
|
175
|
+
configBlockAttributes: e.configBlockAttributes,
|
|
179
176
|
migrate: !0,
|
|
180
|
-
nameStyles:
|
|
181
|
-
buttonStyles:
|
|
182
|
-
priceStyles:
|
|
183
|
-
originalPriceStyles:
|
|
184
|
-
quantityStyles:
|
|
185
|
-
nodeConfig:
|
|
186
|
-
}),
|
|
187
|
-
`<table><tbody><tr>${
|
|
177
|
+
nameStyles: e.nameStyles,
|
|
178
|
+
buttonStyles: e.buttonStyles,
|
|
179
|
+
priceStyles: e.priceStyles,
|
|
180
|
+
originalPriceStyles: e.originalPriceStyles,
|
|
181
|
+
quantityStyles: e.quantityStyles,
|
|
182
|
+
nodeConfig: h(e.configBlockAttributes)
|
|
183
|
+
}), s = this.parser.parseFromString(
|
|
184
|
+
`<table><tbody><tr>${l}</tr></tbody></table>`,
|
|
188
185
|
"text/html"
|
|
189
186
|
).querySelector("td");
|
|
190
|
-
if (
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
187
|
+
if (s && n.parentNode) {
|
|
188
|
+
const _ = h(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);
|
|
195
192
|
}
|
|
196
|
-
}),
|
|
197
|
-
} catch (
|
|
198
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
193
|
+
}), c.documentElement.outerHTML);
|
|
194
|
+
} catch (r) {
|
|
195
|
+
return console.error("ItemsBlockMigrator failed:", r), t;
|
|
199
196
|
}
|
|
200
197
|
}
|
|
201
198
|
/**
|
|
@@ -205,113 +202,28 @@ class N {
|
|
|
205
202
|
* - UI styles from product elements (name, price, button, quantity, etc.)
|
|
206
203
|
*/
|
|
207
204
|
extractConfiguration(t) {
|
|
208
|
-
var C;
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
),
|
|
212
|
-
|
|
213
|
-
|
|
205
|
+
var C, D, P;
|
|
206
|
+
const r = k(
|
|
207
|
+
((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) ?? null
|
|
208
|
+
), c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(c) - 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"]'), l = (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, c), 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, R = (e == null ? void 0 : e.getAttribute("style")) || void 0, E = t.querySelector("p.original-price"), L = (E == null ? void 0 : E.getAttribute("style")) || void 0, T = t.querySelector('[product-attr="quantity"]'), B = (T == null ? void 0 : T.getAttribute("style")) || void 0;
|
|
214
212
|
return {
|
|
215
213
|
orientation: S,
|
|
216
|
-
itemsType:
|
|
217
|
-
itemId:
|
|
218
|
-
currencySymbol:
|
|
219
|
-
currencyLocation:
|
|
220
|
-
formattedPrice:
|
|
221
|
-
configBlockAttributes:
|
|
222
|
-
nameStyles:
|
|
223
|
-
buttonStyles:
|
|
214
|
+
itemsType: r,
|
|
215
|
+
itemId: n,
|
|
216
|
+
currencySymbol: l,
|
|
217
|
+
currencyLocation: s,
|
|
218
|
+
formattedPrice: _,
|
|
219
|
+
configBlockAttributes: d,
|
|
220
|
+
nameStyles: A,
|
|
221
|
+
buttonStyles: m,
|
|
224
222
|
priceStyles: R,
|
|
225
|
-
originalPriceStyles:
|
|
226
|
-
quantityStyles:
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* DOM fallback for hand-edited templates. The esd-config-block is authoritative only for
|
|
231
|
-
* the keys it ACTUALLY carries — every other key follows the live markup, whether the block
|
|
232
|
-
* was deleted outright or (far more common) survives carrying only a couple of `_opened`
|
|
233
|
-
* attributes. Without the per-key split, one such stub block shadows the whole DOM and the
|
|
234
|
-
* card migrates with the boilerplate defaults: caption "Buy", USD, full-width button.
|
|
235
|
-
*/
|
|
236
|
-
applyDomFallbacks(t, e) {
|
|
237
|
-
var b, S;
|
|
238
|
-
const a = t.querySelector("esd-config-block"), r = (...y) => !a || y.every((f) => !(a.getAttribute(f) ?? "").trim());
|
|
239
|
-
Object.entries({
|
|
240
|
-
image: '[product-attr="imageSrc"]',
|
|
241
|
-
name: '[product-attr="name"]',
|
|
242
|
-
price: '[product-attr="price"]',
|
|
243
|
-
original_price: '[product-attr="originalPrice"], p.original-price',
|
|
244
|
-
quantity: '[product-attr="quantity"]',
|
|
245
|
-
button: '[product-attr="button"]'
|
|
246
|
-
}).forEach(([y, f]) => {
|
|
247
|
-
const m = `data-product_${y}_control_enabled`;
|
|
248
|
-
r(m) && (e[m] = t.querySelector(f) ? "true" : "false");
|
|
249
|
-
}), r("data-card_orientation_control_value") && (e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal");
|
|
250
|
-
const i = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), o = (b = i == null ? void 0 : i.textContent) == null ? void 0 : b.replace(/\s+/g, " ").trim();
|
|
251
|
-
o && r("data-product_button_control_label") && (e["data-product_button_control_label"] = o), r("data-product_button_control_atw") && /display:\s*inline/.test((i == null ? void 0 : i.getAttribute("style")) || "") && (e["data-product_button_control_atw"] = "false");
|
|
252
|
-
const u = t.querySelector('[product-attr="imageSrc"]'), n = u ? this.readImageSize(u) : null, d = (n == null ? void 0 : n.height) ?? (n == null ? void 0 : n.width), s = (n == null ? void 0 : n.width) ?? (n == null ? void 0 : n.height);
|
|
253
|
-
d && r("data-product_image_control_image-height") && (e["data-product_image_control_image-height"] = d), s && r("data-product_image_control_image-width") && (e["data-product_image_control_image-width"] = s), this.applyPriceDomFallbacks(t, e, r);
|
|
254
|
-
const p = ((S = t.querySelector('[product-attr="name"]')) == null ? void 0 : S.getAttribute("style")) || "";
|
|
255
|
-
r("data-product_name_control_trim") && /white-space:\s*normal/.test(p) && (e["data-product_name_control_trim"] = "0");
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Carries the price cell's own currency/format attributes into the config attributes when
|
|
259
|
-
* the config block omits them. extractConfiguration used to read the cell separately for the
|
|
260
|
-
* rendered markup while nodeConfig kept the defaults — so a ₺/after card migrated rendering
|
|
261
|
-
* ₺ but reporting USD/before to the settings panel, and the first unrelated price edit wrote
|
|
262
|
-
* the default back over the real value.
|
|
263
|
-
*/
|
|
264
|
-
applyPriceDomFallbacks(t, e, a) {
|
|
265
|
-
var n;
|
|
266
|
-
const r = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
|
|
267
|
-
if (!r)
|
|
268
|
-
return;
|
|
269
|
-
const l = (n = r.getAttribute("data-currency_symbol")) == null ? void 0 : n.trim();
|
|
270
|
-
l && a("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = l);
|
|
271
|
-
const i = r.getAttribute("data-curency");
|
|
272
|
-
if (i && a("data-product_price_currency_location", "data-product_price_control_curency")) {
|
|
273
|
-
const d = i === "after" ? "1" : "0";
|
|
274
|
-
e["data-product_price_currency_location"] = d, e["data-product_price_control_curency"] = d;
|
|
275
|
-
}
|
|
276
|
-
const o = r.getAttribute("data-formated");
|
|
277
|
-
o && a("data-product_price_control_formated") && (e["data-product_price_control_formated"] = o);
|
|
278
|
-
const u = r.getAttribute("data-single_price");
|
|
279
|
-
u && a("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = u);
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Reads an attribute from the block element itself before falling back to a descendant.
|
|
283
|
-
* Real legacy markup carries data-type/data-number on the `.ins-product-td` AND on the
|
|
284
|
-
* esd-config-block; when an author deletes the config block only the td's copy survives.
|
|
285
|
-
*/
|
|
286
|
-
readSelfOrDescendantAttribute(t, e) {
|
|
287
|
-
var a;
|
|
288
|
-
return t.getAttribute(e) || ((a = t.querySelector(`[${e}]`)) == null ? void 0 : a.getAttribute(e)) || null;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Reads the product image's pixel size — `width`/`height` attributes first, then px values
|
|
292
|
-
* in the inline style. An explicit `width`/`height` wins over `max-*`, which is only an
|
|
293
|
-
* upper bound; `max-*` still covers the common `width: 100%` case, where no pixel size can
|
|
294
|
-
* be read from the property itself. Each side is null when it carries no pixel size.
|
|
295
|
-
*/
|
|
296
|
-
readImageSize(t) {
|
|
297
|
-
return {
|
|
298
|
-
width: this.readImageDimension(t, "width"),
|
|
299
|
-
height: this.readImageDimension(t, "height")
|
|
223
|
+
originalPriceStyles: L,
|
|
224
|
+
quantityStyles: B
|
|
300
225
|
};
|
|
301
226
|
}
|
|
302
|
-
/**
|
|
303
|
-
* One side of readImageSize. `width="0"` is not a size — authors who override the real
|
|
304
|
-
* dimensions in CSS zero out the attributes, and taking the 0 collapses the migrated image
|
|
305
|
-
* to nothing, so only a positive integer counts as an answer.
|
|
306
|
-
*/
|
|
307
|
-
readImageDimension(t, e) {
|
|
308
|
-
var n;
|
|
309
|
-
const a = (d) => !!d && /^\d+$/.test(d ?? "") && parseInt(d ?? "") > 0 ? d : null, r = a((n = t.getAttribute(e)) == null ? void 0 : n.trim());
|
|
310
|
-
if (r)
|
|
311
|
-
return r;
|
|
312
|
-
const l = t.getAttribute("style") || "", i = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+)px`), o = new RegExp(`max-${e}:\\s*(\\d+)px`), u = l.match(i) || l.match(o);
|
|
313
|
-
return a(u == null ? void 0 : u[1]);
|
|
314
|
-
}
|
|
315
227
|
/**
|
|
316
228
|
* Extracts all data-* attributes from the esd-config-block element
|
|
317
229
|
* Returns a key-value mapping of all configuration attributes
|
|
@@ -319,27 +231,27 @@ class N {
|
|
|
319
231
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
320
232
|
* @param itemNumber - The item number (1-based index)
|
|
321
233
|
*/
|
|
322
|
-
extractConfigBlockAttributes(t,
|
|
323
|
-
const
|
|
324
|
-
if (
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
if (l["data-product_price_control_curency"]) {
|
|
335
|
-
const o = l["data-product_price_control_curency"];
|
|
336
|
-
let u = o;
|
|
337
|
-
o === "before" ? u = "0" : o === "after" && (u = "1"), l["data-product_price_control_curency"] = u, l["data-product_price_currency_location"] = u;
|
|
234
|
+
extractConfigBlockAttributes(t, r, c) {
|
|
235
|
+
const a = t.querySelector("esd-config-block"), i = {};
|
|
236
|
+
if (!a)
|
|
237
|
+
return this.getDefaultConfigBlockAttributes();
|
|
238
|
+
if (Array.from(a.attributes).forEach((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"];
|
|
242
|
+
if (/^\d+$/.test(e)) {
|
|
243
|
+
const l = parseInt(e) - 1, u = I[r];
|
|
244
|
+
u && u[l] && (i["data-cart_items_select_control_value"] = u[l].value);
|
|
338
245
|
}
|
|
339
|
-
(!l["data-product_price_control_currency_symbol"] || l["data-product_price_control_currency_symbol"].trim() === "") && (l["data-product_price_control_currency_symbol"] = "USD");
|
|
340
246
|
}
|
|
341
|
-
|
|
342
|
-
|
|
247
|
+
if (i["data-product_price_control_curency"]) {
|
|
248
|
+
const e = i["data-product_price_control_curency"];
|
|
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;
|
|
343
255
|
}
|
|
344
256
|
/**
|
|
345
257
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -413,27 +325,25 @@ class N {
|
|
|
413
325
|
backfillV2ProductTdAttributes(t) {
|
|
414
326
|
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
415
327
|
return t;
|
|
416
|
-
const
|
|
417
|
-
let
|
|
418
|
-
return
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
const i = r.getAttribute("esd-ext-config");
|
|
423
|
-
let o = null;
|
|
328
|
+
const r = this.parser.parseFromString(t, "text/html");
|
|
329
|
+
let c = !1;
|
|
330
|
+
return r.querySelectorAll(".ins-product-td").forEach((a) => {
|
|
331
|
+
a.hasAttribute("width") && (a.removeAttribute("width"), c = !0);
|
|
332
|
+
const i = a.getAttribute("esd-ext-config");
|
|
333
|
+
let n = null;
|
|
424
334
|
try {
|
|
425
|
-
|
|
335
|
+
n = i ? JSON.parse(i) : null;
|
|
426
336
|
} catch {
|
|
427
337
|
}
|
|
428
|
-
if (!
|
|
338
|
+
if (!n || (!a.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(n.priceHideDiscount)), c = !0), a.getAttribute("data-type")))
|
|
429
339
|
return;
|
|
430
|
-
const
|
|
431
|
-
if (!
|
|
340
|
+
const e = n.type || n.source;
|
|
341
|
+
if (!e)
|
|
432
342
|
return;
|
|
433
|
-
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
}),
|
|
343
|
+
a.setAttribute("data-type", e), c = !0;
|
|
344
|
+
const l = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
|
|
345
|
+
l && a.getAttribute("data-number") !== l[1] && a.setAttribute("data-number", l[1]);
|
|
346
|
+
}), c ? r.documentElement.outerHTML : t;
|
|
437
347
|
}
|
|
438
348
|
/**
|
|
439
349
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
@@ -454,17 +364,17 @@ class N {
|
|
|
454
364
|
* contains display condition Jinja scripts that should NOT be removed.
|
|
455
365
|
*/
|
|
456
366
|
removeJinjaConditionals(t) {
|
|
457
|
-
const
|
|
458
|
-
let
|
|
459
|
-
return
|
|
367
|
+
const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", c = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
368
|
+
let a = c ? t.replace(c[0], r) : t;
|
|
369
|
+
return a = a.replace(
|
|
460
370
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
461
371
|
""
|
|
462
|
-
),
|
|
372
|
+
), a = a.replace(
|
|
463
373
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
464
374
|
""
|
|
465
|
-
),
|
|
375
|
+
), a = a.replace(/\{%\s*endif\s*%\}/g, ""), c && (a = a.replace(r, c[0])), a = a.replace(/\n\s*\n\s*\n/g, `
|
|
466
376
|
|
|
467
|
-
`),
|
|
377
|
+
`), a;
|
|
468
378
|
}
|
|
469
379
|
/**
|
|
470
380
|
* Replaces template variables with default values from productPairs
|
|
@@ -476,32 +386,32 @@ class N {
|
|
|
476
386
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
477
387
|
*/
|
|
478
388
|
replaceTemplateVariables(t) {
|
|
479
|
-
const { PAIRS_FOR_EXTENSION:
|
|
480
|
-
return t.replace(/{{([^}]+)}}/g, (
|
|
481
|
-
const
|
|
482
|
-
if (!
|
|
483
|
-
return
|
|
484
|
-
const [,
|
|
485
|
-
if (!
|
|
486
|
-
return console.warn(`Unknown variable prefix: ${
|
|
487
|
-
const
|
|
488
|
-
if (!
|
|
489
|
-
return console.warn(`Unknown variable suffix mapping for: ${
|
|
490
|
-
const { pairsKey:
|
|
389
|
+
const { PAIRS_FOR_EXTENSION: r } = K;
|
|
390
|
+
return t.replace(/{{([^}]+)}}/g, (c, a) => {
|
|
391
|
+
const i = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
392
|
+
if (!i)
|
|
393
|
+
return c;
|
|
394
|
+
const [, n, e, l] = i, u = V[n];
|
|
395
|
+
if (!u)
|
|
396
|
+
return console.warn(`Unknown variable prefix: ${n}`), c;
|
|
397
|
+
const s = x[e];
|
|
398
|
+
if (!s)
|
|
399
|
+
return console.warn(`Unknown variable suffix mapping for: ${e}`), c;
|
|
400
|
+
const { pairsKey: _, defaultKey: d, isArray: b } = s, y = r[_][u];
|
|
491
401
|
if (!y)
|
|
492
|
-
return console.warn(`No data found for: ${
|
|
402
|
+
return console.warn(`No data found for: ${_}.${u}`), c;
|
|
493
403
|
if (b) {
|
|
494
|
-
const
|
|
495
|
-
return Array.isArray(
|
|
404
|
+
const f = parseInt(l) - 1, m = y[d];
|
|
405
|
+
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), c);
|
|
496
406
|
}
|
|
497
|
-
const
|
|
498
|
-
return
|
|
407
|
+
const A = y[d];
|
|
408
|
+
return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
|
|
499
409
|
});
|
|
500
410
|
}
|
|
501
411
|
}
|
|
502
|
-
function
|
|
503
|
-
return new
|
|
412
|
+
function Q(o) {
|
|
413
|
+
return new H().migrate(o);
|
|
504
414
|
}
|
|
505
415
|
export {
|
|
506
|
-
|
|
416
|
+
Q as migrateItemsBlock
|
|
507
417
|
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { nameMaxWidthFor as h } from "../../constants/cardLayout.js";
|
|
1
|
+
import { ModificationDescription as l, UIElementType as s, UEAttr as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as p } from "../../../common-control.js";
|
|
4
3
|
import { ItemsBlockControlId as a } from "../../enums/controlEnums.js";
|
|
5
|
-
import { findNameTextNode as
|
|
6
|
-
import { getItemsBlockConfig as r, setItemsBlockConfig as
|
|
7
|
-
const
|
|
4
|
+
import { findNameTextNode as T } from "../../utils/nameNode.js";
|
|
5
|
+
import { getItemsBlockConfig as r, setItemsBlockConfig as c } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const g = a.NAME_TRIMMING, i = {
|
|
8
7
|
TRIMMING: "trimming"
|
|
9
8
|
};
|
|
10
|
-
class
|
|
9
|
+
class y extends p {
|
|
11
10
|
getId() {
|
|
12
|
-
return
|
|
11
|
+
return g;
|
|
13
12
|
}
|
|
14
13
|
getTemplate() {
|
|
15
14
|
return `
|
|
@@ -20,39 +19,39 @@ class E extends T {
|
|
|
20
19
|
}
|
|
21
20
|
onRender() {
|
|
22
21
|
const e = r(this.currentNode);
|
|
23
|
-
this.api.updateValues({ [
|
|
22
|
+
this.api.updateValues({ [i.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(i.TRIMMING, (t) => {
|
|
24
23
|
this._onTrimmingChange(t);
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
26
|
onTemplateNodeUpdated(e) {
|
|
28
27
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
29
28
|
const t = r(this.currentNode);
|
|
30
|
-
this.api.updateValues({ [
|
|
29
|
+
this.api.updateValues({ [i.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
|
|
31
30
|
});
|
|
32
31
|
}
|
|
33
32
|
_onTrimmingChange(e) {
|
|
34
|
-
|
|
33
|
+
c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [i.TRIMMING]: e }), this._applyTrimmingStyles(e);
|
|
35
34
|
}
|
|
36
35
|
_applyTrimmingStyles(e) {
|
|
37
|
-
const t =
|
|
36
|
+
const t = T(this.currentNode);
|
|
38
37
|
if (!t)
|
|
39
38
|
return;
|
|
40
|
-
const
|
|
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",
|
|
39
|
+
const n = r(this.currentNode), m = e !== void 0 ? e : (n == null ? void 0 : n.nameTrimming) ?? !0, o = this.api.getDocumentModifier().modifyHtml(t);
|
|
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", "100%").apply(new l(`Text Trimming ${m ? "Enabled" : "Disabled"}`));
|
|
42
41
|
}
|
|
43
42
|
_getTextTrimming() {
|
|
44
43
|
return `
|
|
45
44
|
<div class="display-flex align-items-center justify-content-between">
|
|
46
45
|
<${s.LABEL}
|
|
47
|
-
${
|
|
46
|
+
${d.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
48
47
|
>
|
|
49
48
|
</${s.LABEL}>
|
|
50
|
-
${this._GuToggle(
|
|
49
|
+
${this._GuToggle(i.TRIMMING)}
|
|
51
50
|
</div>
|
|
52
51
|
`;
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
export {
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
g as CONTROL_BLOCK_ID,
|
|
56
|
+
y as NameTrimmingControl
|
|
58
57
|
};
|