@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,29 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UEAttr as
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { ItemsBlockId as
|
|
7
|
-
import { productPairs as T, templateFirstLine as
|
|
8
|
-
import { ItemTypeOptions as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { useItemsBlockStore as
|
|
12
|
-
import { getDefaultTemplate as
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
const G = "ui-elements-items-block", s = {
|
|
1
|
+
var L = Object.defineProperty;
|
|
2
|
+
var M = (I, h, t) => h in I ? L(I, h, { enumerable: !0, configurable: !0, writable: !0, value: t }) : I[h] = t;
|
|
3
|
+
var O = (I, h, t) => M(I, typeof h != "symbol" ? h + "" : h, t);
|
|
4
|
+
import { UEAttr as C, ModificationDescription as u } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as D } from "../../common-control.js";
|
|
6
|
+
import { ItemsBlockId as m } from "../enums/controlEnums.js";
|
|
7
|
+
import { productPairs as T, templateFirstLine as b } from "../enums/productEnums.js";
|
|
8
|
+
import { ItemTypeOptions as R, OrientationOptions as x, ItemInCartOptions as N, SETTINGS_ENUMS as S, DefaultConfigValues as A } from "../enums/settingsEnums.js";
|
|
9
|
+
import k from "../layouts/horizontal.html.js";
|
|
10
|
+
import H from "../layouts/vertical.html.js";
|
|
11
|
+
import { useItemsBlockStore as U } from "../store/items-block.js";
|
|
12
|
+
import { getDefaultTemplate as F } from "../template.js";
|
|
13
|
+
import { getItemsBlockConfig as P, setItemsBlockConfig as f } from "../utils/nodeConfigUtils.js";
|
|
14
|
+
const $ = "ui-elements-items-block", a = {
|
|
16
15
|
ITEMS_TYPE: "itemsType",
|
|
17
16
|
ORIENTATION: "orientation",
|
|
18
17
|
ITEM_IDS: "itemIds"
|
|
19
18
|
};
|
|
20
|
-
class
|
|
19
|
+
class K extends D {
|
|
21
20
|
constructor() {
|
|
22
21
|
super(...arguments);
|
|
23
|
-
|
|
22
|
+
O(this, "store", U());
|
|
24
23
|
}
|
|
25
24
|
getId() {
|
|
26
|
-
return
|
|
25
|
+
return $;
|
|
27
26
|
}
|
|
28
27
|
getTemplate() {
|
|
29
28
|
return `
|
|
@@ -36,38 +35,39 @@ class te extends x {
|
|
|
36
35
|
}
|
|
37
36
|
onRender() {
|
|
38
37
|
this.api.updateValues({
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
38
|
+
[a.ORIENTATION]: this.store.orientation,
|
|
39
|
+
[a.ITEMS_TYPE]: this.store.itemsType,
|
|
40
|
+
[a.ITEM_IDS]: this.store.itemIds
|
|
42
41
|
}), this._listenToFormUpdates();
|
|
43
42
|
}
|
|
44
|
-
onTemplateNodeUpdated(
|
|
45
|
-
super.onTemplateNodeUpdated(
|
|
43
|
+
onTemplateNodeUpdated(t) {
|
|
44
|
+
super.onTemplateNodeUpdated(t), console.debug("Items Block Config", t.getNodeConfig()), this.handleBlockInstanceChange(
|
|
46
45
|
() => {
|
|
47
|
-
|
|
46
|
+
const e = P(this.currentNode);
|
|
47
|
+
e && (this.store.setItemsType(e.type), this.store.setItemIds(e.itemsSelectValue), this.store.setOrientation(e.orientation), this.store.setCurrencySymbol(e.priceCurrencySymbol), this.store.setCurrencyLocation(e.priceCurrencyLocation), this.store.setFormattedPrice(e.priceFormatted), this.store.setImageLink(e.imageLink), this.store.setButtonLink(e.buttonLink));
|
|
48
48
|
},
|
|
49
49
|
() => {
|
|
50
50
|
this.api.updateValues({
|
|
51
|
-
[
|
|
52
|
-
[
|
|
53
|
-
[
|
|
51
|
+
[a.ORIENTATION]: this.store.orientation,
|
|
52
|
+
[a.ITEMS_TYPE]: this.store.itemsType,
|
|
53
|
+
[a.ITEM_IDS]: this.store.itemIds
|
|
54
54
|
}), this._initializeSelectItems();
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
onDestroy() {
|
|
59
|
-
const
|
|
60
|
-
this.store.setTemplateData(
|
|
59
|
+
const t = this._getTemplateData();
|
|
60
|
+
this.store.setTemplateData(t);
|
|
61
61
|
}
|
|
62
62
|
_getItemsType() {
|
|
63
63
|
return `
|
|
64
64
|
${this._GuOneColumn([
|
|
65
65
|
this._GuLabel({ text: "Item Type" }),
|
|
66
66
|
this._GuSelect({
|
|
67
|
-
name:
|
|
67
|
+
name: a.ITEMS_TYPE,
|
|
68
68
|
className: "es-100",
|
|
69
69
|
placeholder: "Select Item Type",
|
|
70
|
-
options:
|
|
70
|
+
options: R
|
|
71
71
|
})
|
|
72
72
|
])}
|
|
73
73
|
`;
|
|
@@ -77,8 +77,8 @@ class te extends x {
|
|
|
77
77
|
${this._GuTwoColumns([
|
|
78
78
|
this._GuLabel({ text: "Orientation" }),
|
|
79
79
|
this._GuRadioButton({
|
|
80
|
-
name:
|
|
81
|
-
buttons:
|
|
80
|
+
name: a.ORIENTATION,
|
|
81
|
+
buttons: x
|
|
82
82
|
})
|
|
83
83
|
])}
|
|
84
84
|
`;
|
|
@@ -88,7 +88,7 @@ class te extends x {
|
|
|
88
88
|
${this._GuTwoColumns([
|
|
89
89
|
this._GuLabel({ text: "Item in Cart" }),
|
|
90
90
|
this._GuSelect({
|
|
91
|
-
name:
|
|
91
|
+
name: a.ITEM_IDS,
|
|
92
92
|
className: "es-100",
|
|
93
93
|
placeholder: "Select Item In Cart",
|
|
94
94
|
options: []
|
|
@@ -96,221 +96,235 @@ class te extends x {
|
|
|
96
96
|
])}
|
|
97
97
|
`;
|
|
98
98
|
}
|
|
99
|
-
_onOrientationChange(
|
|
100
|
-
|
|
99
|
+
_onOrientationChange(t) {
|
|
100
|
+
this.store.setOrientation(t), this.store.setPriceOrientation("horizontal"), this.api.updateValues({ [a.ORIENTATION]: t }), f(this.currentNode, this.api, {
|
|
101
|
+
orientation: t,
|
|
102
|
+
priceOrientation: "horizontal"
|
|
103
|
+
}), this._reOrderTemplate(), setTimeout(() => {
|
|
101
104
|
this._recalculateTrimming();
|
|
102
105
|
}, 50);
|
|
103
106
|
}
|
|
104
|
-
_onItemsTypeChange(
|
|
105
|
-
const
|
|
106
|
-
!
|
|
107
|
+
_onItemsTypeChange(t) {
|
|
108
|
+
const e = S.ITEMS_TYPE[t], i = N[t], r = i == null ? void 0 : i[0];
|
|
109
|
+
!e || !r || (this.store.setItemsType(e), this.store.setItemIds(r.value), f(this.currentNode, this.api, {
|
|
110
|
+
source: e,
|
|
111
|
+
type: e,
|
|
112
|
+
itemsSelectValue: r.value,
|
|
113
|
+
imageLink: this.store.imageLink,
|
|
114
|
+
buttonLink: this.store.buttonLink
|
|
115
|
+
}), this._updateDataTypeAttributes(e), this._initializeSelectItems(), this._reFillTemplate());
|
|
107
116
|
}
|
|
108
|
-
_onItemIdsChange(
|
|
109
|
-
|
|
117
|
+
_onItemIdsChange(t) {
|
|
118
|
+
this.store.setItemIds(t), this.api.updateValues({ [a.ITEM_IDS]: t }), f(this.currentNode, this.api, {
|
|
119
|
+
itemsSelectValue: t,
|
|
120
|
+
imageLink: this.store.imageLink,
|
|
121
|
+
buttonLink: this.store.buttonLink
|
|
122
|
+
}), this._updateDataNumberAttributes(t), this._reFillTemplate();
|
|
110
123
|
}
|
|
111
124
|
_initializeSelectItems() {
|
|
112
125
|
this.api.setUIEAttribute(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
a.ITEMS_TYPE,
|
|
127
|
+
C.SELECTPICKER.items,
|
|
128
|
+
R
|
|
116
129
|
);
|
|
117
|
-
const { itemsType:
|
|
130
|
+
const { itemsType: t, itemIds: e } = this.store;
|
|
118
131
|
this.api.updateValues({
|
|
119
|
-
[
|
|
132
|
+
[a.ITEMS_TYPE]: t
|
|
120
133
|
});
|
|
121
|
-
const
|
|
134
|
+
const i = N[t];
|
|
122
135
|
this.api.setUIEAttribute(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
a.ITEM_IDS,
|
|
137
|
+
C.SELECTPICKER.items,
|
|
138
|
+
i
|
|
126
139
|
), this.api.updateValues({
|
|
127
|
-
[
|
|
140
|
+
[a.ITEM_IDS]: e
|
|
128
141
|
});
|
|
129
142
|
}
|
|
130
143
|
_listenToFormUpdates() {
|
|
131
144
|
this.api.onValueChanged(
|
|
132
|
-
|
|
133
|
-
(
|
|
145
|
+
a.ITEMS_TYPE,
|
|
146
|
+
(t) => this._onItemsTypeChange(t)
|
|
134
147
|
), this.api.onValueChanged(
|
|
135
|
-
|
|
136
|
-
(
|
|
148
|
+
a.ORIENTATION,
|
|
149
|
+
(t) => this._onOrientationChange(t)
|
|
137
150
|
), this.api.onValueChanged(
|
|
138
|
-
|
|
139
|
-
(
|
|
151
|
+
a.ITEM_IDS,
|
|
152
|
+
(t) => this._onItemIdsChange(t)
|
|
140
153
|
);
|
|
141
154
|
}
|
|
142
155
|
_renderTemplate() {
|
|
143
156
|
const {
|
|
144
|
-
orientation:
|
|
145
|
-
itemsType:
|
|
146
|
-
itemIds:
|
|
157
|
+
orientation: t,
|
|
158
|
+
itemsType: e,
|
|
159
|
+
itemIds: i,
|
|
147
160
|
currencySymbol: r,
|
|
148
161
|
currencyLocation: n,
|
|
149
162
|
formattedPrice: o
|
|
150
163
|
} = this.store;
|
|
151
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(
|
|
152
|
-
orientation:
|
|
153
|
-
itemsType:
|
|
154
|
-
itemId:
|
|
164
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(F({
|
|
165
|
+
orientation: t,
|
|
166
|
+
itemsType: e,
|
|
167
|
+
itemId: i,
|
|
155
168
|
currencySymbol: r,
|
|
156
169
|
currencyLocation: n,
|
|
157
170
|
formattedPrice: o
|
|
158
|
-
})).apply(new
|
|
171
|
+
})).apply(new u("Updated template"));
|
|
159
172
|
}
|
|
160
173
|
_getTemplateData() {
|
|
161
|
-
const { itemsType:
|
|
174
|
+
const { itemsType: t, itemIds: e, formattedPrice: i } = this.store, r = N[t].findIndex((o) => o.value === e), n = r > -1 ? r : 0;
|
|
162
175
|
return {
|
|
163
|
-
imageSrc: T.PAIRS_FOR_EXTENSION.imageSrc[
|
|
164
|
-
name: T.PAIRS_FOR_EXTENSION.name[
|
|
165
|
-
price:
|
|
166
|
-
originalPrice:
|
|
167
|
-
quantity: T.PAIRS_FOR_EXTENSION.quantity[
|
|
168
|
-
button: T.PAIRS_FOR_EXTENSION.button[
|
|
176
|
+
imageSrc: T.PAIRS_FOR_EXTENSION.imageSrc[t].DEFAULT[n],
|
|
177
|
+
name: T.PAIRS_FOR_EXTENSION.name[t].DEFAULT[n],
|
|
178
|
+
price: i ? T.PAIRS_FOR_EXTENSION.price[t].DEFAULT_PRICE_FORMATTED : T.PAIRS_FOR_EXTENSION.price[t].DEFAULT_PRICE,
|
|
179
|
+
originalPrice: i ? T.PAIRS_FOR_EXTENSION.originalPrice[t].DEFAULT_PRICE_FORMATTED : T.PAIRS_FOR_EXTENSION.originalPrice[t].DEFAULT_PRICE,
|
|
180
|
+
quantity: T.PAIRS_FOR_EXTENSION.quantity[t].DEFAULT,
|
|
181
|
+
button: T.PAIRS_FOR_EXTENSION.button[t].DEFAULT_LABEL
|
|
169
182
|
};
|
|
170
183
|
}
|
|
171
|
-
_updateImageSrc(
|
|
172
|
-
var
|
|
173
|
-
const
|
|
174
|
-
|
|
184
|
+
_updateImageSrc(t) {
|
|
185
|
+
var i;
|
|
186
|
+
const e = (i = this.currentNode) == null ? void 0 : i.querySelector(`[esd-extension-block-id="${m.IMAGE}"] img`);
|
|
187
|
+
e && this.api.getDocumentModifier().modifyHtml(e).setAttribute("src", t).apply(new u("Updated image src"));
|
|
175
188
|
}
|
|
176
|
-
_updateName(
|
|
189
|
+
_updateName(t) {
|
|
177
190
|
var n;
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
191
|
+
const e = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${m.NAME}"]`);
|
|
192
|
+
if (!e)
|
|
180
193
|
return;
|
|
181
|
-
const
|
|
182
|
-
let r =
|
|
183
|
-
r = r.replace(
|
|
194
|
+
const i = e.getInnerText().trim();
|
|
195
|
+
let r = e.getInnerHTML();
|
|
196
|
+
r = r.replace(i, t), this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(r).apply(new u("Updated name"));
|
|
184
197
|
}
|
|
185
|
-
_updatePrice(
|
|
198
|
+
_updatePrice(t) {
|
|
186
199
|
var g;
|
|
187
|
-
const
|
|
188
|
-
if (!
|
|
200
|
+
const e = (g = this.currentNode) == null ? void 0 : g.querySelector(`[esd-extension-block-id="${m.PRICE}"]`);
|
|
201
|
+
if (!e)
|
|
189
202
|
return;
|
|
190
|
-
const
|
|
191
|
-
if (!
|
|
203
|
+
const i = this._getParagraphFromBlock(e);
|
|
204
|
+
if (!i)
|
|
192
205
|
return;
|
|
193
|
-
const r =
|
|
194
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
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), d = this._replacePriceNumber(s, t), p = this._buildPriceContent(d, c, l), _ = r.replace(n, p);
|
|
207
|
+
this.api.getDocumentModifier().modifyHtml(i).setInnerHtml(_).apply(new u("Updated price"));
|
|
195
208
|
}
|
|
196
|
-
_updateOriginalPrice(
|
|
209
|
+
_updateOriginalPrice(t) {
|
|
197
210
|
var y;
|
|
198
|
-
const
|
|
199
|
-
`[esd-extension-block-id="${
|
|
211
|
+
const e = (y = this.currentNode) == null ? void 0 : y.querySelector(
|
|
212
|
+
`[esd-extension-block-id="${m.ORIGINAL_PRICE}"]`
|
|
200
213
|
);
|
|
201
|
-
if (!
|
|
214
|
+
if (!e)
|
|
202
215
|
return;
|
|
203
|
-
const
|
|
204
|
-
if (!
|
|
216
|
+
const i = this._getParagraphFromBlock(e);
|
|
217
|
+
if (!i)
|
|
205
218
|
return;
|
|
206
|
-
const r =
|
|
219
|
+
const r = i.querySelector("s");
|
|
207
220
|
if (!r)
|
|
208
221
|
return;
|
|
209
|
-
const n = r.getInnerHTML() || "", o = r.getInnerText() || "", { currencySymbol:
|
|
210
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
222
|
+
const n = r.getInnerHTML() || "", o = r.getInnerText() || "", { currencySymbol: l, currencyLocation: c } = this.store, s = (l == null ? void 0 : l.trim()) || "", d = this._removeCurrencySymbol(o, s), p = this._replacePriceNumber(d, t), _ = this._buildPriceContent(p, s, c), E = `<s>${n.replace(o, _)}</s>`;
|
|
223
|
+
this.api.getDocumentModifier().modifyHtml(i).setInnerHtml(E).apply(new u("Updated original price"));
|
|
211
224
|
}
|
|
212
|
-
_updateQuantity(
|
|
213
|
-
var
|
|
214
|
-
const
|
|
215
|
-
if (!
|
|
225
|
+
_updateQuantity(t) {
|
|
226
|
+
var p;
|
|
227
|
+
const e = this.store.itemsType !== S.ITEMS_TYPE.BROWSED_ITEMS, i = P(this.currentNode), r = (i == null ? void 0 : i.quantityControlEnabled) !== !1, n = e && r, o = (p = this.currentNode) == null ? void 0 : p.querySelector(`[esd-extension-block-id="${m.QUANTITY}"]`);
|
|
228
|
+
if (!o)
|
|
229
|
+
return;
|
|
230
|
+
const l = this._getParagraphFromBlock(o);
|
|
231
|
+
if (!l)
|
|
216
232
|
return;
|
|
217
|
-
const
|
|
218
|
-
let
|
|
219
|
-
|
|
233
|
+
const c = l.getInnerText().trim();
|
|
234
|
+
let s = l.getInnerHTML();
|
|
235
|
+
s = s.replace(c, t);
|
|
236
|
+
const d = this.api.getDocumentModifier();
|
|
237
|
+
d.modifyHtml(l).setInnerHtml(s), d.modifyHtml(o).setStyle("display", n ? "table-cell" : "none"), d.apply(new u("Updated quantity"));
|
|
220
238
|
}
|
|
221
|
-
/**
|
|
222
|
-
* @todo Optimize template reordering for performance.
|
|
223
|
-
* @description Reorders the template structure based on current orientation and visibility settings.
|
|
224
|
-
*/
|
|
225
239
|
_reOrderTemplate() {
|
|
226
|
-
var
|
|
227
|
-
const
|
|
228
|
-
`[esd-extension-block-id="${
|
|
229
|
-
), n = (
|
|
230
|
-
if (!
|
|
240
|
+
var d, p, _, g, E, y;
|
|
241
|
+
const t = (d = this.currentNode) == null ? void 0 : d.querySelector(`[esd-extension-block-id="${m.IMAGE}"]`), e = (p = this.currentNode) == null ? void 0 : p.querySelector(`[esd-extension-block-id="${m.NAME}"]`), i = (_ = this.currentNode) == null ? void 0 : _.querySelector(`[esd-extension-block-id="${m.PRICE}"]`), r = (g = this.currentNode) == null ? void 0 : g.querySelector(
|
|
242
|
+
`[esd-extension-block-id="${m.ORIGINAL_PRICE}"]`
|
|
243
|
+
), n = (E = this.currentNode) == null ? void 0 : E.querySelector(`[esd-extension-block-id="${m.QUANTITY}"]`), o = (y = this.currentNode) == null ? void 0 : y.querySelector(`[esd-extension-block-id="${m.BUTTON}"]`);
|
|
244
|
+
if (!t || !e || !i || !r || !n || !o)
|
|
231
245
|
return;
|
|
232
|
-
const { orientation:
|
|
233
|
-
let
|
|
234
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
235
|
-
|
|
246
|
+
const { orientation: l } = this.store, c = l === S.ORIENTATION.VERTICAL;
|
|
247
|
+
let s = c ? H : k;
|
|
248
|
+
this.api.getDocumentModifier().modifyHtml(t.querySelector("img")).setAttribute("width", A.productImageWidth).setAttribute("height", A.productImageWidth).apply(new u("Updated image width")), setTimeout(() => {
|
|
249
|
+
s = s.replace("{-{-TEMPLATE_FIRST_LINE-}-}", c ? b : "").replace("{-{-PRODUCT_IMAGE-}-}", t.getOuterHTML()).replace("{-{-PRODUCT_NAME-}-}", e.getOuterHTML()).replaceAll("{-{-PRODUCT_PRICE-}-}", i.getOuterHTML()).replaceAll("{-{-PRODUCT_ORIGINAL_PRICE-}-}", r.getOuterHTML()).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"));
|
|
236
250
|
}, 50);
|
|
237
251
|
}
|
|
238
|
-
_updateDataTypeAttributes(
|
|
252
|
+
_updateDataTypeAttributes(t) {
|
|
239
253
|
if (!this.currentNode)
|
|
240
254
|
return;
|
|
241
|
-
const
|
|
242
|
-
|
|
255
|
+
const e = this.currentNode.closest(".ins-product-td"), i = this.api.getDocumentModifier();
|
|
256
|
+
e && i.modifyHtml(e).setAttribute("data-type", t), this.currentNode.querySelectorAll("[data-type]").forEach((n) => {
|
|
243
257
|
const o = n;
|
|
244
|
-
|
|
245
|
-
}),
|
|
258
|
+
i.modifyHtml(o).setAttribute("data-type", t);
|
|
259
|
+
}), i.apply(new u("Updated data-type attribute"));
|
|
246
260
|
}
|
|
247
|
-
_updateDataNumberAttributes(
|
|
261
|
+
_updateDataNumberAttributes(t) {
|
|
248
262
|
if (!this.currentNode)
|
|
249
263
|
return;
|
|
250
|
-
const { itemsType:
|
|
264
|
+
const { itemsType: e } = this.store, i = N[e].findIndex((c) => c.value === t);
|
|
251
265
|
let r = "1";
|
|
252
|
-
if (
|
|
253
|
-
r = String(
|
|
254
|
-
else if (
|
|
255
|
-
const c =
|
|
266
|
+
if (i >= 0)
|
|
267
|
+
r = String(i + 1);
|
|
268
|
+
else if (t) {
|
|
269
|
+
const c = t.match(/\((\d+)\)/);
|
|
256
270
|
if (c) {
|
|
257
|
-
const [,
|
|
258
|
-
r =
|
|
271
|
+
const [, s] = c;
|
|
272
|
+
r = s;
|
|
259
273
|
}
|
|
260
274
|
}
|
|
261
275
|
const n = this.currentNode.closest(".ins-product-td"), o = this.api.getDocumentModifier();
|
|
262
276
|
n && o.modifyHtml(n).setAttribute("data-number", r), this.currentNode.querySelectorAll("[data-number]").forEach((c) => {
|
|
263
|
-
const
|
|
264
|
-
o.modifyHtml(
|
|
265
|
-
}), o.apply(new
|
|
277
|
+
const s = c;
|
|
278
|
+
o.modifyHtml(s).setAttribute("data-number", r);
|
|
279
|
+
}), o.apply(new u("Updated data-number attribute"));
|
|
266
280
|
}
|
|
267
281
|
_reFillTemplate() {
|
|
268
|
-
const
|
|
269
|
-
this._updateImageSrc(
|
|
282
|
+
const t = this._getTemplateData();
|
|
283
|
+
this._updateImageSrc(t.imageSrc), this._updateName(t.name), this._updatePrice(t.price), this._updateOriginalPrice(t.originalPrice), this._updateQuantity(t.quantity);
|
|
270
284
|
}
|
|
271
285
|
_recalculateTrimming() {
|
|
272
286
|
var n;
|
|
273
287
|
if (!this.currentNode)
|
|
274
288
|
return;
|
|
275
|
-
const
|
|
276
|
-
if (!
|
|
289
|
+
const t = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${m.NAME}"]`);
|
|
290
|
+
if (!t)
|
|
277
291
|
return;
|
|
278
|
-
const
|
|
279
|
-
if (!
|
|
292
|
+
const e = t.querySelector("p > a");
|
|
293
|
+
if (!e)
|
|
280
294
|
return;
|
|
281
|
-
const
|
|
282
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
295
|
+
const i = this.store.orientation === S.ORIENTATION.HORIZONTAL, r = this.store.nameTrimming;
|
|
296
|
+
this.api.getDocumentModifier().modifyHtml(e).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"));
|
|
283
297
|
}
|
|
284
|
-
_getParagraphFromBlock(
|
|
285
|
-
return
|
|
298
|
+
_getParagraphFromBlock(t) {
|
|
299
|
+
return t.querySelector("p");
|
|
286
300
|
}
|
|
287
|
-
_escapeRegex(
|
|
288
|
-
return
|
|
301
|
+
_escapeRegex(t) {
|
|
302
|
+
return t.replace(/[-\\^$*+?().|[\]{}]/g, "\\$&");
|
|
289
303
|
}
|
|
290
|
-
_removeCurrencySymbol(
|
|
291
|
-
const
|
|
292
|
-
let r =
|
|
293
|
-
if (
|
|
294
|
-
const n = new RegExp(`\\s*${this._escapeRegex(
|
|
295
|
-
r =
|
|
304
|
+
_removeCurrencySymbol(t, e) {
|
|
305
|
+
const i = t || "";
|
|
306
|
+
let r = i;
|
|
307
|
+
if (e) {
|
|
308
|
+
const n = new RegExp(`\\s*${this._escapeRegex(e)}\\s*`);
|
|
309
|
+
r = i.replace(n, "").trim();
|
|
296
310
|
} else {
|
|
297
|
-
const n =
|
|
311
|
+
const n = i.match(/([^0-9.,\s]+)/);
|
|
298
312
|
if (n && n[1]) {
|
|
299
|
-
const o = n[1].trim(),
|
|
300
|
-
r =
|
|
313
|
+
const o = n[1].trim(), l = new RegExp(`\\s*${this._escapeRegex(o)}\\s*`);
|
|
314
|
+
r = i.replace(l, "").trim();
|
|
301
315
|
}
|
|
302
316
|
}
|
|
303
317
|
return r;
|
|
304
318
|
}
|
|
305
|
-
_replacePriceNumber(
|
|
306
|
-
const
|
|
307
|
-
return
|
|
319
|
+
_replacePriceNumber(t, e) {
|
|
320
|
+
const i = /([0-9][0-9,.]*)/;
|
|
321
|
+
return t.replace(i, e).trim();
|
|
308
322
|
}
|
|
309
|
-
_buildPriceContent(e, i
|
|
310
|
-
return
|
|
323
|
+
_buildPriceContent(t, e, i) {
|
|
324
|
+
return e ? i === "1" ? `${t} ${e}` : `${e} ${t}` : t;
|
|
311
325
|
}
|
|
312
326
|
}
|
|
313
327
|
export {
|
|
314
|
-
|
|
315
|
-
|
|
328
|
+
$ as CONTROL_BLOCK_ID,
|
|
329
|
+
K as ItemsBlockControl
|
|
316
330
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var c = /* @__PURE__ */ ((i) => (i.BUTTON = "items-block-button", i.IMAGE = "items-block-image", i.ORIGINAL_PRICE = "items-block-original-price", i.PRICE = "items-block-price", i.QUANTITY = "items-block-quantity", i.NAME = "items-block-name", i))(c || {}),
|
|
1
|
+
var c = /* @__PURE__ */ ((i) => (i.BUTTON = "items-block-button", i.IMAGE = "items-block-image", i.ORIGINAL_PRICE = "items-block-original-price", i.PRICE = "items-block-price", i.QUANTITY = "items-block-quantity", i.NAME = "items-block-name", i))(c || {}), _ = /* @__PURE__ */ ((i) => (i.BUTTON_ALIGN = "items-block-button-align-control", i.BUTTON_BORDER = "items-block-button-border-control", i.BUTTON_BORDER_RADIUS = "items-block-button-border-radius-control", i.BUTTON_COLOR = "items-block-button-color-control", i.BUTTON_FIT_TO_CONTENT = "items-block-button-fit-to-content-control", i.BUTTON_FONT_FAMILY = "items-block-button-font-family-control", i.BUTTON_MARGINS = "items-block-button-margins-control", i.BUTTON_PADDINGS = "items-block-button-paddings-control", i.BUTTON_TEXT = "items-block-button-text-control", i.BUTTON_TEXT_SIZE = "items-block-button-text-size-control", i.BUTTON_TEXT_STYLE_AND_FONT_COLOR = "items-block-button-text-style-and-font-color-control", i.BUTTON_LINK = "items-block-button-link-control", i.IMAGE_SIZE = "items-block-image-size-control", i.IMAGE_MARGINS = "items-block-image-margins-control", i.IMAGE_LINK = "items-block-image-link-control", i.ORIGINAL_PRICE_ALIGN = "items-block-original-price-align-control", i.ORIGINAL_PRICE_COLOR = "items-block-original-price-color-control", i.ORIGINAL_PRICE_SIZE = "items-block-original-price-size-control", i.ORIGINAL_PRICE_STYLE = "items-block-original-price-style-control", i.ORIGINAL_PRICE_FONT_FAMILY = "items-block-original-price-font-family-control", i.ORIGINAL_PRICE_BACKGROUND = "items-block-original-price-background-control", i.ORIGINAL_PRICE_PADDINGS = "items-block-original-price-paddings-control", i.PRICE_ALIGN = "items-block-price-align-control", i.PRICE_COLOR = "items-block-price-color-control", i.PRICE_SIZE = "items-block-price-size-control", i.PRICE_STYLE = "items-block-price-style-control", i.PRICE_FONT_FAMILY = "items-block-price-font-family-control", i.PRICE_BACKGROUND = "items-block-price-background-control", i.PRICE_PADDINGS = "items-block-price-paddings-control", i.PRICE_HIDE_DISCOUNT = "items-block-price-hide-discount-control", i.PRICE_FORMATTED_PRICE = "items-block-price-formatted-price-control", i.PRICE_SINGLE_PRICE = "items-block-price-single-price-control", i.PRICE_CURRENCY_SYMBOL = "items-block-price-currency-symbol-control", i.PRICE_CURRENCY_LOCATION = "items-block-price-currency-location-control", i.PRICE_ORIENTATION = "items-block-price-orientation-control", i.NAME_ALIGN = "items-block-name-align-control", i.NAME_COLOR = "items-block-name-color-control", i.NAME_SIZE = "items-block-name-size-control", i.NAME_STYLE = "items-block-name-style-control", i.NAME_FONT_FAMILY = "items-block-name-font-family-control", i.NAME_BACKGROUND = "items-block-name-background-control", i.NAME_TRIMMING = "items-block-name-trimming-control", i.NAME_PADDINGS = "items-block-name-paddings-control", i.QUANTITY_ALIGN = "items-block-quantity-align-control", i.QUANTITY_COLOR = "items-block-quantity-color-control", i.QUANTITY_FONT_FAMILY = "items-block-quantity-font-family-control", i.QUANTITY_PADDINGS = "items-block-quantity-paddings-control", i.QUANTITY_SIZE = "items-block-quantity-size-control", i.QUANTITY_STYLE = "items-block-quantity-style-control", i))(_ || {});
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
_ as ItemsBlockControlId,
|
|
4
4
|
c as ItemsBlockId
|
|
5
5
|
};
|