@useinsider/guido 2.1.0-beta.bc18abc → 2.1.0-beta.da327fa

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