@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.
Files changed (36) hide show
  1. package/dist/config/migrator/itemsBlockMigrator.js +123 -140
  2. package/dist/extensions/Blocks/Items/block.js +28 -19
  3. package/dist/extensions/Blocks/Items/controls/button/link.js +31 -19
  4. package/dist/extensions/Blocks/Items/controls/cardComposition.js +81 -97
  5. package/dist/extensions/Blocks/Items/controls/image/link.js +31 -19
  6. package/dist/extensions/Blocks/Items/controls/name/trimming.js +40 -28
  7. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +46 -34
  8. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +50 -45
  9. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +51 -40
  10. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +35 -23
  11. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +57 -45
  12. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +62 -42
  13. package/dist/extensions/Blocks/Items/controls/settingsControl.js +191 -184
  14. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -0
  15. package/dist/extensions/Blocks/Items/extension.js +9 -8
  16. package/dist/extensions/Blocks/Items/store/items-block.js +79 -0
  17. package/dist/extensions/Blocks/Items/template.js +175 -181
  18. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  19. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +3 -3
  20. package/dist/extensions/Blocks/common-control.js +92 -91
  21. package/dist/src/extensions/Blocks/Items/block.d.ts +1 -0
  22. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +1 -0
  23. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +1 -0
  24. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +1 -0
  25. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +1 -0
  26. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +1 -0
  27. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +1 -0
  28. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +1 -0
  29. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +1 -0
  30. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -0
  31. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +5 -0
  32. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +12 -10
  33. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +45 -0
  34. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -2
  35. package/dist/src/extensions/Blocks/common-control.d.ts +5 -4
  36. package/package.json +1 -1
@@ -1,20 +1,28 @@
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 T } from "../enums/controlEnums.js";
4
- import { productPairs as y, templateFirstLine as b } from "../enums/productEnums.js";
5
- import { SETTINGS_ENUMS as p, ItemTypeOptions as D, OrientationOptions as k, ItemInCartOptions as g, DefaultConfigValues as x } from "../enums/settingsEnums.js";
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 { getDefaultTemplate as q } from "../template.js";
9
- import { getItemsBlockConfig as h, setItemsBlockConfig as O, escapeReplacement as A } from "../utils/nodeConfigUtils.js";
10
- const w = "ui-elements-items-block", m = {
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 Z extends U {
19
+ class J extends k {
20
+ constructor() {
21
+ super(...arguments);
22
+ O(this, "store", q());
23
+ }
16
24
  getId() {
17
- return w;
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
- [m.ORIENTATION]: (e == null ? void 0 : e.orientation) ?? p.ORIENTATION.VERTICAL,
32
- [m.ITEMS_TYPE]: (e == null ? void 0 : e.type) ?? p.ITEMS_TYPE.CART_ITEMS,
33
- [m.ITEM_IDS]: (e == null ? void 0 : e.itemsSelectValue) ?? ""
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
- const t = h(this.currentNode);
39
- this.api.updateValues({
40
- [m.ORIENTATION]: (t == null ? void 0 : t.orientation) ?? p.ORIENTATION.VERTICAL,
41
- [m.ITEMS_TYPE]: (t == null ? void 0 : t.type) ?? p.ITEMS_TYPE.CART_ITEMS,
42
- [m.ITEM_IDS]: (t == null ? void 0 : t.itemsSelectValue) ?? ""
43
- }), this._initializeSelectItems();
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: m.ITEMS_TYPE,
67
+ name: a.ITEMS_TYPE,
52
68
  className: "es-100",
53
69
  placeholder: "Select Item Type",
54
- options: D
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: m.ORIENTATION,
65
- buttons: k
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: m.ITEM_IDS,
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({ [m.ORIENTATION]: e });
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
- }, t), t.apply(new N("Changed orientation")), this._reOrderTemplate(), setTimeout(() => {
103
+ }), this._reOrderTemplate(), setTimeout(() => {
90
104
  this._recalculateTrimming();
91
105
  }, 50);
92
106
  }
93
107
  _onItemsTypeChange(e) {
94
- const t = p.ITEMS_TYPE[e], r = g[e], i = r == null ? void 0 : r[0];
95
- if (!t || !i)
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: i.value,
102
- imageLink: s,
103
- buttonLink: n
104
- }, o), this._updateDataTypeAttributes(t, o), this._initializeSelectItems();
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({ [m.ITEM_IDS]: e });
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: r,
114
- buttonLink: t
115
- }, i), this._updateDataNumberAttributes(e, i);
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
- m.ITEMS_TYPE,
122
- L.SELECTPICKER.items,
123
- D
126
+ a.ITEMS_TYPE,
127
+ C.SELECTPICKER.items,
128
+ R
124
129
  );
