@useinsider/guido 2.1.0-beta.3c29284 → 2.1.0-beta.e6bf76b
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.
|
@@ -1,76 +1,82 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { ModificationDescription as
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var A = (n, r, e) => r in n ? C(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e;
|
|
3
|
+
var _ = (n, r, e) => A(n, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { ModificationDescription as L, UIElementType as m, UEAttr as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as h } from "../../../common-control.js";
|
|
6
|
-
import { ItemsBlockControlId as
|
|
7
|
-
import { productPairs as
|
|
8
|
-
import { useItemsBlockStore as
|
|
9
|
-
import { getItemsBlockConfig as
|
|
10
|
-
const
|
|
6
|
+
import { ItemsBlockControlId as l, ItemsBlockId as D } from "../../enums/controlEnums.js";
|
|
7
|
+
import { productPairs as I } from "../../enums/productEnums.js";
|
|
8
|
+
import { useItemsBlockStore as O } from "../../store/items-block.js";
|
|
9
|
+
import { getItemsBlockConfig as u, setItemsBlockConfig as f } from "../../utils/nodeConfigUtils.js";
|
|
10
|
+
const N = l.PRICE_FORMATTED_PRICE, c = {
|
|
11
11
|
FORMATTED_PRICE: "formattedPrice"
|
|
12
12
|
};
|
|
13
|
-
class
|
|
13
|
+
class y extends h {
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...arguments);
|
|
16
|
-
|
|
16
|
+
_(this, "store", O());
|
|
17
17
|
}
|
|
18
18
|
getId() {
|
|
19
|
-
return
|
|
19
|
+
return N;
|
|
20
20
|
}
|
|
21
21
|
getTemplate() {
|
|
22
22
|
return `
|
|
23
|
-
<div class="container ${
|
|
23
|
+
<div class="container ${l.PRICE_FORMATTED_PRICE}">
|
|
24
24
|
${this._getFormattedPrice()}
|
|
25
25
|
</div>
|
|
26
26
|
`;
|
|
27
27
|
}
|
|
28
28
|
onRender() {
|
|
29
|
-
this.api.updateValues({ [
|
|
29
|
+
this.api.updateValues({ [c.FORMATTED_PRICE]: this.store.formattedPrice }), this.api.onValueChanged(c.FORMATTED_PRICE, (e) => {
|
|
30
30
|
this._onFormattedPriceChange(e);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
onTemplateNodeUpdated(e) {
|
|
34
34
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
|
|
35
35
|
() => {
|
|
36
|
-
const
|
|
37
|
-
|
|
36
|
+
const o = u(this.currentNode);
|
|
37
|
+
o && this.store.setFormattedPrice(o.priceFormatted ?? !0);
|
|
38
38
|
},
|
|
39
39
|
() => {
|
|
40
|
-
this.api.updateValues({ [
|
|
40
|
+
this.api.updateValues({ [c.FORMATTED_PRICE]: this.store.formattedPrice });
|
|
41
41
|
}
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
_onFormattedPriceChange(e) {
|
|
45
|
-
if (console.debug("Formatted price changed to: ", e), this.store.setFormattedPrice(e),
|
|
45
|
+
if (console.debug("Formatted price changed to: ", e), this.store.setFormattedPrice(e), f(this.currentNode, this.api, { priceFormatted: e }), !this.currentNode)
|
|
46
46
|
return;
|
|
47
|
-
const { itemsType:
|
|
47
|
+
const { itemsType: o, singlePrice: i } = this.store, t = I.PAIRS_FOR_EXTENSION.price[o], s = I.PAIRS_FOR_EXTENSION.originalPrice[o], [E, R] = e ? [
|
|
48
|
+
i ? t.DEFAULT_SINGLE_PRICE : t.DEFAULT_PRICE,
|
|
49
|
+
i ? t.DEFAULT_SINGLE_PRICE_FORMATTED : t.DEFAULT_PRICE_FORMATTED
|
|
50
|
+
] : [
|
|
51
|
+
i ? t.DEFAULT_SINGLE_PRICE_FORMATTED : t.DEFAULT_PRICE_FORMATTED,
|
|
52
|
+
i ? t.DEFAULT_SINGLE_PRICE : t.DEFAULT_PRICE
|
|
53
|
+
], d = i ? s.DEFAULT_SINGLE_PRICE : s.DEFAULT_PRICE, P = i ? s.DEFAULT_SINGLE_PRICE_FORMATTED : s.DEFAULT_PRICE_FORMATTED, [p, F] = e ? [d, P] : [P, d];
|
|
48
54
|
this._updatePriceBlock(
|
|
49
55
|
this.currentNode,
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
E,
|
|
57
|
+
R,
|
|
52
58
|
"price"
|
|
53
59
|
);
|
|
54
|
-
const
|
|
55
|
-
|
|
60
|
+
const a = this.currentNode.closest(".items-block"), T = a == null ? void 0 : a.querySelector(`[esd-extension-block-id="${D.ORIGINAL_PRICE}"]`);
|
|
61
|
+
T && this._updatePriceBlock(T, p, F, "original price");
|
|
56
62
|
}
|
|
57
|
-
_updatePriceBlock(e,
|
|
58
|
-
const
|
|
59
|
-
this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(
|
|
63
|
+
_updatePriceBlock(e, o, i, t) {
|
|
64
|
+
const s = e.getInnerHTML().replace(o, i), E = `Updated ${t} to ${this.store.formattedPrice ? "formatted" : "unformatted"}`;
|
|
65
|
+
this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(s).apply(new L(E));
|
|
60
66
|
}
|
|
61
67
|
_getFormattedPrice() {
|
|
62
68
|
return `
|
|
63
69
|
<div class="display-flex align-items-center justify-content-between">
|
|
64
|
-
<${
|
|
65
|
-
${
|
|
70
|
+
<${m.LABEL}
|
|
71
|
+
${g.LABEL.text}="${this.api.translate("Formatted Price (e.g. $9.90)")}"
|
|
66
72
|
>
|
|
67
|
-
</${
|
|
68
|
-
${this._GuToggle(
|
|
73
|
+
</${m.LABEL}>
|
|
74
|
+
${this._GuToggle(c.FORMATTED_PRICE)}
|
|
69
75
|
</div>
|
|
70
76
|
`;
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
export {
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
N as CONTROL_BLOCK_ID,
|
|
81
|
+
y as PriceFormattedPriceControl
|
|
76
82
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.e6bf76b",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|