@useinsider/guido 3.23.0-beta.86bed27 → 3.23.0-beta.9f6bfbf
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/README.md +1 -0
- package/dist/@types/config/schemas.js +17 -15
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +58 -56
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +11 -11
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +9 -9
- package/dist/composables/useModuleRepair.js +14 -12
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -22
- package/dist/config/migrator/index.js +16 -15
- package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
- package/dist/config/migrator/recommendation/compositionMapper.js +56 -49
- package/dist/config/migrator/recommendation/extractors.js +100 -40
- package/dist/config/migrator/recommendation/htmlBuilder.js +285 -207
- package/dist/config/migrator/recommendation/settingsMapper.js +37 -36
- package/dist/config/migrator/recommendation/themeMapper.js +53 -41
- package/dist/config/migrator/recommendationMigrator.js +68 -61
- package/dist/extensions/Blocks/Items/block.js +115 -77
- package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
- package/dist/extensions/Blocks/Items/controls/button/link.js +14 -17
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +14 -17
- package/dist/extensions/Blocks/Items/controls/image/link.js +14 -17
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +9 -10
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +40 -30
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +63 -53
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +31 -31
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -16
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +25 -26
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -32
- package/dist/extensions/Blocks/Items/controls/priceFormat.js +145 -0
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +160 -144
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +1 -1
- package/dist/extensions/Blocks/Items/extension.js +9 -8
- package/dist/extensions/Blocks/Items/items.css.js +19 -0
- package/dist/extensions/Blocks/Items/settingsPanel.js +34 -25
- package/dist/extensions/Blocks/Items/template.js +250 -212
- package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
- 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 +165 -175
- 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/Recommendation/utils/priceFormatter.js +1 -0
- package/dist/extensions/Blocks/common-control.js +62 -55
- package/dist/guido.css +1 -1
- package/dist/package.json.js +2 -2
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/config/migrator/index.d.ts +4 -1
- package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/extractors.d.ts +35 -6
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/types.d.ts +11 -1
- package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +23 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +61 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -10
- 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/Recommendation/utils/priceFormatter.d.ts +12 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +2 -0
- package/dist/src/stores/config.d.ts +20 -0
- package/dist/src/stores/unsubscribe.d.ts +10 -0
- package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
- package/dist/stores/unsubscribe.js +33 -29
- package/dist/utils/itemsCurrencyRepair.js +29 -24
- package/dist/utils/pairProductVariables.js +119 -99
- package/package.json +2 -2
|
@@ -1,50 +1,60 @@
|
|
|
1
|
-
import { currencyLocationMaps as
|
|
2
|
-
import { UEAttr as
|
|
3
|
-
import { CommonControl as
|
|
4
|
-
import { ITEMS_CURRENCY_ATTR as
|
|
5
|
-
import { ItemsBlockControlId as
|
|
6
|
-
import { getItemsBlockConfig as
|
|
7
|
-
|
|
1
|
+
import { currencyLocationMaps as u } from "../../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { UEAttr as I, ModificationDescription as T } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
3
|
+
import { CommonControl as E } from "../../../common-control.js";
|
|
4
|
+
import { ITEMS_CURRENCY_ATTR as f, currencyPositionFromLocation as h } from "../../constants/currency.js";
|
|
5
|
+
import { ItemsBlockControlId as d } from "../../enums/controlEnums.js";
|
|
6
|
+
import { getItemsBlockConfig as C, setItemsBlockConfig as O, escapeReplacement as P } from "../../utils/nodeConfigUtils.js";
|
|
7
|
+
import { isNewPriceFormatBlock as b, applyPriceFormatChange as U } from "../priceFormat.js";
|
|
8
|
+
const x = d.PRICE_CURRENCY_LOCATION, a = {
|
|
8
9
|
CURRENCY_LOCATION: "currencyLocation"
|
|
9
10
|
};
|
|
10
|
-
class
|
|
11
|
+
class H extends E {
|
|
11
12
|
getId() {
|
|
12
|
-
return
|
|
13
|
+
return x;
|
|
13
14
|
}
|
|
14
15
|
getTemplate() {
|
|
15
16
|
return `
|
|
16
|
-
<div class="container ${
|
|
17
|
+
<div class="container ${d.PRICE_CURRENCY_LOCATION}">
|
|
17
18
|
${this._getCurrencyLocation()}
|
|
18
19
|
</div>
|
|
19
20
|
`;
|
|
20
21
|
}
|
|
21
22
|
onRender() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this._onCurrencyLocationChange(t);
|
|
23
|
+
this.forgetLastPanelNode(), this.api.setUIEAttribute(a.CURRENCY_LOCATION, I.SELECTPICKER.items, u), this.api.onValueChanged(a.CURRENCY_LOCATION, (e) => {
|
|
24
|
+
this._onCurrencyLocationChange(e);
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
onTemplateNodeUpdated(e) {
|
|
28
28
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
29
|
-
const t =
|
|
30
|
-
this.api.updateValues({ [
|
|
29
|
+
const t = C(this.currentNode);
|
|
30
|
+
this.api.updateValues({ [a.CURRENCY_LOCATION]: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0" });
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
_onCurrencyLocationChange(e) {
|
|
34
|
-
|
|
34
|
+
var l;
|
|
35
|
+
if (console.debug("Currency location changed to: ", e), b(this.currentNode)) {
|
|
36
|
+
((l = C(this.currentNode)) == null ? void 0 : l.priceCurrencyLocation) !== e && U(
|
|
37
|
+
this.currentNode,
|
|
38
|
+
this.api,
|
|
39
|
+
{ priceCurrencyLocation: e },
|
|
40
|
+
`Updated currency location to ${h(e)}`
|
|
41
|
+
);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
|
|
35
45
|
return;
|
|
36
46
|
const t = this._getPriceBlocks();
|
|
37
47
|
if (!t || t.length === 0)
|
|
38
48
|
return;
|
|
39
|
-
const r =
|
|
40
|
-
t.forEach((
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
49
|
+
const r = C(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", c = h(n), i = this.api.getDocumentModifier();
|
|
50
|
+
t.forEach((g) => {
|
|
51
|
+
const s = this._getParagraph(g);
|
|
52
|
+
if (!s)
|
|
43
53
|
return;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
}),
|
|
47
|
-
`Updated currency location to ${
|
|
54
|
+
const _ = s.getInnerHTML().trim() || "", p = s.getInnerText().trim() || "", m = (o == null ? void 0 : o.trim()) || "", y = this._removeCurrencySymbol(p, m), N = this._detectSymbolInText(p) || m, L = this._buildPriceContent(y, N, n), R = _.replace(p, P(L));
|
|
55
|
+
i.modifyHtml(s).setInnerHtml(R).setAttribute(f.POSITION, c);
|
|
56
|
+
}), i.apply(new T(
|
|
57
|
+
`Updated currency location to ${c}`
|
|
48
58
|
));
|
|
49
59
|
}
|
|
50
60
|
_getPriceBlocks() {
|
|
@@ -66,8 +76,8 @@ class Y extends L {
|
|
|
66
76
|
} else {
|
|
67
77
|
const o = r.match(/([^0-9.,\s]+)/);
|
|
68
78
|
if (o && o[1]) {
|
|
69
|
-
const
|
|
70
|
-
n = r.replace(
|
|
79
|
+
const c = o[1].trim(), i = new RegExp(`\\s*${this._escapeRegex(c)}\\s*`);
|
|
80
|
+
n = r.replace(i, "").trim();
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
83
|
return n;
|
|
@@ -84,15 +94,15 @@ class Y extends L {
|
|
|
84
94
|
${this._GuTwoColumns([
|
|
85
95
|
this._GuLabel({ text: "Currency Location" }),
|
|
86
96
|
this._GuSelect({
|
|
87
|
-
name:
|
|
97
|
+
name: a.CURRENCY_LOCATION,
|
|
88
98
|
placeholder: "",
|
|
89
|
-
options:
|
|
99
|
+
options: u
|
|
90
100
|
})
|
|
91
101
|
])}
|
|
92
102
|
`;
|
|
93
103
|
}
|
|
94
104
|
}
|
|
95
105
|
export {
|
|
96
|
-
|
|
97
|
-
|
|
106
|
+
x as CONTROL_BLOCK_ID,
|
|
107
|
+
H as PriceCurrencyLocationControl
|
|
98
108
|
};
|
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
var R = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
var f = (i, c, e) => c in i ? R(i, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[c] = e;
|
|
3
|
+
var y = (i, c, e) => f(i, typeof c != "symbol" ? c + "" : c, e);
|
|
4
|
+
import { useConfig as E } from "../../../../../composables/useConfig.js";
|
|
5
|
+
import { ModificationDescription as B } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
+
import { CommonControl as P } from "../../../common-control.js";
|
|
6
7
|
import { ITEMS_CURRENCY_ATTR as T } from "../../constants/currency.js";
|
|
7
|
-
import { ItemsBlockControlId as
|
|
8
|
-
import { getItemsBlockConfig as p, setItemsBlockConfig as
|
|
9
|
-
|
|
8
|
+
import { ItemsBlockControlId as d } from "../../enums/controlEnums.js";
|
|
9
|
+
import { getItemsBlockConfig as p, setItemsBlockConfig as x, escapeReplacement as I } from "../../utils/nodeConfigUtils.js";
|
|
10
|
+
import { isNewPriceFormatBlock as L, applyPriceFormatChange as M } from "../priceFormat.js";
|
|
11
|
+
const Y = d.PRICE_CURRENCY_SYMBOL, u = {
|
|
10
12
|
CURRENCY_SYMBOL: "currencySymbol"
|
|
11
13
|
};
|
|
12
|
-
class
|
|
14
|
+
class A extends P {
|
|
13
15
|
constructor() {
|
|
14
16
|
super(...arguments);
|
|
15
|
-
|
|
17
|
+
y(this, "originalPriceContents", /* @__PURE__ */ new Map());
|
|
16
18
|
}
|
|
17
19
|
getId() {
|
|
18
|
-
return
|
|
20
|
+
return Y;
|
|
19
21
|
}
|
|
20
22
|
getTemplate() {
|
|
23
|
+
const e = E().isFeatureEnabled("itemsPriceFormatting") ? " no-separator" : "";
|
|
21
24
|
return `
|
|
22
|
-
<div class="container ${
|
|
25
|
+
<div class="container ${d.PRICE_CURRENCY_SYMBOL}${e}">
|
|
23
26
|
${this._getCurrencySymbol()}
|
|
24
27
|
</div>
|
|
25
28
|
`;
|
|
26
29
|
}
|
|
27
30
|
onRender() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this._onCurrencySymbolChange(t);
|
|
31
|
+
this.forgetLastPanelNode(), this.api.onValueChanged(u.CURRENCY_SYMBOL, (e) => {
|
|
32
|
+
this._onCurrencySymbolChange(e);
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
onDestroy() {
|
|
@@ -35,28 +37,36 @@ class $ extends B {
|
|
|
35
37
|
}
|
|
36
38
|
onTemplateNodeUpdated(e) {
|
|
37
39
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
38
|
-
const
|
|
39
|
-
this.api.updateValues({ [u.CURRENCY_SYMBOL]: (
|
|
40
|
+
const r = p(this.currentNode);
|
|
41
|
+
this.api.updateValues({ [u.CURRENCY_SYMBOL]: (r == null ? void 0 : r.priceCurrencySymbol) ?? "" }), this._storeOriginalContents();
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
_onCurrencySymbolChange(e) {
|
|
43
|
-
var
|
|
44
|
-
console.debug("Currency symbol changed to: ", e)
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
var m, C;
|
|
46
|
+
if (console.debug("Currency symbol changed to: ", e), L(this.currentNode)) {
|
|
47
|
+
((m = p(this.currentNode)) == null ? void 0 : m.priceCurrencySymbol) !== e && M(
|
|
48
|
+
this.currentNode,
|
|
49
|
+
this.api,
|
|
50
|
+
{ priceCurrencySymbol: e },
|
|
51
|
+
`Updated currency symbol to ${(e == null ? void 0 : e.trim()) || "removed"}`
|
|
52
|
+
);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const r = p(this.currentNode), n = ((C = r == null ? void 0 : r.priceCurrencySymbol) == null ? void 0 : C.trim()) || "";
|
|
56
|
+
if (x(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
|
|
47
57
|
return;
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
58
|
+
const t = this._getPriceBlocks();
|
|
59
|
+
if (!t || t.length === 0)
|
|
50
60
|
return;
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
61
|
+
const o = (e == null ? void 0 : e.trim()) || "", a = (r == null ? void 0 : r.priceCurrencyLocation) ?? "0", s = this.api.getDocumentModifier();
|
|
62
|
+
t.forEach((g) => {
|
|
63
|
+
const l = this._getParagraph(g);
|
|
64
|
+
if (!l)
|
|
55
65
|
return;
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
}),
|
|
59
|
-
`Updated currency symbol to ${
|
|
66
|
+
const S = l.getInnerHTML().trim() || "", h = l.getInnerText().trim() || "", _ = this._removeCurrencySymbol(h, n), b = this._buildPriceContent(_, o, a), N = S.replace(h, I(b));
|
|
67
|
+
s.modifyHtml(l).setInnerHtml(N).setAttribute(T.SYMBOL, o);
|
|
68
|
+
}), s.apply(new B(
|
|
69
|
+
`Updated currency symbol to ${o || "removed"}`
|
|
60
70
|
));
|
|
61
71
|
}
|
|
62
72
|
_storeOriginalContents() {
|
|
@@ -65,18 +75,18 @@ class $ extends B {
|
|
|
65
75
|
const e = p(this.currentNode);
|
|
66
76
|
this.currentNode.querySelectorAll(
|
|
67
77
|
".items-block-price"
|
|
68
|
-
).forEach((
|
|
69
|
-
var
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
const
|
|
73
|
-
this.originalPriceContents.set(
|
|
78
|
+
).forEach((n) => {
|
|
79
|
+
var o;
|
|
80
|
+
const t = n.querySelector("p");
|
|
81
|
+
if (t && !this.originalPriceContents.has(t)) {
|
|
82
|
+
const a = t.getInnerText() || "", s = ((o = e == null ? void 0 : e.priceCurrencySymbol) == null ? void 0 : o.trim()) || "", m = this._removeCurrencySymbol(a, s);
|
|
83
|
+
this.originalPriceContents.set(t, m);
|
|
74
84
|
}
|
|
75
85
|
});
|
|
76
86
|
}
|
|
77
87
|
_getPriceBlocks() {
|
|
78
|
-
var e,
|
|
79
|
-
return ((
|
|
88
|
+
var e, r;
|
|
89
|
+
return ((r = (e = this.currentNode) == null ? void 0 : e.closest(".items-block")) == null ? void 0 : r.querySelectorAll(".items-block-price")) || [];
|
|
80
90
|
}
|
|
81
91
|
_getParagraph(e) {
|
|
82
92
|
return e.querySelector("p");
|
|
@@ -84,23 +94,23 @@ class $ extends B {
|
|
|
84
94
|
_escapeRegex(e) {
|
|
85
95
|
return e.replace(/[-\\^$*+?().|[\]{}]/g, "\\$&");
|
|
86
96
|
}
|
|
87
|
-
_removeCurrencySymbol(e,
|
|
88
|
-
const
|
|
89
|
-
let
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
|
|
97
|
+
_removeCurrencySymbol(e, r) {
|
|
98
|
+
const n = e || "";
|
|
99
|
+
let t = n;
|
|
100
|
+
if (r) {
|
|
101
|
+
const o = new RegExp(`\\s*${this._escapeRegex(r)}\\s*`);
|
|
102
|
+
t = n.replace(o, "").trim();
|
|
93
103
|
} else {
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
const
|
|
97
|
-
|
|
104
|
+
const o = n.match(/([^0-9.,\s]+)/);
|
|
105
|
+
if (o && o[1]) {
|
|
106
|
+
const a = o[1].trim(), s = new RegExp(`\\s*${this._escapeRegex(a)}\\s*`);
|
|
107
|
+
t = n.replace(s, "").trim();
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
|
-
return
|
|
110
|
+
return t;
|
|
101
111
|
}
|
|
102
|
-
_buildPriceContent(e,
|
|
103
|
-
return
|
|
112
|
+
_buildPriceContent(e, r, n) {
|
|
113
|
+
return r ? n === "1" ? `${e} ${r}` : `${r} ${e}` : e;
|
|
104
114
|
}
|
|
105
115
|
_getCurrencySymbol() {
|
|
106
116
|
return `
|
|
@@ -116,6 +126,6 @@ class $ extends B {
|
|
|
116
126
|
}
|
|
117
127
|
}
|
|
118
128
|
export {
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
Y as CONTROL_BLOCK_ID,
|
|
130
|
+
A as PriceCurrencySymbolControl
|
|
121
131
|
};
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { ModificationDescription as C, UIElementType as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import { productPairs as
|
|
5
|
-
import { getItemsBlockConfig as
|
|
6
|
-
|
|
1
|
+
import { ModificationDescription as C, UIElementType as T, UEAttr as L } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as g } from "../../../common-control.js";
|
|
3
|
+
import { ItemsBlockControlId as p, ItemsBlockId as _ } from "../../enums/controlEnums.js";
|
|
4
|
+
import { productPairs as I } from "../../enums/productEnums.js";
|
|
5
|
+
import { getItemsBlockConfig as m, setItemsBlockConfig as D, escapeReplacement as h } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
import { isNewPriceFormatBlock as O } from "../priceFormat.js";
|
|
7
|
+
const N = p.PRICE_FORMATTED_PRICE, d = {
|
|
7
8
|
FORMATTED_PRICE: "formattedPrice"
|
|
8
9
|
};
|
|
9
|
-
class
|
|
10
|
+
class G extends g {
|
|
10
11
|
getId() {
|
|
11
|
-
return
|
|
12
|
+
return N;
|
|
12
13
|
}
|
|
13
14
|
getTemplate() {
|
|
14
15
|
return `
|
|
15
|
-
<div class="container ${
|
|
16
|
+
<div class="container ${p.PRICE_FORMATTED_PRICE}">
|
|
16
17
|
${this._getFormattedPrice()}
|
|
17
18
|
</div>
|
|
18
19
|
`;
|
|
19
20
|
}
|
|
20
21
|
onRender() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this._onFormattedPriceChange(t);
|
|
22
|
+
this.forgetLastPanelNode(), this.api.onValueChanged(d.FORMATTED_PRICE, (e) => {
|
|
23
|
+
this._onFormattedPriceChange(e);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
onTemplateNodeUpdated(e) {
|
|
27
27
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
28
|
-
const t =
|
|
29
|
-
this.api.updateValues({ [
|
|
28
|
+
const t = m(this.currentNode);
|
|
29
|
+
this.api.updateValues({ [d.FORMATTED_PRICE]: (t == null ? void 0 : t.priceFormatted) ?? !0 });
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
_onFormattedPriceChange(e) {
|
|
33
|
-
if (console.debug("Formatted price changed to: ", e), !this.currentNode)
|
|
33
|
+
if (console.debug("Formatted price changed to: ", e), !this.currentNode || O(this.currentNode))
|
|
34
34
|
return;
|
|
35
|
-
const t =
|
|
35
|
+
const t = m(this.currentNode), n = (t == null ? void 0 : t.type) ?? "CART_ITEMS", o = (t == null ? void 0 : t.priceSinglePrice) ?? !1, r = I.PAIRS_FOR_EXTENSION.price[n], i = I.PAIRS_FOR_EXTENSION.originalPrice[n], [a, R] = e ? [
|
|
36
36
|
o ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE,
|
|
37
37
|
o ? r.DEFAULT_SINGLE_PRICE_FORMATTED : r.DEFAULT_PRICE_FORMATTED
|
|
38
38
|
] : [
|
|
39
39
|
o ? r.DEFAULT_SINGLE_PRICE_FORMATTED : r.DEFAULT_PRICE_FORMATTED,
|
|
40
40
|
o ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE
|
|
41
|
-
],
|
|
42
|
-
|
|
41
|
+
], l = o ? i.DEFAULT_SINGLE_PRICE : i.DEFAULT_PRICE, P = o ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_PRICE_FORMATTED, [F, A] = e ? [l, P] : [P, l], s = this.api.getDocumentModifier();
|
|
42
|
+
D(this.currentNode, this.api, { priceFormatted: e }, s);
|
|
43
43
|
const c = this.currentNode.closest(".items-block");
|
|
44
44
|
((c == null ? void 0 : c.querySelectorAll(
|
|
45
|
-
`[esd-extension-block-id="${
|
|
46
|
-
)) || []).forEach((
|
|
47
|
-
this._updatePriceBlock(s,
|
|
45
|
+
`[esd-extension-block-id="${_.PRICE}"]`
|
|
46
|
+
)) || []).forEach((E) => {
|
|
47
|
+
this._updatePriceBlock(s, E, a, R, e);
|
|
48
48
|
}), ((c == null ? void 0 : c.querySelectorAll(
|
|
49
|
-
`[esd-extension-block-id="${
|
|
50
|
-
)) || []).forEach((
|
|
51
|
-
this._updatePriceBlock(s,
|
|
49
|
+
`[esd-extension-block-id="${_.ORIGINAL_PRICE}"]`
|
|
50
|
+
)) || []).forEach((E) => {
|
|
51
|
+
this._updatePriceBlock(s, E, F, A, e);
|
|
52
52
|
}), s.apply(new C(
|
|
53
53
|
`Updated price to ${e ? "formatted" : "unformatted"}`
|
|
54
54
|
));
|
|
55
55
|
}
|
|
56
56
|
_updatePriceBlock(e, t, n, o, r) {
|
|
57
|
-
const i = `data-formated="${r ? "true" : "false"}"`,
|
|
58
|
-
e.modifyHtml(t).setInnerHtml(
|
|
57
|
+
const i = `data-formated="${r ? "true" : "false"}"`, a = t.getInnerHTML().trim().replace(n, h(o)).replace(/data-formated=(?:"[^"]*"|'[^']*')/g, i);
|
|
58
|
+
e.modifyHtml(t).setInnerHtml(a);
|
|
59
59
|
}
|
|
60
60
|
_getFormattedPrice() {
|
|
61
61
|
return `
|
|
62
62
|
<div class="display-flex align-items-center justify-content-between">
|
|
63
|
-
<${
|
|
63
|
+
<${T.LABEL}
|
|
64
64
|
${L.LABEL.text}="${this.api.translate("Formatted Price (e.g. $9.90)")}"
|
|
65
65
|
>
|
|
66
|
-
</${
|
|
67
|
-
${this._GuToggle(
|
|
66
|
+
</${T.LABEL}>
|
|
67
|
+
${this._GuToggle(d.FORMATTED_PRICE)}
|
|
68
68
|
</div>
|
|
69
69
|
`;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
N as CONTROL_BLOCK_ID,
|
|
74
|
+
G as PriceFormattedPriceControl
|
|
75
75
|
};
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import { getItemsBlockConfig as
|
|
5
|
-
const
|
|
1
|
+
import { ModificationDescription as r, UIElementType as s, UEAttr as c } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as a } from "../../../common-control.js";
|
|
3
|
+
import { ItemsBlockControlId as d } from "../../enums/controlEnums.js";
|
|
4
|
+
import { getItemsBlockConfig as p, setItemsBlockConfig as u } from "../../utils/nodeConfigUtils.js";
|
|
5
|
+
const l = d.PRICE_HIDE_DISCOUNT, i = {
|
|
6
6
|
HIDE_DISCOUNT: "hideDiscount"
|
|
7
7
|
};
|
|
8
|
-
class
|
|
8
|
+
class g extends a {
|
|
9
9
|
getId() {
|
|
10
|
-
return
|
|
10
|
+
return l;
|
|
11
11
|
}
|
|
12
12
|
getTemplate() {
|
|
13
13
|
return `
|
|
14
|
-
<div class="container ${
|
|
14
|
+
<div class="container ${d.PRICE_HIDE_DISCOUNT}">
|
|
15
15
|
${this._getHideDiscount()}
|
|
16
16
|
</div>
|
|
17
17
|
`;
|
|
18
18
|
}
|
|
19
19
|
onRender() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this._onHideDiscountChange(e);
|
|
20
|
+
this.forgetLastPanelNode(), this.api.onValueChanged(i.HIDE_DISCOUNT, (t) => {
|
|
21
|
+
this._onHideDiscountChange(t);
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
24
|
onTemplateNodeUpdated(t) {
|
|
26
25
|
super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
|
|
27
|
-
const e =
|
|
26
|
+
const e = p(this.currentNode);
|
|
28
27
|
this.api.updateValues({ [i.HIDE_DISCOUNT]: (e == null ? void 0 : e.priceHideDiscount) ?? !0 });
|
|
29
28
|
});
|
|
30
29
|
}
|
|
@@ -33,13 +32,13 @@ class E extends p {
|
|
|
33
32
|
const e = this.api.getDocumentModifier();
|
|
34
33
|
u(this.currentNode, this.api, { priceHideDiscount: t }, e);
|
|
35
34
|
const o = (n = this.currentNode) == null ? void 0 : n.closest(".ins-product-td");
|
|
36
|
-
o && e.modifyHtml(o).setAttribute("data-nodup", String(t)), e.apply(new
|
|
35
|
+
o && e.modifyHtml(o).setAttribute("data-nodup", String(t)), e.apply(new r("Update hide-discount setting")), this.api.updateValues({ [i.HIDE_DISCOUNT]: t });
|
|
37
36
|
}
|
|
38
37
|
_getHideDiscount() {
|
|
39
38
|
return `
|
|
40
39
|
<div class="display-flex align-items-center justify-content-between">
|
|
41
40
|
<${s.LABEL}
|
|
42
|
-
${
|
|
41
|
+
${c.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
|
|
43
42
|
>
|
|
44
43
|
</${s.LABEL}>
|
|
45
44
|
${this._GuToggle(i.HIDE_DISCOUNT)}
|
|
@@ -49,6 +48,6 @@ class E extends p {
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
export {
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
l as CONTROL_BLOCK_ID,
|
|
52
|
+
g as PriceHideDiscountControl
|
|
54
53
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
1
|
+
import { ModificationDescription as d } 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 u } from "../../enums/settingsEnums.js";
|
|
5
|
+
import { getItemsBlockConfig as h, setItemsBlockConfig as I } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const y = m.PRICE_ORIENTATION, p = {
|
|
7
7
|
PRICE_ORIENTATION: "priceOrientation"
|
|
8
|
-
},
|
|
8
|
+
}, N = [
|
|
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 y;
|
|
15
15
|
}
|
|
16
16
|
getTemplate() {
|
|
17
17
|
return `
|
|
@@ -21,15 +21,14 @@ class P extends O {
|
|
|
21
21
|
`;
|
|
22
22
|
}
|
|
23
23
|
onRender() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
typeof t == "string" && this._onPriceOrientationChange(t);
|
|
24
|
+
this.forgetLastPanelNode(), this.api.onValueChanged(p.PRICE_ORIENTATION, (i) => {
|
|
25
|
+
typeof i == "string" && this._onPriceOrientationChange(i);
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
onTemplateNodeUpdated(i) {
|
|
30
29
|
super.onTemplateNodeUpdated(i), this.handleBlockInstanceChange(() => {
|
|
31
|
-
const t =
|
|
32
|
-
this.api.updateValues({ [
|
|
30
|
+
const t = h(this.currentNode);
|
|
31
|
+
this.api.updateValues({ [p.PRICE_ORIENTATION]: (t == null ? void 0 : t.priceOrientation) ?? "horizontal" });
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
34
|
_onPriceOrientationChange(i) {
|
|
@@ -37,46 +36,46 @@ class P extends O {
|
|
|
37
36
|
priceOrientation: i
|
|
38
37
|
}), !this.currentNode)
|
|
39
38
|
return;
|
|
40
|
-
const t =
|
|
39
|
+
const t = h(this.currentNode), e = ((t == null ? void 0 : t.orientation) ?? u.ORIENTATION.VERTICAL) === u.ORIENTATION.VERTICAL, o = i === "horizontal";
|
|
41
40
|
e ? this._updateVerticalLayout(o) : this._updateHorizontalLayout(o);
|
|
42
41
|
}
|
|
43
42
|
_updateVerticalLayout(i) {
|
|
44
|
-
var a,
|
|
45
|
-
const t = ((
|
|
43
|
+
var a, l, s, n;
|
|
44
|
+
const t = ((l = (a = this.currentNode) == null ? void 0 : a.closest(".ins-product-td")) == null ? void 0 : l.querySelectorAll(".product-price-class")) || [], r = ((n = (s = this.currentNode) == null ? void 0 : s.closest(".ins-product-td")) == null ? void 0 : n.querySelectorAll(".product-original-price-class")) || [];
|
|
46
45
|
if (!t || !r)
|
|
47
46
|
return;
|
|
48
47
|
const e = i ? "50%" : "100%", o = this.api.getDocumentModifier();
|
|
49
|
-
t.forEach((
|
|
50
|
-
o.modifyHtml(
|
|
51
|
-
}), r.forEach((
|
|
52
|
-
o.modifyHtml(
|
|
53
|
-
}), o.apply(new
|
|
48
|
+
t.forEach((c) => {
|
|
49
|
+
o.modifyHtml(c).setAttribute("width", e).setStyle("width", e);
|
|
50
|
+
}), r.forEach((c) => {
|
|
51
|
+
o.modifyHtml(c).setAttribute("width", e).setStyle("width", e);
|
|
52
|
+
}), o.apply(new d(`Updated original price element width to ${e}`));
|
|
54
53
|
}
|
|
55
54
|
_updateHorizontalLayout(i) {
|
|
56
|
-
var o, a,
|
|
57
|
-
const t = ((a = (o = this.currentNode) == null ? void 0 : o.closest(".ins-product-td")) == null ? void 0 : a.querySelectorAll(".horizontal-price")) || [], r = (
|
|
55
|
+
var o, a, l, s;
|
|
56
|
+
const t = ((a = (o = this.currentNode) == null ? void 0 : o.closest(".ins-product-td")) == null ? void 0 : a.querySelectorAll(".horizontal-price")) || [], r = (s = (l = this.currentNode) == null ? void 0 : l.closest(".ins-product-td")) == null ? void 0 : s.querySelector(".vertical-price");
|
|
58
57
|
if (!t || !r || t.length === 0)
|
|
59
58
|
return;
|
|
60
59
|
const e = this.api.getDocumentModifier();
|
|
61
60
|
i ? (t.forEach((n) => {
|
|
62
61
|
e.modifyHtml(n).setStyle("display", "table-cell");
|
|
63
|
-
}), e.modifyHtml(r).setStyle("display", "none"), e.apply(new
|
|
62
|
+
}), e.modifyHtml(r).setStyle("display", "none"), e.apply(new d("Show horizontal price orientation"))) : (t.forEach((n) => {
|
|
64
63
|
e.modifyHtml(n).setStyle("display", "none");
|
|
65
|
-
}), e.modifyHtml(r).setStyle("display", "table-cell"), e.apply(new
|
|
64
|
+
}), e.modifyHtml(r).setStyle("display", "table-cell"), e.apply(new d("Show vertical price orientation")));
|
|
66
65
|
}
|
|
67
66
|
_getPriceOrientation() {
|
|
68
67
|
return `
|
|
69
68
|
${this._GuTwoColumns([
|
|
70
69
|
this._GuLabel({ text: "Price Orientation" }),
|
|
71
70
|
this._GuRadioButton({
|
|
72
|
-
name:
|
|
73
|
-
buttons:
|
|
71
|
+
name: p.PRICE_ORIENTATION,
|
|
72
|
+
buttons: N
|
|
74
73
|
})
|
|
75
74
|
])}
|
|
76
75
|
`;
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
export {
|
|
80
|
-
|
|
79
|
+
y as CONTROL_BLOCK_ID,
|
|
81
80
|
P as PriceOrientationControl
|
|
82
81
|
};
|