@useinsider/guido 3.21.2-beta.4c14c74 → 3.21.2-beta.5a809f7
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 +22 -22
- package/dist/config/migrator/recommendation/compositionMapper.js +56 -49
- package/dist/config/migrator/recommendation/extractors.js +74 -26
- package/dist/config/migrator/recommendation/htmlBuilder.js +279 -202
- package/dist/config/migrator/recommendation/settingsMapper.js +37 -36
- package/dist/config/migrator/recommendationMigrator.js +65 -59
- package/dist/extensions/Blocks/Items/controls/button/link.js +17 -14
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +17 -14
- package/dist/extensions/Blocks/Items/controls/image/link.js +17 -14
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +10 -9
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +13 -12
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +30 -29
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +16 -15
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +26 -25
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +28 -27
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +80 -75
- package/dist/extensions/Blocks/Recommendation/block.js +33 -24
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +27 -26
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +13 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +216 -236
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +15 -15
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +10 -10
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +1 -1
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +23 -22
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +19 -18
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +82 -91
- package/dist/extensions/Blocks/Recommendation/utils/inlinePriceOrder.js +12 -0
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +3 -2
- package/dist/extensions/Blocks/common-control.js +55 -62
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/extractors.d.ts +26 -0
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +4 -11
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -13
- package/dist/src/extensions/Blocks/Recommendation/utils/inlinePriceOrder.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +2 -19
- package/dist/src/extensions/Blocks/common-control.d.ts +0 -2
- package/package.json +1 -1
|
@@ -2,20 +2,20 @@ var R = Object.defineProperty;
|
|
|
2
2
|
var N = (s, c, e) => c in s ? R(s, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[c] = e;
|
|
3
3
|
var h = (s, c, e) => N(s, typeof c != "symbol" ? c + "" : c, e);
|
|
4
4
|
import { ModificationDescription as E } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { ITEMS_CURRENCY_ATTR as
|
|
5
|
+
import { CommonControl as B } from "../../../common-control.js";
|
|
6
|
+
import { ITEMS_CURRENCY_ATTR as T } from "../../constants/currency.js";
|
|
7
7
|
import { ItemsBlockControlId as y } from "../../enums/controlEnums.js";
|
|
8
|
-
import { getItemsBlockConfig as p, setItemsBlockConfig as
|
|
9
|
-
const
|
|
8
|
+
import { getItemsBlockConfig as p, setItemsBlockConfig as Y, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
|
|
9
|
+
const x = y.PRICE_CURRENCY_SYMBOL, u = {
|
|
10
10
|
CURRENCY_SYMBOL: "currencySymbol"
|
|
11
11
|
};
|
|
12
|
-
class $ extends
|
|
12
|
+
class $ extends B {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
15
|
h(this, "originalPriceContents", /* @__PURE__ */ new Map());
|
|
16
16
|
}
|
|
17
17
|
getId() {
|
|
18
|
-
return
|
|
18
|
+
return x;
|
|
19
19
|
}
|
|
20
20
|
getTemplate() {
|
|
21
21
|
return `
|
|
@@ -25,8 +25,9 @@ class $ extends f {
|
|
|
25
25
|
`;
|
|
26
26
|
}
|
|
27
27
|
onRender() {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const e = p(this.currentNode);
|
|
29
|
+
this.api.updateValues({ [u.CURRENCY_SYMBOL]: (e == null ? void 0 : e.priceCurrencySymbol) ?? "" }), this._storeOriginalContents(), this.api.onValueChanged(u.CURRENCY_SYMBOL, (t) => {
|
|
30
|
+
this._onCurrencySymbolChange(t);
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
onDestroy() {
|
|
@@ -42,7 +43,7 @@ class $ extends f {
|
|
|
42
43
|
var a;
|
|
43
44
|
console.debug("Currency symbol changed to: ", e);
|
|
44
45
|
const t = p(this.currentNode), o = ((a = t == null ? void 0 : t.priceCurrencySymbol) == null ? void 0 : a.trim()) || "";
|
|
45
|
-
if (
|
|
46
|
+
if (Y(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
|
|
46
47
|
return;
|
|
47
48
|
const r = this._getPriceBlocks();
|
|
48
49
|
if (!r || r.length === 0)
|
|
@@ -52,8 +53,8 @@ class $ extends f {
|
|
|
52
53
|
const m = this._getParagraph(d);
|
|
53
54
|
if (!m)
|
|
54
55
|
return;
|
|
55
|
-
const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C,
|
|
56
|
-
i.modifyHtml(m).setInnerHtml(b).setAttribute(
|
|
56
|
+
const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, f(S));
|
|
57
|
+
i.modifyHtml(m).setInnerHtml(b).setAttribute(T.SYMBOL, n);
|
|
57
58
|
}), i.apply(new E(
|
|
58
59
|
`Updated currency symbol to ${n || "removed"}`
|
|
59
60
|
));
|
|
@@ -115,6 +116,6 @@ class $ extends f {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
export {
|
|
118
|
-
|
|
119
|
+
x as CONTROL_BLOCK_ID,
|
|
119
120
|
$ as PriceCurrencySymbolControl
|
|
120
121
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ModificationDescription as C, UIElementType as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as R, ItemsBlockId as
|
|
4
|
-
import { productPairs as
|
|
5
|
-
import { getItemsBlockConfig as
|
|
6
|
-
const O = R.PRICE_FORMATTED_PRICE,
|
|
1
|
+
import { ModificationDescription as C, UIElementType as _, UEAttr as L } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as D } from "../../../common-control.js";
|
|
3
|
+
import { ItemsBlockControlId as R, ItemsBlockId as I } from "../../enums/controlEnums.js";
|
|
4
|
+
import { productPairs as p } from "../../enums/productEnums.js";
|
|
5
|
+
import { getItemsBlockConfig as l, setItemsBlockConfig as h, escapeReplacement as g } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const O = R.PRICE_FORMATTED_PRICE, a = {
|
|
7
7
|
FORMATTED_PRICE: "formattedPrice"
|
|
8
8
|
};
|
|
9
|
-
class k extends
|
|
9
|
+
class k extends D {
|
|
10
10
|
getId() {
|
|
11
11
|
return O;
|
|
12
12
|
}
|
|
@@ -18,52 +18,53 @@ class k extends g {
|
|
|
18
18
|
`;
|
|
19
19
|
}
|
|
20
20
|
onRender() {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const e = l(this.currentNode);
|
|
22
|
+
this.api.updateValues({ [a.FORMATTED_PRICE]: (e == null ? void 0 : e.priceFormatted) ?? !0 }), this.api.onValueChanged(a.FORMATTED_PRICE, (t) => {
|
|
23
|
+
this._onFormattedPriceChange(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 = l(this.currentNode);
|
|
29
|
+
this.api.updateValues({ [a.FORMATTED_PRICE]: (t == null ? void 0 : t.priceFormatted) ?? !0 });
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
_onFormattedPriceChange(e) {
|
|
32
33
|
if (console.debug("Formatted price changed to: ", e), !this.currentNode)
|
|
33
34
|
return;
|
|
34
|
-
const t =
|
|
35
|
+
const t = l(this.currentNode), n = (t == null ? void 0 : t.type) ?? "CART_ITEMS", o = (t == null ? void 0 : t.priceSinglePrice) ?? !1, r = p.PAIRS_FOR_EXTENSION.price[n], i = p.PAIRS_FOR_EXTENSION.originalPrice[n], [E, m] = e ? [
|
|
35
36
|
o ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE,
|
|
36
37
|
o ? r.DEFAULT_SINGLE_PRICE_FORMATTED : r.DEFAULT_PRICE_FORMATTED
|
|
37
38
|
] : [
|
|
38
39
|
o ? r.DEFAULT_SINGLE_PRICE_FORMATTED : r.DEFAULT_PRICE_FORMATTED,
|
|
39
40
|
o ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE
|
|
40
|
-
],
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
((
|
|
44
|
-
`[esd-extension-block-id="${
|
|
45
|
-
)) || []).forEach((
|
|
46
|
-
this._updatePriceBlock(s,
|
|
47
|
-
}), ((
|
|
48
|
-
`[esd-extension-block-id="${
|
|
49
|
-
)) || []).forEach((
|
|
50
|
-
this._updatePriceBlock(s,
|
|
41
|
+
], T = o ? i.DEFAULT_SINGLE_PRICE : i.DEFAULT_PRICE, P = o ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_PRICE_FORMATTED, [F, A] = e ? [T, P] : [P, T], s = this.api.getDocumentModifier();
|
|
42
|
+
h(this.currentNode, this.api, { priceFormatted: e }, s);
|
|
43
|
+
const c = this.currentNode.closest(".items-block");
|
|
44
|
+
((c == null ? void 0 : c.querySelectorAll(
|
|
45
|
+
`[esd-extension-block-id="${I.PRICE}"]`
|
|
46
|
+
)) || []).forEach((d) => {
|
|
47
|
+
this._updatePriceBlock(s, d, E, m, e);
|
|
48
|
+
}), ((c == null ? void 0 : c.querySelectorAll(
|
|
49
|
+
`[esd-extension-block-id="${I.ORIGINAL_PRICE}"]`
|
|
50
|
+
)) || []).forEach((d) => {
|
|
51
|
+
this._updatePriceBlock(s, d, F, A, e);
|
|
51
52
|
}), s.apply(new C(
|
|
52
53
|
`Updated price to ${e ? "formatted" : "unformatted"}`
|
|
53
54
|
));
|
|
54
55
|
}
|
|
55
|
-
_updatePriceBlock(e, t,
|
|
56
|
-
const i = `data-formated="${r ? "true" : "false"}"`,
|
|
57
|
-
e.modifyHtml(t).setInnerHtml(
|
|
56
|
+
_updatePriceBlock(e, t, n, o, r) {
|
|
57
|
+
const i = `data-formated="${r ? "true" : "false"}"`, E = t.getInnerHTML().trim().replace(n, g(o)).replace(/data-formated=(?:"[^"]*"|'[^']*')/g, i);
|
|
58
|
+
e.modifyHtml(t).setInnerHtml(E);
|
|
58
59
|
}
|
|
59
60
|
_getFormattedPrice() {
|
|
60
61
|
return `
|
|
61
62
|
<div class="display-flex align-items-center justify-content-between">
|
|
62
|
-
<${
|
|
63
|
+
<${_.LABEL}
|
|
63
64
|
${L.LABEL.text}="${this.api.translate("Formatted Price (e.g. $9.90)")}"
|
|
64
65
|
>
|
|
65
|
-
</${
|
|
66
|
-
${this._GuToggle(
|
|
66
|
+
</${_.LABEL}>
|
|
67
|
+
${this._GuToggle(a.FORMATTED_PRICE)}
|
|
67
68
|
</div>
|
|
68
69
|
`;
|
|
69
70
|
}
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import { getItemsBlockConfig as
|
|
5
|
-
const
|
|
1
|
+
import { ModificationDescription as c, UIElementType as s, UEAttr as a } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as p } from "../../../common-control.js";
|
|
3
|
+
import { ItemsBlockControlId as r } from "../../enums/controlEnums.js";
|
|
4
|
+
import { getItemsBlockConfig as d, setItemsBlockConfig as u } from "../../utils/nodeConfigUtils.js";
|
|
5
|
+
const D = r.PRICE_HIDE_DISCOUNT, i = {
|
|
6
6
|
HIDE_DISCOUNT: "hideDiscount"
|
|
7
7
|
};
|
|
8
|
-
class
|
|
8
|
+
class E extends p {
|
|
9
9
|
getId() {
|
|
10
|
-
return
|
|
10
|
+
return D;
|
|
11
11
|
}
|
|
12
12
|
getTemplate() {
|
|
13
13
|
return `
|
|
14
|
-
<div class="container ${
|
|
14
|
+
<div class="container ${r.PRICE_HIDE_DISCOUNT}">
|
|
15
15
|
${this._getHideDiscount()}
|
|
16
16
|
</div>
|
|
17
17
|
`;
|
|
18
18
|
}
|
|
19
19
|
onRender() {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const t = d(this.currentNode);
|
|
21
|
+
this.api.updateValues({ [i.HIDE_DISCOUNT]: (t == null ? void 0 : t.priceHideDiscount) ?? !0 }), this.api.onValueChanged(i.HIDE_DISCOUNT, (e) => {
|
|
22
|
+
this._onHideDiscountChange(e);
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
onTemplateNodeUpdated(t) {
|
|
25
26
|
super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
|
|
26
|
-
const e =
|
|
27
|
+
const e = d(this.currentNode);
|
|
27
28
|
this.api.updateValues({ [i.HIDE_DISCOUNT]: (e == null ? void 0 : e.priceHideDiscount) ?? !0 });
|
|
28
29
|
});
|
|
29
30
|
}
|
|
@@ -32,13 +33,13 @@ class g extends a {
|
|
|
32
33
|
const e = this.api.getDocumentModifier();
|
|
33
34
|
u(this.currentNode, this.api, { priceHideDiscount: t }, e);
|
|
34
35
|
const o = (n = this.currentNode) == null ? void 0 : n.closest(".ins-product-td");
|
|
35
|
-
o && e.modifyHtml(o).setAttribute("data-nodup", String(t)), e.apply(new
|
|
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 });
|
|
36
37
|
}
|
|
37
38
|
_getHideDiscount() {
|
|
38
39
|
return `
|
|
39
40
|
<div class="display-flex align-items-center justify-content-between">
|
|
40
41
|
<${s.LABEL}
|
|
41
|
-
${
|
|
42
|
+
${a.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
|
|
42
43
|
>
|
|
43
44
|
</${s.LABEL}>
|
|
44
45
|
${this._GuToggle(i.HIDE_DISCOUNT)}
|
|
@@ -48,6 +49,6 @@ class g extends a {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
D as CONTROL_BLOCK_ID,
|
|
53
|
+
E as PriceHideDiscountControl
|
|
53
54
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
1
|
+
import { ModificationDescription as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { CommonControl as O } from "../../../common-control.js";
|
|
3
3
|
import { ItemsBlockControlId as m } from "../../enums/controlEnums.js";
|
|
4
|
-
import { SETTINGS_ENUMS as
|
|
5
|
-
import { getItemsBlockConfig as
|
|
6
|
-
const
|
|
4
|
+
import { SETTINGS_ENUMS as h } from "../../enums/settingsEnums.js";
|
|
5
|
+
import { getItemsBlockConfig as u, setItemsBlockConfig as I } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const N = m.PRICE_ORIENTATION, c = {
|
|
7
7
|
PRICE_ORIENTATION: "priceOrientation"
|
|
8
|
-
},
|
|
8
|
+
}, y = [
|
|
9
9
|
{ icon: "vertical-orientation", value: "vertical" },
|
|
10
10
|
{ icon: "horizontal-orientation", value: "horizontal" }
|
|
11
11
|
];
|
|
12
12
|
class P extends O {
|
|
13
13
|
getId() {
|
|
14
|
-
return
|
|
14
|
+
return N;
|
|
15
15
|
}
|
|
16
16
|
getTemplate() {
|
|
17
17
|
return `
|
|
@@ -21,14 +21,15 @@ class P extends O {
|
|
|
21
21
|
`;
|
|
22
22
|
}
|
|
23
23
|
onRender() {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const i = u(this.currentNode);
|
|
25
|
+
this.api.updateValues({ [c.PRICE_ORIENTATION]: (i == null ? void 0 : i.priceOrientation) ?? "horizontal" }), this.api.onValueChanged(c.PRICE_ORIENTATION, (t) => {
|
|
26
|
+
typeof t == "string" && this._onPriceOrientationChange(t);
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
onTemplateNodeUpdated(i) {
|
|
29
30
|
super.onTemplateNodeUpdated(i), this.handleBlockInstanceChange(() => {
|
|
30
|
-
const t =
|
|
31
|
-
this.api.updateValues({ [
|
|
31
|
+
const t = u(this.currentNode);
|
|
32
|
+
this.api.updateValues({ [c.PRICE_ORIENTATION]: (t == null ? void 0 : t.priceOrientation) ?? "horizontal" });
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
_onPriceOrientationChange(i) {
|
|
@@ -36,46 +37,46 @@ class P extends O {
|
|
|
36
37
|
priceOrientation: i
|
|
37
38
|
}), !this.currentNode)
|
|
38
39
|
return;
|
|
39
|
-
const t =
|
|
40
|
+
const t = u(this.currentNode), e = ((t == null ? void 0 : t.orientation) ?? h.ORIENTATION.VERTICAL) === h.ORIENTATION.VERTICAL, o = i === "horizontal";
|
|
40
41
|
e ? this._updateVerticalLayout(o) : this._updateHorizontalLayout(o);
|
|
41
42
|
}
|
|
42
43
|
_updateVerticalLayout(i) {
|
|
43
|
-
var a,
|
|
44
|
-
const t = ((
|
|
44
|
+
var a, s, l, n;
|
|
45
|
+
const t = ((s = (a = this.currentNode) == null ? void 0 : a.closest(".ins-product-td")) == null ? void 0 : s.querySelectorAll(".product-price-class")) || [], r = ((n = (l = this.currentNode) == null ? void 0 : l.closest(".ins-product-td")) == null ? void 0 : n.querySelectorAll(".product-original-price-class")) || [];
|
|
45
46
|
if (!t || !r)
|
|
46
47
|
return;
|
|
47
48
|
const e = i ? "50%" : "100%", o = this.api.getDocumentModifier();
|
|
48
|
-
t.forEach((
|
|
49
|
-
o.modifyHtml(
|
|
50
|
-
}), r.forEach((
|
|
51
|
-
o.modifyHtml(
|
|
52
|
-
}), o.apply(new
|
|
49
|
+
t.forEach((d) => {
|
|
50
|
+
o.modifyHtml(d).setAttribute("width", e).setStyle("width", e);
|
|
51
|
+
}), r.forEach((d) => {
|
|
52
|
+
o.modifyHtml(d).setAttribute("width", e).setStyle("width", e);
|
|
53
|
+
}), o.apply(new p(`Updated original price element width to ${e}`));
|
|
53
54
|
}
|
|
54
55
|
_updateHorizontalLayout(i) {
|
|
55
|
-
var o, a,
|
|
56
|
-
const t = ((a = (o = this.currentNode) == null ? void 0 : o.closest(".ins-product-td")) == null ? void 0 : a.querySelectorAll(".horizontal-price")) || [], r = (
|
|
56
|
+
var o, a, s, l;
|
|
57
|
+
const t = ((a = (o = this.currentNode) == null ? void 0 : o.closest(".ins-product-td")) == null ? void 0 : a.querySelectorAll(".horizontal-price")) || [], r = (l = (s = this.currentNode) == null ? void 0 : s.closest(".ins-product-td")) == null ? void 0 : l.querySelector(".vertical-price");
|
|
57
58
|
if (!t || !r || t.length === 0)
|
|
58
59
|
return;
|
|
59
60
|
const e = this.api.getDocumentModifier();
|
|
60
61
|
i ? (t.forEach((n) => {
|
|
61
62
|
e.modifyHtml(n).setStyle("display", "table-cell");
|
|
62
|
-
}), e.modifyHtml(r).setStyle("display", "none"), e.apply(new
|
|
63
|
+
}), e.modifyHtml(r).setStyle("display", "none"), e.apply(new p("Show horizontal price orientation"))) : (t.forEach((n) => {
|
|
63
64
|
e.modifyHtml(n).setStyle("display", "none");
|
|
64
|
-
}), e.modifyHtml(r).setStyle("display", "table-cell"), e.apply(new
|
|
65
|
+
}), e.modifyHtml(r).setStyle("display", "table-cell"), e.apply(new p("Show vertical price orientation")));
|
|
65
66
|
}
|
|
66
67
|
_getPriceOrientation() {
|
|
67
68
|
return `
|
|
68
69
|
${this._GuTwoColumns([
|
|
69
70
|
this._GuLabel({ text: "Price Orientation" }),
|
|
70
71
|
this._GuRadioButton({
|
|
71
|
-
name:
|
|
72
|
-
buttons:
|
|
72
|
+
name: c.PRICE_ORIENTATION,
|
|
73
|
+
buttons: y
|
|
73
74
|
})
|
|
74
75
|
])}
|
|
75
76
|
`;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
export {
|
|
79
|
-
|
|
80
|
+
N as CONTROL_BLOCK_ID,
|
|
80
81
|
P as PriceOrientationControl
|
|
81
82
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ModificationDescription as S, UIElementType as
|
|
1
|
+
import { ModificationDescription as S, UIElementType as d, UEAttr as m } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { CommonControl as A } from "../../../common-control.js";
|
|
3
|
-
import { ItemsBlockControlId as T, ItemsBlockId as
|
|
4
|
-
import { productPairs as
|
|
5
|
-
import { getItemsBlockConfig as
|
|
6
|
-
const u = T.PRICE_SINGLE_PRICE,
|
|
3
|
+
import { ItemsBlockControlId as T, ItemsBlockId as p } from "../../enums/controlEnums.js";
|
|
4
|
+
import { productPairs as R } from "../../enums/productEnums.js";
|
|
5
|
+
import { getItemsBlockConfig as I, setItemsBlockConfig as N, escapeReplacement as h } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const u = T.PRICE_SINGLE_PRICE, l = {
|
|
7
7
|
SINGLE_PRICE: "singlePrice"
|
|
8
8
|
};
|
|
9
9
|
class k extends A {
|
|
@@ -18,52 +18,53 @@ class k extends A {
|
|
|
18
18
|
`;
|
|
19
19
|
}
|
|
20
20
|
onRender() {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const e = I(this.currentNode);
|
|
22
|
+
this.api.updateValues({ [l.SINGLE_PRICE]: (e == null ? void 0 : e.priceSinglePrice) ?? !1 }), this.api.onValueChanged(l.SINGLE_PRICE, (i) => {
|
|
23
|
+
this._onSinglePriceChange(i);
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
onTemplateNodeUpdated(e) {
|
|
26
27
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
27
|
-
const
|
|
28
|
-
this.api.updateValues({ [
|
|
28
|
+
const i = I(this.currentNode);
|
|
29
|
+
this.api.updateValues({ [l.SINGLE_PRICE]: (i == null ? void 0 : i.priceSinglePrice) ?? !1 });
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
_onSinglePriceChange(e) {
|
|
32
33
|
if (console.debug("Single price changed to: ", e), !this.currentNode)
|
|
33
34
|
return;
|
|
34
|
-
const
|
|
35
|
-
r ?
|
|
36
|
-
r ?
|
|
35
|
+
const i = I(this.currentNode), c = (i == null ? void 0 : i.type) ?? "CART_ITEMS", r = (i == null ? void 0 : i.priceFormatted) ?? !1, t = R.PAIRS_FOR_EXTENSION.price[c], n = R.PAIRS_FOR_EXTENSION.originalPrice[c], [E, g] = e ? [
|
|
36
|
+
r ? t.DEFAULT_PRICE_FORMATTED : t.DEFAULT_PRICE,
|
|
37
|
+
r ? t.DEFAULT_SINGLE_PRICE_FORMATTED : t.DEFAULT_SINGLE_PRICE
|
|
37
38
|
] : [
|
|
38
|
-
r ?
|
|
39
|
-
r ?
|
|
40
|
-
],
|
|
39
|
+
r ? t.DEFAULT_SINGLE_PRICE_FORMATTED : t.DEFAULT_SINGLE_PRICE,
|
|
40
|
+
r ? t.DEFAULT_PRICE_FORMATTED : t.DEFAULT_PRICE
|
|
41
|
+
], P = r ? n.DEFAULT_PRICE_FORMATTED : n.DEFAULT_PRICE, _ = r ? n.DEFAULT_SINGLE_PRICE_FORMATTED : n.DEFAULT_SINGLE_PRICE, [L, C] = e ? [P, _] : [_, P], s = this.api.getDocumentModifier();
|
|
41
42
|
N(this.currentNode, this.api, { priceSinglePrice: e }, s);
|
|
42
43
|
const o = this.currentNode.closest(".items-block");
|
|
43
44
|
((o == null ? void 0 : o.querySelectorAll(
|
|
44
|
-
`[esd-extension-block-id="${
|
|
45
|
-
)) || []).forEach((
|
|
46
|
-
this._updatePriceBlock(s,
|
|
45
|
+
`[esd-extension-block-id="${p.PRICE}"]`
|
|
46
|
+
)) || []).forEach((a) => {
|
|
47
|
+
this._updatePriceBlock(s, a, E, g, e);
|
|
47
48
|
}), ((o == null ? void 0 : o.querySelectorAll(
|
|
48
|
-
`[esd-extension-block-id="${
|
|
49
|
-
)) || []).forEach((
|
|
50
|
-
this._updatePriceBlock(s,
|
|
49
|
+
`[esd-extension-block-id="${p.ORIGINAL_PRICE}"]`
|
|
50
|
+
)) || []).forEach((a) => {
|
|
51
|
+
this._updatePriceBlock(s, a, L, C, e);
|
|
51
52
|
}), s.apply(new S(
|
|
52
53
|
`Updated price to ${e ? "single" : "total"} price`
|
|
53
54
|
));
|
|
54
55
|
}
|
|
55
|
-
_updatePriceBlock(e,
|
|
56
|
-
const n = `data-single_price="${
|
|
57
|
-
e.modifyHtml(
|
|
56
|
+
_updatePriceBlock(e, i, c, r, t) {
|
|
57
|
+
const n = `data-single_price="${t ? "true" : "false"}"`, E = i.getInnerHTML().trim().replace(c, h(r)).replace(/data-single_price=(?:"[^"]*"|'[^']*')/g, n);
|
|
58
|
+
e.modifyHtml(i).setInnerHtml(E);
|
|
58
59
|
}
|
|
59
60
|
_getSinglePrice() {
|
|
60
61
|
return `
|
|
61
62
|
<div class="display-flex align-items-center justify-content-between">
|
|
62
|
-
<${
|
|
63
|
+
<${d.LABEL}
|
|
63
64
|
${m.LABEL.text}="${this.api.translate("Show Single Product Price")}"
|
|
64
65
|
>
|
|
65
|
-
</${
|
|
66
|
-
${this._GuToggle(
|
|
66
|
+
</${d.LABEL}>
|
|
67
|
+
${this._GuToggle(l.SINGLE_PRICE)}
|
|
67
68
|
</div>
|
|
68
69
|
`;
|
|
69
70
|
}
|