@useinsider/guido 3.9.0-beta.c84fcd0 → 3.9.0-beta.dd40fcd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +118 -110
- package/dist/config/migrator/itemsBlockMigrator.js +114 -159
- package/dist/config/migrator/unsubscribeMigrator.js +86 -64
- package/dist/extensions/Blocks/Items/block.js +37 -57
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +78 -67
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +9 -13
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +14 -26
- package/dist/extensions/Blocks/Items/template.js +247 -245
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +45 -53
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +15 -15
- package/dist/src/extensions/Blocks/Items/block.d.ts +0 -9
- package/dist/src/extensions/Blocks/Items/template.d.ts +0 -7
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +0 -12
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { BlockId as
|
|
1
|
+
import { BlockId as u } from "../../../enums/block.js";
|
|
2
2
|
import { useOnboardingStore as p } from "../../../stores/onboarding.js";
|
|
3
|
-
import { getMigrationBannerHtml as
|
|
4
|
-
import { Block as I, BlockCompositionType as
|
|
5
|
-
import { SETTINGS_ENUMS as
|
|
6
|
-
import { getDefaultTemplate as
|
|
7
|
-
import { getItemsBlockContainer as
|
|
8
|
-
const
|
|
9
|
-
class
|
|
3
|
+
import { getMigrationBannerHtml as C } from "../../../utils/migrationBannerHtml.js";
|
|
4
|
+
import { Block as I, BlockCompositionType as y, ModificationDescription as s } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { SETTINGS_ENUMS as c, DefaultConfigValues as a } from "./enums/settingsEnums.js";
|
|
6
|
+
import { getDefaultTemplate as h } from "./template.js";
|
|
7
|
+
import { getItemsBlockContainer as l, getItemsBlockConfig as m, getDefaultItemsBlockConfig as b } from "./utils/nodeConfigUtils.js";
|
|
8
|
+
const d = u.Items;
|
|
9
|
+
class E extends I {
|
|
10
10
|
getId() {
|
|
11
|
-
return
|
|
11
|
+
return d;
|
|
12
12
|
}
|
|
13
13
|
getIcon() {
|
|
14
14
|
return "items-icon";
|
|
15
15
|
}
|
|
16
16
|
getBlockCompositionType() {
|
|
17
|
-
return
|
|
17
|
+
return y.CONTAINER;
|
|
18
18
|
}
|
|
19
19
|
getName() {
|
|
20
20
|
return this.api.translate("Items");
|
|
@@ -23,20 +23,20 @@ class P extends I {
|
|
|
23
23
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
24
24
|
}
|
|
25
25
|
getSettingsPanelTitleHtml() {
|
|
26
|
-
return
|
|
27
|
-
|
|
26
|
+
return C(
|
|
27
|
+
d,
|
|
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
|
-
return
|
|
34
|
-
orientation:
|
|
35
|
-
itemsType:
|
|
33
|
+
return h({
|
|
34
|
+
orientation: c.ORIENTATION.VERTICAL,
|
|
35
|
+
itemsType: c.ITEMS_TYPE.CART_ITEMS,
|
|
36
36
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
37
|
-
currencySymbol:
|
|
38
|
-
currencyLocation:
|
|
39
|
-
formattedPrice:
|
|
37
|
+
currencySymbol: a.productPriceCurrencySymbolControlValue,
|
|
38
|
+
currencyLocation: a.productPriceCurrencyLocationControlValue,
|
|
39
|
+
formattedPrice: a.productPriceFormattedControlValue === "1"
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
allowInnerBlocksDND() {
|
|
@@ -45,23 +45,18 @@ class P extends I {
|
|
|
45
45
|
canBeSavedAsModule() {
|
|
46
46
|
return !0;
|
|
47
47
|
}
|
|
48
|
-
onCreated(
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
48
|
+
onCreated(i) {
|
|
49
|
+
const n = this.api.getDocumentModifier(), r = this.api.getDocumentRootCssNode();
|
|
50
|
+
r.querySelector('[product-attr="imageSrc"] img') || n.modifyCss(r).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
51
|
+
const t = l(i);
|
|
52
|
+
if (!t)
|
|
53
53
|
return;
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
n.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...n, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
|
|
58
|
-
else {
|
|
59
|
-
const a = this.api.getDocumentModifier();
|
|
60
|
-
a.modifyHtml(e).setNodeConfig(n), this._stampProductTdDomAttributes(e, n, a), a.apply(new c("Migrate legacy config to nodeConfig"));
|
|
61
|
-
}
|
|
54
|
+
const e = t.getNodeConfig(), g = e && Object.keys(e).length > 0, o = m(i);
|
|
55
|
+
if (o != null && o.initialized)
|
|
56
|
+
g ? o.blockInstanceId || this.api.getDocumentModifier().modifyHtml(t).setNodeConfig({ ...o, blockInstanceId: String(Date.now()) }).apply(new s("Assign block instance ID to block")) : this.api.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new s("Migrate legacy config to nodeConfig"));
|
|
62
57
|
else {
|
|
63
|
-
const
|
|
64
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
58
|
+
const f = b();
|
|
59
|
+
this.api.getDocumentModifier().modifyHtml(t).setNodeConfig(f).apply(new s("Initialize Items block with default configuration")), p().startOnboarding("itemsOnboarding");
|
|
65
60
|
}
|
|
66
61
|
}
|
|
67
62
|
/**
|
|
@@ -70,33 +65,18 @@ class P extends I {
|
|
|
70
65
|
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
71
66
|
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
72
67
|
*/
|
|
73
|
-
onDocumentChanged(
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
76
|
-
return;
|
|
77
|
-
const i = t.getNodeConfig();
|
|
78
|
-
if (i && Object.keys(i).length > 0)
|
|
68
|
+
onDocumentChanged(i) {
|
|
69
|
+
const n = l(i);
|
|
70
|
+
if (!n)
|
|
79
71
|
return;
|
|
80
|
-
const r =
|
|
81
|
-
if (
|
|
72
|
+
const r = n.getNodeConfig();
|
|
73
|
+
if (r && Object.keys(r).length > 0)
|
|
82
74
|
return;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`) onto the
|
|
88
|
-
* `.ins-product-td` container from the recovered config. Required for saved modules:
|
|
89
|
-
* `migrate()` (which backfills these) only runs at template load — never when a module
|
|
90
|
-
* is dropped into a live editor — so this is the one place the namespace + index get
|
|
91
|
-
* restored before export. The name `<a>` carries no data-type/data-number of its own and
|
|
92
|
-
* relies on this td-level fallback in pairProductVariables.
|
|
93
|
-
*/
|
|
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);
|
|
75
|
+
const e = m(i);
|
|
76
|
+
e != null && e.initialized && this.api.getDocumentModifier().modifyHtml(n).setNodeConfig(e).apply(new s("Recover Items block config from saved module"));
|
|
97
77
|
}
|
|
98
78
|
}
|
|
99
79
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
80
|
+
d as BLOCK_ID,
|
|
81
|
+
E as ItemsBlock
|
|
102
82
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
1
|
+
import { ModificationDescription as s, UIElementType as a, UEAttr as T } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as d } from "../../../common-control.js";
|
|
3
3
|
import { ItemsBlockControlId as l } from "../../enums/controlEnums.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { SETTINGS_ENUMS as h } from "../../enums/settingsEnums.js";
|
|
5
|
+
import { getItemsBlockConfig as r, setItemsBlockConfig as c } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const I = l.NAME_TRIMMING, n = {
|
|
6
7
|
TRIMMING: "trimming"
|
|
7
8
|
};
|
|
8
|
-
class
|
|
9
|
+
class S extends d {
|
|
9
10
|
getId() {
|
|
10
|
-
return
|
|
11
|
+
return I;
|
|
11
12
|
}
|
|
12
13
|
getTemplate() {
|
|
13
14
|
return `
|
|
@@ -17,41 +18,41 @@ class y extends T {
|
|
|
17
18
|
`;
|
|
18
19
|
}
|
|
19
20
|
onRender() {
|
|
20
|
-
const e =
|
|
21
|
-
this.api.updateValues({ [
|
|
21
|
+
const e = r(this.currentNode);
|
|
22
|
+
this.api.updateValues({ [n.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(n.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
|
-
this.api.updateValues({ [
|
|
28
|
+
const t = r(this.currentNode);
|
|
29
|
+
this.api.updateValues({ [n.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
_onTrimmingChange(e) {
|
|
32
|
-
c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [
|
|
33
|
+
c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [n.TRIMMING]: e }), this._applyTrimmingStyles(e);
|
|
33
34
|
}
|
|
34
35
|
_applyTrimmingStyles(e) {
|
|
35
36
|
var m;
|
|
36
37
|
const t = (m = this.currentNode) == null ? void 0 : m.querySelector("p > a");
|
|
37
38
|
if (!t)
|
|
38
39
|
return;
|
|
39
|
-
const
|
|
40
|
-
|
|
40
|
+
const i = r(this.currentNode), p = e !== void 0 ? e : (i == null ? void 0 : i.nameTrimming) ?? !0, o = (i == null ? void 0 : i.orientation) === h.ORIENTATION.VERTICAL;
|
|
41
|
+
p ? this.api.getDocumentModifier().modifyHtml(t).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", o ? "130px" : "520px").apply(new s("Text Trimming Enabled")) : this.api.getDocumentModifier().modifyHtml(t).removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow").removeStyle("max-width").setStyle("max-width", o ? "130px" : "520px").apply(new s("Text Trimming Disabled"));
|
|
41
42
|
}
|
|
42
43
|
_getTextTrimming() {
|
|
43
44
|
return `
|
|
44
45
|
<div class="display-flex align-items-center justify-content-between">
|
|
45
46
|
<${a.LABEL}
|
|
46
|
-
${
|
|
47
|
+
${T.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
47
48
|
>
|
|
48
49
|
</${a.LABEL}>
|
|
49
|
-
${this._GuToggle(
|
|
50
|
+
${this._GuToggle(n.TRIMMING)}
|
|
50
51
|
</div>
|
|
51
52
|
`;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
I as CONTROL_BLOCK_ID,
|
|
57
|
+
S as NameTrimmingControl
|
|
57
58
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
1
|
+
import { ModificationDescription as N, UEAttr as L } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as U } from "../../common-control.js";
|
|
3
3
|
import { ItemsBlockId as I } from "../enums/controlEnums.js";
|
|
4
|
-
import { productPairs as
|
|
5
|
-
import { SETTINGS_ENUMS as d, ItemTypeOptions as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { getDefaultTemplate as
|
|
9
|
-
import { getItemsBlockConfig as _, setItemsBlockConfig as
|
|
10
|
-
const
|
|
4
|
+
import { productPairs as y, templateFirstLine as b } from "../enums/productEnums.js";
|
|
5
|
+
import { SETTINGS_ENUMS as d, ItemTypeOptions as D, OrientationOptions as k, ItemInCartOptions as g, DefaultConfigValues as x } from "../enums/settingsEnums.js";
|
|
6
|
+
import F from "../layouts/horizontal.html.js";
|
|
7
|
+
import $ from "../layouts/vertical.html.js";
|
|
8
|
+
import { getDefaultTemplate as q } from "../template.js";
|
|
9
|
+
import { getItemsBlockConfig as _, setItemsBlockConfig as O, escapeReplacement as A } from "../utils/nodeConfigUtils.js";
|
|
10
|
+
const w = "ui-elements-items-block", m = {
|
|
11
11
|
ITEMS_TYPE: "itemsType",
|
|
12
12
|
ORIENTATION: "orientation",
|
|
13
13
|
ITEM_IDS: "itemIds"
|
|
14
14
|
};
|
|
15
|
-
class Z extends
|
|
15
|
+
class Z extends U {
|
|
16
16
|
getId() {
|
|
17
|
-
return
|
|
17
|
+
return w;
|
|
18
18
|
}
|
|
19
19
|
getTemplate() {
|
|
20
20
|
return `
|
|
@@ -51,7 +51,7 @@ class Z extends k {
|
|
|
51
51
|
name: m.ITEMS_TYPE,
|
|
52
52
|
className: "es-100",
|
|
53
53
|
placeholder: "Select Item Type",
|
|
54
|
-
options:
|
|
54
|
+
options: D
|
|
55
55
|
})
|
|
56
56
|
])}
|
|
57
57
|
`;
|
|
@@ -62,7 +62,7 @@ class Z extends k {
|
|
|
62
62
|
this._GuLabel({ text: "Orientation" }),
|
|
63
63
|
this._GuRadioButton({
|
|
64
64
|
name: m.ORIENTATION,
|
|
65
|
-
buttons:
|
|
65
|
+
buttons: k
|
|
66
66
|
})
|
|
67
67
|
])}
|
|
68
68
|
`;
|
|
@@ -83,50 +83,50 @@ class Z extends k {
|
|
|
83
83
|
_onOrientationChange(e) {
|
|
84
84
|
this.api.updateValues({ [m.ORIENTATION]: e });
|
|
85
85
|
const r = this.api.getDocumentModifier();
|
|
86
|
-
|
|
86
|
+
O(this.currentNode, this.api, {
|
|
87
87
|
orientation: e,
|
|
88
88
|
priceOrientation: "horizontal"
|
|
89
|
-
}, r), r.apply(new
|
|
89
|
+
}, r), r.apply(new N("Changed orientation")), this._reOrderTemplate(), setTimeout(() => {
|
|
90
90
|
this._recalculateTrimming();
|
|
91
91
|
}, 50);
|
|
92
92
|
}
|
|
93
93
|
_onItemsTypeChange(e) {
|
|
94
|
-
const r = d.ITEMS_TYPE[e], t =
|
|
94
|
+
const r = d.ITEMS_TYPE[e], t = g[e], i = t == null ? void 0 : t[0];
|
|
95
95
|
if (!r || !i)
|
|
96
96
|
return;
|
|
97
97
|
const n = i.value, s = i.value.replace("Url}}", "Image}}"), o = this.api.getDocumentModifier();
|
|
98
|
-
|
|
98
|
+
O(this.currentNode, this.api, {
|
|
99
99
|
source: r,
|
|
100
100
|
type: r,
|
|
101
101
|
itemsSelectValue: i.value,
|
|
102
102
|
imageLink: s,
|
|
103
103
|
buttonLink: n
|
|
104
104
|
}, o), this._updateDataTypeAttributes(r, o), this._initializeSelectItems();
|
|
105
|
-
const
|
|
106
|
-
this._updateImageSrc(
|
|
105
|
+
const l = this._getTemplateData(r, i.value);
|
|
106
|
+
this._updateImageSrc(l.imageSrc, o), this._updateName(l.name, o), this._updatePrice(l.price, o), this._updateOriginalPrice(l.originalPrice, o), this._updateQuantity(l.quantity, r, o), o.apply(new N("Updated items type"));
|
|
107
107
|
}
|
|
108
108
|
_onItemIdsChange(e) {
|
|
109
109
|
this.api.updateValues({ [m.ITEM_IDS]: e });
|
|
110
110
|
const r = e, t = e.replace("Url}}", "Image}}"), i = this.api.getDocumentModifier();
|
|
111
|
-
|
|
111
|
+
O(this.currentNode, this.api, {
|
|
112
112
|
itemsSelectValue: e,
|
|
113
113
|
imageLink: t,
|
|
114
114
|
buttonLink: r
|
|
115
115
|
}, i), this._updateDataNumberAttributes(e, i);
|
|
116
116
|
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
|
|
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 N("Updated item selection"));
|
|
118
118
|
}
|
|
119
119
|
_initializeSelectItems() {
|
|
120
120
|
this.api.setUIEAttribute(
|
|
121
121
|
m.ITEMS_TYPE,
|
|
122
122
|
L.SELECTPICKER.items,
|
|
123
|
-
|
|
123
|
+
D
|
|
124
124
|
);
|
|
125
125
|
const e = _(this.currentNode), r = (e == null ? void 0 : e.type) ?? d.ITEMS_TYPE.CART_ITEMS, t = (e == null ? void 0 : e.itemsSelectValue) ?? "";
|
|
126
126
|
this.api.updateValues({
|
|
127
127
|
[m.ITEMS_TYPE]: r
|
|
128
128
|
});
|
|
129
|
-
const i =
|
|
129
|
+
const i = g[r];
|
|
130
130
|
this.api.setUIEAttribute(
|
|
131
131
|
m.ITEM_IDS,
|
|
132
132
|
L.SELECTPICKER.items,
|
|
@@ -149,25 +149,25 @@ class Z extends k {
|
|
|
149
149
|
}
|
|
150
150
|
_renderTemplate() {
|
|
151
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;
|
|
152
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(
|
|
152
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(q({
|
|
153
153
|
orientation: r,
|
|
154
154
|
itemsType: t,
|
|
155
155
|
itemId: i,
|
|
156
156
|
currencySymbol: n,
|
|
157
157
|
currencyLocation: s,
|
|
158
158
|
formattedPrice: o
|
|
159
|
-
})).apply(new
|
|
159
|
+
})).apply(new N("Updated template"));
|
|
160
160
|
}
|
|
161
161
|
_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,
|
|
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, l = g[i].findIndex((h) => h.value === n), a = l > -1 ? l : 0, c = y.PAIRS_FOR_EXTENSION.price[i], T = y.PAIRS_FOR_EXTENSION.originalPrice[i];
|
|
163
163
|
let u, p;
|
|
164
|
-
return o ? (u = s ?
|
|
165
|
-
imageSrc:
|
|
166
|
-
name:
|
|
164
|
+
return o ? (u = s ? c.DEFAULT_SINGLE_PRICE_FORMATTED : c.DEFAULT_SINGLE_PRICE, p = s ? T.DEFAULT_SINGLE_PRICE_FORMATTED : T.DEFAULT_SINGLE_PRICE) : (u = s ? c.DEFAULT_PRICE_FORMATTED : c.DEFAULT_PRICE, p = s ? T.DEFAULT_PRICE_FORMATTED : T.DEFAULT_PRICE), {
|
|
165
|
+
imageSrc: y.PAIRS_FOR_EXTENSION.imageSrc[i].DEFAULT[a],
|
|
166
|
+
name: y.PAIRS_FOR_EXTENSION.name[i].DEFAULT[a],
|
|
167
167
|
price: u,
|
|
168
168
|
originalPrice: p,
|
|
169
|
-
quantity:
|
|
170
|
-
button:
|
|
169
|
+
quantity: y.PAIRS_FOR_EXTENSION.quantity[i].DEFAULT,
|
|
170
|
+
button: y.PAIRS_FOR_EXTENSION.button[i].DEFAULT_LABEL
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
_updateImageSrc(e, r) {
|
|
@@ -182,18 +182,18 @@ class Z extends k {
|
|
|
182
182
|
return;
|
|
183
183
|
const i = t.getInnerText().trim();
|
|
184
184
|
let n = t.getInnerHTML().trim();
|
|
185
|
-
n = n.replace(i,
|
|
185
|
+
n = n.replace(i, A(e)), r.modifyHtml(t).setInnerHtml(n);
|
|
186
186
|
}
|
|
187
187
|
_updatePrice(e, r) {
|
|
188
188
|
var o;
|
|
189
189
|
const t = ((o = this.currentNode) == null ? void 0 : o.querySelectorAll(
|
|
190
190
|
`[esd-extension-block-id="${I.PRICE}"]`
|
|
191
191
|
)) || [], i = _(this.currentNode), n = (i == null ? void 0 : i.priceCurrencySymbol) ?? "", s = (i == null ? void 0 : i.priceCurrencyLocation) ?? "0";
|
|
192
|
-
t.forEach((
|
|
193
|
-
const a = this._getParagraphFromBlock(
|
|
192
|
+
t.forEach((l) => {
|
|
193
|
+
const a = this._getParagraphFromBlock(l);
|
|
194
194
|
if (!a)
|
|
195
195
|
return;
|
|
196
|
-
const
|
|
196
|
+
const c = 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 = c.replace(T, A(E));
|
|
197
197
|
r.modifyHtml(a).setInnerHtml(S);
|
|
198
198
|
});
|
|
199
199
|
}
|
|
@@ -202,51 +202,51 @@ class Z extends k {
|
|
|
202
202
|
const t = ((o = this.currentNode) == null ? void 0 : o.querySelectorAll(
|
|
203
203
|
`[esd-extension-block-id="${I.ORIGINAL_PRICE}"]`
|
|
204
204
|
)) || [], i = _(this.currentNode), n = (i == null ? void 0 : i.priceCurrencySymbol) ?? "", s = (i == null ? void 0 : i.priceCurrencyLocation) ?? "0";
|
|
205
|
-
t.forEach((
|
|
206
|
-
const a = this._getParagraphFromBlock(
|
|
205
|
+
t.forEach((l) => {
|
|
206
|
+
const a = this._getParagraphFromBlock(l);
|
|
207
207
|
if (!a)
|
|
208
208
|
return;
|
|
209
|
-
const
|
|
210
|
-
if (!
|
|
209
|
+
const c = a.querySelector("s");
|
|
210
|
+
if (!c)
|
|
211
211
|
return;
|
|
212
|
-
const T =
|
|
212
|
+
const T = c.getInnerHTML().trim() || "", u = c.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, A(S))}</s>`;
|
|
213
213
|
r.modifyHtml(a).setInnerHtml(R);
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
_updateQuantity(e, r, t) {
|
|
217
217
|
var h;
|
|
218
|
-
const i = _(this.currentNode), s = (r ?? (i == null ? void 0 : i.type) ?? d.ITEMS_TYPE.CART_ITEMS) !== d.ITEMS_TYPE.BROWSED_ITEMS, o = (i == null ? void 0 : i.quantityControlEnabled) !== !1,
|
|
218
|
+
const i = _(this.currentNode), s = (r ?? (i == null ? void 0 : i.type) ?? d.ITEMS_TYPE.CART_ITEMS) !== d.ITEMS_TYPE.BROWSED_ITEMS, o = (i == null ? void 0 : i.quantityControlEnabled) !== !1, l = s && o, a = (h = this.currentNode) == null ? void 0 : h.querySelector(`[esd-extension-block-id="${I.QUANTITY}"]`);
|
|
219
219
|
if (!a)
|
|
220
220
|
return;
|
|
221
|
-
const
|
|
222
|
-
if (!
|
|
221
|
+
const c = this._getParagraphFromBlock(a);
|
|
222
|
+
if (!c)
|
|
223
223
|
return;
|
|
224
|
-
const T =
|
|
225
|
-
let u =
|
|
226
|
-
function p(E, S,
|
|
224
|
+
const T = c.getInnerText().trim();
|
|
225
|
+
let u = c.getInnerHTML().trim();
|
|
226
|
+
function p(E, S, C) {
|
|
227
227
|
return E.replace(
|
|
228
228
|
new RegExp(`(>\\s*)?${S}(\\s*<)?`, "g"),
|
|
229
|
-
`$1${
|
|
229
|
+
`$1${C}$2`
|
|
230
230
|
);
|
|
231
231
|
}
|
|
232
|
-
u = p(u, T, e), t.modifyHtml(
|
|
232
|
+
u = p(u, T, e), t.modifyHtml(c).setInnerHtml(u), t.modifyHtml(a).setStyle("display", l ? "table-cell" : "none");
|
|
233
233
|
}
|
|
234
234
|
_reOrderTemplate(e) {
|
|
235
|
-
var h, E, S,
|
|
235
|
+
var h, E, S, C, R, M;
|
|
236
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(
|
|
237
237
|
`[esd-extension-block-id="${I.PRICE}"]`
|
|
238
|
-
)) || [], n = ((
|
|
238
|
+
)) || [], n = ((C = this.currentNode) == null ? void 0 : C.querySelectorAll(
|
|
239
239
|
`[esd-extension-block-id="${I.ORIGINAL_PRICE}"]`
|
|
240
|
-
)) || [], [s] = i, [o] = n,
|
|
241
|
-
if (!r || !t || !s || !o || !
|
|
240
|
+
)) || [], [s] = i, [o] = n, l = (R = this.currentNode) == null ? void 0 : R.querySelector(`[esd-extension-block-id="${I.QUANTITY}"]`), a = (M = this.currentNode) == null ? void 0 : M.querySelector(`[esd-extension-block-id="${I.BUTTON}"]`);
|
|
241
|
+
if (!r || !t || !s || !o || !l || !a)
|
|
242
242
|
return;
|
|
243
|
-
const
|
|
244
|
-
let p = u ?
|
|
243
|
+
const c = _(this.currentNode), u = ((c == null ? void 0 : c.orientation) ?? d.ORIENTATION.VERTICAL) === d.ORIENTATION.VERTICAL;
|
|
244
|
+
let p = u ? $ : F;
|
|
245
245
|
setTimeout(() => {
|
|
246
|
-
const
|
|
247
|
-
p = p.replace("{-{-TEMPLATE_FIRST_LINE-}-}", u ?
|
|
246
|
+
const H = A(s.getOuterHTML()), f = A(o.getOuterHTML());
|
|
247
|
+
p = p.replace("{-{-TEMPLATE_FIRST_LINE-}-}", u ? b : "").replace("{-{-PRODUCT_IMAGE-}-}", r.getOuterHTML()).replace("{-{-PRODUCT_NAME-}-}", t.getOuterHTML()).replaceAll("{-{-PRODUCT_PRICE-}-}", H).replaceAll("{-{-PRODUCT_ORIGINAL_PRICE-}-}", f).replace("{-{-PRODUCT_QUANTITY-}-}", l.getOuterHTML()).replace("{-{-PRODUCT_BUTTON-}-}", a.getOuterHTML()), p = p.trim().replace(b, "").slice(0, -5);
|
|
248
248
|
const P = e ?? this.api.getDocumentModifier();
|
|
249
|
-
P.modifyHtml(r.querySelector("img")).setAttribute("width",
|
|
249
|
+
P.modifyHtml(r.querySelector("img")).setAttribute("width", x.productImageWidth).setAttribute("height", x.productImageWidth), P.modifyHtml(this.currentNode).setInnerHtml(p), e || P.apply(new N("Reordered template"));
|
|
250
250
|
}, 50);
|
|
251
251
|
}
|
|
252
252
|
_updateDataTypeAttributes(e, r) {
|
|
@@ -261,28 +261,39 @@ class Z extends k {
|
|
|
261
261
|
_updateDataNumberAttributes(e, r) {
|
|
262
262
|
if (!this.currentNode)
|
|
263
263
|
return;
|
|
264
|
-
const t = _(this.currentNode), i = (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n =
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
264
|
+
const t = _(this.currentNode), i = (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n = g[i].findIndex((a) => a.value === e);
|
|
265
|
+
let s = "1";
|
|
266
|
+
if (n >= 0)
|
|
267
|
+
s = String(n + 1);
|
|
268
|
+
else if (e) {
|
|
269
|
+
const a = e.match(/\((\d+)\)/);
|
|
270
|
+
if (a) {
|
|
271
|
+
const [, c] = a;
|
|
272
|
+
s = c;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const o = this.currentNode.closest(".ins-product-td");
|
|
276
|
+
o && r.modifyHtml(o).setAttribute("data-number", s), this.currentNode.querySelectorAll("[data-number]").forEach((a) => {
|
|
277
|
+
const c = a;
|
|
278
|
+
r.modifyHtml(c).setAttribute("data-number", s);
|
|
268
279
|
});
|
|
269
280
|
}
|
|
270
281
|
_reFillTemplate(e) {
|
|
271
282
|
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
|
|
283
|
+
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 N("Refilled template"));
|
|
273
284
|
}
|
|
274
285
|
_recalculateTrimming() {
|
|
275
|
-
var
|
|
286
|
+
var s;
|
|
276
287
|
if (!this.currentNode)
|
|
277
288
|
return;
|
|
278
|
-
const e = (
|
|
289
|
+
const e = (s = this.currentNode) == null ? void 0 : s.querySelector(`[esd-extension-block-id="${I.NAME}"]`);
|
|
279
290
|
if (!e)
|
|
280
291
|
return;
|
|
281
292
|
const r = e.querySelector("p > a");
|
|
282
293
|
if (!r)
|
|
283
294
|
return;
|
|
284
|
-
const t = _(this.currentNode), i = (t == null ? void 0 : t.nameTrimming) ?? !0;
|
|
285
|
-
this.api.getDocumentModifier().modifyHtml(r).setStyle("overflow", "hidden").setStyle("white-space",
|
|
295
|
+
const t = _(this.currentNode), i = (t == null ? void 0 : t.orientation) === d.ORIENTATION.HORIZONTAL, n = (t == null ? void 0 : t.nameTrimming) ?? !0;
|
|
296
|
+
this.api.getDocumentModifier().modifyHtml(r).setStyle("overflow", "hidden").setStyle("white-space", n ? "nowrap" : "normal").setStyle("text-overflow", n ? "ellipsis" : "unset").setStyle("max-width", i ? "130px" : "520px").setStyle("width", i ? "130px" : "520px").apply(new N("Recalculated trimming after orientation change"));
|
|
286
297
|
}
|
|
287
298
|
_getParagraphFromBlock(e) {
|
|
288
299
|
return e.querySelector("p");
|
|
@@ -314,6 +325,6 @@ class Z extends k {
|
|
|
314
325
|
}
|
|
315
326
|
}
|
|
316
327
|
export {
|
|
317
|
-
|
|
328
|
+
w as CONTROL_BLOCK_ID,
|
|
318
329
|
Z as ItemsBlockControl
|
|
319
330
|
};
|
|
@@ -6,42 +6,38 @@ const t = `{-{-TEMPLATE_FIRST_LINE-}-}
|
|
|
6
6
|
<table class="es-left esdev-disable-select" cellspacing="0" cellpadding="0" align="left" width="100%">
|
|
7
7
|
<tbody>
|
|
8
8
|
<tr>
|
|
9
|
-
<td class="product-image-class
|
|
10
|
-
|
|
11
|
-
<tbody>
|
|
12
|
-
{-{-PRODUCT_IMAGE-}-}
|
|
13
|
-
</tbody>
|
|
14
|
-
</table>
|
|
9
|
+
<td class="product-image-class" data-slot-1>
|
|
10
|
+
{-{-PRODUCT_IMAGE-}-}
|
|
15
11
|
</td>
|
|
16
|
-
<td class="product-name-class
|
|
17
|
-
<table
|
|
12
|
+
<td class="product-name-class" data-slot-2>
|
|
13
|
+
<table>
|
|
18
14
|
<tbody>
|
|
19
15
|
{-{-PRODUCT_NAME-}-}
|
|
20
16
|
</tbody>
|
|
21
17
|
</table>
|
|
22
18
|
</td>
|
|
23
|
-
<td class="product-quantity-class
|
|
19
|
+
<td class="product-quantity-class" data-slot-3>
|
|
24
20
|
<table width="100%">
|
|
25
21
|
<tbody>
|
|
26
22
|
{-{-PRODUCT_QUANTITY-}-}
|
|
27
23
|
</tbody>
|
|
28
24
|
</table>
|
|
29
25
|
</td>
|
|
30
|
-
<td class="product-price-class horizontal-price
|
|
26
|
+
<td class="product-price-class horizontal-price" data-slot-4>
|
|
31
27
|
<table width="100%">
|
|
32
28
|
<tbody>
|
|
33
29
|
{-{-PRODUCT_PRICE-}-}
|
|
34
30
|
</tbody>
|
|
35
31
|
</table>
|
|
36
32
|
</td>
|
|
37
|
-
<td class="product-original-price-class horizontal-price
|
|
33
|
+
<td class="product-original-price-class horizontal-price" data-slot-5>
|
|
38
34
|
<table width="100%">
|
|
39
35
|
<tbody>
|
|
40
36
|
{-{-PRODUCT_ORIGINAL_PRICE-}-}
|
|
41
37
|
</tbody>
|
|
42
38
|
</table>
|
|
43
39
|
</td>
|
|
44
|
-
<td class="product-price-container vertical-price
|
|
40
|
+
<td class="product-price-container vertical-price" data-slot-4 style="display: none;">
|
|
45
41
|
<table class="product-price-class" width="100%" data-slot-4>
|
|
46
42
|
<tbody>
|
|
47
43
|
{-{-PRODUCT_PRICE-}-}
|
|
@@ -54,7 +50,7 @@ const t = `{-{-TEMPLATE_FIRST_LINE-}-}
|
|
|
54
50
|
</tbody>
|
|
55
51
|
</table>
|
|
56
52
|
</td>
|
|
57
|
-
<td class="product-button-class
|
|
53
|
+
<td class="product-button-class" data-slot-6>
|
|
58
54
|
<table width="100%">
|
|
59
55
|
<tbody>
|
|
60
56
|
{-{-PRODUCT_BUTTON-}-}
|