@useinsider/guido 2.1.0-beta.01eaf27 → 2.1.0-beta.13ada05
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/composables/useActionsApi.js +15 -13
- package/dist/extensions/Blocks/Items/block.js +27 -25
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +117 -94
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +29 -29
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +29 -29
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +31 -29
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +0 -1
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +29 -27
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +164 -158
- package/dist/extensions/Blocks/Items/extension.js +8 -9
- package/dist/extensions/Blocks/Items/template.js +5 -4
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +16 -16
- package/dist/package.json.js +1 -1
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -4
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +9 -9
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
- package/package.json +2 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (s, c, e) =>
|
|
4
|
-
import { ModificationDescription as
|
|
5
|
-
import { CommonControl as
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var N = (s, c, e) => c in s ? R(s, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[c] = e;
|
|
3
|
+
var h = (s, c, e) => N(s, typeof c != "symbol" ? c + "" : c, e);
|
|
4
|
+
import { ModificationDescription as B } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as E } from "../../../common-control.js";
|
|
6
6
|
import { ItemsBlockControlId as y } from "../../enums/controlEnums.js";
|
|
7
|
-
import { getItemsBlockConfig as
|
|
8
|
-
const I = y.PRICE_CURRENCY_SYMBOL,
|
|
7
|
+
import { getItemsBlockConfig as p, setItemsBlockConfig as x, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
|
|
8
|
+
const I = y.PRICE_CURRENCY_SYMBOL, u = {
|
|
9
9
|
CURRENCY_SYMBOL: "currencySymbol"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class P extends E {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments);
|
|
14
14
|
h(this, "originalPriceContents", /* @__PURE__ */ new Map());
|
|
@@ -24,8 +24,8 @@ class O extends B {
|
|
|
24
24
|
`;
|
|
25
25
|
}
|
|
26
26
|
onRender() {
|
|
27
|
-
const e =
|
|
28
|
-
this.api.updateValues({ [
|
|
27
|
+
const e = p(this.currentNode);
|
|
28
|
+
this.api.updateValues({ [u.CURRENCY_SYMBOL]: (e == null ? void 0 : e.priceCurrencySymbol) ?? "" }), this._storeOriginalContents(), this.api.onValueChanged(u.CURRENCY_SYMBOL, (t) => {
|
|
29
29
|
this._onCurrencySymbolChange(t);
|
|
30
30
|
});
|
|
31
31
|
}
|
|
@@ -34,42 +34,42 @@ class O extends B {
|
|
|
34
34
|
}
|
|
35
35
|
onTemplateNodeUpdated(e) {
|
|
36
36
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
37
|
-
const t =
|
|
38
|
-
this.api.updateValues({ [
|
|
37
|
+
const t = p(this.currentNode);
|
|
38
|
+
this.api.updateValues({ [u.CURRENCY_SYMBOL]: (t == null ? void 0 : t.priceCurrencySymbol) ?? "" }), this._storeOriginalContents();
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
_onCurrencySymbolChange(e) {
|
|
42
|
-
var
|
|
42
|
+
var a;
|
|
43
43
|
console.debug("Currency symbol changed to: ", e);
|
|
44
|
-
const t =
|
|
45
|
-
if (
|
|
44
|
+
const t = p(this.currentNode), o = ((a = t == null ? void 0 : t.priceCurrencySymbol) == null ? void 0 : a.trim()) || "";
|
|
45
|
+
if (x(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
|
|
46
46
|
return;
|
|
47
47
|
const r = this._getPriceBlocks();
|
|
48
48
|
if (!r || r.length === 0)
|
|
49
49
|
return;
|
|
50
|
-
const n = (e == null ? void 0 : e.trim()) || "", l = (t == null ? void 0 : t.priceCurrencyLocation) ?? "0";
|
|
51
|
-
r.forEach((
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
50
|
+
const n = (e == null ? void 0 : e.trim()) || "", l = (t == null ? void 0 : t.priceCurrencyLocation) ?? "0", i = this.api.getDocumentModifier();
|
|
51
|
+
r.forEach((d) => {
|
|
52
|
+
const m = this._getParagraph(d);
|
|
53
|
+
if (!m)
|
|
54
54
|
return;
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, f(S));
|
|
56
|
+
i.modifyHtml(m).setInnerHtml(b);
|
|
57
|
+
}), i.apply(new B(
|
|
58
|
+
`Updated currency symbol to ${n || "removed"}`
|
|
59
|
+
));
|
|
60
60
|
}
|
|
61
61
|
_storeOriginalContents() {
|
|
62
62
|
if (!this.currentNode)
|
|
63
63
|
return;
|
|
64
|
-
const e =
|
|
64
|
+
const e = p(this.currentNode);
|
|
65
65
|
this.currentNode.querySelectorAll(
|
|
66
66
|
".items-block-price"
|
|
67
67
|
).forEach((o) => {
|
|
68
68
|
var n;
|
|
69
69
|
const r = o.querySelector("p");
|
|
70
70
|
if (r && !this.originalPriceContents.has(r)) {
|
|
71
|
-
const l = r.getInnerText() || "", i = ((n = e == null ? void 0 : e.priceCurrencySymbol) == null ? void 0 : n.trim()) || "",
|
|
72
|
-
this.originalPriceContents.set(r,
|
|
71
|
+
const l = r.getInnerText() || "", i = ((n = e == null ? void 0 : e.priceCurrencySymbol) == null ? void 0 : n.trim()) || "", a = this._removeCurrencySymbol(l, i);
|
|
72
|
+
this.originalPriceContents.set(r, a);
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
}
|
|
@@ -106,7 +106,7 @@ class O extends B {
|
|
|
106
106
|
${this._GuTwoColumns([
|
|
107
107
|
this._GuLabel({ text: "Currency Symbol" }),
|
|
108
108
|
this._GuTextInput({
|
|
109
|
-
name:
|
|
109
|
+
name: u.CURRENCY_SYMBOL,
|
|
110
110
|
placeholder: "Enter Currency Symbol",
|
|
111
111
|
className: "es-180w"
|
|
112
112
|
})
|
|
@@ -116,5 +116,5 @@ class O extends B {
|
|
|
116
116
|
}
|
|
117
117
|
export {
|
|
118
118
|
I as CONTROL_BLOCK_ID,
|
|
119
|
-
|
|
119
|
+
P as PriceCurrencySymbolControl
|
|
120
120
|
};
|
|
@@ -1,63 +1,65 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
1
|
+
import { ModificationDescription as L, UIElementType as P, UEAttr as D } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as h } from "../../../common-control.js";
|
|
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 d, setItemsBlockConfig as
|
|
6
|
-
const g =
|
|
5
|
+
import { getItemsBlockConfig as d, setItemsBlockConfig as u, escapeReplacement as O } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const g = R.PRICE_FORMATTED_PRICE, s = {
|
|
7
7
|
FORMATTED_PRICE: "formattedPrice"
|
|
8
8
|
};
|
|
9
|
-
class
|
|
9
|
+
class k extends h {
|
|
10
10
|
getId() {
|
|
11
11
|
return g;
|
|
12
12
|
}
|
|
13
13
|
getTemplate() {
|
|
14
14
|
return `
|
|
15
|
-
<div class="container ${
|
|
15
|
+
<div class="container ${R.PRICE_FORMATTED_PRICE}">
|
|
16
16
|
${this._getFormattedPrice()}
|
|
17
17
|
</div>
|
|
18
18
|
`;
|
|
19
19
|
}
|
|
20
20
|
onRender() {
|
|
21
|
-
const
|
|
22
|
-
this.api.updateValues({ [s.FORMATTED_PRICE]: (
|
|
23
|
-
this._onFormattedPriceChange(
|
|
21
|
+
const t = d(this.currentNode);
|
|
22
|
+
this.api.updateValues({ [s.FORMATTED_PRICE]: (t == null ? void 0 : t.priceFormatted) ?? !0 }), this.api.onValueChanged(s.FORMATTED_PRICE, (e) => {
|
|
23
|
+
this._onFormattedPriceChange(e);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
onTemplateNodeUpdated(
|
|
27
|
-
super.onTemplateNodeUpdated(
|
|
28
|
-
const
|
|
29
|
-
this.api.updateValues({ [s.FORMATTED_PRICE]: (
|
|
26
|
+
onTemplateNodeUpdated(t) {
|
|
27
|
+
super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
|
|
28
|
+
const e = d(this.currentNode);
|
|
29
|
+
this.api.updateValues({ [s.FORMATTED_PRICE]: (e == null ? void 0 : e.priceFormatted) ?? !0 });
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
_onFormattedPriceChange(
|
|
33
|
-
if (console.debug("Formatted price changed to: ",
|
|
32
|
+
_onFormattedPriceChange(t) {
|
|
33
|
+
if (console.debug("Formatted price changed to: ", t), u(this.currentNode, this.api, { priceFormatted: t }), !this.currentNode)
|
|
34
34
|
return;
|
|
35
|
-
const
|
|
35
|
+
const e = d(this.currentNode), n = (e == null ? void 0 : e.type) ?? "CART_ITEMS", i = (e == null ? void 0 : e.priceSinglePrice) ?? !1, r = I.PAIRS_FOR_EXTENSION.price[n], c = I.PAIRS_FOR_EXTENSION.originalPrice[n], [p, m] = t ? [
|
|
36
36
|
i ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE,
|
|
37
37
|
i ? r.DEFAULT_SINGLE_PRICE_FORMATTED : r.DEFAULT_PRICE_FORMATTED
|
|
38
38
|
] : [
|
|
39
39
|
i ? r.DEFAULT_SINGLE_PRICE_FORMATTED : r.DEFAULT_PRICE_FORMATTED,
|
|
40
40
|
i ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE
|
|
41
|
-
], l = i ?
|
|
42
|
-
((c == null ? void 0 : c.querySelectorAll(
|
|
41
|
+
], l = i ? c.DEFAULT_SINGLE_PRICE : c.DEFAULT_PRICE, T = i ? c.DEFAULT_SINGLE_PRICE_FORMATTED : c.DEFAULT_PRICE_FORMATTED, [F, A] = t ? [l, T] : [T, l], o = this.currentNode.closest(".items-block"), C = (o == null ? void 0 : o.querySelectorAll(
|
|
43
42
|
`[esd-extension-block-id="${_.PRICE}"]`
|
|
44
|
-
)) || []
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
)) || [], E = this.api.getDocumentModifier();
|
|
44
|
+
C.forEach((a) => {
|
|
45
|
+
this._updatePriceBlock(E, a, p, m);
|
|
46
|
+
}), ((o == null ? void 0 : o.querySelectorAll(
|
|
47
47
|
`[esd-extension-block-id="${_.ORIGINAL_PRICE}"]`
|
|
48
48
|
)) || []).forEach((a) => {
|
|
49
|
-
this._updatePriceBlock(
|
|
50
|
-
})
|
|
49
|
+
this._updatePriceBlock(E, a, F, A);
|
|
50
|
+
}), E.apply(new L(
|
|
51
|
+
`Updated price to ${t ? "formatted" : "unformatted"}`
|
|
52
|
+
));
|
|
51
53
|
}
|
|
52
|
-
_updatePriceBlock(
|
|
53
|
-
const
|
|
54
|
-
|
|
54
|
+
_updatePriceBlock(t, e, n, i) {
|
|
55
|
+
const r = e.getInnerHTML().trim().replace(n, O(i));
|
|
56
|
+
t.modifyHtml(e).setInnerHtml(r);
|
|
55
57
|
}
|
|
56
58
|
_getFormattedPrice() {
|
|
57
59
|
return `
|
|
58
60
|
<div class="display-flex align-items-center justify-content-between">
|
|
59
61
|
<${P.LABEL}
|
|
60
|
-
${
|
|
62
|
+
${D.LABEL.text}="${this.api.translate("Formatted Price (e.g. $9.90)")}"
|
|
61
63
|
>
|
|
62
64
|
</${P.LABEL}>
|
|
63
65
|
${this._GuToggle(s.FORMATTED_PRICE)}
|
|
@@ -67,5 +69,5 @@ class $ extends L {
|
|
|
67
69
|
}
|
|
68
70
|
export {
|
|
69
71
|
g as CONTROL_BLOCK_ID,
|
|
70
|
-
|
|
72
|
+
k as PriceFormattedPriceControl
|
|
71
73
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import { productPairs as
|
|
5
|
-
import { getItemsBlockConfig as I, setItemsBlockConfig as u, escapeReplacement as
|
|
6
|
-
const
|
|
1
|
+
import { ModificationDescription as m, UIElementType as _, UEAttr as A } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as h } from "../../../common-control.js";
|
|
3
|
+
import { ItemsBlockControlId as L, ItemsBlockId as R } from "../../enums/controlEnums.js";
|
|
4
|
+
import { productPairs as T } from "../../enums/productEnums.js";
|
|
5
|
+
import { getItemsBlockConfig as I, setItemsBlockConfig as u, escapeReplacement as N } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const D = L.PRICE_SINGLE_PRICE, l = {
|
|
7
7
|
SINGLE_PRICE: "singlePrice"
|
|
8
8
|
};
|
|
9
|
-
class
|
|
9
|
+
class y extends h {
|
|
10
10
|
getId() {
|
|
11
|
-
return
|
|
11
|
+
return D;
|
|
12
12
|
}
|
|
13
13
|
getTemplate() {
|
|
14
14
|
return `
|
|
15
|
-
<div class="container ${
|
|
15
|
+
<div class="container ${L.PRICE_SINGLE_PRICE}">
|
|
16
16
|
${this._getSinglePrice()}
|
|
17
17
|
</div>
|
|
18
18
|
`;
|
|
@@ -32,34 +32,36 @@ class M extends m {
|
|
|
32
32
|
_onSinglePriceChange(e) {
|
|
33
33
|
if (console.debug("Single price changed to: ", e), u(this.currentNode, this.api, { priceSinglePrice: e }), !this.currentNode)
|
|
34
34
|
return;
|
|
35
|
-
const t = I(this.currentNode),
|
|
35
|
+
const t = I(this.currentNode), o = (t == null ? void 0 : t.type) ?? "CART_ITEMS", r = (t == null ? void 0 : t.priceFormatted) ?? !1, i = T.PAIRS_FOR_EXTENSION.price[o], c = T.PAIRS_FOR_EXTENSION.originalPrice[o], [P, p] = e ? [
|
|
36
36
|
r ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE,
|
|
37
37
|
r ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE
|
|
38
38
|
] : [
|
|
39
39
|
r ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE,
|
|
40
40
|
r ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE
|
|
41
|
-
],
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this._updatePriceBlock(
|
|
46
|
-
}), ((
|
|
47
|
-
`[esd-extension-block-id="${
|
|
48
|
-
)) || []).forEach((
|
|
49
|
-
this._updatePriceBlock(
|
|
50
|
-
})
|
|
41
|
+
], s = r ? c.DEFAULT_PRICE_FORMATTED : c.DEFAULT_PRICE, d = r ? c.DEFAULT_SINGLE_PRICE_FORMATTED : c.DEFAULT_SINGLE_PRICE, [g, C] = e ? [s, d] : [d, s], n = this.currentNode.closest(".items-block"), S = (n == null ? void 0 : n.querySelectorAll(
|
|
42
|
+
`[esd-extension-block-id="${R.PRICE}"]`
|
|
43
|
+
)) || [], E = this.api.getDocumentModifier();
|
|
44
|
+
S.forEach((a) => {
|
|
45
|
+
this._updatePriceBlock(E, a, P, p, e);
|
|
46
|
+
}), ((n == null ? void 0 : n.querySelectorAll(
|
|
47
|
+
`[esd-extension-block-id="${R.ORIGINAL_PRICE}"]`
|
|
48
|
+
)) || []).forEach((a) => {
|
|
49
|
+
this._updatePriceBlock(E, a, g, C, e);
|
|
50
|
+
}), E.apply(new m(
|
|
51
|
+
`Updated price to ${e ? "single" : "total"} price`
|
|
52
|
+
));
|
|
51
53
|
}
|
|
52
|
-
_updatePriceBlock(e, t,
|
|
53
|
-
const c =
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
_updatePriceBlock(e, t, o, r, i) {
|
|
55
|
+
const c = t.getInnerHTML().trim().replace(o, N(r));
|
|
56
|
+
e.modifyHtml(t).setInnerHtml(c), t.querySelectorAll('[product-attr="price"], [product-attr="originalPrice"]').forEach((s) => {
|
|
57
|
+
e.modifyHtml(s).setAttribute("data-single_price", i ? "true" : "false");
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
_getSinglePrice() {
|
|
59
61
|
return `
|
|
60
62
|
<div class="display-flex align-items-center justify-content-between">
|
|
61
63
|
<${_.LABEL}
|
|
62
|
-
${
|
|
64
|
+
${A.LABEL.text}="${this.api.translate("Show Single Product Price")}"
|
|
63
65
|
>
|
|
64
66
|
</${_.LABEL}>
|
|
65
67
|
${this._GuToggle(l.SINGLE_PRICE)}
|
|
@@ -68,6 +70,6 @@ class M extends m {
|
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
export {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
D as CONTROL_BLOCK_ID,
|
|
74
|
+
y as PriceSinglePriceControl
|
|
73
75
|
};
|