@useinsider/guido 2.1.0-beta.411f2a9 → 2.1.0-beta.425dfd0
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 +123 -140
- package/dist/extensions/Blocks/Items/block.js +28 -19
- package/dist/extensions/Blocks/Items/controls/button/link.js +31 -19
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +81 -97
- package/dist/extensions/Blocks/Items/controls/image/link.js +31 -19
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +40 -28
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +46 -34
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +50 -45
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +51 -40
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +35 -23
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +57 -45
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +62 -42
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +191 -184
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -0
- package/dist/extensions/Blocks/Items/extension.js +9 -8
- package/dist/extensions/Blocks/Items/store/items-block.js +79 -0
- package/dist/extensions/Blocks/Items/template.js +175 -181
- 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 +92 -91
- package/dist/src/extensions/Blocks/Items/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +12 -10
- package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +45 -0
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -2
- package/dist/src/extensions/Blocks/common-control.d.ts +5 -4
- package/package.json +1 -1
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var H = (E, h, e) => h in E ? x(E, h, { enumerable: !0, configurable: !0, writable: !0, value: e }) : E[h] = e;
|
|
3
|
+
var O = (E, h, e) => H(E, typeof h != "symbol" ? h + "" : h, e);
|
|
4
|
+
import { UEAttr as C, ModificationDescription as u } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as k } from "../../common-control.js";
|
|
6
|
+
import { ItemsBlockId as m } from "../enums/controlEnums.js";
|
|
7
|
+
import { productPairs as _, templateFirstLine as b } from "../enums/productEnums.js";
|
|
8
|
+
import { ItemTypeOptions as R, OrientationOptions as U, ItemInCartOptions as N, SETTINGS_ENUMS as S, DefaultConfigValues as P } from "../enums/settingsEnums.js";
|
|
6
9
|
import F from "../layouts/horizontal.html.js";
|
|
7
10
|
import $ from "../layouts/vertical.html.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
+
import { useItemsBlockStore as q } from "../store/items-block.js";
|
|
12
|
+
import { getDefaultTemplate as w } from "../template.js";
|
|
13
|
+
import { getItemsBlockConfig as A, setItemsBlockConfig as f, escapeReplacement as L } from "../utils/nodeConfigUtils.js";
|
|
14
|
+
const B = "ui-elements-items-block", a = {
|
|
11
15
|
ITEMS_TYPE: "itemsType",
|
|
12
16
|
ORIENTATION: "orientation",
|
|
13
17
|
ITEM_IDS: "itemIds"
|
|
14
18
|
};
|
|
15
|
-
class
|
|
19
|
+
class J extends k {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
O(this, "store", q());
|
|
23
|
+
}
|
|
16
24
|
getId() {
|
|
17
|
-
return
|
|
25
|
+
return B;
|
|
18
26
|
}
|
|
19
27
|
getTemplate() {
|
|
20
28
|
return `
|
|
@@ -26,32 +34,40 @@ class Z extends U {
|
|
|
26
34
|
`;
|
|
27
35
|
}
|
|
28
36
|
onRender() {
|
|
29
|
-
const e = h(this.currentNode);
|
|
30
37
|
this.api.updateValues({
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
38
|
+
[a.ORIENTATION]: this.store.orientation,
|
|
39
|
+
[a.ITEMS_TYPE]: this.store.itemsType,
|
|
40
|
+
[a.ITEM_IDS]: this.store.itemIds
|
|
34
41
|
}), this._listenToFormUpdates();
|
|
35
42
|
}
|
|
36
43
|
onTemplateNodeUpdated(e) {
|
|
37
|
-
super.onTemplateNodeUpdated(e), console.debug("Items Block Config", e.getNodeConfig()), this.handleBlockInstanceChange(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
super.onTemplateNodeUpdated(e), console.debug("Items Block Config", e.getNodeConfig()), this.handleBlockInstanceChange(
|
|
45
|
+
() => {
|
|
46
|
+
const t = A(this.currentNode);
|
|
47
|
+
t && (this.store.setItemsType(t.type), this.store.setItemIds(t.itemsSelectValue), this.store.setOrientation(t.orientation), this.store.setCurrencySymbol(t.priceCurrencySymbol), this.store.setCurrencyLocation(t.priceCurrencyLocation), this.store.setFormattedPrice(t.priceFormatted), this.store.setImageLink(t.imageLink), this.store.setButtonLink(t.buttonLink));
|
|
48
|
+
},
|
|
49
|
+
() => {
|
|
50
|
+
this.api.updateValues({
|
|
51
|
+
[a.ORIENTATION]: this.store.orientation,
|
|
52
|
+
[a.ITEMS_TYPE]: this.store.itemsType,
|
|
53
|
+
[a.ITEM_IDS]: this.store.itemIds
|
|
54
|
+
}), this._initializeSelectItems();
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
onDestroy() {
|
|
59
|
+
const e = this._getTemplateData();
|
|
60
|
+
this.store.setTemplateData(e);
|
|
45
61
|
}
|
|
46
62
|
_getItemsType() {
|
|
47
63
|
return `
|
|
48
64
|
${this._GuOneColumn([
|
|
49
65
|
this._GuLabel({ text: "Item Type" }),
|
|
50
66
|
this._GuSelect({
|
|
51
|
-
name:
|
|
67
|
+
name: a.ITEMS_TYPE,
|
|
52
68
|
className: "es-100",
|
|
53
69
|
placeholder: "Select Item Type",
|
|
54
|
-
options:
|
|
70
|
+
options: R
|
|
55
71
|
})
|
|
56
72
|
])}
|
|
57
73
|
`;
|
|
@@ -61,8 +77,8 @@ class Z extends U {
|
|
|
61
77
|
${this._GuTwoColumns([
|
|
62
78
|
this._GuLabel({ text: "Orientation" }),
|
|
63
79
|
this._GuRadioButton({
|
|
64
|
-
name:
|
|
65
|
-
buttons:
|
|
80
|
+
name: a.ORIENTATION,
|
|
81
|
+
buttons: U
|
|
66
82
|
})
|
|
67
83
|
])}
|
|
68
84
|
`;
|
|
@@ -72,7 +88,7 @@ class Z extends U {
|
|
|
72
88
|
${this._GuTwoColumns([
|
|
73
89
|
this._GuLabel({ text: "Item in Cart" }),
|
|
74
90
|
this._GuSelect({
|
|
75
|
-
name:
|
|
91
|
+
name: a.ITEM_IDS,
|
|
76
92
|
className: "es-100",
|
|
77
93
|
placeholder: "Select Item In Cart",
|
|
78
94
|
options: []
|
|
@@ -81,219 +97,210 @@ class Z extends U {
|
|
|
81
97
|
`;
|
|
82
98
|
}
|
|
83
99
|
_onOrientationChange(e) {
|
|
84
|
-
this.api.updateValues({ [
|
|
85
|
-
const t = this.api.getDocumentModifier();
|
|
86
|
-
O(this.currentNode, this.api, {
|
|
100
|
+
this.store.setOrientation(e), this.store.setPriceOrientation("horizontal"), this.api.updateValues({ [a.ORIENTATION]: e }), f(this.currentNode, this.api, {
|
|
87
101
|
orientation: e,
|
|
88
102
|
priceOrientation: "horizontal"
|
|
89
|
-
}
|
|
103
|
+
}), this._reOrderTemplate(), setTimeout(() => {
|
|
90
104
|
this._recalculateTrimming();
|
|
91
105
|
}, 50);
|
|
92
106
|
}
|
|
93
107
|
_onItemsTypeChange(e) {
|
|
94
|
-
const t =
|
|
95
|
-
|
|
96
|
-
return;
|
|
97
|
-
const n = i.value, s = i.value.replace("Url}}", "Image}}"), o = this.api.getDocumentModifier();
|
|
98
|
-
O(this.currentNode, this.api, {
|
|
108
|
+
const t = S.ITEMS_TYPE[e], i = N[e], r = i == null ? void 0 : i[0];
|
|
109
|
+
!t || !r || (this.store.setItemsType(t), this.store.setItemIds(r.value), f(this.currentNode, this.api, {
|
|
99
110
|
source: t,
|
|
100
111
|
type: t,
|
|
101
|
-
itemsSelectValue:
|
|
102
|
-
imageLink:
|
|
103
|
-
buttonLink:
|
|
104
|
-
}
|
|
105
|
-
const l = this._getTemplateData(t);
|
|
106
|
-
this._updateImageSrc(l.imageSrc, o), this._updateName(l.name, o), this._updatePrice(l.price, o), this._updateOriginalPrice(l.originalPrice, o), this._updateQuantity(l.quantity, t, o), o.apply(new N("Updated items type"));
|
|
112
|
+
itemsSelectValue: r.value,
|
|
113
|
+
imageLink: this.store.imageLink,
|
|
114
|
+
buttonLink: this.store.buttonLink
|
|
115
|
+
}), this._updateDataTypeAttributes(t), this._initializeSelectItems(), this._reFillTemplate());
|
|
107
116
|
}
|
|
108
117
|
_onItemIdsChange(e) {
|
|
109
|
-
this.api.updateValues({ [
|
|
110
|
-
const t = e, r = e.replace("Url}}", "Image}}"), i = this.api.getDocumentModifier();
|
|
111
|
-
O(this.currentNode, this.api, {
|
|
118
|
+
this.store.setItemIds(e), this.api.updateValues({ [a.ITEM_IDS]: e }), f(this.currentNode, this.api, {
|
|
112
119
|
itemsSelectValue: e,
|
|
113
|
-
imageLink:
|
|
114
|
-
buttonLink:
|
|
115
|
-
}
|
|
116
|
-
const n = this._getTemplateData();
|
|
117
|
-
this._updateImageSrc(n.imageSrc, i), this._updateName(n.name, i), this._updatePrice(n.price, i), this._updateOriginalPrice(n.originalPrice, i), this._updateQuantity(n.quantity, void 0, i), i.apply(new N("Updated item selection"));
|
|
120
|
+
imageLink: this.store.imageLink,
|
|
121
|
+
buttonLink: this.store.buttonLink
|
|
122
|
+
}), this._updateDataNumberAttributes(e), this._reFillTemplate();
|
|
118
123
|
}
|
|
119
124
|
_initializeSelectItems() {
|
|
120
125
|
this.api.setUIEAttribute(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
a.ITEMS_TYPE,
|
|
127
|
+
C.SELECTPICKER.items,
|
|
128
|
+
R
|
|
124
129
|
);
|
|
125
|
-
const
|
|
130
|
+
const { itemsType: e, itemIds: t } = this.store;
|
|
126
131
|
this.api.updateValues({
|
|
127
|
-
[
|
|
132
|
+
[a.ITEMS_TYPE]: e
|
|
128
133
|
});
|
|
129
|
-
const i =
|
|
134
|
+
const i = N[e];
|
|
130
135
|
this.api.setUIEAttribute(
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
a.ITEM_IDS,
|
|
137
|
+
C.SELECTPICKER.items,
|
|
133
138
|
i
|
|
134
139
|
), this.api.updateValues({
|
|
135
|
-
[
|
|
140
|
+
[a.ITEM_IDS]: t
|
|
136
141
|
});
|
|
137
142
|
}
|
|
138
143
|
_listenToFormUpdates() {
|
|
139
144
|
this.api.onValueChanged(
|
|
140
|
-
|
|
145
|
+
a.ITEMS_TYPE,
|
|
141
146
|
(e) => this._onItemsTypeChange(e)
|
|
142
147
|
), this.api.onValueChanged(
|
|
143
|
-
|
|
148
|
+
a.ORIENTATION,
|
|
144
149
|
(e) => this._onOrientationChange(e)
|
|
145
150
|
), this.api.onValueChanged(
|
|
146
|
-
|
|
151
|
+
a.ITEM_IDS,
|
|
147
152
|
(e) => this._onItemIdsChange(e)
|
|
148
153
|
);
|
|
149
154
|
}
|
|
150
155
|
_renderTemplate() {
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
const {
|
|
157
|
+
orientation: e,
|
|
158
|
+
itemsType: t,
|
|
159
|
+
itemIds: i,
|
|
160
|
+
currencySymbol: r,
|
|
161
|
+
currencyLocation: n,
|
|
162
|
+
formattedPrice: o
|
|
163
|
+
} = this.store;
|
|
164
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(w({
|
|
165
|
+
orientation: e,
|
|
166
|
+
itemsType: t,
|
|
155
167
|
itemId: i,
|
|
156
|
-
currencySymbol:
|
|
157
|
-
currencyLocation:
|
|
168
|
+
currencySymbol: r,
|
|
169
|
+
currencyLocation: n,
|
|
158
170
|
formattedPrice: o
|
|
159
|
-
})).apply(new
|
|
171
|
+
})).apply(new u("Updated template"));
|
|
160
172
|
}
|
|
161
|
-
_getTemplateData(
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
button: y.PAIRS_FOR_EXTENSION.button[r].DEFAULT_LABEL
|
|
173
|
+
_getTemplateData() {
|
|
174
|
+
const { itemsType: e, itemIds: t, formattedPrice: i } = this.store, r = N[e].findIndex((o) => o.value === t), n = r > -1 ? r : 0;
|
|
175
|
+
return {
|
|
176
|
+
imageSrc: _.PAIRS_FOR_EXTENSION.imageSrc[e].DEFAULT[n],
|
|
177
|
+
name: _.PAIRS_FOR_EXTENSION.name[e].DEFAULT[n],
|
|
178
|
+
price: i ? _.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE_FORMATTED : _.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE,
|
|
179
|
+
originalPrice: i ? _.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE_FORMATTED : _.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE,
|
|
180
|
+
quantity: _.PAIRS_FOR_EXTENSION.quantity[e].DEFAULT,
|
|
181
|
+
button: _.PAIRS_FOR_EXTENSION.button[e].DEFAULT_LABEL
|
|
171
182
|
};
|
|
172
183
|
}
|
|
173
|
-
_updateImageSrc(e
|
|
184
|
+
_updateImageSrc(e) {
|
|
174
185
|
var i;
|
|
175
|
-
const
|
|
176
|
-
|
|
186
|
+
const t = (i = this.currentNode) == null ? void 0 : i.querySelector(`[esd-extension-block-id="${m.IMAGE}"] img`);
|
|
187
|
+
t && this.api.getDocumentModifier().modifyHtml(t).setAttribute("src", e).apply(new u("Updated image src"));
|
|
177
188
|
}
|
|
178
|
-
_updateName(e
|
|
179
|
-
var
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
189
|
+
_updateName(e) {
|
|
190
|
+
var n;
|
|
191
|
+
const t = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${m.NAME}"]`);
|
|
192
|
+
if (!t)
|
|
182
193
|
return;
|
|
183
|
-
const i =
|
|
184
|
-
let
|
|
185
|
-
|
|
194
|
+
const i = t.getInnerText().trim();
|
|
195
|
+
let r = t.getInnerHTML();
|
|
196
|
+
r = r.replace(i, e), this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(r).apply(new u("Updated name"));
|
|
186
197
|
}
|
|
187
|
-
_updatePrice(e
|
|
188
|
-
var
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
t.modifyHtml(a).setInnerHtml(S);
|
|
198
|
-
});
|
|
198
|
+
_updatePrice(e) {
|
|
199
|
+
var I;
|
|
200
|
+
const t = (I = this.currentNode) == null ? void 0 : I.querySelector(`[esd-extension-block-id="${m.PRICE}"]`);
|
|
201
|
+
if (!t)
|
|
202
|
+
return;
|
|
203
|
+
const i = this._getParagraphFromBlock(t);
|
|
204
|
+
if (!i)
|
|
205
|
+
return;
|
|
206
|
+
const r = i.getInnerHTML() || "", n = i.getInnerText() || "", { currencySymbol: o, currencyLocation: l } = this.store, c = (o == null ? void 0 : o.trim()) || "", s = this._removeCurrencySymbol(n, c), T = this._replacePriceNumber(s, e), p = this._buildPriceContent(T, c, l), d = r.replace(n, p);
|
|
207
|
+
this.api.getDocumentModifier().modifyHtml(i).setInnerHtml(d).apply(new u("Updated price"));
|
|
199
208
|
}
|
|
200
|
-
_updateOriginalPrice(e
|
|
201
|
-
var
|
|
202
|
-
const
|
|
203
|
-
`[esd-extension-block-id="${
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
209
|
+
_updateOriginalPrice(e) {
|
|
210
|
+
var g;
|
|
211
|
+
const t = (g = this.currentNode) == null ? void 0 : g.querySelector(
|
|
212
|
+
`[esd-extension-block-id="${m.ORIGINAL_PRICE}"]`
|
|
213
|
+
);
|
|
214
|
+
if (!t)
|
|
215
|
+
return;
|
|
216
|
+
const i = this._getParagraphFromBlock(t);
|
|
217
|
+
if (!i)
|
|
218
|
+
return;
|
|
219
|
+
const r = i.querySelector("s");
|
|
220
|
+
if (!r)
|
|
221
|
+
return;
|
|
222
|
+
const n = r.getInnerHTML() || "", o = r.getInnerText() || "", { currencySymbol: l, currencyLocation: c } = this.store, s = (l == null ? void 0 : l.trim()) || "", T = this._removeCurrencySymbol(o, s), p = this._replacePriceNumber(T, e), d = this._buildPriceContent(p, s, c), y = `<s>${n.replace(o, d)}</s>`;
|
|
223
|
+
this.api.getDocumentModifier().modifyHtml(i).setInnerHtml(y).apply(new u("Updated original price"));
|
|
215
224
|
}
|
|
216
|
-
_updateQuantity(e
|
|
217
|
-
var
|
|
218
|
-
const
|
|
219
|
-
if (!
|
|
225
|
+
_updateQuantity(e) {
|
|
226
|
+
var d;
|
|
227
|
+
const t = this.store.itemsType !== S.ITEMS_TYPE.BROWSED_ITEMS, i = A(this.currentNode), r = (i == null ? void 0 : i.quantityControlEnabled) !== !1, n = t && r, o = (d = this.currentNode) == null ? void 0 : d.querySelector(`[esd-extension-block-id="${m.QUANTITY}"]`);
|
|
228
|
+
if (!o)
|
|
220
229
|
return;
|
|
221
|
-
const
|
|
222
|
-
if (!
|
|
230
|
+
const l = this._getParagraphFromBlock(o);
|
|
231
|
+
if (!l)
|
|
223
232
|
return;
|
|
224
|
-
const
|
|
225
|
-
let
|
|
226
|
-
function
|
|
227
|
-
return
|
|
228
|
-
new RegExp(`(>\\s*)
|
|
229
|
-
`$1${
|
|
233
|
+
const c = l.getInnerText().trim();
|
|
234
|
+
let s = l.getInnerHTML();
|
|
235
|
+
function T(I, y, g) {
|
|
236
|
+
return I.replace(
|
|
237
|
+
new RegExp(`(>\\s*)${y}(\\s*<)`, "g"),
|
|
238
|
+
`$1${g}$2`
|
|
230
239
|
);
|
|
231
240
|
}
|
|
232
|
-
|
|
241
|
+
s = T(s, c, e);
|
|
242
|
+
const p = this.api.getDocumentModifier();
|
|
243
|
+
p.modifyHtml(l).setInnerHtml(s), p.modifyHtml(o).setStyle("display", n ? "table-cell" : "none"), p.apply(new u("Updated quantity"));
|
|
233
244
|
}
|
|
234
|
-
_reOrderTemplate(
|
|
235
|
-
var
|
|
236
|
-
const
|
|
237
|
-
`[esd-extension-block-id="${
|
|
238
|
-
))
|
|
239
|
-
|
|
240
|
-
)) || [], [s] = i, [o] = n, l = (R = this.currentNode) == null ? void 0 : R.querySelector(`[esd-extension-block-id="${T.QUANTITY}"]`), a = (M = this.currentNode) == null ? void 0 : M.querySelector(`[esd-extension-block-id="${T.BUTTON}"]`);
|
|
241
|
-
if (!t || !r || !s || !o || !l || !a)
|
|
245
|
+
_reOrderTemplate() {
|
|
246
|
+
var T, p, d, I, y, g;
|
|
247
|
+
const e = (T = this.currentNode) == null ? void 0 : T.querySelector(`[esd-extension-block-id="${m.IMAGE}"]`), t = (p = this.currentNode) == null ? void 0 : p.querySelector(`[esd-extension-block-id="${m.NAME}"]`), i = (d = this.currentNode) == null ? void 0 : d.querySelector(`[esd-extension-block-id="${m.PRICE}"]`), r = (I = this.currentNode) == null ? void 0 : I.querySelector(
|
|
248
|
+
`[esd-extension-block-id="${m.ORIGINAL_PRICE}"]`
|
|
249
|
+
), n = (y = this.currentNode) == null ? void 0 : y.querySelector(`[esd-extension-block-id="${m.QUANTITY}"]`), o = (g = this.currentNode) == null ? void 0 : g.querySelector(`[esd-extension-block-id="${m.BUTTON}"]`);
|
|
250
|
+
if (!e || !t || !i || !r || !n || !o)
|
|
242
251
|
return;
|
|
243
|
-
const
|
|
244
|
-
let
|
|
245
|
-
setTimeout(() => {
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
const P = e ?? this.api.getDocumentModifier();
|
|
249
|
-
P.modifyHtml(t.querySelector("img")).setAttribute("width", x.productImageWidth).setAttribute("height", x.productImageWidth), P.modifyHtml(this.currentNode).setInnerHtml(d), e || P.apply(new N("Reordered template"));
|
|
252
|
+
const { orientation: l } = this.store, c = l === S.ORIENTATION.VERTICAL;
|
|
253
|
+
let s = c ? $ : F;
|
|
254
|
+
this.api.getDocumentModifier().modifyHtml(e.querySelector("img")).setAttribute("width", P.productImageWidth).setAttribute("height", P.productImageWidth).apply(new u("Updated image width")), setTimeout(() => {
|
|
255
|
+
const M = L(i.getOuterHTML()), D = L(r.getOuterHTML());
|
|
256
|
+
s = s.replace("{-{-TEMPLATE_FIRST_LINE-}-}", c ? b : "").replace("{-{-PRODUCT_IMAGE-}-}", e.getOuterHTML()).replace("{-{-PRODUCT_NAME-}-}", t.getOuterHTML()).replaceAll("{-{-PRODUCT_PRICE-}-}", M).replaceAll("{-{-PRODUCT_ORIGINAL_PRICE-}-}", D).replace("{-{-PRODUCT_QUANTITY-}-}", n.getOuterHTML()).replace("{-{-PRODUCT_BUTTON-}-}", o.getOuterHTML()), s = s.trim().replace(b, "").slice(0, -5), this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(s).apply(new u("Reordered template"));
|
|
250
257
|
}, 50);
|
|
251
258
|
}
|
|
252
|
-
_updateDataTypeAttributes(e
|
|
259
|
+
_updateDataTypeAttributes(e) {
|
|
253
260
|
if (!this.currentNode)
|
|
254
261
|
return;
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
});
|
|
262
|
+
const t = this.currentNode.closest(".ins-product-td"), i = this.api.getDocumentModifier();
|
|
263
|
+
t && i.modifyHtml(t).setAttribute("data-type", e), this.currentNode.querySelectorAll("[data-type]").forEach((n) => {
|
|
264
|
+
const o = n;
|
|
265
|
+
i.modifyHtml(o).setAttribute("data-type", e);
|
|
266
|
+
}), i.apply(new u("Updated data-type attribute"));
|
|
260
267
|
}
|
|
261
|
-
_updateDataNumberAttributes(e
|
|
268
|
+
_updateDataNumberAttributes(e) {
|
|
262
269
|
if (!this.currentNode)
|
|
263
270
|
return;
|
|
264
|
-
const
|
|
265
|
-
let
|
|
266
|
-
if (
|
|
267
|
-
|
|
271
|
+
const { itemsType: t } = this.store, i = N[t].findIndex((c) => c.value === e);
|
|
272
|
+
let r = "1";
|
|
273
|
+
if (i >= 0)
|
|
274
|
+
r = String(i + 1);
|
|
268
275
|
else if (e) {
|
|
269
|
-
const
|
|
270
|
-
if (
|
|
271
|
-
const [,
|
|
272
|
-
|
|
276
|
+
const c = e.match(/\((\d+)\)/);
|
|
277
|
+
if (c) {
|
|
278
|
+
const [, s] = c;
|
|
279
|
+
r = s;
|
|
273
280
|
}
|
|
274
281
|
}
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
});
|
|
282
|
+
const n = this.currentNode.closest(".ins-product-td"), o = this.api.getDocumentModifier();
|
|
283
|
+
n && o.modifyHtml(n).setAttribute("data-number", r), this.currentNode.querySelectorAll("[data-number]").forEach((c) => {
|
|
284
|
+
const s = c;
|
|
285
|
+
o.modifyHtml(s).setAttribute("data-number", r);
|
|
286
|
+
}), o.apply(new u("Updated data-number attribute"));
|
|
280
287
|
}
|
|
281
|
-
_reFillTemplate(
|
|
282
|
-
const
|
|
283
|
-
this._updateImageSrc(
|
|
288
|
+
_reFillTemplate() {
|
|
289
|
+
const e = this._getTemplateData();
|
|
290
|
+
this._updateImageSrc(e.imageSrc), this._updateName(e.name), this._updatePrice(e.price), this._updateOriginalPrice(e.originalPrice), this._updateQuantity(e.quantity);
|
|
284
291
|
}
|
|
285
292
|
_recalculateTrimming() {
|
|
286
|
-
var
|
|
293
|
+
var n;
|
|
287
294
|
if (!this.currentNode)
|
|
288
295
|
return;
|
|
289
|
-
const e = (
|
|
296
|
+
const e = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${m.NAME}"]`);
|
|
290
297
|
if (!e)
|
|
291
298
|
return;
|
|
292
299
|
const t = e.querySelector("p > a");
|
|
293
300
|
if (!t)
|
|
294
301
|
return;
|
|
295
|
-
const
|
|
296
|
-
this.api.getDocumentModifier().modifyHtml(t).setStyle("overflow", "hidden").setStyle("white-space",
|
|
302
|
+
const i = this.store.orientation === S.ORIENTATION.HORIZONTAL, r = this.store.nameTrimming;
|
|
303
|
+
this.api.getDocumentModifier().modifyHtml(t).setStyle("overflow", "hidden").setStyle("white-space", r ? "nowrap" : "normal").setStyle("text-overflow", r ? "ellipsis" : "unset").setStyle("max-width", i ? "130px" : "520px").setStyle("width", i ? "130px" : "520px").apply(new u("Recalculated trimming after orientation change"));
|
|
297
304
|
}
|
|
298
305
|
_getParagraphFromBlock(e) {
|
|
299
306
|
return e.querySelector("p");
|
|
@@ -302,29 +309,29 @@ class Z extends U {
|
|
|
302
309
|
return e.replace(/[-\\^$*+?().|[\]{}]/g, "\\$&");
|
|
303
310
|
}
|
|
304
311
|
_removeCurrencySymbol(e, t) {
|
|
305
|
-
const
|
|
306
|
-
let
|
|
312
|
+
const i = e || "";
|
|
313
|
+
let r = i;
|
|
307
314
|
if (t) {
|
|
308
315
|
const n = new RegExp(`\\s*${this._escapeRegex(t)}\\s*`);
|
|
309
|
-
|
|
316
|
+
r = i.replace(n, "").trim();
|
|
310
317
|
} else {
|
|
311
|
-
const n =
|
|
318
|
+
const n = i.match(/([^0-9.,\s]+)/);
|
|
312
319
|
if (n && n[1]) {
|
|
313
|
-
const
|
|
314
|
-
|
|
320
|
+
const o = n[1].trim(), l = new RegExp(`\\s*${this._escapeRegex(o)}\\s*`);
|
|
321
|
+
r = i.replace(l, "").trim();
|
|
315
322
|
}
|
|
316
323
|
}
|
|
317
|
-
return
|
|
324
|
+
return r;
|
|
318
325
|
}
|
|
319
326
|
_replacePriceNumber(e, t) {
|
|
320
|
-
const
|
|
321
|
-
return e.replace(
|
|
327
|
+
const i = /([0-9][0-9,.]*)/;
|
|
328
|
+
return e.replace(i, t).trim();
|
|
322
329
|
}
|
|
323
|
-
_buildPriceContent(e, t,
|
|
324
|
-
return t ?
|
|
330
|
+
_buildPriceContent(e, t, i) {
|
|
331
|
+
return t ? i === "1" ? `${e} ${t}` : `${t} ${e}` : e;
|
|
325
332
|
}
|
|
326
333
|
}
|
|
327
334
|
export {
|
|
328
|
-
|
|
329
|
-
|
|
335
|
+
B as CONTROL_BLOCK_ID,
|
|
336
|
+
J as ItemsBlockControl
|
|
330
337
|
};
|
|
@@ -16,7 +16,9 @@ const e = {
|
|
|
16
16
|
{ icon: "vertical-orientation", value: e.ORIENTATION.VERTICAL },
|
|
17
17
|
{ icon: "horizontal-orientation", value: e.ORIENTATION.HORIZONTAL }
|
|
18
18
|
], a = {
|
|
19
|
+
itemsType: e.ITEMS_TYPE.CART_ITEMS,
|
|
19
20
|
cartItemsSelectControlValue: "{{Abandoned Cart Item (1) Url}}",
|
|
21
|
+
cardOrientationControlValue: e.ORIENTATION.VERTICAL,
|
|
20
22
|
productNameTrimmingControlValue: "1",
|
|
21
23
|
productPriceHideDiscountControlValue: "1",
|
|
22
24
|
productPriceFormattedControlValue: "1",
|
|
@@ -3,19 +3,20 @@ import { ItemsBlock as i } from "./block.js";
|
|
|
3
3
|
import { ButtonLinkControl as C } from "./controls/button/link.js";
|
|
4
4
|
import { ItemsBlockCardCompositionControl as e } from "./controls/cardComposition.js";
|
|
5
5
|
import { ImageLinkControl as m } from "./controls/image/link.js";
|
|
6
|
-
import { NameControls as
|
|
6
|
+
import { NameControls as t, QuantityControls as n, OriginalPriceControls as r, PriceControls as d, ImageControls as l, ButtonControls as o } from "./controls/index.js";
|
|
7
7
|
import { NameTrimmingControl as s } from "./controls/name/trimming.js";
|
|
8
8
|
import { PriceCurrencyLocationControl as c } from "./controls/price/currencyLocation.js";
|
|
9
|
-
import { PriceCurrencySymbolControl as
|
|
10
|
-
import { PriceFormattedPriceControl as
|
|
9
|
+
import { PriceCurrencySymbolControl as f } from "./controls/price/currencySymbol.js";
|
|
10
|
+
import { PriceFormattedPriceControl as g } from "./controls/price/formattedPrice.js";
|
|
11
11
|
import { PriceHideDiscountControl as p } from "./controls/price/hideDiscount.js";
|
|
12
12
|
import { PriceOrientationControl as y } from "./controls/price/priceOrientation.js";
|
|
13
13
|
import { PriceSinglePriceControl as u } from "./controls/price/singlePrice.js";
|
|
14
14
|
import { ItemsBlockControl as P } from "./controls/settingsControl.js";
|
|
15
|
-
import {
|
|
16
|
-
import I from "./
|
|
17
|
-
import
|
|
18
|
-
|
|
15
|
+
import { ItemsBlockId as k } from "./enums/controlEnums.js";
|
|
16
|
+
import { ItemsIconsRegistry as I } from "./iconsRegistry.js";
|
|
17
|
+
import b from "./items.css.js";
|
|
18
|
+
import { SettingsPanel as B } from "./settingsPanel.js";
|
|
19
|
+
const M = new a().addBlock(i).withSettingsPanelRegistry(B).addControl(P).addControl(e).addControl(t.align).addControl(t.color).addControl(t.size).addControl(t.style).addControl(t.fontFamily).addControl(t.background).addControl(t.paddings).addControl(s).addControl(n.align).addControl(n.color).addControl(n.fontFamily).addControl(n.paddings).addControl(n.size).addControl(n.style).addControl(r.align).addControl(r.color).addControl(r.size).addControl(r.style).addControl(r.fontFamily).addControl(r.background).addControl(r.paddings).addControl(d.align).addControl(d.color).addControl(d.size).addControl(d.style).addControl(d.fontFamily).addControl(d.background).addControl(d.paddings).addControl(p).addControl(g).addControl(u).addControl(f).addControl(c).addControl(y).addControl(m).addControl(l.size).addControl(l.margins).addControl(C).addControl(o.align).addControl(o.border).addControl(o.borderRadius).addControl(o.color).addControl(o.fontFamily).addControl(o.margins).addControl(o.paddings).addControl(o.text).addControl(o.textSize).addControl(o.textStyleAndFontColor).addControl(o.fitToContent).addStyles(b).withPreviewStyles(`[esd-extension-block-id="${k.IMAGE}"] img {object-fit: contain;}`).withIconsRegistry(I).build();
|
|
19
20
|
export {
|
|
20
|
-
|
|
21
|
+
M as default
|
|
21
22
|
};
|