@useinsider/guido 2.1.0-beta.411f2a9 → 2.1.0-beta.425dfd0
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/migrator/itemsBlockMigrator.js +123 -140
- package/dist/extensions/Blocks/Items/block.js +28 -19
- package/dist/extensions/Blocks/Items/controls/button/link.js +31 -19
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +81 -97
- package/dist/extensions/Blocks/Items/controls/image/link.js +31 -19
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +40 -28
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +46 -34
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +50 -45
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +51 -40
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +35 -23
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +57 -45
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +62 -42
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +191 -184
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -0
- package/dist/extensions/Blocks/Items/extension.js +9 -8
- package/dist/extensions/Blocks/Items/store/items-block.js +79 -0
- package/dist/extensions/Blocks/Items/template.js +175 -181
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +3 -3
- package/dist/extensions/Blocks/common-control.js +92 -91
- package/dist/src/extensions/Blocks/Items/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +12 -10
- package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +45 -0
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -2
- package/dist/src/extensions/Blocks/common-control.d.ts +5 -4
- package/package.json +1 -1
|
@@ -1,73 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var R = (n, r, e) => r in n ? C(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e;
|
|
3
|
+
var d = (n, r, e) => R(n, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { ModificationDescription as _, UIElementType as g, UEAttr as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as u } from "../../../common-control.js";
|
|
6
|
+
import { ItemsBlockControlId as m, ItemsBlockId as N } from "../../enums/controlEnums.js";
|
|
7
|
+
import { productPairs as S } from "../../enums/productEnums.js";
|
|
8
|
+
import { useItemsBlockStore as A } from "../../store/items-block.js";
|
|
9
|
+
import { setItemsBlockConfig as f } from "../../utils/nodeConfigUtils.js";
|
|
10
|
+
const D = m.PRICE_SINGLE_PRICE, l = {
|
|
7
11
|
SINGLE_PRICE: "singlePrice"
|
|
8
12
|
};
|
|
9
|
-
class
|
|
13
|
+
class k extends u {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
d(this, "store", A());
|
|
17
|
+
}
|
|
10
18
|
getId() {
|
|
11
|
-
return
|
|
19
|
+
return D;
|
|
12
20
|
}
|
|
13
21
|
getTemplate() {
|
|
14
22
|
return `
|
|
15
|
-
<div class="container ${
|
|
23
|
+
<div class="container ${m.PRICE_SINGLE_PRICE}">
|
|
16
24
|
${this._getSinglePrice()}
|
|
17
25
|
</div>
|
|
18
26
|
`;
|
|
19
27
|
}
|
|
20
28
|
onRender() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this._onSinglePriceChange(t);
|
|
29
|
+
this.api.updateValues({ [l.SINGLE_PRICE]: this.store.singlePrice }), this.api.onValueChanged(l.SINGLE_PRICE, (e) => {
|
|
30
|
+
this._onSinglePriceChange(e);
|
|
24
31
|
});
|
|
25
32
|
}
|
|
26
33
|
onTemplateNodeUpdated(e) {
|
|
27
|
-
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
|
|
35
|
+
() => this._syncSinglePriceFromNodeConfig(),
|
|
36
|
+
() => {
|
|
37
|
+
this.api.updateValues({ [l.SINGLE_PRICE]: this.store.singlePrice });
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Syncs single price state from nodeConfig.
|
|
43
|
+
*/
|
|
44
|
+
_syncSinglePriceFromNodeConfig() {
|
|
45
|
+
var i;
|
|
46
|
+
const e = (i = this.currentNode) == null ? void 0 : i.closest(".items-block");
|
|
47
|
+
if (!e)
|
|
48
|
+
return;
|
|
49
|
+
const o = e.getNodeConfig(), t = (o == null ? void 0 : o.priceSinglePrice) ?? !1;
|
|
50
|
+
this.store.setSinglePrice(t);
|
|
31
51
|
}
|
|
32
52
|
_onSinglePriceChange(e) {
|
|
33
|
-
if (console.debug("Single price changed to: ", e),
|
|
53
|
+
if (console.debug("Single price changed to: ", e), this.store.setSinglePrice(e), f(this.currentNode, this.api, { priceSinglePrice: e }), !this.currentNode)
|
|
34
54
|
return;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
55
|
+
const { itemsType: o, formattedPrice: t } = this.store, i = S.PAIRS_FOR_EXTENSION.price[o], c = S.PAIRS_FOR_EXTENSION.originalPrice[o], [E, a] = e ? [
|
|
56
|
+
t ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE,
|
|
57
|
+
t ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE
|
|
38
58
|
] : [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
],
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
t ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE,
|
|
60
|
+
t ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE
|
|
61
|
+
], P = t ? c.DEFAULT_PRICE_FORMATTED : c.DEFAULT_PRICE, s = t ? c.DEFAULT_SINGLE_PRICE_FORMATTED : c.DEFAULT_SINGLE_PRICE, [L, T] = e ? [P, s] : [s, P];
|
|
62
|
+
this._updatePriceBlock(
|
|
63
|
+
this.currentNode,
|
|
64
|
+
E,
|
|
65
|
+
a,
|
|
66
|
+
e,
|
|
67
|
+
"price"
|
|
68
|
+
);
|
|
69
|
+
const p = this.currentNode.closest(".items-block"), I = p == null ? void 0 : p.querySelector(`[esd-extension-block-id="${N.ORIGINAL_PRICE}"]`);
|
|
70
|
+
I && this._updatePriceBlock(I, L, T, e, "original price");
|
|
51
71
|
}
|
|
52
|
-
_updatePriceBlock(e,
|
|
53
|
-
const
|
|
54
|
-
this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
_updatePriceBlock(e, o, t, i, c) {
|
|
73
|
+
const E = e.getInnerHTML().replace(o, t), a = `Updated ${c} to ${i ? "single" : "total"} price`;
|
|
74
|
+
this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(E).apply(new _(a));
|
|
75
|
+
const s = e.querySelector('[product-attr="price"], [product-attr="originalPrice"]');
|
|
76
|
+
s && this.api.getDocumentModifier().modifyHtml(s).setAttribute("data-single_price", i ? "true" : "false").apply(new _("Update single price attribute"));
|
|
57
77
|
}
|
|
58
78
|
_getSinglePrice() {
|
|
59
79
|
return `
|
|
60
80
|
<div class="display-flex align-items-center justify-content-between">
|
|
61
|
-
<${
|
|
62
|
-
${
|
|
81
|
+
<${g.LABEL}
|
|
82
|
+
${h.LABEL.text}="${this.api.translate("Show Single Product Price")}"
|
|
63
83
|
>
|
|
64
|
-
</${
|
|
84
|
+
</${g.LABEL}>
|
|
65
85
|
${this._GuToggle(l.SINGLE_PRICE)}
|
|
66
86
|
</div>
|
|
67
87
|
`;
|
|
68
88
|
}
|
|
69
89
|
}
|
|
70
90
|
export {
|
|
71
|
-
|
|
72
|
-
|
|
91
|
+
D as CONTROL_BLOCK_ID,
|
|
92
|
+
k as PriceSinglePriceControl
|
|
73
93
|
};
|