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