@useinsider/guido 3.14.0 → 3.15.0
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/useEmailTemplateApplier.js +46 -32
- package/dist/composables/useHtmlValidator.js +111 -106
- package/dist/config/compiler/itemsCompilerRules.js +25 -4
- package/dist/config/compiler/utils/itemsCompilerUtils.js +28 -0
- package/dist/config/migrator/index.js +9 -8
- package/dist/config/migrator/itemsBlockMigrator.js +47 -45
- package/dist/config/migrator/productNameLinkMigrator.js +27 -0
- package/dist/extensions/Blocks/Items/block.js +30 -30
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +16 -16
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +26 -22
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +36 -35
- package/dist/extensions/Blocks/Items/template.js +228 -263
- package/dist/extensions/Blocks/Items/utils/nameNode.js +4 -0
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +12 -0
- package/dist/src/config/migrator/productNameLinkMigrator.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/utils/nameNode.d.ts +9 -0
- package/dist/src/stores/dynamic-content.d.ts +8 -0
- package/dist/src/utils/registerUsedDynamicContent.d.ts +8 -0
- package/dist/src/utils/unwrapProductNameLink.d.ts +15 -0
- package/dist/stores/dynamic-content.js +12 -2
- package/dist/utils/pairProductVariables.js +75 -72
- package/dist/utils/registerUsedDynamicContent.js +23 -0
- package/dist/utils/unwrapProductNameLink.js +37 -0
- package/package.json +1 -1
|
@@ -88,11 +88,11 @@ function k(o) {
|
|
|
88
88
|
}
|
|
89
89
|
function h(o) {
|
|
90
90
|
var e;
|
|
91
|
-
const t = (
|
|
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
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
93
|
if (n && !n.includes("{{") && /^\d+$/.test(n)) {
|
|
94
|
-
const
|
|
95
|
-
u && u[
|
|
94
|
+
const l = parseInt(n) - 1, u = I[a];
|
|
95
|
+
u && u[l] && (n = u[l].value);
|
|
96
96
|
}
|
|
97
97
|
return {
|
|
98
98
|
initialized: !0,
|
|
@@ -148,7 +148,7 @@ function N(o, t) {
|
|
|
148
148
|
};
|
|
149
149
|
return r[o] || r.CART_ITEMS;
|
|
150
150
|
}
|
|
151
|
-
class
|
|
151
|
+
class H {
|
|
152
152
|
constructor() {
|
|
153
153
|
M(this, "parser");
|
|
154
154
|
this.parser = new DOMParser();
|
|
@@ -159,13 +159,13 @@ class z {
|
|
|
159
159
|
return this.backfillV2ProductTdAttributes(t);
|
|
160
160
|
let r = this.removeJinjaConditionals(t);
|
|
161
161
|
r = this.replaceTemplateVariables(r);
|
|
162
|
-
const
|
|
162
|
+
const c = this.parser.parseFromString(r, "text/html"), a = c.querySelectorAll(
|
|
163
163
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
164
164
|
);
|
|
165
165
|
return q().$patch((n) => {
|
|
166
166
|
n.migrations = { ...n.migrations, [w]: a.length };
|
|
167
167
|
}), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (a.forEach((n) => {
|
|
168
|
-
const e = this.extractConfiguration(n),
|
|
168
|
+
const e = this.extractConfiguration(n), l = F({
|
|
169
169
|
orientation: e.orientation,
|
|
170
170
|
itemsType: e.itemsType,
|
|
171
171
|
itemId: e.itemId,
|
|
@@ -181,7 +181,7 @@ class z {
|
|
|
181
181
|
quantityStyles: e.quantityStyles,
|
|
182
182
|
nodeConfig: h(e.configBlockAttributes)
|
|
183
183
|
}), s = this.parser.parseFromString(
|
|
184
|
-
`<table><tbody><tr>${
|
|
184
|
+
`<table><tbody><tr>${l}</tr></tbody></table>`,
|
|
185
185
|
"text/html"
|
|
186
186
|
).querySelector("td");
|
|
187
187
|
if (s && n.parentNode) {
|
|
@@ -190,7 +190,7 @@ class z {
|
|
|
190
190
|
const d = s.querySelector("esd-config-block");
|
|
191
191
|
d && d.remove(), n.parentNode.replaceChild(s, n);
|
|
192
192
|
}
|
|
193
|
-
}),
|
|
193
|
+
}), c.documentElement.outerHTML);
|
|
194
194
|
} catch (r) {
|
|
195
195
|
return console.error("ItemsBlockMigrator failed:", r), t;
|
|
196
196
|
}
|
|
@@ -205,15 +205,15 @@ class z {
|
|
|
205
205
|
var C, D, P;
|
|
206
206
|
const r = k(
|
|
207
207
|
((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) ?? null
|
|
208
|
-
),
|
|
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
209
|
let S;
|
|
210
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,
|
|
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;
|
|
212
212
|
return {
|
|
213
213
|
orientation: S,
|
|
214
214
|
itemsType: r,
|
|
215
215
|
itemId: n,
|
|
216
|
-
currencySymbol:
|
|
216
|
+
currencySymbol: l,
|
|
217
217
|
currencyLocation: s,
|
|
218
218
|
formattedPrice: _,
|
|
219
219
|
configBlockAttributes: d,
|
|
@@ -231,7 +231,7 @@ class z {
|
|
|
231
231
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
232
232
|
* @param itemNumber - The item number (1-based index)
|
|
233
233
|
*/
|
|
234
|
-
extractConfigBlockAttributes(t, r,
|
|
234
|
+
extractConfigBlockAttributes(t, r, c) {
|
|
235
235
|
const a = t.querySelector("esd-config-block"), i = {};
|
|
236
236
|
if (!a)
|
|
237
237
|
return this.getDefaultConfigBlockAttributes();
|
|
@@ -240,18 +240,18 @@ class z {
|
|
|
240
240
|
}), i["data-cart_items_select_control_value"]) {
|
|
241
241
|
const e = i["data-cart_items_select_control_value"];
|
|
242
242
|
if (/^\d+$/.test(e)) {
|
|
243
|
-
const
|
|
244
|
-
u && u[
|
|
243
|
+
const l = parseInt(e) - 1, u = I[r];
|
|
244
|
+
u && u[l] && (i["data-cart_items_select_control_value"] = u[l].value);
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
if (i["data-product_price_control_curency"]) {
|
|
248
248
|
const e = i["data-product_price_control_curency"];
|
|
249
|
-
let
|
|
250
|
-
e === "before" ?
|
|
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
251
|
}
|
|
252
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
253
|
const n = { ...this.getDefaultConfigBlockAttributes(), ...i };
|
|
254
|
-
return n["data-type"] = r, n["data-source"] = r, n["data-product_image_link"] = $(r,
|
|
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;
|
|
255
255
|
}
|
|
256
256
|
/**
|
|
257
257
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -301,7 +301,7 @@ class z {
|
|
|
301
301
|
};
|
|
302
302
|
}
|
|
303
303
|
/**
|
|
304
|
-
* Backfills data-type (and data-number) onto v2 `.ins-product-td` elements
|
|
304
|
+
* Backfills data-type (and data-number, data-nodup) onto v2 `.ins-product-td` elements
|
|
305
305
|
* from their persisted `esd-ext-config` nodeConfig, and strips the legacy
|
|
306
306
|
* static `width` that older builds baked onto the product-td.
|
|
307
307
|
*
|
|
@@ -326,22 +326,24 @@ class z {
|
|
|
326
326
|
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
327
327
|
return t;
|
|
328
328
|
const r = this.parser.parseFromString(t, "text/html");
|
|
329
|
-
let
|
|
329
|
+
let c = !1;
|
|
330
330
|
return r.querySelectorAll(".ins-product-td").forEach((a) => {
|
|
331
|
-
|
|
332
|
-
return;
|
|
331
|
+
a.hasAttribute("width") && (a.removeAttribute("width"), c = !0);
|
|
333
332
|
const i = a.getAttribute("esd-ext-config");
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
333
|
+
let n = null;
|
|
334
|
+
try {
|
|
335
|
+
n = i ? JSON.parse(i) : null;
|
|
336
|
+
} catch {
|
|
337
|
+
}
|
|
338
|
+
if (!n || (!a.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(n.priceHideDiscount)), c = !0), a.getAttribute("data-type")))
|
|
339
|
+
return;
|
|
340
|
+
const e = n.type || n.source;
|
|
341
|
+
if (!e)
|
|
342
|
+
return;
|
|
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;
|
|
345
347
|
}
|
|
346
348
|
/**
|
|
347
349
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
@@ -362,15 +364,15 @@ class z {
|
|
|
362
364
|
* contains display condition Jinja scripts that should NOT be removed.
|
|
363
365
|
*/
|
|
364
366
|
removeJinjaConditionals(t) {
|
|
365
|
-
const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__",
|
|
366
|
-
let a =
|
|
367
|
+
const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", c = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
368
|
+
let a = c ? t.replace(c[0], r) : t;
|
|
367
369
|
return a = a.replace(
|
|
368
370
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
369
371
|
""
|
|
370
372
|
), a = a.replace(
|
|
371
373
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
372
374
|
""
|
|
373
|
-
), a = a.replace(/\{%\s*endif\s*%\}/g, ""),
|
|
375
|
+
), a = a.replace(/\{%\s*endif\s*%\}/g, ""), c && (a = a.replace(r, c[0])), a = a.replace(/\n\s*\n\s*\n/g, `
|
|
374
376
|
|
|
375
377
|
`), a;
|
|
376
378
|
}
|
|
@@ -385,30 +387,30 @@ class z {
|
|
|
385
387
|
*/
|
|
386
388
|
replaceTemplateVariables(t) {
|
|
387
389
|
const { PAIRS_FOR_EXTENSION: r } = K;
|
|
388
|
-
return t.replace(/{{([^}]+)}}/g, (
|
|
390
|
+
return t.replace(/{{([^}]+)}}/g, (c, a) => {
|
|
389
391
|
const i = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
390
392
|
if (!i)
|
|
391
|
-
return
|
|
392
|
-
const [, n, e,
|
|
393
|
+
return c;
|
|
394
|
+
const [, n, e, l] = i, u = V[n];
|
|
393
395
|
if (!u)
|
|
394
|
-
return console.warn(`Unknown variable prefix: ${n}`),
|
|
396
|
+
return console.warn(`Unknown variable prefix: ${n}`), c;
|
|
395
397
|
const s = x[e];
|
|
396
398
|
if (!s)
|
|
397
|
-
return console.warn(`Unknown variable suffix mapping for: ${e}`),
|
|
399
|
+
return console.warn(`Unknown variable suffix mapping for: ${e}`), c;
|
|
398
400
|
const { pairsKey: _, defaultKey: d, isArray: b } = s, y = r[_][u];
|
|
399
401
|
if (!y)
|
|
400
|
-
return console.warn(`No data found for: ${_}.${u}`),
|
|
402
|
+
return console.warn(`No data found for: ${_}.${u}`), c;
|
|
401
403
|
if (b) {
|
|
402
|
-
const f = parseInt(
|
|
403
|
-
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`),
|
|
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);
|
|
404
406
|
}
|
|
405
407
|
const A = y[d];
|
|
406
|
-
return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`),
|
|
408
|
+
return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
|
|
407
409
|
});
|
|
408
410
|
}
|
|
409
411
|
}
|
|
410
412
|
function Q(o) {
|
|
411
|
-
return new
|
|
413
|
+
return new H().migrate(o);
|
|
412
414
|
}
|
|
413
415
|
export {
|
|
414
416
|
Q as migrateItemsBlock
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var n = Object.defineProperty;
|
|
2
|
+
var a = (e, r, t) => r in e ? n(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var o = (e, r, t) => a(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { unwrapProductNameLinks as i } from "../../utils/unwrapProductNameLink.js";
|
|
5
|
+
const c = /<a[^>]*product-attr="name"/i;
|
|
6
|
+
class s {
|
|
7
|
+
constructor() {
|
|
8
|
+
o(this, "parser");
|
|
9
|
+
this.parser = new DOMParser();
|
|
10
|
+
}
|
|
11
|
+
migrate(r) {
|
|
12
|
+
try {
|
|
13
|
+
if (!r.includes("items-block-v2") || !c.test(r))
|
|
14
|
+
return r;
|
|
15
|
+
const t = this.parser.parseFromString(r, "text/html");
|
|
16
|
+
return i(t), t.documentElement.outerHTML;
|
|
17
|
+
} catch (t) {
|
|
18
|
+
return console.error("ProductNameLinkMigrator failed:", t), r;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function d(e) {
|
|
23
|
+
return new s().migrate(e);
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
d as migrateProductNameLink
|
|
27
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { BlockId as
|
|
2
|
-
import { useOnboardingStore as
|
|
1
|
+
import { BlockId as f } from "../../../enums/block.js";
|
|
2
|
+
import { useOnboardingStore as g } from "../../../stores/onboarding.js";
|
|
3
3
|
import { getMigrationBannerHtml as y } from "../../../utils/migrationBannerHtml.js";
|
|
4
4
|
import { Block as I, BlockCompositionType as C, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
-
import { SETTINGS_ENUMS as
|
|
5
|
+
import { SETTINGS_ENUMS as d, DefaultConfigValues as m } from "./enums/settingsEnums.js";
|
|
6
6
|
import { getDefaultTemplate as b } from "./template.js";
|
|
7
|
-
import { getItemsBlockContainer as
|
|
8
|
-
const
|
|
9
|
-
class
|
|
7
|
+
import { getItemsBlockContainer as l, getItemsBlockConfig as u, deriveItemNumber as h, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
|
|
8
|
+
const p = f.Items;
|
|
9
|
+
class O extends I {
|
|
10
10
|
getId() {
|
|
11
|
-
return
|
|
11
|
+
return p;
|
|
12
12
|
}
|
|
13
13
|
getIcon() {
|
|
14
14
|
return "items-icon";
|
|
@@ -24,15 +24,15 @@ class P extends I {
|
|
|
24
24
|
}
|
|
25
25
|
getSettingsPanelTitleHtml() {
|
|
26
26
|
return y(
|
|
27
|
-
|
|
27
|
+
p,
|
|
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
33
|
return b({
|
|
34
|
-
orientation:
|
|
35
|
-
itemsType:
|
|
34
|
+
orientation: d.ORIENTATION.VERTICAL,
|
|
35
|
+
itemsType: d.ITEMS_TYPE.CART_ITEMS,
|
|
36
36
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
37
37
|
currencySymbol: m.productPriceCurrencySymbolControlValue,
|
|
38
38
|
currencyLocation: m.productPriceCurrencyLocationControlValue,
|
|
@@ -45,23 +45,23 @@ class P extends I {
|
|
|
45
45
|
canBeSavedAsModule() {
|
|
46
46
|
return !0;
|
|
47
47
|
}
|
|
48
|
-
onCreated(
|
|
49
|
-
const t = this.api.getDocumentModifier(),
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
48
|
+
onCreated(e) {
|
|
49
|
+
const t = this.api.getDocumentModifier(), o = this.api.getDocumentRootCssNode();
|
|
50
|
+
o.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(o).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
51
|
+
const i = l(e);
|
|
52
|
+
if (!i)
|
|
53
53
|
return;
|
|
54
|
-
const r =
|
|
54
|
+
const r = i.getNodeConfig(), s = r && Object.keys(r).length > 0, n = u(e);
|
|
55
55
|
if (n != null && n.initialized)
|
|
56
56
|
if (s)
|
|
57
|
-
n.blockInstanceId || this.api.getDocumentModifier().modifyHtml(
|
|
57
|
+
n.blockInstanceId || this.api.getDocumentModifier().modifyHtml(i).setNodeConfig({ ...n, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
|
|
58
58
|
else {
|
|
59
59
|
const a = this.api.getDocumentModifier();
|
|
60
|
-
a.modifyHtml(
|
|
60
|
+
a.modifyHtml(i).setNodeConfig(n), this._stampProductTdDomAttributes(i, n, a), a.apply(new c("Migrate legacy config to nodeConfig"));
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
63
|
const a = N();
|
|
64
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
64
|
+
this.api.getDocumentModifier().modifyHtml(i).setNodeConfig(a).apply(new c("Initialize Items block with default configuration")), g().startOnboarding("itemsOnboarding");
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
@@ -70,33 +70,33 @@ class P extends I {
|
|
|
70
70
|
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
71
71
|
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
72
72
|
*/
|
|
73
|
-
onDocumentChanged(
|
|
74
|
-
const t =
|
|
73
|
+
onDocumentChanged(e) {
|
|
74
|
+
const t = l(e);
|
|
75
75
|
if (!t)
|
|
76
76
|
return;
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
77
|
+
const o = t.getNodeConfig();
|
|
78
|
+
if (o && Object.keys(o).length > 0)
|
|
79
79
|
return;
|
|
80
|
-
const r = u(
|
|
80
|
+
const r = u(e);
|
|
81
81
|
if (!(r != null && r.initialized))
|
|
82
82
|
return;
|
|
83
83
|
const s = this.api.getDocumentModifier();
|
|
84
84
|
s.modifyHtml(t).setNodeConfig(r), this._stampProductTdDomAttributes(t, r, s), s.apply(new c("Recover Items block config from saved module"));
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
|
-
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`) onto the
|
|
87
|
+
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
|
|
88
88
|
* `.ins-product-td` container from the recovered config. Required for saved modules:
|
|
89
89
|
* `migrate()` (which backfills these) only runs at template load — never when a module
|
|
90
90
|
* is dropped into a live editor — so this is the one place the namespace + index get
|
|
91
91
|
* restored before export. The name `<a>` carries no data-type/data-number of its own and
|
|
92
92
|
* relies on this td-level fallback in pairProductVariables.
|
|
93
93
|
*/
|
|
94
|
-
_stampProductTdDomAttributes(
|
|
95
|
-
const
|
|
96
|
-
|
|
94
|
+
_stampProductTdDomAttributes(e, t, o) {
|
|
95
|
+
const i = h(t.itemsSelectValue, t.type);
|
|
96
|
+
o.modifyHtml(e).setAttribute("data-type", t.type), o.modifyHtml(e).setAttribute("data-number", i), o.modifyHtml(e).setAttribute("data-nodup", String(t.priceHideDiscount));
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
p as BLOCK_ID,
|
|
101
|
+
O as ItemsBlock
|
|
102
102
|
};
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import {
|
|
5
|
-
|
|
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";
|
|
3
|
+
import { ItemsBlockControlId as a } from "../../enums/controlEnums.js";
|
|
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 = {
|
|
6
7
|
TRIMMING: "trimming"
|
|
7
8
|
};
|
|
8
|
-
class y extends
|
|
9
|
+
class y extends p {
|
|
9
10
|
getId() {
|
|
10
11
|
return g;
|
|
11
12
|
}
|
|
12
13
|
getTemplate() {
|
|
13
14
|
return `
|
|
14
|
-
<div class="container ${
|
|
15
|
+
<div class="container ${a.NAME_TRIMMING}">
|
|
15
16
|
${this._getTextTrimming()}
|
|
16
17
|
</div>
|
|
17
18
|
`;
|
|
18
19
|
}
|
|
19
20
|
onRender() {
|
|
20
|
-
const e =
|
|
21
|
+
const e = r(this.currentNode);
|
|
21
22
|
this.api.updateValues({ [i.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(i.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
|
+
const t = r(this.currentNode);
|
|
28
29
|
this.api.updateValues({ [i.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
|
|
29
30
|
});
|
|
30
31
|
}
|
|
@@ -32,20 +33,19 @@ class y extends T {
|
|
|
32
33
|
c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [i.TRIMMING]: e }), this._applyTrimmingStyles(e);
|
|
33
34
|
}
|
|
34
35
|
_applyTrimmingStyles(e) {
|
|
35
|
-
|
|
36
|
-
const t = (m = this.currentNode) == null ? void 0 : m.querySelector("p > a");
|
|
36
|
+
const t = T(this.currentNode);
|
|
37
37
|
if (!t)
|
|
38
38
|
return;
|
|
39
|
-
const n =
|
|
40
|
-
|
|
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"}`));
|
|
41
41
|
}
|
|
42
42
|
_getTextTrimming() {
|
|
43
43
|
return `
|
|
44
44
|
<div class="display-flex align-items-center justify-content-between">
|
|
45
|
-
<${
|
|
46
|
-
${
|
|
45
|
+
<${s.LABEL}
|
|
46
|
+
${d.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
47
47
|
>
|
|
48
|
-
</${
|
|
48
|
+
</${s.LABEL}>
|
|
49
49
|
${this._GuToggle(i.TRIMMING)}
|
|
50
50
|
</div>
|
|
51
51
|
`;
|
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
import { UIElementType as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import { getItemsBlockConfig as
|
|
5
|
-
const
|
|
1
|
+
import { ModificationDescription as c, UIElementType as s, UEAttr as a } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as p } from "../../../common-control.js";
|
|
3
|
+
import { ItemsBlockControlId as r } from "../../enums/controlEnums.js";
|
|
4
|
+
import { getItemsBlockConfig as d, setItemsBlockConfig as u } from "../../utils/nodeConfigUtils.js";
|
|
5
|
+
const D = r.PRICE_HIDE_DISCOUNT, i = {
|
|
6
6
|
HIDE_DISCOUNT: "hideDiscount"
|
|
7
7
|
};
|
|
8
|
-
class
|
|
8
|
+
class E extends p {
|
|
9
9
|
getId() {
|
|
10
|
-
return
|
|
10
|
+
return D;
|
|
11
11
|
}
|
|
12
12
|
getTemplate() {
|
|
13
13
|
return `
|
|
14
|
-
<div class="container ${
|
|
14
|
+
<div class="container ${r.PRICE_HIDE_DISCOUNT}">
|
|
15
15
|
${this._getHideDiscount()}
|
|
16
16
|
</div>
|
|
17
17
|
`;
|
|
18
18
|
}
|
|
19
19
|
onRender() {
|
|
20
|
-
const
|
|
21
|
-
this.api.updateValues({ [i.HIDE_DISCOUNT]: (
|
|
22
|
-
this._onHideDiscountChange(
|
|
20
|
+
const t = d(this.currentNode);
|
|
21
|
+
this.api.updateValues({ [i.HIDE_DISCOUNT]: (t == null ? void 0 : t.priceHideDiscount) ?? !0 }), this.api.onValueChanged(i.HIDE_DISCOUNT, (e) => {
|
|
22
|
+
this._onHideDiscountChange(e);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
onTemplateNodeUpdated(
|
|
26
|
-
super.onTemplateNodeUpdated(
|
|
27
|
-
const
|
|
28
|
-
this.api.updateValues({ [i.HIDE_DISCOUNT]: (
|
|
25
|
+
onTemplateNodeUpdated(t) {
|
|
26
|
+
super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
|
|
27
|
+
const e = d(this.currentNode);
|
|
28
|
+
this.api.updateValues({ [i.HIDE_DISCOUNT]: (e == null ? void 0 : e.priceHideDiscount) ?? !0 });
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
_onHideDiscountChange(
|
|
32
|
-
|
|
31
|
+
_onHideDiscountChange(t) {
|
|
32
|
+
var n;
|
|
33
|
+
const e = this.api.getDocumentModifier();
|
|
34
|
+
u(this.currentNode, this.api, { priceHideDiscount: t }, e);
|
|
35
|
+
const o = (n = this.currentNode) == null ? void 0 : n.closest(".ins-product-td");
|
|
36
|
+
o && e.modifyHtml(o).setAttribute("data-nodup", String(t)), e.apply(new c("Update hide-discount setting")), this.api.updateValues({ [i.HIDE_DISCOUNT]: t });
|
|
33
37
|
}
|
|
34
38
|
_getHideDiscount() {
|
|
35
39
|
return `
|
|
36
40
|
<div class="display-flex align-items-center justify-content-between">
|
|
37
|
-
<${
|
|
38
|
-
${
|
|
41
|
+
<${s.LABEL}
|
|
42
|
+
${a.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
|
|
39
43
|
>
|
|
40
|
-
</${
|
|
44
|
+
</${s.LABEL}>
|
|
41
45
|
${this._GuToggle(i.HIDE_DISCOUNT)}
|
|
42
46
|
</div>
|
|
43
47
|
</div>
|
|
@@ -45,6 +49,6 @@ class C extends r {
|
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
D as CONTROL_BLOCK_ID,
|
|
53
|
+
E as PriceHideDiscountControl
|
|
50
54
|
};
|