125
- const e = h(this.currentNode), t = (e == null ? void 0 : e.type) ?? p.ITEMS_TYPE.CART_ITEMS, r = (e == null ? void 0 : e.itemsSelectValue) ?? "";
130
+ const { itemsType: e, itemIds: t } = this.store;
126
131
  this.api.updateValues({
127
- [m.ITEMS_TYPE]: t
132
+ [a.ITEMS_TYPE]: e
128
133
  });
129
- const i = g[t];
134
+ const i = N[e];
130
135
  this.api.setUIEAttribute(
131
- m.ITEM_IDS,
132
- L.SELECTPICKER.items,
136
+ a.ITEM_IDS,
137
+ C.SELECTPICKER.items,
133
138
  i
134
139
  ), this.api.updateValues({
135
- [m.ITEM_IDS]: r
140
+ [a.ITEM_IDS]: t
136
141
  });
137
142
  }
138
143
  _listenToFormUpdates() {
139
144
  this.api.onValueChanged(
140
- m.ITEMS_TYPE,
145
+ a.ITEMS_TYPE,
141
146
  (e) => this._onItemsTypeChange(e)
142
147
  ), this.api.onValueChanged(
143
- m.ORIENTATION,
148
+ a.ORIENTATION,
144
149
  (e) => this._onOrientationChange(e)
145
150
  ), this.api.onValueChanged(
146
- m.ITEM_IDS,
151
+ a.ITEM_IDS,
147
152
  (e) => this._onItemIdsChange(e)
148
153
  );
149
154
  }
150
155
  _renderTemplate() {
151
- const e = h(this.currentNode), t = (e == null ? void 0 : e.orientation) ?? p.ORIENTATION.VERTICAL, r = (e == null ? void 0 : e.type) ?? p.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: t,
154
- itemsType: r,
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: n,
157
- currencyLocation: s,
168
+ currencySymbol: r,
169
+ currencyLocation: n,
158
170
  formattedPrice: o
159
- })).apply(new N("Updated template"));
171
+ })).apply(new u("Updated template"));
160
172
  }
