@useinsider/guido 2.0.0-beta.c588e27 → 2.0.0-beta.c6d6ca6
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/@types/config/schemas.js +53 -39
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +2 -2
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue.js +12 -12
- package/dist/components/organisms/header/LeftSlot.vue2.js +6 -6
- package/dist/components/organisms/header/RightSlot.vue2.js +10 -10
- package/dist/composables/useConfig.js +29 -27
- package/dist/composables/useSave.js +13 -11
- package/dist/config/migrator/index.js +9 -8
- package/dist/config/migrator/itemsBlockMigrator.js +334 -0
- package/dist/extensions/Blocks/Items/block.js +36 -40
- package/dist/extensions/Blocks/Items/controls/button/link.js +22 -29
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +66 -46
- package/dist/extensions/Blocks/Items/controls/image/link.js +23 -30
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +25 -25
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +19 -17
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +31 -29
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +36 -36
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +21 -19
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +29 -27
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +93 -0
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +176 -162
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
- package/dist/extensions/Blocks/Items/enums/productEnums.js +43 -45
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +4 -5
- package/dist/extensions/Blocks/Items/extension.js +11 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +58 -49
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +48 -59
- package/dist/extensions/Blocks/Items/settingsPanel.js +27 -26
- package/dist/extensions/Blocks/Items/store/items-block.js +11 -7
- package/dist/extensions/Blocks/Items/template.js +387 -140
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +174 -0
- package/dist/extensions/Blocks/Recommendation/control.js +1 -1
- package/dist/extensions/Blocks/Unsubscribe/extension.js +9 -9
- package/dist/extensions/Blocks/common-control.js +26 -27
- package/dist/extensions/Blocks/controlFactories.js +55 -45
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +364 -285
- package/dist/package.json.js +1 -1
- package/dist/src/@types/config/index.d.ts +2 -2
- package/dist/src/@types/config/schemas.d.ts +26 -0
- package/dist/src/@types/config/types.d.ts +7 -1
- package/dist/src/composables/useConfig.d.ts +6 -0
- package/dist/src/config/migrator/itemsBlockMigrator.d.ts +6 -0
- package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -2
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +9 -0
- package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -2
- package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +18 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -4
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +24 -26
- package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +1 -2
- package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +22 -1
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +71 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +9 -10
- package/dist/src/stores/config.d.ts +147 -1
- package/dist/static/styles/components/button.css.js +1 -1
- package/dist/stores/config.js +7 -0
- package/dist/utils/pairProductVariables.js +61 -58
- package/package.json +3 -3
- package/dist/extensions/Blocks/Items/utils/configBlockUtils.js +0 -17
- package/dist/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.js +0 -28
- package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +0 -76
- package/dist/extensions/Blocks/Items/utils/updateAttributes.js +0 -46
- package/dist/src/extensions/Blocks/Items/utils/configBlockUtils.d.ts +0 -23
- package/dist/src/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.d.ts +0 -32
- package/dist/src/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.d.ts +0 -50
- package/dist/src/extensions/Blocks/Items/utils/updateAttributes.d.ts +0 -8
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var O = Object.defineProperty;
|
|
2
|
+
var y = (a, r, t) => r in a ? O(a, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[r] = t;
|
|
3
|
+
var P = (a, r, t) => y(a, typeof r != "symbol" ? r + "" : r, t);
|
|
4
4
|
import { ModificationDescription as l } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
-
import { CommonControl as
|
|
5
|
+
import { CommonControl as I } from "../../common-control.js";
|
|
6
6
|
import { ItemsBlockId as s } from "../enums/controlEnums.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
const h = "ui-elements-items-card-composition-block", i = {
|
|
7
|
+
import { SETTINGS_ENUMS as h } from "../enums/settingsEnums.js";
|
|
8
|
+
import { useItemsBlockStore as p } from "../store/items-block.js";
|
|
9
|
+
import { getItemsBlockConfig as R, setItemsBlockConfig as U } from "../utils/nodeConfigUtils.js";
|
|
10
|
+
const b = "ui-elements-items-card-composition-block", i = {
|
|
12
11
|
PRODUCT_IMAGE: "image",
|
|
13
12
|
PRODUCT_NAME: "name",
|
|
14
13
|
PRODUCT_QUANTITY: "quantity",
|
|
@@ -16,11 +15,11 @@ const h = "ui-elements-items-card-composition-block", i = {
|
|
|
16
15
|
PRODUCT_ORIGINAL_PRICE: "originalPrice",
|
|
17
16
|
PRODUCT_BUTTON: "button"
|
|
18
17
|
};
|
|
19
|
-
class
|
|
18
|
+
class S extends I {
|
|
20
19
|
constructor() {
|
|
21
20
|
super(...arguments);
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
P(this, "store", p());
|
|
22
|
+
P(this, "visibilityState", {
|
|
24
23
|
[i.PRODUCT_IMAGE]: !0,
|
|
25
24
|
[i.PRODUCT_NAME]: !0,
|
|
26
25
|
[i.PRODUCT_QUANTITY]: !0,
|
|
@@ -30,7 +29,7 @@ class g extends R {
|
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
31
|
getId() {
|
|
33
|
-
return
|
|
32
|
+
return b;
|
|
34
33
|
}
|
|
35
34
|
getTemplate() {
|
|
36
35
|
return `
|
|
@@ -83,20 +82,20 @@ class g extends R {
|
|
|
83
82
|
});
|
|
84
83
|
}
|
|
85
84
|
_syncVisibilityFromAttributes() {
|
|
86
|
-
const t =
|
|
85
|
+
const t = R(this.currentNode);
|
|
87
86
|
if (!t)
|
|
88
87
|
return;
|
|
89
88
|
const e = {
|
|
90
|
-
[i.PRODUCT_IMAGE]: "
|
|
91
|
-
[i.PRODUCT_NAME]: "
|
|
92
|
-
[i.PRODUCT_QUANTITY]: "
|
|
93
|
-
[i.PRODUCT_PRICE]: "
|
|
94
|
-
[i.PRODUCT_ORIGINAL_PRICE]: "
|
|
95
|
-
[i.PRODUCT_BUTTON]: "
|
|
89
|
+
[i.PRODUCT_IMAGE]: "imageVisible",
|
|
90
|
+
[i.PRODUCT_NAME]: "nameVisible",
|
|
91
|
+
[i.PRODUCT_QUANTITY]: "quantityControlEnabled",
|
|
92
|
+
[i.PRODUCT_PRICE]: "priceVisible",
|
|
93
|
+
[i.PRODUCT_ORIGINAL_PRICE]: "originalPriceVisible",
|
|
94
|
+
[i.PRODUCT_BUTTON]: "buttonVisible"
|
|
96
95
|
};
|
|
97
|
-
Object.entries(e).forEach(([o,
|
|
98
|
-
const
|
|
99
|
-
this.visibilityState[o] =
|
|
96
|
+
Object.entries(e).forEach(([o, n]) => {
|
|
97
|
+
const c = t[n];
|
|
98
|
+
this.visibilityState[o] = c !== !1;
|
|
100
99
|
});
|
|
101
100
|
}
|
|
102
101
|
/**
|
|
@@ -105,11 +104,10 @@ class g extends R {
|
|
|
105
104
|
* and mark it as '0'
|
|
106
105
|
*/
|
|
107
106
|
_handleBrowsedItemsQuantity() {
|
|
108
|
-
|
|
109
|
-
const t = this.store.itemsType !== u.ITEMS_TYPE.BROWSED_ITEMS, e = (r = this.currentNode) == null ? void 0 : r.querySelector("esd-config-block");
|
|
107
|
+
const t = this.store.itemsType !== h.ITEMS_TYPE.BROWSED_ITEMS, e = R(this.currentNode);
|
|
110
108
|
if (!e)
|
|
111
109
|
return;
|
|
112
|
-
const o = e.
|
|
110
|
+
const o = e.quantityControlEnabled !== !1;
|
|
113
111
|
this.visibilityState[i.PRODUCT_QUANTITY] = t && o, this.api.setVisibility(`${i.PRODUCT_QUANTITY}Container`, t), this._updateVisibilityAttribute(i.PRODUCT_QUANTITY, t && o);
|
|
114
112
|
}
|
|
115
113
|
_applyVisibilityStyles() {
|
|
@@ -123,26 +121,25 @@ class g extends R {
|
|
|
123
121
|
};
|
|
124
122
|
Object.entries(t).forEach(([e, o]) => {
|
|
125
123
|
var d;
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
124
|
+
const n = (d = this.currentNode) == null ? void 0 : d.querySelector(`[esd-extension-block-id="${o}"]`);
|
|
125
|
+
if (!n)
|
|
128
126
|
return;
|
|
129
|
-
const
|
|
130
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
131
|
-
});
|
|
127
|
+
const c = this.visibilityState[e];
|
|
128
|
+
this.api.getDocumentModifier().modifyHtml(n).setStyle("display", c ? "table-cell" : "none").apply(new l(`Applied ${e} visibility from attributes`));
|
|
129
|
+
}), this._updatePriceCellWidthsForVerticalLayout();
|
|
132
130
|
}
|
|
133
131
|
_updateVisibilityAttribute(t, e) {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
[i.
|
|
139
|
-
[i.
|
|
140
|
-
[i.
|
|
141
|
-
[i.PRODUCT_PRICE]: "PRODUCT_PRICE_VISIBLE",
|
|
142
|
-
[i.PRODUCT_ORIGINAL_PRICE]: "PRODUCT_ORIGINAL_PRICE_VISIBLE",
|
|
143
|
-
[i.PRODUCT_BUTTON]: "PRODUCT_BUTTON_VISIBLE"
|
|
132
|
+
const n = {
|
|
133
|
+
[i.PRODUCT_IMAGE]: "imageVisible",
|
|
134
|
+
[i.PRODUCT_NAME]: "nameVisible",
|
|
135
|
+
[i.PRODUCT_QUANTITY]: "quantityControlEnabled",
|
|
136
|
+
[i.PRODUCT_PRICE]: "priceVisible",
|
|
137
|
+
[i.PRODUCT_ORIGINAL_PRICE]: "originalPriceVisible",
|
|
138
|
+
[i.PRODUCT_BUTTON]: "buttonVisible"
|
|
144
139
|
}[t];
|
|
145
|
-
|
|
140
|
+
n && U(this.currentNode, this.api, {
|
|
141
|
+
[n]: e
|
|
142
|
+
});
|
|
146
143
|
}
|
|
147
144
|
_listenToFormUpdates() {
|
|
148
145
|
this.api.onValueChanged(i.PRODUCT_IMAGE, (t) => this._onProductImageChange(t)), this.api.onValueChanged(i.PRODUCT_NAME, (t) => this._onProductNameChange(t)), this.api.onValueChanged(i.PRODUCT_QUANTITY, (t) => this._onProductQuantityChange(t)), this.api.onValueChanged(i.PRODUCT_PRICE, (t) => this._onProductPriceChange(t)), this.api.onValueChanged(
|
|
@@ -170,7 +167,7 @@ class g extends R {
|
|
|
170
167
|
_onProductPriceChange(t) {
|
|
171
168
|
var o;
|
|
172
169
|
const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.PRICE}"]`);
|
|
173
|
-
e && (this.visibilityState[i.PRODUCT_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product price visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_PRICE, t));
|
|
170
|
+
e && (this.visibilityState[i.PRODUCT_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product price visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_PRICE, t), this._updatePriceCellWidthsForVerticalLayout());
|
|
174
171
|
}
|
|
175
172
|
_onProductOriginalPriceChange(t) {
|
|
176
173
|
var o;
|
|
@@ -179,7 +176,30 @@ class g extends R {
|
|
|
179
176
|
);
|
|
180
177
|
e && (this.visibilityState[i.PRODUCT_ORIGINAL_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(
|
|
181
178
|
`Product original price visibility changed to ${t ? "visible" : "hidden"}`
|
|
182
|
-
)), this._updateVisibilityAttribute(i.PRODUCT_ORIGINAL_PRICE, t));
|
|
179
|
+
)), this._updateVisibilityAttribute(i.PRODUCT_ORIGINAL_PRICE, t), this._updatePriceCellWidthsForVerticalLayout());
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Updates both price cell widths in vertical layout based on priceOrientation and visibility.
|
|
183
|
+
* - When priceOrientation is 'vertical': both cells are 100% (stacked layout)
|
|
184
|
+
* - When priceOrientation is 'horizontal':
|
|
185
|
+
* - When original price is hidden, price cell expands to 100%
|
|
186
|
+
* - When price is hidden, original price cell expands to 100%
|
|
187
|
+
* - When both are visible, they share 50% each
|
|
188
|
+
*/
|
|
189
|
+
_updatePriceCellWidthsForVerticalLayout() {
|
|
190
|
+
var u, _;
|
|
191
|
+
if (!(this.store.orientation === h.ORIENTATION.VERTICAL))
|
|
192
|
+
return;
|
|
193
|
+
const e = (u = this.currentNode) == null ? void 0 : u.querySelector(".product-price-class"), o = (_ = this.currentNode) == null ? void 0 : _.querySelector(".product-original-price-class"), n = this.store.priceOrientation === "vertical", c = this.visibilityState[i.PRODUCT_PRICE], d = this.visibilityState[i.PRODUCT_ORIGINAL_PRICE], T = this.api.getDocumentModifier();
|
|
194
|
+
if (e) {
|
|
195
|
+
const C = n || !d ? "100%" : "50%";
|
|
196
|
+
T.modifyHtml(e).setStyle("width", C);
|
|
197
|
+
}
|
|
198
|
+
if (o) {
|
|
199
|
+
const C = n || !c ? "100%" : "50%";
|
|
200
|
+
T.modifyHtml(o).setStyle("width", C);
|
|
201
|
+
}
|
|
202
|
+
T.apply(new l("Updated price cell widths for vertical layout"));
|
|
183
203
|
}
|
|
184
204
|
_onProductButtonChange(t) {
|
|
185
205
|
var o;
|
|
@@ -188,6 +208,6 @@ class g extends R {
|
|
|
188
208
|
}
|
|
189
209
|
}
|
|
190
210
|
export {
|
|
191
|
-
|
|
192
|
-
|
|
211
|
+
b as COMPOSITION_CONTROL_BLOCK_ID,
|
|
212
|
+
S as ItemsBlockCardCompositionControl
|
|
193
213
|
};
|
|
@@ -1,59 +1,52 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { CommonControl as
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var m = (t, e, n) => e in t ? a(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var s = (t, e, n) => m(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { CommonControl as l } from "../../../common-control.js";
|
|
5
5
|
import { ItemsBlockControlId as d } from "../../enums/controlEnums.js";
|
|
6
|
-
import { useItemsBlockStore as
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
const s = d.IMAGE_LINK, n = {
|
|
6
|
+
import { useItemsBlockStore as L } from "../../store/items-block.js";
|
|
7
|
+
import { getItemsBlockConfig as p } from "../../utils/nodeConfigUtils.js";
|
|
8
|
+
const r = d.IMAGE_LINK, i = {
|
|
10
9
|
LINK: "link"
|
|
11
10
|
};
|
|
12
|
-
class
|
|
11
|
+
class g extends l {
|
|
13
12
|
constructor() {
|
|
14
13
|
super(...arguments);
|
|
15
|
-
|
|
14
|
+
s(this, "store", L());
|
|
16
15
|
}
|
|
17
16
|
getId() {
|
|
18
|
-
return
|
|
17
|
+
return r;
|
|
19
18
|
}
|
|
20
19
|
getTemplate() {
|
|
21
20
|
return `
|
|
22
|
-
<div class="${
|
|
21
|
+
<div class="container ${r}">
|
|
23
22
|
${this._getLink()}
|
|
24
23
|
</div>
|
|
25
24
|
`;
|
|
26
25
|
}
|
|
27
26
|
onRender() {
|
|
28
27
|
this.api.updateValues({
|
|
29
|
-
[
|
|
30
|
-
})
|
|
28
|
+
[i.LINK]: this.store.imageLink
|
|
29
|
+
});
|
|
31
30
|
}
|
|
32
|
-
onTemplateNodeUpdated(
|
|
33
|
-
super.onTemplateNodeUpdated(
|
|
34
|
-
() =>
|
|
31
|
+
onTemplateNodeUpdated(n) {
|
|
32
|
+
super.onTemplateNodeUpdated(n), this.handleBlockInstanceChange(
|
|
33
|
+
() => {
|
|
34
|
+
const o = p(this.currentNode);
|
|
35
|
+
o != null && o.imageLink && this.store.setImageLink(o.imageLink);
|
|
36
|
+
},
|
|
35
37
|
() => {
|
|
36
38
|
this.api.updateValues({
|
|
37
|
-
[
|
|
39
|
+
[i.LINK]: this.store.imageLink
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
);
|
|
41
43
|
}
|
|
42
|
-
_listenToFormUpdates() {
|
|
43
|
-
this.api.onValueChanged(
|
|
44
|
-
n.LINK,
|
|
45
|
-
(e) => this._onLinkChange(e)
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
_onLinkChange(e) {
|
|
49
|
-
console.debug("Image link changed to: ", e), this.store.setImageLink(e), p(this.currentNode, this.api);
|
|
50
|
-
}
|
|
51
44
|
_getLink() {
|
|
52
45
|
return `
|
|
53
46
|
${this._GuOneColumn([
|
|
54
47
|
this._GuLabel({ text: "Link" }),
|
|
55
48
|
this._GuTextInput({
|
|
56
|
-
name:
|
|
49
|
+
name: i.LINK,
|
|
57
50
|
placeholder: "Enter Link",
|
|
58
51
|
className: "es-100",
|
|
59
52
|
disabled: !0
|
|
@@ -63,6 +56,6 @@ class N extends m {
|
|
|
63
56
|
}
|
|
64
57
|
}
|
|
65
58
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
r as CONTROL_BLOCK_ID,
|
|
60
|
+
g as ImageLinkControl
|
|
68
61
|
};
|
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { ModificationDescription as a, UIElementType as l, UEAttr as
|
|
2
|
+
var g = (i, t, e) => t in i ? d(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var s = (i, t, e) => g(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { ModificationDescription as a, UIElementType as l, UEAttr as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as c } from "../../../common-control.js";
|
|
6
6
|
import { ItemsBlockControlId as p } from "../../enums/controlEnums.js";
|
|
7
7
|
import { SETTINGS_ENUMS as I } from "../../enums/settingsEnums.js";
|
|
8
8
|
import { useItemsBlockStore as N } from "../../store/items-block.js";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
const y = p.NAME_TRIMMING, o = {
|
|
9
|
+
import { getItemsBlockConfig as f, setItemsBlockConfig as M } from "../../utils/nodeConfigUtils.js";
|
|
10
|
+
const y = p.NAME_TRIMMING, m = {
|
|
12
11
|
TRIMMING: "trimming"
|
|
13
12
|
};
|
|
14
13
|
class _ extends c {
|
|
15
14
|
constructor() {
|
|
16
15
|
super(...arguments);
|
|
17
|
-
|
|
16
|
+
s(this, "store", N());
|
|
18
17
|
}
|
|
19
18
|
getId() {
|
|
20
19
|
return y;
|
|
21
20
|
}
|
|
22
21
|
getTemplate() {
|
|
23
22
|
return `
|
|
24
|
-
<div class="${p.NAME_TRIMMING}">
|
|
23
|
+
<div class="container ${p.NAME_TRIMMING}">
|
|
25
24
|
${this._getTextTrimming()}
|
|
26
25
|
</div>
|
|
27
26
|
`;
|
|
28
27
|
}
|
|
29
28
|
onRender() {
|
|
30
|
-
this.api.updateValues({ [
|
|
29
|
+
this.api.updateValues({ [m.TRIMMING]: this.store.nameTrimming }), this.api.onValueChanged(m.TRIMMING, (e) => {
|
|
31
30
|
this._onTrimmingChange(e);
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
33
|
onTemplateNodeUpdated(e) {
|
|
35
34
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
|
|
36
|
-
() => M(this.currentNode),
|
|
37
35
|
() => {
|
|
38
|
-
|
|
36
|
+
const o = f(this.currentNode);
|
|
37
|
+
o && this.store.setNameTrimming(o.nameTrimming ?? !0);
|
|
38
|
+
},
|
|
39
|
+
() => {
|
|
40
|
+
this.api.updateValues({ [m.TRIMMING]: this.store.nameTrimming });
|
|
39
41
|
}
|
|
40
42
|
);
|
|
41
43
|
}
|
|
42
44
|
_onTrimmingChange(e) {
|
|
43
|
-
this.store.setNameTrimming(e),
|
|
45
|
+
this.store.setNameTrimming(e), M(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [m.TRIMMING]: e }), this._applyTrimmingStyles(e);
|
|
44
46
|
}
|
|
45
47
|
_applyTrimmingStyles(e) {
|
|
46
|
-
var
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
48
|
+
var r;
|
|
49
|
+
const o = (r = this.currentNode) == null ? void 0 : r.querySelector("p > a");
|
|
50
|
+
if (!o)
|
|
49
51
|
return;
|
|
50
|
-
const T = e !== void 0 ? e : this.store.nameTrimming,
|
|
51
|
-
T ? this.api.getDocumentModifier().modifyHtml(
|
|
52
|
+
const T = e !== void 0 ? e : this.store.nameTrimming, n = this.store.orientation === I.ORIENTATION.VERTICAL;
|
|
53
|
+
T ? this.api.getDocumentModifier().modifyHtml(o).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", n ? "130px" : "520px").apply(new a("Text Trimming Enabled")) : this.api.getDocumentModifier().modifyHtml(o).removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow").removeStyle("max-width").setStyle("max-width", n ? "130px" : "520px").apply(new a("Text Trimming Disabled"));
|
|
52
54
|
}
|
|
53
55
|
_getTextTrimming() {
|
|
54
56
|
return `
|
|
55
|
-
<div class="
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
${this._GuToggle(o.TRIMMING)}
|
|
62
|
-
</div>
|
|
57
|
+
<div class="display-flex align-items-center justify-content-between">
|
|
58
|
+
<${l.LABEL}
|
|
59
|
+
${h.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
60
|
+
>
|
|
61
|
+
</${l.LABEL}>
|
|
62
|
+
${this._GuToggle(m.TRIMMING)}
|
|
63
63
|
</div>
|
|
64
64
|
`;
|
|
65
65
|
}
|
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
var
|
|
2
|
-
var R = (i, o, e) => o in i ?
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var R = (i, o, e) => o in i ? y(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
|
|
3
3
|
var p = (i, o, e) => R(i, typeof o != "symbol" ? o + "" : o, e);
|
|
4
4
|
import { currencyLocationMaps as m } from "../../../../../enums/extensions/recommendationBlock.js";
|
|
5
|
-
import { UEAttr as
|
|
5
|
+
import { UEAttr as I, ModificationDescription as N } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { CommonControl as T } from "../../../common-control.js";
|
|
7
7
|
import { ItemsBlockControlId as h } from "../../enums/controlEnums.js";
|
|
8
|
-
import { useItemsBlockStore as
|
|
9
|
-
import {
|
|
10
|
-
import { updateConfigBlockAttributes as O } from "../../utils/updateAttributes.js";
|
|
8
|
+
import { useItemsBlockStore as f } from "../../store/items-block.js";
|
|
9
|
+
import { getItemsBlockConfig as E, setItemsBlockConfig as O } from "../../utils/nodeConfigUtils.js";
|
|
11
10
|
const b = h.PRICE_CURRENCY_LOCATION, a = {
|
|
12
11
|
CURRENCY_LOCATION: "currencyLocation"
|
|
13
12
|
};
|
|
14
|
-
class
|
|
13
|
+
class B extends T {
|
|
15
14
|
constructor() {
|
|
16
15
|
super(...arguments);
|
|
17
|
-
p(this, "store",
|
|
16
|
+
p(this, "store", f());
|
|
18
17
|
}
|
|
19
18
|
getId() {
|
|
20
19
|
return b;
|
|
21
20
|
}
|
|
22
21
|
getTemplate() {
|
|
23
22
|
return `
|
|
24
|
-
<div class="${h.PRICE_CURRENCY_LOCATION}">
|
|
23
|
+
<div class="container ${h.PRICE_CURRENCY_LOCATION}">
|
|
25
24
|
${this._getCurrencyLocation()}
|
|
26
25
|
</div>
|
|
27
26
|
`;
|
|
28
27
|
}
|
|
29
28
|
onRender() {
|
|
30
|
-
this.api.setUIEAttribute(a.CURRENCY_LOCATION,
|
|
29
|
+
this.api.setUIEAttribute(a.CURRENCY_LOCATION, I.SELECTPICKER.items, m), this.api.updateValues({ [a.CURRENCY_LOCATION]: this.store.currencyLocation }), this.api.onValueChanged(a.CURRENCY_LOCATION, (e) => {
|
|
31
30
|
this._onCurrencyLocationChange(e);
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
33
|
onTemplateNodeUpdated(e) {
|
|
35
34
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
|
|
36
|
-
() =>
|
|
35
|
+
() => {
|
|
36
|
+
const t = E(this.currentNode);
|
|
37
|
+
t && this.store.setCurrencyLocation(t.priceCurrencyLocation || "0");
|
|
38
|
+
},
|
|
37
39
|
() => {
|
|
38
40
|
this.api.updateValues({ [a.CURRENCY_LOCATION]: this.store.currencyLocation });
|
|
39
41
|
}
|
|
40
42
|
);
|
|
41
43
|
}
|
|
42
44
|
_onCurrencyLocationChange(e) {
|
|
43
|
-
if (console.debug("Currency location changed to: ", e), this.store.setCurrencyLocation(e), O(this.currentNode, this.api), !this.currentNode)
|
|
45
|
+
if (console.debug("Currency location changed to: ", e), this.store.setCurrencyLocation(e), O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
|
|
44
46
|
return;
|
|
45
47
|
const t = this._getPriceBlocks();
|
|
46
48
|
if (!t || t.length === 0)
|
|
@@ -50,8 +52,8 @@ class Y extends T {
|
|
|
50
52
|
const s = this._getParagraph(c);
|
|
51
53
|
if (!s)
|
|
52
54
|
return;
|
|
53
|
-
const
|
|
54
|
-
this.api.getDocumentModifier().modifyHtml(s).setInnerHtml(
|
|
55
|
+
const C = s.getInnerHTML() || "", l = s.getInnerText() || "", u = (n == null ? void 0 : n.trim()) || "", d = this._removeCurrencySymbol(l, u), g = this._detectSymbolInText(l) || u, _ = this._buildPriceContent(d, g, r), L = C.replace(l, _);
|
|
56
|
+
this.api.getDocumentModifier().modifyHtml(s).setInnerHtml(L).apply(new N(
|
|
55
57
|
`Updated currency location to ${r === "1" ? "after" : "before"}`
|
|
56
58
|
));
|
|
57
59
|
});
|
|
@@ -75,8 +77,8 @@ class Y extends T {
|
|
|
75
77
|
} else {
|
|
76
78
|
const c = r.match(/([^0-9.,\s]+)/);
|
|
77
79
|
if (c && c[1]) {
|
|
78
|
-
const s = c[1].trim(),
|
|
79
|
-
n = r.replace(
|
|
80
|
+
const s = c[1].trim(), C = new RegExp(`\\s*${this._escapeRegex(s)}\\s*`);
|
|
81
|
+
n = r.replace(C, "").trim();
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
return n;
|
|
@@ -103,5 +105,5 @@ class Y extends T {
|
|
|
103
105
|
}
|
|
104
106
|
export {
|
|
105
107
|
b as CONTROL_BLOCK_ID,
|
|
106
|
-
|
|
108
|
+
B as PriceCurrencyLocationControl
|
|
107
109
|
};
|
|
@@ -5,12 +5,11 @@ import { ModificationDescription as b } from "../../../../../node_modules/@strip
|
|
|
5
5
|
import { CommonControl as R } from "../../../common-control.js";
|
|
6
6
|
import { ItemsBlockControlId as h } from "../../enums/controlEnums.js";
|
|
7
7
|
import { useItemsBlockStore as f } from "../../store/items-block.js";
|
|
8
|
-
import {
|
|
9
|
-
import { updateConfigBlockAttributes as B } from "../../utils/updateAttributes.js";
|
|
8
|
+
import { getItemsBlockConfig as B, setItemsBlockConfig as N } from "../../utils/nodeConfigUtils.js";
|
|
10
9
|
const E = h.PRICE_CURRENCY_SYMBOL, m = {
|
|
11
10
|
CURRENCY_SYMBOL: "currencySymbol"
|
|
12
11
|
};
|
|
13
|
-
class
|
|
12
|
+
class M extends R {
|
|
14
13
|
constructor() {
|
|
15
14
|
super(...arguments);
|
|
16
15
|
u(this, "store", f());
|
|
@@ -21,7 +20,7 @@ class P extends R {
|
|
|
21
20
|
}
|
|
22
21
|
getTemplate() {
|
|
23
22
|
return `
|
|
24
|
-
<div class="${h.PRICE_CURRENCY_SYMBOL}">
|
|
23
|
+
<div class="container ${h.PRICE_CURRENCY_SYMBOL}">
|
|
25
24
|
${this._getCurrencySymbol()}
|
|
26
25
|
</div>
|
|
27
26
|
`;
|
|
@@ -36,7 +35,10 @@ class P extends R {
|
|
|
36
35
|
}
|
|
37
36
|
onTemplateNodeUpdated(e) {
|
|
38
37
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
|
|
39
|
-
() =>
|
|
38
|
+
() => {
|
|
39
|
+
const t = B(this.currentNode);
|
|
40
|
+
t && this.store.setCurrencySymbol(t.priceCurrencySymbol || "");
|
|
41
|
+
},
|
|
40
42
|
() => {
|
|
41
43
|
this.api.updateValues({ [m.CURRENCY_SYMBOL]: this.store.currencySymbol }), this._storeOriginalContents();
|
|
42
44
|
}
|
|
@@ -45,18 +47,18 @@ class P extends R {
|
|
|
45
47
|
_onCurrencySymbolChange(e) {
|
|
46
48
|
var i;
|
|
47
49
|
console.debug("Currency symbol changed to: ", e);
|
|
48
|
-
const
|
|
49
|
-
if (this.store.setCurrencySymbol(e),
|
|
50
|
+
const t = ((i = this.store.currencySymbol) == null ? void 0 : i.trim()) || "";
|
|
51
|
+
if (this.store.setCurrencySymbol(e), N(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
|
|
50
52
|
return;
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
53
|
+
const r = this._getPriceBlocks();
|
|
54
|
+
if (!r || r.length === 0)
|
|
53
55
|
return;
|
|
54
56
|
const o = (e == null ? void 0 : e.trim()) || "", { currencyLocation: n } = this.store;
|
|
55
|
-
|
|
57
|
+
r.forEach((l) => {
|
|
56
58
|
const a = this._getParagraph(l);
|
|
57
59
|
if (!a)
|
|
58
60
|
return;
|
|
59
|
-
const y = a.getInnerHTML() || "", p = a.getInnerText() || "", C = this._removeCurrencySymbol(p,
|
|
61
|
+
const y = a.getInnerHTML() || "", p = a.getInnerText() || "", C = this._removeCurrencySymbol(p, t), g = this._buildPriceContent(C, o, n), d = y.replace(p, g);
|
|
60
62
|
this.api.getDocumentModifier().modifyHtml(a).setInnerHtml(d).apply(new b(
|
|
61
63
|
`Updated currency symbol to ${o || "removed"}`
|
|
62
64
|
));
|
|
@@ -67,18 +69,18 @@ class P extends R {
|
|
|
67
69
|
return;
|
|
68
70
|
this.currentNode.querySelectorAll(
|
|
69
71
|
".items-block-price"
|
|
70
|
-
).forEach((
|
|
72
|
+
).forEach((t) => {
|
|
71
73
|
var o;
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
const n =
|
|
75
|
-
this.originalPriceContents.set(
|
|
74
|
+
const r = t.querySelector("p");
|
|
75
|
+
if (r && !this.originalPriceContents.has(r)) {
|
|
76
|
+
const n = r.getInnerText() || "", i = ((o = this.store.currencySymbol) == null ? void 0 : o.trim()) || "", l = this._removeCurrencySymbol(n, i);
|
|
77
|
+
this.originalPriceContents.set(r, l);
|
|
76
78
|
}
|
|
77
79
|
});
|
|
78
80
|
}
|
|
79
81
|
_getPriceBlocks() {
|
|
80
|
-
var e,
|
|
81
|
-
return ((
|
|
82
|
+
var e, t;
|
|
83
|
+
return ((t = (e = this.currentNode) == null ? void 0 : e.closest(".items-block")) == null ? void 0 : t.querySelectorAll(".items-block-price")) || [];
|
|
82
84
|
}
|
|
83
85
|
_getParagraph(e) {
|
|
84
86
|
return e.querySelector("p");
|
|
@@ -86,23 +88,23 @@ class P extends R {
|
|
|
86
88
|
_escapeRegex(e) {
|
|
87
89
|
return e.replace(/[-\\^$*+?().|[\]{}]/g, "\\$&");
|
|
88
90
|
}
|
|
89
|
-
_removeCurrencySymbol(e,
|
|
90
|
-
const
|
|
91
|
-
let o =
|
|
92
|
-
if (
|
|
93
|
-
const n = new RegExp(`\\s*${this._escapeRegex(
|
|
94
|
-
o =
|
|
91
|
+
_removeCurrencySymbol(e, t) {
|
|
92
|
+
const r = e || "";
|
|
93
|
+
let o = r;
|
|
94
|
+
if (t) {
|
|
95
|
+
const n = new RegExp(`\\s*${this._escapeRegex(t)}\\s*`);
|
|
96
|
+
o = r.replace(n, "").trim();
|
|
95
97
|
} else {
|
|
96
|
-
const n =
|
|
98
|
+
const n = r.match(/([^0-9.,\s]+)/);
|
|
97
99
|
if (n && n[1]) {
|
|
98
100
|
const i = n[1].trim(), l = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
|
|
99
|
-
o =
|
|
101
|
+
o = r.replace(l, "").trim();
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
return o;
|
|
103
105
|
}
|
|
104
|
-
_buildPriceContent(e,
|
|
105
|
-
return
|
|
106
|
+
_buildPriceContent(e, t, r) {
|
|
107
|
+
return t ? r === "1" ? `${e} ${t}` : `${t} ${e}` : e;
|
|
106
108
|
}
|
|
107
109
|
_getCurrencySymbol() {
|
|
108
110
|
return `
|
|
@@ -119,5 +121,5 @@ class P extends R {
|
|
|
119
121
|
}
|
|
120
122
|
export {
|
|
121
123
|
E as CONTROL_BLOCK_ID,
|
|
122
|
-
|
|
124
|
+
M as PriceCurrencySymbolControl
|
|
123
125
|
};
|