@useinsider/guido 3.23.0-beta.9f6bfbf → 3.23.0-beta.cddbd15
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/README.md +0 -1
- package/dist/@types/config/schemas.js +15 -17
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +56 -58
- package/dist/composables/useModuleRepair.js +12 -14
- package/dist/config/migrator/index.js +15 -16
- package/dist/extensions/Blocks/Items/block.js +77 -115
- package/dist/extensions/Blocks/Items/constants/currency.js +14 -59
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +22 -33
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +51 -62
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +17 -18
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +31 -42
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +120 -141
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +1 -1
- package/dist/extensions/Blocks/Items/extension.js +8 -9
- package/dist/extensions/Blocks/Items/items.css.js +0 -19
- package/dist/extensions/Blocks/Items/settingsPanel.js +25 -34
- package/dist/extensions/Blocks/Items/template.js +212 -250
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +0 -1
- package/dist/guido.css +1 -1
- package/dist/package.json.js +1 -1
- package/dist/src/@types/config/schemas.d.ts +0 -4
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/config/migrator/index.d.ts +1 -4
- package/dist/src/extensions/Blocks/Items/block.d.ts +9 -6
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +0 -32
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/template.d.ts +1 -4
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +0 -3
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +0 -12
- package/dist/src/stores/config.d.ts +0 -20
- package/dist/src/utils/itemsCurrencyRepair.d.ts +1 -5
- package/dist/static/stripo-runtime-manifest.json.js +1 -1
- package/dist/utils/itemsCurrencyRepair.js +24 -29
- package/dist/utils/pairProductVariables.js +99 -119
- package/package.json +2 -2
- package/dist/config/migrator/itemsPriceFormatMigrator.js +0 -20
- package/dist/extensions/Blocks/Items/controls/priceFormat.js +0 -145
- package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +0 -185
- package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +0 -23
- package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +0 -61
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { ModificationDescription as C, UIElementType as T, UEAttr as L } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { CommonControl as g } from "../../../common-control.js";
|
|
3
|
-
import { ItemsBlockControlId as
|
|
3
|
+
import { ItemsBlockControlId as R, ItemsBlockId as _ } from "../../enums/controlEnums.js";
|
|
4
4
|
import { productPairs as I } from "../../enums/productEnums.js";
|
|
5
|
-
import { getItemsBlockConfig as
|
|
6
|
-
|
|
7
|
-
const N = p.PRICE_FORMATTED_PRICE, d = {
|
|
5
|
+
import { getItemsBlockConfig as p, setItemsBlockConfig as D, escapeReplacement as h } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const O = R.PRICE_FORMATTED_PRICE, d = {
|
|
8
7
|
FORMATTED_PRICE: "formattedPrice"
|
|
9
8
|
};
|
|
10
|
-
class
|
|
9
|
+
class k extends g {
|
|
11
10
|
getId() {
|
|
12
|
-
return
|
|
11
|
+
return O;
|
|
13
12
|
}
|
|
14
13
|
getTemplate() {
|
|
15
14
|
return `
|
|
16
|
-
<div class="container ${
|
|
15
|
+
<div class="container ${R.PRICE_FORMATTED_PRICE}">
|
|
17
16
|
${this._getFormattedPrice()}
|
|
18
17
|
</div>
|
|
19
18
|
`;
|
|
@@ -25,14 +24,14 @@ class G extends g {
|
|
|
25
24
|
}
|
|
26
25
|
onTemplateNodeUpdated(e) {
|
|
27
26
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
28
|
-
const t =
|
|
27
|
+
const t = p(this.currentNode);
|
|
29
28
|
this.api.updateValues({ [d.FORMATTED_PRICE]: (t == null ? void 0 : t.priceFormatted) ?? !0 });
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
31
|
_onFormattedPriceChange(e) {
|
|
33
|
-
if (console.debug("Formatted price changed to: ", e), !this.currentNode
|
|
32
|
+
if (console.debug("Formatted price changed to: ", e), !this.currentNode)
|
|
34
33
|
return;
|
|
35
|
-
const t =
|
|
34
|
+
const t = p(this.currentNode), c = (t == null ? void 0 : t.type) ?? "CART_ITEMS", o = (t == null ? void 0 : t.priceSinglePrice) ?? !1, r = I.PAIRS_FOR_EXTENSION.price[c], i = I.PAIRS_FOR_EXTENSION.originalPrice[c], [a, m] = e ? [
|
|
36
35
|
o ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE,
|
|
37
36
|
o ? r.DEFAULT_SINGLE_PRICE_FORMATTED : r.DEFAULT_PRICE_FORMATTED
|
|
38
37
|
] : [
|
|
@@ -40,12 +39,12 @@ class G extends g {
|
|
|
40
39
|
o ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE
|
|
41
40
|
], l = o ? i.DEFAULT_SINGLE_PRICE : i.DEFAULT_PRICE, P = o ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_PRICE_FORMATTED, [F, A] = e ? [l, P] : [P, l], s = this.api.getDocumentModifier();
|
|
42
41
|
D(this.currentNode, this.api, { priceFormatted: e }, s);
|
|
43
|
-
const
|
|
44
|
-
((
|
|
42
|
+
const n = this.currentNode.closest(".items-block");
|
|
43
|
+
((n == null ? void 0 : n.querySelectorAll(
|
|
45
44
|
`[esd-extension-block-id="${_.PRICE}"]`
|
|
46
45
|
)) || []).forEach((E) => {
|
|
47
|
-
this._updatePriceBlock(s, E, a,
|
|
48
|
-
}), ((
|
|
46
|
+
this._updatePriceBlock(s, E, a, m, e);
|
|
47
|
+
}), ((n == null ? void 0 : n.querySelectorAll(
|
|
49
48
|
`[esd-extension-block-id="${_.ORIGINAL_PRICE}"]`
|
|
50
49
|
)) || []).forEach((E) => {
|
|
51
50
|
this._updatePriceBlock(s, E, F, A, e);
|
|
@@ -53,8 +52,8 @@ class G extends g {
|
|
|
53
52
|
`Updated price to ${e ? "formatted" : "unformatted"}`
|
|
54
53
|
));
|
|
55
54
|
}
|
|
56
|
-
_updatePriceBlock(e, t,
|
|
57
|
-
const i = `data-formated="${r ? "true" : "false"}"`, a = t.getInnerHTML().trim().replace(
|
|
55
|
+
_updatePriceBlock(e, t, c, o, r) {
|
|
56
|
+
const i = `data-formated="${r ? "true" : "false"}"`, a = t.getInnerHTML().trim().replace(c, h(o)).replace(/data-formated=(?:"[^"]*"|'[^']*')/g, i);
|
|
58
57
|
e.modifyHtml(t).setInnerHtml(a);
|
|
59
58
|
}
|
|
60
59
|
_getFormattedPrice() {
|
|
@@ -70,6 +69,6 @@ class G extends g {
|
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
O as CONTROL_BLOCK_ID,
|
|
73
|
+
k as PriceFormattedPriceControl
|
|
75
74
|
};
|
|
@@ -1,85 +1,74 @@
|
|
|
1
|
-
import { ModificationDescription as S, UIElementType as _, UEAttr as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import { productPairs as
|
|
5
|
-
import { getItemsBlockConfig as
|
|
6
|
-
|
|
7
|
-
const f = L.PRICE_SINGLE_PRICE, P = {
|
|
1
|
+
import { ModificationDescription as S, UIElementType as _, UEAttr as m } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as A } from "../../../common-control.js";
|
|
3
|
+
import { ItemsBlockControlId as T, ItemsBlockId as d } from "../../enums/controlEnums.js";
|
|
4
|
+
import { productPairs as p } from "../../enums/productEnums.js";
|
|
5
|
+
import { getItemsBlockConfig as g, setItemsBlockConfig as N, escapeReplacement as h } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const u = T.PRICE_SINGLE_PRICE, a = {
|
|
8
7
|
SINGLE_PRICE: "singlePrice"
|
|
9
8
|
};
|
|
10
|
-
class
|
|
9
|
+
class k extends A {
|
|
11
10
|
getId() {
|
|
12
|
-
return
|
|
11
|
+
return u;
|
|
13
12
|
}
|
|
14
13
|
getTemplate() {
|
|
15
14
|
return `
|
|
16
|
-
<div class="container ${
|
|
15
|
+
<div class="container ${T.PRICE_SINGLE_PRICE}">
|
|
17
16
|
${this._getSinglePrice()}
|
|
18
17
|
</div>
|
|
19
18
|
`;
|
|
20
19
|
}
|
|
21
20
|
onRender() {
|
|
22
|
-
this.forgetLastPanelNode(), this.api.onValueChanged(
|
|
21
|
+
this.forgetLastPanelNode(), this.api.onValueChanged(a.SINGLE_PRICE, (e) => {
|
|
23
22
|
this._onSinglePriceChange(e);
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
onTemplateNodeUpdated(e) {
|
|
27
26
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
28
|
-
const
|
|
29
|
-
this.api.updateValues({ [
|
|
27
|
+
const t = g(this.currentNode);
|
|
28
|
+
this.api.updateValues({ [a.SINGLE_PRICE]: (t == null ? void 0 : t.priceSinglePrice) ?? !1 });
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
31
|
_onSinglePriceChange(e) {
|
|
33
|
-
|
|
34
|
-
if (console.debug("Single price changed to: ", e), u(this.currentNode)) {
|
|
35
|
-
((I = a(this.currentNode)) == null ? void 0 : I.priceSinglePrice) !== e && D(
|
|
36
|
-
this.currentNode,
|
|
37
|
-
this.api,
|
|
38
|
-
{ priceSinglePrice: e },
|
|
39
|
-
`Updated price to ${e ? "single" : "total"} price`
|
|
40
|
-
);
|
|
32
|
+
if (console.debug("Single price changed to: ", e), !this.currentNode)
|
|
41
33
|
return;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const i = a(this.currentNode), c = (i == null ? void 0 : i.type) ?? "CART_ITEMS", r = (i == null ? void 0 : i.priceFormatted) ?? !1, t = T.PAIRS_FOR_EXTENSION.price[c], n = T.PAIRS_FOR_EXTENSION.originalPrice[c], [l, R] = e ? [
|
|
46
|
-
r ? t.DEFAULT_PRICE_FORMATTED : t.DEFAULT_PRICE,
|
|
47
|
-
r ? t.DEFAULT_SINGLE_PRICE_FORMATTED : t.DEFAULT_SINGLE_PRICE
|
|
34
|
+
const t = g(this.currentNode), c = (t == null ? void 0 : t.type) ?? "CART_ITEMS", r = (t == null ? void 0 : t.priceFormatted) ?? !1, i = p.PAIRS_FOR_EXTENSION.price[c], n = p.PAIRS_FOR_EXTENSION.originalPrice[c], [l, L] = e ? [
|
|
35
|
+
r ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE,
|
|
36
|
+
r ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE
|
|
48
37
|
] : [
|
|
49
|
-
r ?
|
|
50
|
-
r ?
|
|
51
|
-
],
|
|
52
|
-
|
|
38
|
+
r ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE,
|
|
39
|
+
r ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE
|
|
40
|
+
], I = r ? n.DEFAULT_PRICE_FORMATTED : n.DEFAULT_PRICE, P = r ? n.DEFAULT_SINGLE_PRICE_FORMATTED : n.DEFAULT_SINGLE_PRICE, [R, C] = e ? [I, P] : [P, I], s = this.api.getDocumentModifier();
|
|
41
|
+
N(this.currentNode, this.api, { priceSinglePrice: e }, s);
|
|
53
42
|
const o = this.currentNode.closest(".items-block");
|
|
54
43
|
((o == null ? void 0 : o.querySelectorAll(
|
|
55
|
-
`[esd-extension-block-id="${
|
|
44
|
+
`[esd-extension-block-id="${d.PRICE}"]`
|
|
56
45
|
)) || []).forEach((E) => {
|
|
57
|
-
this._updatePriceBlock(s, E, l,
|
|
46
|
+
this._updatePriceBlock(s, E, l, L, e);
|
|
58
47
|
}), ((o == null ? void 0 : o.querySelectorAll(
|
|
59
|
-
`[esd-extension-block-id="${
|
|
48
|
+
`[esd-extension-block-id="${d.ORIGINAL_PRICE}"]`
|
|
60
49
|
)) || []).forEach((E) => {
|
|
61
|
-
this._updatePriceBlock(s, E,
|
|
50
|
+
this._updatePriceBlock(s, E, R, C, e);
|
|
62
51
|
}), s.apply(new S(
|
|
63
52
|
`Updated price to ${e ? "single" : "total"} price`
|
|
64
53
|
));
|
|
65
54
|
}
|
|
66
|
-
_updatePriceBlock(e,
|
|
67
|
-
const n = `data-single_price="${
|
|
68
|
-
e.modifyHtml(
|
|
55
|
+
_updatePriceBlock(e, t, c, r, i) {
|
|
56
|
+
const n = `data-single_price="${i ? "true" : "false"}"`, l = t.getInnerHTML().trim().replace(c, h(r)).replace(/data-single_price=(?:"[^"]*"|'[^']*')/g, n);
|
|
57
|
+
e.modifyHtml(t).setInnerHtml(l);
|
|
69
58
|
}
|
|
70
59
|
_getSinglePrice() {
|
|
71
60
|
return `
|
|
72
61
|
<div class="display-flex align-items-center justify-content-between">
|
|
73
62
|
<${_.LABEL}
|
|
74
|
-
${
|
|
63
|
+
${m.LABEL.text}="${this.api.translate("Show Single Product Price")}"
|
|
75
64
|
>
|
|
76
65
|
</${_.LABEL}>
|
|
77
|
-
${this._GuToggle(
|
|
66
|
+
${this._GuToggle(a.SINGLE_PRICE)}
|
|
78
67
|
</div>
|
|
79
68
|
`;
|
|
80
69
|
}
|
|
81
70
|
}
|
|
82
71
|
export {
|
|
83
|
-
|
|
84
|
-
|
|
72
|
+
u as CONTROL_BLOCK_ID,
|
|
73
|
+
k as PriceSinglePriceControl
|
|
85
74
|
};
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { ModificationDescription as N, UEAttr as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { reorientBlockCellPadding as
|
|
4
|
-
import { isNewPriceFormatConfig as O } from "../constants/currency.js";
|
|
1
|
+
import { ModificationDescription as N, UEAttr as L } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as F } from "../../common-control.js";
|
|
3
|
+
import { reorientBlockCellPadding as D, nameMaxWidthFor as $ } from "../constants/cardLayout.js";
|
|
5
4
|
import { ItemsBlockId as T } from "../enums/controlEnums.js";
|
|
6
|
-
import { productPairs as S, templateFirstLine as
|
|
7
|
-
import { SETTINGS_ENUMS as I, ItemTypeOptions as H, OrientationOptions as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { getDefaultTemplate as
|
|
11
|
-
import { findNameTextNode as
|
|
12
|
-
import { getItemsBlockConfig as _, setItemsBlockConfig as
|
|
13
|
-
|
|
14
|
-
const X = "ui-elements-items-block", p = {
|
|
5
|
+
import { productPairs as S, templateFirstLine as x } from "../enums/productEnums.js";
|
|
6
|
+
import { SETTINGS_ENUMS as I, ItemTypeOptions as H, OrientationOptions as w, ItemInCartOptions as O, DefaultConfigValues as U } from "../enums/settingsEnums.js";
|
|
7
|
+
import q from "../layouts/horizontal.html.js";
|
|
8
|
+
import B from "../layouts/vertical.html.js";
|
|
9
|
+
import { getDefaultTemplate as V, wrapInTableRow as C, applyPriceOrientationStyles as G } from "../template.js";
|
|
10
|
+
import { findNameTextNode as Y } from "../utils/nameNode.js";
|
|
11
|
+
import { getItemsBlockConfig as _, setItemsBlockConfig as b, escapeReplacement as g, deriveItemNumber as v } from "../utils/nodeConfigUtils.js";
|
|
12
|
+
const Q = "ui-elements-items-block", p = {
|
|
15
13
|
ITEMS_TYPE: "itemsType",
|
|
16
14
|
ORIENTATION: "orientation",
|
|
17
15
|
ITEM_IDS: "itemIds"
|
|
18
16
|
};
|
|
19
|
-
class
|
|
17
|
+
class oe extends F {
|
|
20
18
|
getId() {
|
|
21
|
-
return
|
|
19
|
+
return Q;
|
|
22
20
|
}
|
|
23
21
|
getTemplate() {
|
|
24
22
|
return `
|
|
@@ -34,11 +32,11 @@ class me extends $ {
|
|
|
34
32
|
}
|
|
35
33
|
onTemplateNodeUpdated(e) {
|
|
36
34
|
super.onTemplateNodeUpdated(e), console.debug("Items Block Config", e.getNodeConfig()), this.handleBlockInstanceChange(() => {
|
|
37
|
-
const
|
|
35
|
+
const r = _(this.currentNode);
|
|
38
36
|
this.api.updateValues({
|
|
39
|
-
[p.ORIENTATION]: (
|
|
40
|
-
[p.ITEMS_TYPE]: (
|
|
41
|
-
[p.ITEM_IDS]: (
|
|
37
|
+
[p.ORIENTATION]: (r == null ? void 0 : r.orientation) ?? I.ORIENTATION.VERTICAL,
|
|
38
|
+
[p.ITEMS_TYPE]: (r == null ? void 0 : r.type) ?? I.ITEMS_TYPE.CART_ITEMS,
|
|
39
|
+
[p.ITEM_IDS]: (r == null ? void 0 : r.itemsSelectValue) ?? ""
|
|
42
40
|
}), this._initializeSelectItems();
|
|
43
41
|
});
|
|
44
42
|
}
|
|
@@ -61,7 +59,7 @@ class me extends $ {
|
|
|
61
59
|
this._GuLabel({ text: "Orientation" }),
|
|
62
60
|
this._GuRadioButton({
|
|
63
61
|
name: p.ORIENTATION,
|
|
64
|
-
buttons:
|
|
62
|
+
buttons: w
|
|
65
63
|
})
|
|
66
64
|
])}
|
|
67
65
|
`;
|
|
@@ -81,55 +79,55 @@ class me extends $ {
|
|
|
81
79
|
}
|
|
82
80
|
_onOrientationChange(e) {
|
|
83
81
|
this.api.updateValues({ [p.ORIENTATION]: e });
|
|
84
|
-
const
|
|
85
|
-
|
|
82
|
+
const r = this.api.getDocumentModifier();
|
|
83
|
+
b(this.currentNode, this.api, {
|
|
86
84
|
orientation: e,
|
|
87
85
|
priceOrientation: "horizontal"
|
|
88
|
-
},
|
|
86
|
+
}, r), r.apply(new N("Changed orientation")), this._reOrderTemplate(), setTimeout(() => {
|
|
89
87
|
this._recalculateTrimming();
|
|
90
88
|
}, 50);
|
|
91
89
|
}
|
|
92
90
|
_onItemsTypeChange(e) {
|
|
93
|
-
const
|
|
94
|
-
if (!
|
|
91
|
+
const r = I.ITEMS_TYPE[e], t = O[e], i = t == null ? void 0 : t[0];
|
|
92
|
+
if (!r || !i)
|
|
95
93
|
return;
|
|
96
|
-
const n =
|
|
97
|
-
|
|
98
|
-
source:
|
|
99
|
-
type:
|
|
100
|
-
itemsSelectValue:
|
|
94
|
+
const n = i.value, o = i.value.replace("Url}}", "Image}}"), a = this.api.getDocumentModifier();
|
|
95
|
+
b(this.currentNode, this.api, {
|
|
96
|
+
source: r,
|
|
97
|
+
type: r,
|
|
98
|
+
itemsSelectValue: i.value,
|
|
101
99
|
imageLink: o,
|
|
102
100
|
buttonLink: n
|
|
103
|
-
}, a), this._updateDataTypeAttributes(
|
|
104
|
-
const
|
|
105
|
-
this._updateImageSrc(
|
|
101
|
+
}, a), this._updateDataTypeAttributes(r, a), this._initializeSelectItems();
|
|
102
|
+
const l = this._getTemplateData(r, i.value);
|
|
103
|
+
this._updateImageSrc(l.imageSrc, a), this._updateName(l.name, a), this._updatePrice(l.price, a), this._updateOriginalPrice(l.originalPrice, a), this._updateQuantity(l.quantity, r, a), a.apply(new N("Updated items type"));
|
|
106
104
|
}
|
|
107
105
|
_onItemIdsChange(e) {
|
|
108
106
|
this.api.updateValues({ [p.ITEM_IDS]: e });
|
|
109
|
-
const
|
|
110
|
-
|
|
107
|
+
const r = e, t = e.replace("Url}}", "Image}}"), i = this.api.getDocumentModifier();
|
|
108
|
+
b(this.currentNode, this.api, {
|
|
111
109
|
itemsSelectValue: e,
|
|
112
110
|
imageLink: t,
|
|
113
|
-
buttonLink:
|
|
114
|
-
},
|
|
111
|
+
buttonLink: r
|
|
112
|
+
}, i), this._updateDataNumberAttributes(e, i);
|
|
115
113
|
const n = this._getTemplateData(void 0, e);
|
|
116
|
-
this._updateImageSrc(n.imageSrc,
|
|
114
|
+
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"));
|
|
117
115
|
}
|
|
118
116
|
_initializeSelectItems() {
|
|
119
117
|
this.api.setUIEAttribute(
|
|
120
118
|
p.ITEMS_TYPE,
|
|
121
|
-
|
|
119
|
+
L.SELECTPICKER.items,
|
|
122
120
|
H
|
|
123
121
|
);
|
|
124
|
-
const e = _(this.currentNode),
|
|
122
|
+
const e = _(this.currentNode), r = (e == null ? void 0 : e.type) ?? I.ITEMS_TYPE.CART_ITEMS, t = (e == null ? void 0 : e.itemsSelectValue) ?? "";
|
|
125
123
|
this.api.updateValues({
|
|
126
|
-
[p.ITEMS_TYPE]:
|
|
124
|
+
[p.ITEMS_TYPE]: r
|
|
127
125
|
});
|
|
128
|
-
const
|
|
126
|
+
const i = O[r];
|
|
129
127
|
this.api.setUIEAttribute(
|
|
130
128
|
p.ITEM_IDS,
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
L.SELECTPICKER.items,
|
|
130
|
+
i
|
|
133
131
|
), this.api.updateValues({
|
|
134
132
|
[p.ITEM_IDS]: t
|
|
135
133
|
});
|
|
@@ -147,148 +145,136 @@ class me extends $ {
|
|
|
147
145
|
);
|
|
148
146
|
}
|
|
149
147
|
_renderTemplate() {
|
|
150
|
-
const e = _(this.currentNode),
|
|
151
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(
|
|
152
|
-
orientation:
|
|
148
|
+
const e = _(this.currentNode), r = (e == null ? void 0 : e.orientation) ?? I.ORIENTATION.VERTICAL, t = (e == null ? void 0 : e.type) ?? I.ITEMS_TYPE.CART_ITEMS, i = (e == null ? void 0 : e.itemsSelectValue) ?? "", n = (e == null ? void 0 : e.priceCurrencySymbol) ?? "", o = (e == null ? void 0 : e.priceCurrencyLocation) ?? "0", a = (e == null ? void 0 : e.priceFormatted) ?? !1;
|
|
149
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(V({
|
|
150
|
+
orientation: r,
|
|
153
151
|
itemsType: t,
|
|
154
|
-
itemId:
|
|
152
|
+
itemId: i,
|
|
155
153
|
currencySymbol: n,
|
|
156
154
|
currencyLocation: o,
|
|
157
155
|
formattedPrice: a
|
|
158
156
|
})).apply(new N("Updated template"));
|
|
159
157
|
}
|
|
160
|
-
_getTemplateData(e,
|
|
161
|
-
const t = _(this.currentNode),
|
|
158
|
+
_getTemplateData(e, r) {
|
|
159
|
+
const t = _(this.currentNode), i = e ?? (t == null ? void 0 : t.type) ?? I.ITEMS_TYPE.CART_ITEMS, n = r ?? (t == null ? void 0 : t.itemsSelectValue) ?? "", o = (t == null ? void 0 : t.priceFormatted) ?? !1, a = (t == null ? void 0 : t.priceSinglePrice) ?? !1, l = O[i].findIndex((h) => h.value === n), c = l > -1 ? l : 0, s = S.PAIRS_FOR_EXTENSION.price[i], d = S.PAIRS_FOR_EXTENSION.originalPrice[i];
|
|
162
160
|
let m, u;
|
|
163
|
-
return
|
|
164
|
-
imageSrc: S.PAIRS_FOR_EXTENSION.imageSrc[
|
|
165
|
-
name: S.PAIRS_FOR_EXTENSION.name[
|
|
161
|
+
return a ? (m = o ? s.DEFAULT_SINGLE_PRICE_FORMATTED : s.DEFAULT_SINGLE_PRICE, u = o ? d.DEFAULT_SINGLE_PRICE_FORMATTED : d.DEFAULT_SINGLE_PRICE) : (m = o ? s.DEFAULT_PRICE_FORMATTED : s.DEFAULT_PRICE, u = o ? d.DEFAULT_PRICE_FORMATTED : d.DEFAULT_PRICE), {
|
|
162
|
+
imageSrc: S.PAIRS_FOR_EXTENSION.imageSrc[i].DEFAULT[c],
|
|
163
|
+
name: S.PAIRS_FOR_EXTENSION.name[i].DEFAULT[c],
|
|
166
164
|
price: m,
|
|
167
165
|
originalPrice: u,
|
|
168
|
-
quantity: S.PAIRS_FOR_EXTENSION.quantity[
|
|
169
|
-
button: S.PAIRS_FOR_EXTENSION.button[
|
|
166
|
+
quantity: S.PAIRS_FOR_EXTENSION.quantity[i].DEFAULT,
|
|
167
|
+
button: S.PAIRS_FOR_EXTENSION.button[i].DEFAULT_LABEL
|
|
170
168
|
};
|
|
171
169
|
}
|
|
172
|
-
_updateImageSrc(e,
|
|
173
|
-
var
|
|
174
|
-
const t = (
|
|
175
|
-
t &&
|
|
170
|
+
_updateImageSrc(e, r) {
|
|
171
|
+
var i;
|
|
172
|
+
const t = (i = this.currentNode) == null ? void 0 : i.querySelector(`[esd-extension-block-id="${T.IMAGE}"] img`);
|
|
173
|
+
t && r.modifyHtml(t).setAttribute("src", e);
|
|
176
174
|
}
|
|
177
|
-
_updateName(e,
|
|
175
|
+
_updateName(e, r) {
|
|
178
176
|
var o;
|
|
179
177
|
const t = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${T.NAME}"]`);
|
|
180
178
|
if (!t)
|
|
181
179
|
return;
|
|
182
|
-
const
|
|
180
|
+
const i = t.getInnerText().trim();
|
|
183
181
|
let n = t.getInnerHTML().trim();
|
|
184
|
-
n = n.replace(
|
|
182
|
+
n = n.replace(i, g(e)), r.modifyHtml(t).setInnerHtml(n);
|
|
185
183
|
}
|
|
186
|
-
_updatePrice(e,
|
|
184
|
+
_updatePrice(e, r) {
|
|
187
185
|
var a;
|
|
188
186
|
const t = ((a = this.currentNode) == null ? void 0 : a.querySelectorAll(
|
|
189
187
|
`[esd-extension-block-id="${T.PRICE}"]`
|
|
190
|
-
)) || [],
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
});
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
t.forEach((c) => {
|
|
198
|
-
const l = this._getParagraphFromBlock(c);
|
|
199
|
-
if (!l)
|
|
188
|
+
)) || [], i = _(this.currentNode), n = (i == null ? void 0 : i.priceCurrencySymbol) ?? "", o = (i == null ? void 0 : i.priceCurrencyLocation) ?? "0";
|
|
189
|
+
t.forEach((l) => {
|
|
190
|
+
const c = this._getParagraphFromBlock(l);
|
|
191
|
+
if (!c)
|
|
200
192
|
return;
|
|
201
|
-
const s =
|
|
202
|
-
|
|
193
|
+
const s = c.getInnerHTML().trim() || "", d = c.getInnerText().trim() || "", m = (n == null ? void 0 : n.trim()) || "", u = this._removeCurrencySymbol(d, m), h = this._replacePriceNumber(u, e), E = this._buildPriceContent(h, m, o), y = s.replace(d, g(E));
|
|
194
|
+
r.modifyHtml(c).setInnerHtml(y);
|
|
203
195
|
});
|
|
204
196
|
}
|
|
205
|
-
_updateOriginalPrice(e,
|
|
197
|
+
_updateOriginalPrice(e, r) {
|
|
206
198
|
var a;
|
|
207
199
|
const t = ((a = this.currentNode) == null ? void 0 : a.querySelectorAll(
|
|
208
200
|
`[esd-extension-block-id="${T.ORIGINAL_PRICE}"]`
|
|
209
|
-
)) || [],
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
});
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
t.forEach((c) => {
|
|
217
|
-
const l = this._getParagraphFromBlock(c);
|
|
218
|
-
if (!l)
|
|
201
|
+
)) || [], i = _(this.currentNode), n = (i == null ? void 0 : i.priceCurrencySymbol) ?? "", o = (i == null ? void 0 : i.priceCurrencyLocation) ?? "0";
|
|
202
|
+
t.forEach((l) => {
|
|
203
|
+
const c = this._getParagraphFromBlock(l);
|
|
204
|
+
if (!c)
|
|
219
205
|
return;
|
|
220
|
-
const s =
|
|
206
|
+
const s = c.querySelector("s");
|
|
221
207
|
if (!s)
|
|
222
208
|
return;
|
|
223
|
-
const d = s.getInnerHTML().trim() || "", m = s.getInnerText().trim() || "", u = (n == null ? void 0 : n.trim()) || "", h = this._removeCurrencySymbol(m, u), E = this._replacePriceNumber(h, e), y = this._buildPriceContent(E, u, o), A = `<s>${d.replace(m,
|
|
224
|
-
|
|
209
|
+
const d = s.getInnerHTML().trim() || "", m = s.getInnerText().trim() || "", u = (n == null ? void 0 : n.trim()) || "", h = this._removeCurrencySymbol(m, u), E = this._replacePriceNumber(h, e), y = this._buildPriceContent(E, u, o), A = `<s>${d.replace(m, g(y))}</s>`;
|
|
210
|
+
r.modifyHtml(c).setInnerHtml(A);
|
|
225
211
|
});
|
|
226
212
|
}
|
|
227
|
-
_updateQuantity(e,
|
|
213
|
+
_updateQuantity(e, r, t) {
|
|
228
214
|
var h;
|
|
229
|
-
const
|
|
230
|
-
if (!
|
|
215
|
+
const i = _(this.currentNode), o = (r ?? (i == null ? void 0 : i.type) ?? I.ITEMS_TYPE.CART_ITEMS) !== I.ITEMS_TYPE.BROWSED_ITEMS, a = (i == null ? void 0 : i.quantityControlEnabled) !== !1, l = o && a, c = (h = this.currentNode) == null ? void 0 : h.querySelector(`[esd-extension-block-id="${T.QUANTITY}"]`);
|
|
216
|
+
if (!c)
|
|
231
217
|
return;
|
|
232
|
-
const s = this._getParagraphFromBlock(
|
|
218
|
+
const s = this._getParagraphFromBlock(c);
|
|
233
219
|
if (!s)
|
|
234
220
|
return;
|
|
235
221
|
const d = s.getInnerText().trim();
|
|
236
222
|
let m = s.getInnerHTML().trim();
|
|
237
|
-
function u(E, y,
|
|
223
|
+
function u(E, y, P) {
|
|
238
224
|
return E.replace(
|
|
239
225
|
new RegExp(`(>\\s*)?${y}(\\s*<)?`, "g"),
|
|
240
|
-
`$1${
|
|
226
|
+
`$1${P}$2`
|
|
241
227
|
);
|
|
242
228
|
}
|
|
243
|
-
m = u(m, d, e), t.modifyHtml(s).setInnerHtml(m), t.modifyHtml(
|
|
229
|
+
m = u(m, d, e), t.modifyHtml(s).setInnerHtml(m), t.modifyHtml(c).setStyle("display", l ? "table-cell" : "none");
|
|
244
230
|
}
|
|
245
231
|
_reOrderTemplate(e) {
|
|
246
|
-
var h, E, y,
|
|
247
|
-
const
|
|
232
|
+
var h, E, y, P, A, M;
|
|
233
|
+
const r = (h = this.currentNode) == null ? void 0 : h.querySelector(`[esd-extension-block-id="${T.IMAGE}"]`), t = (E = this.currentNode) == null ? void 0 : E.querySelector(`[esd-extension-block-id="${T.NAME}"]`), i = ((y = this.currentNode) == null ? void 0 : y.querySelectorAll(
|
|
248
234
|
`[esd-extension-block-id="${T.PRICE}"]`
|
|
249
|
-
)) || [], n = ((
|
|
235
|
+
)) || [], n = ((P = this.currentNode) == null ? void 0 : P.querySelectorAll(
|
|
250
236
|
`[esd-extension-block-id="${T.ORIGINAL_PRICE}"]`
|
|
251
|
-
)) || [], [o] =
|
|
252
|
-
if (!
|
|
237
|
+
)) || [], [o] = i, [a] = n, l = (A = this.currentNode) == null ? void 0 : A.querySelector(`[esd-extension-block-id="${T.QUANTITY}"]`), c = (M = this.currentNode) == null ? void 0 : M.querySelector(`[esd-extension-block-id="${T.BUTTON}"]`);
|
|
238
|
+
if (!r || !t || !o || !a || !l || !c)
|
|
253
239
|
return;
|
|
254
240
|
const s = _(this.currentNode), d = (s == null ? void 0 : s.orientation) ?? I.ORIENTATION.VERTICAL, m = d === I.ORIENTATION.VERTICAL;
|
|
255
|
-
let u = m ?
|
|
241
|
+
let u = m ? B : q;
|
|
256
242
|
setTimeout(() => {
|
|
257
|
-
const
|
|
258
|
-
|
|
243
|
+
const f = g(D(o.getOuterHTML(), m)), k = g(
|
|
244
|
+
D(a.getOuterHTML(), m)
|
|
259
245
|
);
|
|
260
|
-
u = u.replace("{-{-TEMPLATE_FIRST_LINE-}-}", m ?
|
|
246
|
+
u = u.replace("{-{-TEMPLATE_FIRST_LINE-}-}", m ? x : "").replace("{-{-PRODUCT_IMAGE-}-}", C(r.getOuterHTML())).replace("{-{-PRODUCT_NAME-}-}", C(t.getOuterHTML())).replaceAll("{-{-PRODUCT_PRICE-}-}", C(f)).replaceAll("{-{-PRODUCT_ORIGINAL_PRICE-}-}", C(k)).replace("{-{-PRODUCT_QUANTITY-}-}", C(l.getOuterHTML())).replace("{-{-PRODUCT_BUTTON-}-}", C(c.getOuterHTML())), u = G(
|
|
261
247
|
u,
|
|
262
248
|
d,
|
|
263
249
|
(s == null ? void 0 : s.priceOrientation) ?? "horizontal",
|
|
264
250
|
(s == null ? void 0 : s.priceVisible) ?? !0,
|
|
265
251
|
(s == null ? void 0 : s.originalPriceVisible) ?? !0
|
|
266
|
-
), u = u.trim().replace(
|
|
252
|
+
), u = u.trim().replace(x, "").slice(0, -5);
|
|
267
253
|
const R = e ?? this.api.getDocumentModifier();
|
|
268
|
-
R.modifyHtml(
|
|
254
|
+
R.modifyHtml(r.querySelector("img")).setAttribute("width", U.productImageWidth).setAttribute("height", U.productImageWidth), R.modifyHtml(this.currentNode).setInnerHtml(u), e || R.apply(new N("Reordered template"));
|
|
269
255
|
}, 50);
|
|
270
256
|
}
|
|
271
|
-
_updateDataTypeAttributes(e,
|
|
257
|
+
_updateDataTypeAttributes(e, r) {
|
|
272
258
|
if (!this.currentNode)
|
|
273
259
|
return;
|
|
274
260
|
const t = this.currentNode.closest(".ins-product-td");
|
|
275
|
-
t &&
|
|
261
|
+
t && r.modifyHtml(t).setAttribute("data-type", e), this.currentNode.querySelectorAll("[data-type]").forEach((n) => {
|
|
276
262
|
const o = n;
|
|
277
|
-
|
|
263
|
+
r.modifyHtml(o).setAttribute("data-type", e);
|
|
278
264
|
});
|
|
279
265
|
}
|
|
280
|
-
_updateDataNumberAttributes(e,
|
|
266
|
+
_updateDataNumberAttributes(e, r) {
|
|
281
267
|
if (!this.currentNode)
|
|
282
268
|
return;
|
|
283
|
-
const t = _(this.currentNode),
|
|
284
|
-
o &&
|
|
285
|
-
const
|
|
286
|
-
|
|
269
|
+
const t = _(this.currentNode), i = (t == null ? void 0 : t.type) ?? I.ITEMS_TYPE.CART_ITEMS, n = v(e, i), o = this.currentNode.closest(".ins-product-td");
|
|
270
|
+
o && r.modifyHtml(o).setAttribute("data-number", n), this.currentNode.querySelectorAll("[data-number]").forEach((l) => {
|
|
271
|
+
const c = l;
|
|
272
|
+
r.modifyHtml(c).setAttribute("data-number", n);
|
|
287
273
|
});
|
|
288
274
|
}
|
|
289
275
|
_reFillTemplate(e) {
|
|
290
|
-
const
|
|
291
|
-
this._updateImageSrc(
|
|
276
|
+
const r = this._getTemplateData(e), t = this.api.getDocumentModifier();
|
|
277
|
+
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"));
|
|
292
278
|
}
|
|
293
279
|
_recalculateTrimming() {
|
|
294
280
|
var o;
|
|
@@ -297,49 +283,42 @@ class me extends $ {
|
|
|
297
283
|
const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${T.NAME}"]`);
|
|
298
284
|
if (!e)
|
|
299
285
|
return;
|
|
300
|
-
const
|
|
301
|
-
if (!
|
|
286
|
+
const r = Y(e);
|
|
287
|
+
if (!r)
|
|
302
288
|
return;
|
|
303
|
-
const t = _(this.currentNode),
|
|
304
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
289
|
+
const t = _(this.currentNode), i = (t == null ? void 0 : t.nameTrimming) ?? !0, n = $(t == null ? void 0 : t.orientation);
|
|
290
|
+
this.api.getDocumentModifier().modifyHtml(r).setStyle("overflow", "hidden").setStyle("white-space", i ? "nowrap" : "normal").setStyle("text-overflow", i ? "ellipsis" : "unset").setStyle("max-width", n).removeStyle("width").apply(new N("Recalculated trimming after orientation change"));
|
|
305
291
|
}
|
|
306
292
|
_getParagraphFromBlock(e) {
|
|
307
293
|
return e.querySelector("p");
|
|
308
294
|
}
|
|
309
|
-
_replacePriceText(e, i, t) {
|
|
310
|
-
const r = this._getParagraphFromBlock(e);
|
|
311
|
-
if (!r)
|
|
312
|
-
return;
|
|
313
|
-
const n = r.getInnerText().trim();
|
|
314
|
-
t.modifyHtml(r).setInnerHtml(z(r.getInnerHTML(), n, i));
|
|
315
|
-
}
|
|
316
295
|
_escapeRegex(e) {
|
|
317
296
|
return e.replace(/[-\\^$*+?().|[\]{}]/g, "\\$&");
|
|
318
297
|
}
|
|
319
|
-
_removeCurrencySymbol(e,
|
|
298
|
+
_removeCurrencySymbol(e, r) {
|
|
320
299
|
const t = e || "";
|
|
321
|
-
let
|
|
322
|
-
if (
|
|
323
|
-
const n = new RegExp(`\\s*${this._escapeRegex(
|
|
324
|
-
|
|
300
|
+
let i = t;
|
|
301
|
+
if (r) {
|
|
302
|
+
const n = new RegExp(`\\s*${this._escapeRegex(r)}\\s*`);
|
|
303
|
+
i = t.replace(n, "").trim();
|
|
325
304
|
} else {
|
|
326
305
|
const n = t.match(/([^0-9.,\s]+)/);
|
|
327
306
|
if (n && n[1]) {
|
|
328
307
|
const o = n[1].trim(), a = new RegExp(`\\s*${this._escapeRegex(o)}\\s*`);
|
|
329
|
-
|
|
308
|
+
i = t.replace(a, "").trim();
|
|
330
309
|
}
|
|
331
310
|
}
|
|
332
|
-
return
|
|
311
|
+
return i;
|
|
333
312
|
}
|
|
334
|
-
_replacePriceNumber(e,
|
|
313
|
+
_replacePriceNumber(e, r) {
|
|
335
314
|
const t = /([0-9][0-9,.]*)/;
|
|
336
|
-
return e.replace(t,
|
|
315
|
+
return e.replace(t, r).trim();
|
|
337
316
|
}
|
|
338
|
-
_buildPriceContent(e,
|
|
339
|
-
return
|
|
317
|
+
_buildPriceContent(e, r, t) {
|
|
318
|
+
return r ? t === "1" ? `${e} ${r}` : `${r} ${e}` : e;
|
|
340
319
|
}
|
|
341
320
|
}
|
|
342
321
|
export {
|
|
343
|
-
|
|
344
|
-
|
|
322
|
+
Q as CONTROL_BLOCK_ID,
|
|
323
|
+
oe as ItemsBlockControl
|
|
345
324
|
};
|