@useinsider/guido 3.14.0-beta.38ef0be → 3.14.0-beta.5d003b0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composables/useHtmlValidator.js +106 -111
- package/dist/config/compiler/itemsCompilerRules.js +4 -25
- package/dist/config/migrator/index.js +8 -9
- package/dist/config/migrator/itemsBlockMigrator.js +45 -47
- 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 +22 -26
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +35 -36
- package/dist/extensions/Blocks/Items/template.js +263 -228
- package/dist/src/extensions/Blocks/Items/block.d.ts +1 -1
- package/dist/utils/pairProductVariables.js +72 -75
- package/package.json +1 -1
- package/dist/config/compiler/utils/itemsCompilerUtils.js +0 -28
- package/dist/config/migrator/productNameLinkMigrator.js +0 -27
- package/dist/extensions/Blocks/Items/utils/nameNode.js +0 -4
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +0 -12
- package/dist/src/config/migrator/productNameLinkMigrator.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/utils/nameNode.d.ts +0 -9
- package/dist/src/utils/unwrapProductNameLink.d.ts +0 -15
- package/dist/utils/unwrapProductNameLink.js +0 -37
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { BlockId as
|
|
2
|
-
import { useOnboardingStore as
|
|
1
|
+
import { BlockId as g } from "../../../enums/block.js";
|
|
2
|
+
import { useOnboardingStore as p } 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 l, 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 d, getItemsBlockConfig as u, deriveItemNumber as h, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
|
|
8
|
+
const f = g.Items;
|
|
9
|
+
class P extends I {
|
|
10
10
|
getId() {
|
|
11
|
-
return
|
|
11
|
+
return f;
|
|
12
12
|
}
|
|
13
13
|
getIcon() {
|
|
14
14
|
return "items-icon";
|
|
@@ -24,15 +24,15 @@ class O extends I {
|
|
|
24
24
|
}
|
|
25
25
|
getSettingsPanelTitleHtml() {
|
|
26
26
|
return y(
|
|
27
|
-
|
|
27
|
+
f,
|
|
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: l.ORIENTATION.VERTICAL,
|
|
35
|
+
itemsType: l.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 O 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(o) {
|
|
49
|
+
const t = this.api.getDocumentModifier(), i = this.api.getDocumentRootCssNode();
|
|
50
|
+
i.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(i).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
51
|
+
const e = d(o);
|
|
52
|
+
if (!e)
|
|
53
53
|
return;
|
|
54
|
-
const r =
|
|
54
|
+
const r = e.getNodeConfig(), s = r && Object.keys(r).length > 0, n = u(o);
|
|
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(e).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(e).setNodeConfig(n), this._stampProductTdDomAttributes(e, 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(e).setNodeConfig(a).apply(new c("Initialize Items block with default configuration")), p().startOnboarding("itemsOnboarding");
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
@@ -70,33 +70,33 @@ class O 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(o) {
|
|
74
|
+
const t = d(o);
|
|
75
75
|
if (!t)
|
|
76
76
|
return;
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
77
|
+
const i = t.getNodeConfig();
|
|
78
|
+
if (i && Object.keys(i).length > 0)
|
|
79
79
|
return;
|
|
80
|
-
const r = u(
|
|
80
|
+
const r = u(o);
|
|
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
|
|
87
|
+
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`) 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(o, t, i) {
|
|
95
|
+
const e = h(t.itemsSelectValue, t.type);
|
|
96
|
+
i.modifyHtml(o).setAttribute("data-type", t.type), i.modifyHtml(o).setAttribute("data-number", e);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
f as BLOCK_ID,
|
|
101
|
+
P as ItemsBlock
|
|
102
102
|
};
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const g = a.NAME_TRIMMING, i = {
|
|
1
|
+
import { ModificationDescription as d, UIElementType as a, 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 { ItemsBlockControlId as l } from "../../enums/controlEnums.js";
|
|
4
|
+
import { getItemsBlockConfig as o, setItemsBlockConfig as c } from "../../utils/nodeConfigUtils.js";
|
|
5
|
+
const g = l.NAME_TRIMMING, i = {
|
|
7
6
|
TRIMMING: "trimming"
|
|
8
7
|
};
|
|
9
|
-
class y extends
|
|
8
|
+
class y extends T {
|
|
10
9
|
getId() {
|
|
11
10
|
return g;
|
|
12
11
|
}
|
|
13
12
|
getTemplate() {
|
|
14
13
|
return `
|
|
15
|
-
<div class="container ${
|
|
14
|
+
<div class="container ${l.NAME_TRIMMING}">
|
|
16
15
|
${this._getTextTrimming()}
|
|
17
16
|
</div>
|
|
18
17
|
`;
|
|
19
18
|
}
|
|
20
19
|
onRender() {
|
|
21
|
-
const e =
|
|
20
|
+
const e = o(this.currentNode);
|
|
22
21
|
this.api.updateValues({ [i.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(i.TRIMMING, (t) => {
|
|
23
22
|
this._onTrimmingChange(t);
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
onTemplateNodeUpdated(e) {
|
|
27
26
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
28
|
-
const t =
|
|
27
|
+
const t = o(this.currentNode);
|
|
29
28
|
this.api.updateValues({ [i.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
|
|
30
29
|
});
|
|
31
30
|
}
|
|
@@ -33,19 +32,20 @@ class y extends p {
|
|
|
33
32
|
c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [i.TRIMMING]: e }), this._applyTrimmingStyles(e);
|
|
34
33
|
}
|
|
35
34
|
_applyTrimmingStyles(e) {
|
|
36
|
-
|
|
35
|
+
var m;
|
|
36
|
+
const t = (m = this.currentNode) == null ? void 0 : m.querySelector("p > a");
|
|
37
37
|
if (!t)
|
|
38
38
|
return;
|
|
39
|
-
const n =
|
|
40
|
-
|
|
39
|
+
const n = o(this.currentNode), s = e !== void 0 ? e : (n == null ? void 0 : n.nameTrimming) ?? !0, r = this.api.getDocumentModifier().modifyHtml(t);
|
|
40
|
+
s ? r.setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis") : r.removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow"), r.setStyle("max-width", "100%").apply(new d(`Text Trimming ${s ? "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
|
+
<${a.LABEL}
|
|
46
|
+
${p.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
47
47
|
>
|
|
48
|
-
</${
|
|
48
|
+
</${a.LABEL}>
|
|
49
49
|
${this._GuToggle(i.TRIMMING)}
|
|
50
50
|
</div>
|
|
51
51
|
`;
|
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import { getItemsBlockConfig as
|
|
5
|
-
const
|
|
1
|
+
import { UIElementType as o, UEAttr as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as r } from "../../../common-control.js";
|
|
3
|
+
import { ItemsBlockControlId as n } from "../../enums/controlEnums.js";
|
|
4
|
+
import { getItemsBlockConfig as s, setItemsBlockConfig as a } from "../../utils/nodeConfigUtils.js";
|
|
5
|
+
const c = n.PRICE_HIDE_DISCOUNT, i = {
|
|
6
6
|
HIDE_DISCOUNT: "hideDiscount"
|
|
7
7
|
};
|
|
8
|
-
class
|
|
8
|
+
class C extends r {
|
|
9
9
|
getId() {
|
|
10
|
-
return
|
|
10
|
+
return c;
|
|
11
11
|
}
|
|
12
12
|
getTemplate() {
|
|
13
13
|
return `
|
|
14
|
-
<div class="container ${
|
|
14
|
+
<div class="container ${n.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 e = s(this.currentNode);
|
|
21
|
+
this.api.updateValues({ [i.HIDE_DISCOUNT]: (e == null ? void 0 : e.priceHideDiscount) ?? !0 }), this.api.onValueChanged(i.HIDE_DISCOUNT, (t) => {
|
|
22
|
+
this._onHideDiscountChange(t);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
onTemplateNodeUpdated(
|
|
26
|
-
super.onTemplateNodeUpdated(
|
|
27
|
-
const
|
|
28
|
-
this.api.updateValues({ [i.HIDE_DISCOUNT]: (
|
|
25
|
+
onTemplateNodeUpdated(e) {
|
|
26
|
+
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
27
|
+
const t = s(this.currentNode);
|
|
28
|
+
this.api.updateValues({ [i.HIDE_DISCOUNT]: (t == null ? void 0 : t.priceHideDiscount) ?? !0 });
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
_onHideDiscountChange(
|
|
32
|
-
|
|
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 });
|
|
31
|
+
_onHideDiscountChange(e) {
|
|
32
|
+
a(this.currentNode, this.api, { priceHideDiscount: e }), this.api.updateValues({ [i.HIDE_DISCOUNT]: e });
|
|
37
33
|
}
|
|
38
34
|
_getHideDiscount() {
|
|
39
35
|
return `
|
|
40
36
|
<div class="display-flex align-items-center justify-content-between">
|
|
41
|
-
<${
|
|
42
|
-
${
|
|
37
|
+
<${o.LABEL}
|
|
38
|
+
${d.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
|
|
43
39
|
>
|
|
44
|
-
</${
|
|
40
|
+
</${o.LABEL}>
|
|
45
41
|
${this._GuToggle(i.HIDE_DISCOUNT)}
|
|
46
42
|
</div>
|
|
47
43
|
</div>
|
|
@@ -49,6 +45,6 @@ class E extends p {
|
|
|
49
45
|
}
|
|
50
46
|
}
|
|
51
47
|
export {
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
c as CONTROL_BLOCK_ID,
|
|
49
|
+
C as PriceHideDiscountControl
|
|
54
50
|
};
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
1
|
+
import { ModificationDescription as y, 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 N, 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
|
-
|
|
11
|
-
const G = "ui-elements-items-block", m = {
|
|
7
|
+
import q from "../layouts/vertical.html.js";
|
|
8
|
+
import { getDefaultTemplate as w, wrapInTableRow as C } from "../template.js";
|
|
9
|
+
import { getItemsBlockConfig as _, setItemsBlockConfig as M, escapeReplacement as g, deriveItemNumber as V } from "../utils/nodeConfigUtils.js";
|
|
10
|
+
const B = "ui-elements-items-block", m = {
|
|
12
11
|
ITEMS_TYPE: "itemsType",
|
|
13
12
|
ORIENTATION: "orientation",
|
|
14
13
|
ITEM_IDS: "itemIds"
|
|
15
14
|
};
|
|
16
|
-
class
|
|
15
|
+
class Z extends k {
|
|
17
16
|
getId() {
|
|
18
|
-
return
|
|
17
|
+
return B;
|
|
19
18
|
}
|
|
20
19
|
getTemplate() {
|
|
21
20
|
return `
|
|
@@ -87,7 +86,7 @@ class te extends k {
|
|
|
87
86
|
M(this.currentNode, this.api, {
|
|
88
87
|
orientation: e,
|
|
89
88
|
priceOrientation: "horizontal"
|
|
90
|
-
}, r), r.apply(new
|
|
89
|
+
}, r), r.apply(new y("Changed orientation")), this._reOrderTemplate(), setTimeout(() => {
|
|
91
90
|
this._recalculateTrimming();
|
|
92
91
|
}, 50);
|
|
93
92
|
}
|
|
@@ -104,7 +103,7 @@ class te extends k {
|
|
|
104
103
|
buttonLink: n
|
|
105
104
|
}, o), this._updateDataTypeAttributes(r, o), this._initializeSelectItems();
|
|
106
105
|
const c = this._getTemplateData(r, i.value);
|
|
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
|
|
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 y("Updated items type"));
|
|
108
107
|
}
|
|
109
108
|
_onItemIdsChange(e) {
|
|
110
109
|
this.api.updateValues({ [m.ITEM_IDS]: e });
|
|
@@ -115,7 +114,7 @@ class te extends k {
|
|
|
115
114
|
buttonLink: r
|
|
116
115
|
}, i), this._updateDataNumberAttributes(e, i);
|
|
117
116
|
const n = this._getTemplateData(void 0, e);
|
|
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
|
|
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 y("Updated item selection"));
|
|
119
118
|
}
|
|
120
119
|
_initializeSelectItems() {
|
|
121
120
|
this.api.setUIEAttribute(
|
|
@@ -150,25 +149,25 @@ class te extends k {
|
|
|
150
149
|
}
|
|
151
150
|
_renderTemplate() {
|
|
152
151
|
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;
|
|
153
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(
|
|
152
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(w({
|
|
154
153
|
orientation: r,
|
|
155
154
|
itemsType: t,
|
|
156
155
|
itemId: i,
|
|
157
156
|
currencySymbol: n,
|
|
158
157
|
currencyLocation: s,
|
|
159
158
|
formattedPrice: o
|
|
160
|
-
})).apply(new
|
|
159
|
+
})).apply(new y("Updated template"));
|
|
161
160
|
}
|
|
162
161
|
_getTemplateData(e, r) {
|
|
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 =
|
|
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 = N.PAIRS_FOR_EXTENSION.price[i], T = N.PAIRS_FOR_EXTENSION.originalPrice[i];
|
|
164
163
|
let u, p;
|
|
165
164
|
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), {
|
|
166
|
-
imageSrc:
|
|
167
|
-
name:
|
|
165
|
+
imageSrc: N.PAIRS_FOR_EXTENSION.imageSrc[i].DEFAULT[a],
|
|
166
|
+
name: N.PAIRS_FOR_EXTENSION.name[i].DEFAULT[a],
|
|
168
167
|
price: u,
|
|
169
168
|
originalPrice: p,
|
|
170
|
-
quantity:
|
|
171
|
-
button:
|
|
169
|
+
quantity: N.PAIRS_FOR_EXTENSION.quantity[i].DEFAULT,
|
|
170
|
+
button: N.PAIRS_FOR_EXTENSION.button[i].DEFAULT_LABEL
|
|
172
171
|
};
|
|
173
172
|
}
|
|
174
173
|
_updateImageSrc(e, r) {
|
|
@@ -194,8 +193,8 @@ class te extends k {
|
|
|
194
193
|
const a = this._getParagraphFromBlock(c);
|
|
195
194
|
if (!a)
|
|
196
195
|
return;
|
|
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),
|
|
198
|
-
r.modifyHtml(a).setInnerHtml(
|
|
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), S = l.replace(T, g(E));
|
|
197
|
+
r.modifyHtml(a).setInnerHtml(S);
|
|
199
198
|
});
|
|
200
199
|
}
|
|
201
200
|
_updateOriginalPrice(e, r) {
|
|
@@ -210,7 +209,7 @@ class te extends k {
|
|
|
210
209
|
const l = a.querySelector("s");
|
|
211
210
|
if (!l)
|
|
212
211
|
return;
|
|
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),
|
|
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), S = this._buildPriceContent(E, p, s), R = `<s>${T.replace(u, g(S))}</s>`;
|
|
214
213
|
r.modifyHtml(a).setInnerHtml(R);
|
|
215
214
|
});
|
|
216
215
|
}
|
|
@@ -224,17 +223,17 @@ class te extends k {
|
|
|
224
223
|
return;
|
|
225
224
|
const T = l.getInnerText().trim();
|
|
226
225
|
let u = l.getInnerHTML().trim();
|
|
227
|
-
function p(E,
|
|
226
|
+
function p(E, S, A) {
|
|
228
227
|
return E.replace(
|
|
229
|
-
new RegExp(`(>\\s*)?${
|
|
228
|
+
new RegExp(`(>\\s*)?${S}(\\s*<)?`, "g"),
|
|
230
229
|
`$1${A}$2`
|
|
231
230
|
);
|
|
232
231
|
}
|
|
233
232
|
u = p(u, T, e), t.modifyHtml(l).setInnerHtml(u), t.modifyHtml(a).setStyle("display", c ? "table-cell" : "none");
|
|
234
233
|
}
|
|
235
234
|
_reOrderTemplate(e) {
|
|
236
|
-
var h, E,
|
|
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 = ((
|
|
235
|
+
var h, E, S, A, R, b;
|
|
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 = ((S = this.currentNode) == null ? void 0 : S.querySelectorAll(
|
|
238
237
|
`[esd-extension-block-id="${I.PRICE}"]`
|
|
239
238
|
)) || [], n = ((A = this.currentNode) == null ? void 0 : A.querySelectorAll(
|
|
240
239
|
`[esd-extension-block-id="${I.ORIGINAL_PRICE}"]`
|
|
@@ -242,12 +241,12 @@ class te extends k {
|
|
|
242
241
|
if (!r || !t || !s || !o || !c || !a)
|
|
243
242
|
return;
|
|
244
243
|
const l = _(this.currentNode), u = ((l == null ? void 0 : l.orientation) ?? d.ORIENTATION.VERTICAL) === d.ORIENTATION.VERTICAL;
|
|
245
|
-
let p = u ?
|
|
244
|
+
let p = u ? q : $;
|
|
246
245
|
setTimeout(() => {
|
|
247
|
-
const
|
|
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(
|
|
246
|
+
const U = g(s.getOuterHTML()), f = g(o.getOuterHTML());
|
|
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(U)).replaceAll("{-{-PRODUCT_ORIGINAL_PRICE-}-}", C(f)).replace("{-{-PRODUCT_QUANTITY-}-}", C(c.getOuterHTML())).replace("{-{-PRODUCT_BUTTON-}-}", C(a.getOuterHTML())), p = p.trim().replace(D, "").slice(0, -5);
|
|
249
248
|
const P = e ?? this.api.getDocumentModifier();
|
|
250
|
-
P.modifyHtml(r.querySelector("img")).setAttribute("width", H.productImageWidth).setAttribute("height", H.productImageWidth), P.modifyHtml(this.currentNode).setInnerHtml(p), e || P.apply(new
|
|
249
|
+
P.modifyHtml(r.querySelector("img")).setAttribute("width", H.productImageWidth).setAttribute("height", H.productImageWidth), P.modifyHtml(this.currentNode).setInnerHtml(p), e || P.apply(new y("Reordered template"));
|
|
251
250
|
}, 50);
|
|
252
251
|
}
|
|
253
252
|
_updateDataTypeAttributes(e, r) {
|
|
@@ -262,7 +261,7 @@ class te extends k {
|
|
|
262
261
|
_updateDataNumberAttributes(e, r) {
|
|
263
262
|
if (!this.currentNode)
|
|
264
263
|
return;
|
|
265
|
-
const t = _(this.currentNode), i = (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n =
|
|
264
|
+
const t = _(this.currentNode), i = (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n = V(e, i), s = this.currentNode.closest(".ins-product-td");
|
|
266
265
|
s && r.modifyHtml(s).setAttribute("data-number", n), this.currentNode.querySelectorAll("[data-number]").forEach((c) => {
|
|
267
266
|
const a = c;
|
|
268
267
|
r.modifyHtml(a).setAttribute("data-number", n);
|
|
@@ -270,7 +269,7 @@ class te extends k {
|
|
|
270
269
|
}
|
|
271
270
|
_reFillTemplate(e) {
|
|
272
271
|
const r = this._getTemplateData(e), t = this.api.getDocumentModifier();
|
|
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
|
|
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 y("Refilled template"));
|
|
274
273
|
}
|
|
275
274
|
_recalculateTrimming() {
|
|
276
275
|
var n;
|
|
@@ -279,11 +278,11 @@ class te extends k {
|
|
|
279
278
|
const e = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${I.NAME}"]`);
|
|
280
279
|
if (!e)
|
|
281
280
|
return;
|
|
282
|
-
const r =
|
|
281
|
+
const r = e.querySelector("p > a");
|
|
283
282
|
if (!r)
|
|
284
283
|
return;
|
|
285
284
|
const t = _(this.currentNode), i = (t == null ? void 0 : t.nameTrimming) ?? !0;
|
|
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
|
|
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 y("Recalculated trimming after orientation change"));
|
|
287
286
|
}
|
|
288
287
|
_getParagraphFromBlock(e) {
|
|
289
288
|
return e.querySelector("p");
|
|
@@ -315,6 +314,6 @@ class te extends k {
|
|
|
315
314
|
}
|
|
316
315
|
}
|
|
317
316
|
export {
|
|
318
|
-
|
|
319
|
-
|
|
317
|
+
B as CONTROL_BLOCK_ID,
|
|
318
|
+
Z as ItemsBlockControl
|
|
320
319
|
};
|