@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
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
1
|
+
import { ModificationDescription as S, UEAttr as L } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { CommonControl as k } from "../../common-control.js";
|
|
3
3
|
import { ItemsBlockId as I } from "../enums/controlEnums.js";
|
|
4
|
-
import { productPairs as
|
|
4
|
+
import { productPairs as y, templateFirstLine as D } from "../enums/productEnums.js";
|
|
5
5
|
import { SETTINGS_ENUMS as d, ItemTypeOptions as x, OrientationOptions as F, ItemInCartOptions as O, DefaultConfigValues as H } from "../enums/settingsEnums.js";
|
|
6
6
|
import $ from "../layouts/horizontal.html.js";
|
|
7
|
-
import
|
|
8
|
-
import { getDefaultTemplate as
|
|
9
|
-
import {
|
|
10
|
-
|
|
7
|
+
import w from "../layouts/vertical.html.js";
|
|
8
|
+
import { getDefaultTemplate as q, wrapInTableRow as C } from "../template.js";
|
|
9
|
+
import { findNameTextNode as V } from "../utils/nameNode.js";
|
|
10
|
+
import { getItemsBlockConfig as _, setItemsBlockConfig as M, escapeReplacement as g, deriveItemNumber as B } from "../utils/nodeConfigUtils.js";
|
|
11
|
+
const G = "ui-elements-items-block", m = {
|
|
11
12
|
ITEMS_TYPE: "itemsType",
|
|
12
13
|
ORIENTATION: "orientation",
|
|
13
14
|
ITEM_IDS: "itemIds"
|
|
14
15
|
};
|
|
15
|
-
class
|
|
16
|
+
class te extends k {
|
|
16
17
|
getId() {
|
|
17
|
-
return
|
|
18
|
+
return G;
|
|
18
19
|
}
|
|
19
20
|
getTemplate() {
|
|
20
21
|
return `
|
|
@@ -86,7 +87,7 @@ class Z extends k {
|
|
|
86
87
|
M(this.currentNode, this.api, {
|
|
87
88
|
orientation: e,
|
|
88
89
|
priceOrientation: "horizontal"
|
|
89
|
-
}, r), r.apply(new
|
|
90
|
+
}, r), r.apply(new S("Changed orientation")), this._reOrderTemplate(), setTimeout(() => {
|
|
90
91
|
this._recalculateTrimming();
|
|
91
92
|
}, 50);
|
|
92
93
|
}
|
|
@@ -103,7 +104,7 @@ class Z extends k {
|
|
|
103
104
|
buttonLink: n
|
|
104
105
|
}, o), this._updateDataTypeAttributes(r, o), this._initializeSelectItems();
|
|
105
106
|
const c = this._getTemplateData(r, i.value);
|
|
106
|
-
this._updateImageSrc(c.imageSrc, o), this._updateName(c.name, o), this._updatePrice(c.price, o), this._updateOriginalPrice(c.originalPrice, o), this._updateQuantity(c.quantity, r, o), o.apply(new
|
|
107
|
+
this._updateImageSrc(c.imageSrc, o), this._updateName(c.name, o), this._updatePrice(c.price, o), this._updateOriginalPrice(c.originalPrice, o), this._updateQuantity(c.quantity, r, o), o.apply(new S("Updated items type"));
|
|
107
108
|
}
|
|
108
109
|
_onItemIdsChange(e) {
|
|
109
110
|
this.api.updateValues({ [m.ITEM_IDS]: e });
|
|
@@ -114,7 +115,7 @@ class Z extends k {
|
|
|
114
115
|
buttonLink: r
|
|
115
116
|
}, i), this._updateDataNumberAttributes(e, i);
|
|
116
117
|
const n = this._getTemplateData(void 0, e);
|
|
117
|
-
this._updateImageSrc(n.imageSrc, i), this._updateName(n.name, i), this._updatePrice(n.price, i), this._updateOriginalPrice(n.originalPrice, i), this._updateQuantity(n.quantity, void 0, i), i.apply(new
|
|
118
|
+
this._updateImageSrc(n.imageSrc, i), this._updateName(n.name, i), this._updatePrice(n.price, i), this._updateOriginalPrice(n.originalPrice, i), this._updateQuantity(n.quantity, void 0, i), i.apply(new S("Updated item selection"));
|
|
118
119
|
}
|
|
119
120
|
_initializeSelectItems() {
|
|
120
121
|
this.api.setUIEAttribute(
|
|
@@ -149,25 +150,25 @@ class Z extends k {
|
|
|
149
150
|
}
|
|
150
151
|
_renderTemplate() {
|
|
151
152
|
const e = _(this.currentNode), r = (e == null ? void 0 : e.orientation) ?? d.ORIENTATION.VERTICAL, t = (e == null ? void 0 : e.type) ?? d.ITEMS_TYPE.CART_ITEMS, i = (e == null ? void 0 : e.itemsSelectValue) ?? "", n = (e == null ? void 0 : e.priceCurrencySymbol) ?? "", s = (e == null ? void 0 : e.priceCurrencyLocation) ?? "0", o = (e == null ? void 0 : e.priceFormatted) ?? !1;
|
|
152
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(
|
|
153
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(q({
|
|
153
154
|
orientation: r,
|
|
154
155
|
itemsType: t,
|
|
155
156
|
itemId: i,
|
|
156
157
|
currencySymbol: n,
|
|
157
158
|
currencyLocation: s,
|
|
158
159
|
formattedPrice: o
|
|
159
|
-
})).apply(new
|
|
160
|
+
})).apply(new S("Updated template"));
|
|
160
161
|
}
|
|
161
162
|
_getTemplateData(e, r) {
|
|
162
|
-
const t = _(this.currentNode), i = e ?? (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n = r ?? (t == null ? void 0 : t.itemsSelectValue) ?? "", s = (t == null ? void 0 : t.priceFormatted) ?? !1, o = (t == null ? void 0 : t.priceSinglePrice) ?? !1, c = O[i].findIndex((h) => h.value === n), a = c > -1 ? c : 0, l =
|
|
163
|
+
const t = _(this.currentNode), i = e ?? (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n = r ?? (t == null ? void 0 : t.itemsSelectValue) ?? "", s = (t == null ? void 0 : t.priceFormatted) ?? !1, o = (t == null ? void 0 : t.priceSinglePrice) ?? !1, c = O[i].findIndex((h) => h.value === n), a = c > -1 ? c : 0, l = y.PAIRS_FOR_EXTENSION.price[i], T = y.PAIRS_FOR_EXTENSION.originalPrice[i];
|
|
163
164
|
let u, p;
|
|
164
165
|
return o ? (u = s ? l.DEFAULT_SINGLE_PRICE_FORMATTED : l.DEFAULT_SINGLE_PRICE, p = s ? T.DEFAULT_SINGLE_PRICE_FORMATTED : T.DEFAULT_SINGLE_PRICE) : (u = s ? l.DEFAULT_PRICE_FORMATTED : l.DEFAULT_PRICE, p = s ? T.DEFAULT_PRICE_FORMATTED : T.DEFAULT_PRICE), {
|
|
165
|
-
imageSrc:
|
|
166
|
-
name:
|
|
166
|
+
imageSrc: y.PAIRS_FOR_EXTENSION.imageSrc[i].DEFAULT[a],
|
|
167
|
+
name: y.PAIRS_FOR_EXTENSION.name[i].DEFAULT[a],
|
|
167
168
|
price: u,
|
|
168
169
|
originalPrice: p,
|
|
169
|
-
quantity:
|
|
170
|
-
button:
|
|
170
|
+
quantity: y.PAIRS_FOR_EXTENSION.quantity[i].DEFAULT,
|
|
171
|
+
button: y.PAIRS_FOR_EXTENSION.button[i].DEFAULT_LABEL
|
|
171
172
|
};
|
|
172
173
|
}
|
|
173
174
|
_updateImageSrc(e, r) {
|
|
@@ -193,8 +194,8 @@ class Z extends k {
|
|
|
193
194
|
const a = this._getParagraphFromBlock(c);
|
|
194
195
|
if (!a)
|
|
195
196
|
return;
|
|
196
|
-
const l = a.getInnerHTML().trim() || "", T = a.getInnerText().trim() || "", u = (n == null ? void 0 : n.trim()) || "", p = this._removeCurrencySymbol(T, u), h = this._replacePriceNumber(p, e), E = this._buildPriceContent(h, u, s),
|
|
197
|
-
r.modifyHtml(a).setInnerHtml(
|
|
197
|
+
const l = a.getInnerHTML().trim() || "", T = a.getInnerText().trim() || "", u = (n == null ? void 0 : n.trim()) || "", p = this._removeCurrencySymbol(T, u), h = this._replacePriceNumber(p, e), E = this._buildPriceContent(h, u, s), N = l.replace(T, g(E));
|
|
198
|
+
r.modifyHtml(a).setInnerHtml(N);
|
|
198
199
|
});
|
|
199
200
|
}
|
|
200
201
|
_updateOriginalPrice(e, r) {
|
|
@@ -209,7 +210,7 @@ class Z extends k {
|
|
|
209
210
|
const l = a.querySelector("s");
|
|
210
211
|
if (!l)
|
|
211
212
|
return;
|
|
212
|
-
const T = l.getInnerHTML().trim() || "", u = l.getInnerText().trim() || "", p = (n == null ? void 0 : n.trim()) || "", h = this._removeCurrencySymbol(u, p), E = this._replacePriceNumber(h, e),
|
|
213
|
+
const T = l.getInnerHTML().trim() || "", u = l.getInnerText().trim() || "", p = (n == null ? void 0 : n.trim()) || "", h = this._removeCurrencySymbol(u, p), E = this._replacePriceNumber(h, e), N = this._buildPriceContent(E, p, s), R = `<s>${T.replace(u, g(N))}</s>`;
|
|
213
214
|
r.modifyHtml(a).setInnerHtml(R);
|
|
214
215
|
});
|
|
215
216
|
}
|
|
@@ -223,17 +224,17 @@ class Z extends k {
|
|
|
223
224
|
return;
|
|
224
225
|
const T = l.getInnerText().trim();
|
|
225
226
|
let u = l.getInnerHTML().trim();
|
|
226
|
-
function p(E,
|
|
227
|
+
function p(E, N, A) {
|
|
227
228
|
return E.replace(
|
|
228
|
-
new RegExp(`(>\\s*)?${
|
|
229
|
+
new RegExp(`(>\\s*)?${N}(\\s*<)?`, "g"),
|
|
229
230
|
`$1${A}$2`
|
|
230
231
|
);
|
|
231
232
|
}
|
|
232
233
|
u = p(u, T, e), t.modifyHtml(l).setInnerHtml(u), t.modifyHtml(a).setStyle("display", c ? "table-cell" : "none");
|
|
233
234
|
}
|
|
234
235
|
_reOrderTemplate(e) {
|
|
235
|
-
var h, E,
|
|
236
|
-
const r = (h = this.currentNode) == null ? void 0 : h.querySelector(`[esd-extension-block-id="${I.IMAGE}"]`), t = (E = this.currentNode) == null ? void 0 : E.querySelector(`[esd-extension-block-id="${I.NAME}"]`), i = ((
|
|
236
|
+
var h, E, N, A, R, b;
|
|
237
|
+
const r = (h = this.currentNode) == null ? void 0 : h.querySelector(`[esd-extension-block-id="${I.IMAGE}"]`), t = (E = this.currentNode) == null ? void 0 : E.querySelector(`[esd-extension-block-id="${I.NAME}"]`), i = ((N = this.currentNode) == null ? void 0 : N.querySelectorAll(
|
|
237
238
|
`[esd-extension-block-id="${I.PRICE}"]`
|
|
238
239
|
)) || [], n = ((A = this.currentNode) == null ? void 0 : A.querySelectorAll(
|
|
239
240
|
`[esd-extension-block-id="${I.ORIGINAL_PRICE}"]`
|
|
@@ -241,12 +242,12 @@ class Z extends k {
|
|
|
241
242
|
if (!r || !t || !s || !o || !c || !a)
|
|
242
243
|
return;
|
|
243
244
|
const l = _(this.currentNode), u = ((l == null ? void 0 : l.orientation) ?? d.ORIENTATION.VERTICAL) === d.ORIENTATION.VERTICAL;
|
|
244
|
-
let p = u ?
|
|
245
|
+
let p = u ? w : $;
|
|
245
246
|
setTimeout(() => {
|
|
246
|
-
const
|
|
247
|
-
p = p.replace("{-{-TEMPLATE_FIRST_LINE-}-}", u ? D : "").replace("{-{-PRODUCT_IMAGE-}-}", C(r.getOuterHTML())).replace("{-{-PRODUCT_NAME-}-}", C(t.getOuterHTML())).replaceAll("{-{-PRODUCT_PRICE-}-}", C(
|
|
247
|
+
const f = g(s.getOuterHTML()), U = g(o.getOuterHTML());
|
|
248
|
+
p = p.replace("{-{-TEMPLATE_FIRST_LINE-}-}", u ? D : "").replace("{-{-PRODUCT_IMAGE-}-}", C(r.getOuterHTML())).replace("{-{-PRODUCT_NAME-}-}", C(t.getOuterHTML())).replaceAll("{-{-PRODUCT_PRICE-}-}", C(f)).replaceAll("{-{-PRODUCT_ORIGINAL_PRICE-}-}", C(U)).replace("{-{-PRODUCT_QUANTITY-}-}", C(c.getOuterHTML())).replace("{-{-PRODUCT_BUTTON-}-}", C(a.getOuterHTML())), p = p.trim().replace(D, "").slice(0, -5);
|
|
248
249
|
const P = e ?? this.api.getDocumentModifier();
|
|
249
|
-
P.modifyHtml(r.querySelector("img")).setAttribute("width", H.productImageWidth).setAttribute("height", H.productImageWidth), P.modifyHtml(this.currentNode).setInnerHtml(p), e || P.apply(new
|
|
250
|
+
P.modifyHtml(r.querySelector("img")).setAttribute("width", H.productImageWidth).setAttribute("height", H.productImageWidth), P.modifyHtml(this.currentNode).setInnerHtml(p), e || P.apply(new S("Reordered template"));
|
|
250
251
|
}, 50);
|
|
251
252
|
}
|
|
252
253
|
_updateDataTypeAttributes(e, r) {
|
|
@@ -261,7 +262,7 @@ class Z extends k {
|
|
|
261
262
|
_updateDataNumberAttributes(e, r) {
|
|
262
263
|
if (!this.currentNode)
|
|
263
264
|
return;
|
|
264
|
-
const t = _(this.currentNode), i = (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n =
|
|
265
|
+
const t = _(this.currentNode), i = (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n = B(e, i), s = this.currentNode.closest(".ins-product-td");
|
|
265
266
|
s && r.modifyHtml(s).setAttribute("data-number", n), this.currentNode.querySelectorAll("[data-number]").forEach((c) => {
|
|
266
267
|
const a = c;
|
|
267
268
|
r.modifyHtml(a).setAttribute("data-number", n);
|
|
@@ -269,7 +270,7 @@ class Z extends k {
|
|
|
269
270
|
}
|
|
270
271
|
_reFillTemplate(e) {
|
|
271
272
|
const r = this._getTemplateData(e), t = this.api.getDocumentModifier();
|
|
272
|
-
this._updateImageSrc(r.imageSrc, t), this._updateName(r.name, t), this._updatePrice(r.price, t), this._updateOriginalPrice(r.originalPrice, t), this._updateQuantity(r.quantity, e, t), t.apply(new
|
|
273
|
+
this._updateImageSrc(r.imageSrc, t), this._updateName(r.name, t), this._updatePrice(r.price, t), this._updateOriginalPrice(r.originalPrice, t), this._updateQuantity(r.quantity, e, t), t.apply(new S("Refilled template"));
|
|
273
274
|
}
|
|
274
275
|
_recalculateTrimming() {
|
|
275
276
|
var n;
|
|
@@ -278,11 +279,11 @@ class Z extends k {
|
|
|
278
279
|
const e = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${I.NAME}"]`);
|
|
279
280
|
if (!e)
|
|
280
281
|
return;
|
|
281
|
-
const r = e
|
|
282
|
+
const r = V(e);
|
|
282
283
|
if (!r)
|
|
283
284
|
return;
|
|
284
285
|
const t = _(this.currentNode), i = (t == null ? void 0 : t.nameTrimming) ?? !0;
|
|
285
|
-
this.api.getDocumentModifier().modifyHtml(r).setStyle("overflow", "hidden").setStyle("white-space", i ? "nowrap" : "normal").setStyle("text-overflow", i ? "ellipsis" : "unset").setStyle("max-width", "100%").setStyle("width", "100%").apply(new
|
|
286
|
+
this.api.getDocumentModifier().modifyHtml(r).setStyle("overflow", "hidden").setStyle("white-space", i ? "nowrap" : "normal").setStyle("text-overflow", i ? "ellipsis" : "unset").setStyle("max-width", "100%").setStyle("width", "100%").apply(new S("Recalculated trimming after orientation change"));
|
|
286
287
|
}
|
|
287
288
|
_getParagraphFromBlock(e) {
|
|
288
289
|
return e.querySelector("p");
|
|
@@ -314,6 +315,6 @@ class Z extends k {
|
|
|
314
315
|
}
|
|
315
316
|
}
|
|
316
317
|
export {
|
|
317
|
-
|
|
318
|
-
|
|
318
|
+
G as CONTROL_BLOCK_ID,
|
|
319
|
+
te as ItemsBlockControl
|
|
319
320
|
};
|