161
- _getTemplateData(e) {
162
- const t = h(this.currentNode), r = e ?? (t == null ? void 0 : t.type) ?? p.ITEMS_TYPE.CART_ITEMS, i = (t == null ? void 0 : t.itemsSelectValue) ?? "", n = (t == null ? void 0 : t.priceFormatted) ?? !1, s = (t == null ? void 0 : t.priceSinglePrice) ?? !1, o = g[r].findIndex((d) => d.value === i), l = o > -1 ? o : 0, a = y.PAIRS_FOR_EXTENSION.price[r], c = y.PAIRS_FOR_EXTENSION.originalPrice[r];
163
- let I, u;
164
- return s ? (I = n ? a.DEFAULT_SINGLE_PRICE_FORMATTED : a.DEFAULT_SINGLE_PRICE, u = n ? c.DEFAULT_SINGLE_PRICE_FORMATTED : c.DEFAULT_SINGLE_PRICE) : (I = n ? a.DEFAULT_PRICE_FORMATTED : a.DEFAULT_PRICE, u = n ? c.DEFAULT_PRICE_FORMATTED : c.DEFAULT_PRICE), {
165
- imageSrc: y.PAIRS_FOR_EXTENSION.imageSrc[r].DEFAULT[l],
166
- name: y.PAIRS_FOR_EXTENSION.name[r].DEFAULT[l],
167
- price: I,
168
- originalPrice: u,
169
- quantity: y.PAIRS_FOR_EXTENSION.quantity[r].DEFAULT,
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, t) {
184
+ _updateImageSrc(e) {
174
185
  var i;
175
- const r = (i = this.currentNode) == null ? void 0 : i.querySelector(`[esd-extension-block-id="${T.IMAGE}"] img`);
176
- r && t.modifyHtml(r).setAttribute("src", e);
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, t) {
179
- var s;
180
- const r = (s = this.currentNode) == null ? void 0 : s.querySelector(`[esd-extension-block-id="${T.NAME}"]`);
181
- if (!r)
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 = r.getInnerText().trim();
184
- let n = r.getInnerHTML().trim();
185
- n = n.replace(i, A(e)), t.modifyHtml(r).setInnerHtml(n);
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, t) {
188
- var o;
189
- const r = ((o = this.currentNode) == null ? void 0 : o.querySelectorAll(
190
- `[esd-extension-block-id="${T.PRICE}"]`
191
- )) || [], i = h(this.currentNode), n = (i == null ? void 0 : i.priceCurrencySymbol) ?? "", s = (i == null ? void 0 : i.priceCurrencyLocation) ?? "0";
192
- r.forEach((l) => {
193
- const a = this._getParagraphFromBlock(l);
194
- if (!a)
195
- return;
196
- const c = a.getInnerHTML().trim() || "", I = a.getInnerText().trim() || "", u = (n == null ? void 0 : n.trim()) || "", d = this._removeCurrencySymbol(I, u), _ = this._replacePriceNumber(d, e), E = this._buildPriceContent(_, u, s), S = c.replace(I, A(E));
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, t) {
201
- var o;
202
- const r = ((o = this.currentNode) == null ? void 0 : o.querySelectorAll(
203
- `[esd-extension-block-id="${T.ORIGINAL_PRICE}"]`
204
- )) || [], i = h(this.currentNode), n = (i == null ? void 0 : i.priceCurrencySymbol) ?? "", s = (i == null ? void 0 : i.priceCurrencyLocation) ?? "0";
205
- r.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 I = c.getInnerHTML().trim() || "", u = c.getInnerText().trim() || "", d = (n == null ? void 0 : n.trim()) || "", _ = this._removeCurrencySymbol(u, d), E = this._replacePriceNumber(_, e), S = this._buildPriceContent(E, d, s), R = `<s>${I.replace(u, A(S))}</s>`;
213
- t.modifyHtml(a).setInnerHtml(R);
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, t, r) {
217
- var _;
218
- const i = h(this.currentNode), s = (t ?? (i == null ? void 0 : i.type) ?? p.ITEMS_TYPE.CART_ITEMS) !== p.ITEMS_TYPE.BROWSED_ITEMS, o = (i == null ? void 0 : i.quantityControlEnabled) !== !1, l = s && o, a = (_ = this.currentNode) == null ? void 0 : _.querySelector(`[esd-extension-block-id="${T.QUANTITY}"]`);
219
- if (!a)
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 c = this._getParagraphFromBlock(a);
222
- if (!c)
230
+ const l = this._getParagraphFromBlock(o);
231
+ if (!l)
223
232
  return;
224
- const I = c.getInnerText().trim();
225
- let u = c.getInnerHTML().trim();
226
- function d(E, S, C) {
227
- return E.replace(
228
- new RegExp(`(>\\s*)?${S}(\\s*<)?`, "g"),
229
- `$1${C}$2`
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
- u = d(u, I, e), r.modifyHtml(c).setInnerHtml(u), r.modifyHtml(a).setStyle("display", l ? "table-cell" : "none");
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(e) {
235
- var _, E, S, C, R, M;
236
- const t = (_ = this.currentNode) == null ? void 0 : _.querySelector(`[esd-extension-block-id="${T.IMAGE}"]`), r = (E = this.currentNode) == null ? void 0 : E.querySelector(`[esd-extension-block-id="${T.NAME}"]`), i = ((S = this.currentNode) == null ? void 0 : S.querySelectorAll(
237
- `[esd-extension-block-id="${T.PRICE}"]`
238
- )) || [], n = ((C = this.currentNode) == null ? void 0 : C.querySelectorAll(
239
- `[esd-extension-block-id="${T.ORIGINAL_PRICE}"]`
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 c = h(this.currentNode), u = ((c == null ? void 0 : c.orientation) ?? p.ORIENTATION.VERTICAL) === p.ORIENTATION.VERTICAL;
244
- let d = u ? $ : F;
245
- setTimeout(() => {
246
- const H = A(s.getOuterHTML()), f = A(o.getOuterHTML());
247
- d = d.replace("{-{-TEMPLATE_FIRST_LINE-}-}", u ? b : "").replace("{-{-PRODUCT_IMAGE-}-}", t.getOuterHTML()).replace("{-{-PRODUCT_NAME-}-}", r.getOuterHTML()).replaceAll("{-{-PRODUCT_PRICE-}-}", H).replaceAll("{-{-PRODUCT_ORIGINAL_PRICE-}-}", f).replace("{-{-PRODUCT_QUANTITY-}-}", l.getOuterHTML()).replace("{-{-PRODUCT_BUTTON-}-}", a.getOuterHTML()), d = d.trim().replace(b, "").slice(0, -5);
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, t) {
259
+ _updateDataTypeAttributes(e) {
253
260
  if (!this.currentNode)
254
261
  return;
255
- const r = this.currentNode.closest(".ins-product-td");
256
- r && t.modifyHtml(r).setAttribute("data-type", e), this.currentNode.querySelectorAll("[data-type]").forEach((n) => {
257
- const s = n;
258
- t.modifyHtml(s).setAttribute("data-type", e);
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, t) {
268
+ _updateDataNumberAttributes(e) {
262
269
  if (!this.currentNode)
263
270
  return;
264
- const r = h(this.currentNode), i = (r == null ? void 0 : r.type) ?? p.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);
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 a = e.match(/\((\d+)\)/);
270
- if (a) {
271
- const [, c] = a;
272
- s = c;
276
+ const c = e.match(/\((\d+)\)/);
277
+ if (c) {
278
+ const [, s] = c;
279
+ r = s;
273
280
  }
274
281
  }
275
- const o = this.currentNode.closest(".ins-product-td");
276
- o && t.modifyHtml(o).setAttribute("data-number", s), this.currentNode.querySelectorAll("[data-number]").forEach((a) => {
277
- const c = a;
278
- t.modifyHtml(c).setAttribute("data-number", s);
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(e) {
282
- const t = this._getTemplateData(e), r = this.api.getDocumentModifier();
283
- this._updateImageSrc(t.imageSrc, r), this._updateName(t.name, r), this._updatePrice(t.price, r), this._updateOriginalPrice(t.originalPrice, r), this._updateQuantity(t.quantity, e, r), r.apply(new N("Refilled template"));
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 s;
293
+ var n;
287
294
  if (!this.currentNode)
288
295
  return;
289
- const e = (s = this.currentNode) == null ? void 0 : s.querySelector(`[esd-extension-block-id="${T.NAME}"]`);
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 r = h(this.currentNode), i = (r == null ? void 0 : r.orientation) === p.ORIENTATION.HORIZONTAL, n = (r == null ? void 0 : r.nameTrimming) ?? !0;
296
- this.api.getDocumentModifier().modifyHtml(t).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"));
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 r = e || "";
306
- let i = r;
312
+ const i = e || "";
313
+ let r = i;
307
314
  if (t) {
308
315
  const n = new RegExp(`\\s*${this._escapeRegex(t)}\\s*`);
309
- i = r.replace(n, "").trim();
316
+ r = i.replace(n, "").trim();
310
317
  } else {
311
- const n = r.match(/([^0-9.,\s]+)/);
318
+ const n = i.match(/([^0-9.,\s]+)/);
312
319
  if (n && n[1]) {
313
- const s = n[1].trim(), o = new RegExp(`\\s*${this._escapeRegex(s)}\\s*`);
314
- i = r.replace(o, "").trim();
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 i;
324
+ return r;
318
325
  }
319
326
  _replacePriceNumber(e, t) {
320
- const r = /([0-9][0-9,.]*)/;
321
- return e.replace(r, t).trim();
327
+ const i = /([0-9][0-9,.]*)/;
328
+ return e.replace(i, t).trim();
322
329
  }
323
- _buildPriceContent(e, t, r) {
324
- return t ? r === "1" ? `${e}&nbsp;${t}` : `${t}&nbsp;${e}` : e;
330
+ _buildPriceContent(e, t, i) {
331
+ return t ? i === "1" ? `${e}&nbsp;${t}` : `${t}&nbsp;${e}` : e;
325
332
  }
326
333
  }
327
334
  export {
328
- w as CONTROL_BLOCK_ID,
329
- Z as ItemsBlockControl
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 r, QuantityControls as n, OriginalPriceControls as t, PriceControls as d, ImageControls as l, ButtonControls as o } from "./controls/index.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";
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 g } from "./controls/price/currencySymbol.js";
10
- import { PriceFormattedPriceControl as f } from "./controls/price/formattedPrice.js";
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 { 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();
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
- j as default
21
+ M as default
21
22
  };