@useinsider/guido 2.1.0-beta.01eaf27 → 2.1.0-beta.13ada05

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.
@@ -1,20 +1,20 @@
1
- import { UEAttr as P, ModificationDescription as h } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
1
+ import { ModificationDescription as N, UEAttr as L } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
2
  import { CommonControl as U } from "../../common-control.js";
3
3
  import { ItemsBlockId as I } from "../enums/controlEnums.js";
4
- import { productPairs as S, templateFirstLine as M } from "../enums/productEnums.js";
5
- import { SETTINGS_ENUMS as d, ItemTypeOptions as b, OrientationOptions as f, ItemInCartOptions as R, DefaultConfigValues as L } from "../enums/settingsEnums.js";
6
- import H from "../layouts/horizontal.html.js";
7
- import F from "../layouts/vertical.html.js";
8
- import { getDefaultTemplate as k } from "../template.js";
9
- import { getItemsBlockConfig as E, setItemsBlockConfig as O, escapeReplacement as A } from "../utils/nodeConfigUtils.js";
10
- const $ = "ui-elements-items-block", l = {
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";
6
+ import F from "../layouts/horizontal.html.js";
7
+ import $ from "../layouts/vertical.html.js";
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 = {
11
11
  ITEMS_TYPE: "itemsType",
12
12
  ORIENTATION: "orientation",
13
13
  ITEM_IDS: "itemIds"
14
14
  };
15
- class X extends U {
15
+ class Z extends U {
16
16
  getId() {
17
- return $;
17
+ return w;
18
18
  }
19
19
  getTemplate() {
20
20
  return `
@@ -26,20 +26,20 @@ class X extends U {
26
26
  `;
27
27
  }
28
28
  onRender() {
29
- const e = E(this.currentNode);
29
+ const e = _(this.currentNode);
30
30
  this.api.updateValues({
31
- [l.ORIENTATION]: (e == null ? void 0 : e.orientation) ?? d.ORIENTATION.VERTICAL,
32
- [l.ITEMS_TYPE]: (e == null ? void 0 : e.type) ?? d.ITEMS_TYPE.CART_ITEMS,
33
- [l.ITEM_IDS]: (e == null ? void 0 : e.itemsSelectValue) ?? ""
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) ?? ""
34
34
  }), this._listenToFormUpdates();
35
35
  }
36
36
  onTemplateNodeUpdated(e) {
37
37
  super.onTemplateNodeUpdated(e), console.debug("Items Block Config", e.getNodeConfig()), this.handleBlockInstanceChange(() => {
38
- const t = E(this.currentNode);
38
+ const r = _(this.currentNode);
39
39
  this.api.updateValues({
40
- [l.ORIENTATION]: (t == null ? void 0 : t.orientation) ?? d.ORIENTATION.VERTICAL,
41
- [l.ITEMS_TYPE]: (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS,
42
- [l.ITEM_IDS]: (t == null ? void 0 : t.itemsSelectValue) ?? ""
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
43
  }), this._initializeSelectItems();
44
44
  });
45
45
  }
@@ -48,10 +48,10 @@ class X extends U {
48
48
  ${this._GuOneColumn([
49
49
  this._GuLabel({ text: "Item Type" }),
50
50
  this._GuSelect({
51
- name: l.ITEMS_TYPE,
51
+ name: m.ITEMS_TYPE,
52
52
  className: "es-100",
53
53
  placeholder: "Select Item Type",
54
- options: b
54
+ options: D
55
55
  })
56
56
  ])}
57
57
  `;
@@ -61,8 +61,8 @@ class X extends U {
61
61
  ${this._GuTwoColumns([
62
62
  this._GuLabel({ text: "Orientation" }),
63
63
  this._GuRadioButton({
64
- name: l.ORIENTATION,
65
- buttons: f
64
+ name: m.ORIENTATION,
65
+ buttons: k
66
66
  })
67
67
  ])}
68
68
  `;
@@ -72,7 +72,7 @@ class X extends U {
72
72
  ${this._GuTwoColumns([
73
73
  this._GuLabel({ text: "Item in Cart" }),
74
74
  this._GuSelect({
75
- name: l.ITEM_IDS,
75
+ name: m.ITEM_IDS,
76
76
  className: "es-100",
77
77
  placeholder: "Select Item In Cart",
78
78
  options: []
@@ -81,213 +81,219 @@ class X extends U {
81
81
  `;
82
82
  }
83
83
  _onOrientationChange(e) {
84
- this.api.updateValues({ [l.ORIENTATION]: e }), O(this.currentNode, this.api, {
84
+ this.api.updateValues({ [m.ORIENTATION]: e });
85
+ const r = this.api.getDocumentModifier();
86
+ O(this.currentNode, this.api, {
85
87
  orientation: e,
86
88
  priceOrientation: "horizontal"
87
- }), this._reOrderTemplate(), setTimeout(() => {
89
+ }, r), r.apply(new N("Changed orientation")), this._reOrderTemplate(), setTimeout(() => {
88
90
  this._recalculateTrimming();
89
91
  }, 50);
90
92
  }
91
93
  _onItemsTypeChange(e) {
92
- const t = d.ITEMS_TYPE[e], r = R[e], i = r == null ? void 0 : r[0];
93
- if (!t || !i)
94
+ const r = d.ITEMS_TYPE[e], t = g[e], i = t == null ? void 0 : t[0];
95
+ if (!r || !i)
94
96
  return;
95
- const n = i.value, o = i.value.replace("Url}}", "Image}}");
97
+ const n = i.value, s = i.value.replace("Url}}", "Image}}"), o = this.api.getDocumentModifier();
96
98
  O(this.currentNode, this.api, {
97
- source: t,
98
- type: t,
99
+ source: r,
100
+ type: r,
99
101
  itemsSelectValue: i.value,
100
- imageLink: o,
102
+ imageLink: s,
101
103
  buttonLink: n
102
- }), this._updateDataTypeAttributes(t), this._initializeSelectItems(), this._reFillTemplate(t);
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"));
103
107
  }
104
108
  _onItemIdsChange(e) {
105
- this.api.updateValues({ [l.ITEM_IDS]: e });
106
- const t = e, r = e.replace("Url}}", "Image}}");
109
+ this.api.updateValues({ [m.ITEM_IDS]: e });
110
+ const r = e, t = e.replace("Url}}", "Image}}"), i = this.api.getDocumentModifier();
107
111
  O(this.currentNode, this.api, {
108
112
  itemsSelectValue: e,
109
- imageLink: r,
110
- buttonLink: t
111
- }), 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"));
112
118
  }
113
119
  _initializeSelectItems() {
114
120
  this.api.setUIEAttribute(
115
- l.ITEMS_TYPE,
116
- P.SELECTPICKER.items,
117
- b
121
+ m.ITEMS_TYPE,
122
+ L.SELECTPICKER.items,
123
+ D
118
124
  );
119
- const e = E(this.currentNode), t = (e == null ? void 0 : e.type) ?? d.ITEMS_TYPE.CART_ITEMS, r = (e == null ? void 0 : e.itemsSelectValue) ?? "";
125
+ const e = _(this.currentNode), r = (e == null ? void 0 : e.type) ?? d.ITEMS_TYPE.CART_ITEMS, t = (e == null ? void 0 : e.itemsSelectValue) ?? "";
120
126
  this.api.updateValues({
121
- [l.ITEMS_TYPE]: t
127
+ [m.ITEMS_TYPE]: r
122
128
  });
123
- const i = R[t];
129
+ const i = g[r];
124
130
  this.api.setUIEAttribute(
125
- l.ITEM_IDS,
126
- P.SELECTPICKER.items,
131
+ m.ITEM_IDS,
132
+ L.SELECTPICKER.items,
127
133
  i
128
134
  ), this.api.updateValues({
129
- [l.ITEM_IDS]: r
135
+ [m.ITEM_IDS]: t
130
136
  });
131
137
  }
132
138
  _listenToFormUpdates() {
133
139
  this.api.onValueChanged(
134
- l.ITEMS_TYPE,
140
+ m.ITEMS_TYPE,
135
141
  (e) => this._onItemsTypeChange(e)
136
142
  ), this.api.onValueChanged(
137
- l.ORIENTATION,
143
+ m.ORIENTATION,
138
144
  (e) => this._onOrientationChange(e)
139
145
  ), this.api.onValueChanged(
140
- l.ITEM_IDS,
146
+ m.ITEM_IDS,
141
147
  (e) => this._onItemIdsChange(e)
142
148
  );
143
149
  }
144
150
  _renderTemplate() {
145
- const e = E(this.currentNode), t = (e == null ? void 0 : e.orientation) ?? d.ORIENTATION.VERTICAL, r = (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) ?? "", o = (e == null ? void 0 : e.priceCurrencyLocation) ?? "0", a = (e == null ? void 0 : e.priceFormatted) ?? !1;
146
- this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(k({
147
- orientation: t,
148
- itemsType: r,
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,
154
+ itemsType: t,
149
155
  itemId: i,
150
156
  currencySymbol: n,
151
- currencyLocation: o,
152
- formattedPrice: a
153
- })).apply(new h("Updated template"));
157
+ currencyLocation: s,
158
+ formattedPrice: o
159
+ })).apply(new N("Updated template"));
154
160
  }
155
- _getTemplateData(e) {
156
- const t = E(this.currentNode), r = e ?? (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, i = (t == null ? void 0 : t.itemsSelectValue) ?? "", n = (t == null ? void 0 : t.priceFormatted) ?? !1, o = (t == null ? void 0 : t.priceSinglePrice) ?? !1, a = R[r].findIndex((T) => T.value === i), c = a > -1 ? a : 0, s = S.PAIRS_FOR_EXTENSION.price[r], m = S.PAIRS_FOR_EXTENSION.originalPrice[r];
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];
157
163
  let u, p;
158
- return o ? (u = n ? s.DEFAULT_SINGLE_PRICE_FORMATTED : s.DEFAULT_SINGLE_PRICE, p = n ? m.DEFAULT_SINGLE_PRICE_FORMATTED : m.DEFAULT_SINGLE_PRICE) : (u = n ? s.DEFAULT_PRICE_FORMATTED : s.DEFAULT_PRICE, p = n ? m.DEFAULT_PRICE_FORMATTED : m.DEFAULT_PRICE), {
159
- imageSrc: S.PAIRS_FOR_EXTENSION.imageSrc[r].DEFAULT[c],
160
- name: S.PAIRS_FOR_EXTENSION.name[r].DEFAULT[c],
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],
161
167
  price: u,
162
168
  originalPrice: p,
163
- quantity: S.PAIRS_FOR_EXTENSION.quantity[r].DEFAULT,
164
- button: S.PAIRS_FOR_EXTENSION.button[r].DEFAULT_LABEL
169
+ quantity: y.PAIRS_FOR_EXTENSION.quantity[i].DEFAULT,
170
+ button: y.PAIRS_FOR_EXTENSION.button[i].DEFAULT_LABEL
165
171
  };
166
172
  }
167
- _updateImageSrc(e) {
168
- var r;
169
- const t = (r = this.currentNode) == null ? void 0 : r.querySelector(`[esd-extension-block-id="${I.IMAGE}"] img`);
170
- t && this.api.getDocumentModifier().modifyHtml(t).setAttribute("src", e).apply(new h("Updated image src"));
173
+ _updateImageSrc(e, r) {
174
+ var i;
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);
171
177
  }
172
- _updateName(e) {
173
- var n;
174
- const t = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${I.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}"]`);
175
181
  if (!t)
176
182
  return;
177
- const r = t.getInnerText().trim();
178
- let i = t.getInnerHTML().trim();
179
- i = i.replace(r, A(e)), this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(i).apply(new h("Updated name"));
183
+ const i = t.getInnerText().trim();
184
+ let n = t.getInnerHTML().trim();
185
+ n = n.replace(i, A(e)), r.modifyHtml(t).setInnerHtml(n);
180
186
  }
181
- _updatePrice(e) {
187
+ _updatePrice(e, r) {
182
188
  var o;
183
189
  const t = ((o = this.currentNode) == null ? void 0 : o.querySelectorAll(
184
190
  `[esd-extension-block-id="${I.PRICE}"]`
185
- )) || [], r = E(this.currentNode), i = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", n = (r == null ? void 0 : r.priceCurrencyLocation) ?? "0";
186
- t.forEach((a) => {
187
- const c = this._getParagraphFromBlock(a);
188
- if (!c)
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)
189
195
  return;
190
- const s = c.getInnerHTML().trim() || "", m = c.getInnerText().trim() || "", u = (i == null ? void 0 : i.trim()) || "", p = this._removeCurrencySymbol(m, u), T = this._replacePriceNumber(p, e), _ = this._buildPriceContent(T, u, n), y = s.replace(m, A(_));
191
- this.api.getDocumentModifier().modifyHtml(c).setInnerHtml(y).apply(new h("Updated price"));
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);
192
198
  });
193
199
  }
194
- _updateOriginalPrice(e) {
200
+ _updateOriginalPrice(e, r) {
195
201
  var o;
196
202
  const t = ((o = this.currentNode) == null ? void 0 : o.querySelectorAll(
197
203
  `[esd-extension-block-id="${I.ORIGINAL_PRICE}"]`
198
- )) || [], r = E(this.currentNode), i = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", n = (r == null ? void 0 : r.priceCurrencyLocation) ?? "0";
199
- t.forEach((a) => {
200
- const c = this._getParagraphFromBlock(a);
201
- if (!c)
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)
202
208
  return;
203
- const s = c.querySelector("s");
204
- if (!s)
209
+ const c = a.querySelector("s");
210
+ if (!c)
205
211
  return;
206
- const m = s.getInnerHTML().trim() || "", u = s.getInnerText().trim() || "", p = (i == null ? void 0 : i.trim()) || "", T = this._removeCurrencySymbol(u, p), _ = this._replacePriceNumber(T, e), y = this._buildPriceContent(_, p, n), N = `<s>${m.replace(u, A(y))}</s>`;
207
- this.api.getDocumentModifier().modifyHtml(c).setInnerHtml(N).apply(new h("Updated original price"));
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);
208
214
  });
209
215
  }
210
- _updateQuantity(e, t) {
211
- var _;
212
- const r = E(this.currentNode), n = (t ?? (r == null ? void 0 : r.type) ?? d.ITEMS_TYPE.CART_ITEMS) !== d.ITEMS_TYPE.BROWSED_ITEMS, o = (r == null ? void 0 : r.quantityControlEnabled) !== !1, a = n && o, c = (_ = this.currentNode) == null ? void 0 : _.querySelector(`[esd-extension-block-id="${I.QUANTITY}"]`);
213
- if (!c)
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)
214
220
  return;
215
- const s = this._getParagraphFromBlock(c);
216
- if (!s)
221
+ const c = this._getParagraphFromBlock(a);
222
+ if (!c)
217
223
  return;
218
- const m = s.getInnerText().trim();
219
- let u = s.getInnerHTML().trim();
220
- function p(y, C, N) {
221
- return y.replace(
222
- new RegExp(`(>\\s*)?${C}(\\s*<)?`, "g"),
223
- `$1${N}$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`
224
230
  );
225
231
  }
226
- u = p(u, m, e);
227
- const T = this.api.getDocumentModifier();
228
- T.modifyHtml(s).setInnerHtml(u), T.modifyHtml(c).setStyle("display", a ? "table-cell" : "none"), T.apply(new h("Updated quantity"));
232
+ u = p(u, T, e), t.modifyHtml(c).setInnerHtml(u), t.modifyHtml(a).setStyle("display", l ? "table-cell" : "none");
229
233
  }
230
- _reOrderTemplate() {
231
- var T, _, y, C, N, g;
232
- const e = (T = this.currentNode) == null ? void 0 : T.querySelector(`[esd-extension-block-id="${I.IMAGE}"]`), t = (_ = this.currentNode) == null ? void 0 : _.querySelector(`[esd-extension-block-id="${I.NAME}"]`), r = ((y = this.currentNode) == null ? void 0 : y.querySelectorAll(
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(
233
237
  `[esd-extension-block-id="${I.PRICE}"]`
234
- )) || [], i = ((C = this.currentNode) == null ? void 0 : C.querySelectorAll(
238
+ )) || [], n = ((C = this.currentNode) == null ? void 0 : C.querySelectorAll(
235
239
  `[esd-extension-block-id="${I.ORIGINAL_PRICE}"]`
236
- )) || [], [n] = r, [o] = i, a = (N = this.currentNode) == null ? void 0 : N.querySelector(`[esd-extension-block-id="${I.QUANTITY}"]`), c = (g = this.currentNode) == null ? void 0 : g.querySelector(`[esd-extension-block-id="${I.BUTTON}"]`);
237
- if (!e || !t || !n || !o || !a || !c)
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)
238
242
  return;
239
- const s = E(this.currentNode), u = ((s == null ? void 0 : s.orientation) ?? d.ORIENTATION.VERTICAL) === d.ORIENTATION.VERTICAL;
240
- let p = u ? F : H;
241
- this.api.getDocumentModifier().modifyHtml(e.querySelector("img")).setAttribute("width", L.productImageWidth).setAttribute("height", L.productImageWidth).apply(new h("Updated image width")), setTimeout(() => {
242
- const D = A(n.getOuterHTML()), x = A(o.getOuterHTML());
243
- p = p.replace("{-{-TEMPLATE_FIRST_LINE-}-}", u ? M : "").replace("{-{-PRODUCT_IMAGE-}-}", e.getOuterHTML()).replace("{-{-PRODUCT_NAME-}-}", t.getOuterHTML()).replaceAll("{-{-PRODUCT_PRICE-}-}", D).replaceAll("{-{-PRODUCT_ORIGINAL_PRICE-}-}", x).replace("{-{-PRODUCT_QUANTITY-}-}", a.getOuterHTML()).replace("{-{-PRODUCT_BUTTON-}-}", c.getOuterHTML()), p = p.trim().replace(M, "").slice(0, -5), this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(p).apply(new h("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"));
244
250
  }, 50);
245
251
  }
246
- _updateDataTypeAttributes(e) {
252
+ _updateDataTypeAttributes(e, r) {
247
253
  if (!this.currentNode)
248
254
  return;
249
- const t = this.currentNode.closest(".ins-product-td"), r = this.api.getDocumentModifier();
255
+ const t = this.currentNode.closest(".ins-product-td");
250
256
  t && r.modifyHtml(t).setAttribute("data-type", e), this.currentNode.querySelectorAll("[data-type]").forEach((n) => {
251
- const o = n;
252
- r.modifyHtml(o).setAttribute("data-type", e);
253
- }), r.apply(new h("Updated data-type attribute"));
257
+ const s = n;
258
+ r.modifyHtml(s).setAttribute("data-type", e);
259
+ });
254
260
  }
255
- _updateDataNumberAttributes(e) {
261
+ _updateDataNumberAttributes(e, r) {
256
262
  if (!this.currentNode)
257
263
  return;
258
- const t = E(this.currentNode), r = (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, i = R[r].findIndex((s) => s.value === e);
259
- let n = "1";
260
- if (i >= 0)
261
- n = 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);
262
268
  else if (e) {
263
- const s = e.match(/\((\d+)\)/);
264
- if (s) {
265
- const [, m] = s;
266
- n = m;
269
+ const a = e.match(/\((\d+)\)/);
270
+ if (a) {
271
+ const [, c] = a;
272
+ s = c;
267
273
  }
268
274
  }
269
- const o = this.currentNode.closest(".ins-product-td"), a = this.api.getDocumentModifier();
270
- o && a.modifyHtml(o).setAttribute("data-number", n), this.currentNode.querySelectorAll("[data-number]").forEach((s) => {
271
- const m = s;
272
- a.modifyHtml(m).setAttribute("data-number", n);
273
- }), a.apply(new h("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
+ });
274
280
  }
275
281
  _reFillTemplate(e) {
276
- const t = this._getTemplateData(e);
277
- this._updateImageSrc(t.imageSrc), this._updateName(t.name), this._updatePrice(t.price), this._updateOriginalPrice(t.originalPrice), this._updateQuantity(t.quantity, 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"));
278
284
  }
279
285
  _recalculateTrimming() {
280
- var o;
286
+ var s;
281
287
  if (!this.currentNode)
282
288
  return;
283
- const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${I.NAME}"]`);
289
+ const e = (s = this.currentNode) == null ? void 0 : s.querySelector(`[esd-extension-block-id="${I.NAME}"]`);
284
290
  if (!e)
285
291
  return;
286
- const t = e.querySelector("p > a");
287
- if (!t)
292
+ const r = e.querySelector("p > a");
293
+ if (!r)
288
294
  return;
289
- const r = E(this.currentNode), i = (r == null ? void 0 : r.orientation) === d.ORIENTATION.HORIZONTAL, n = (r == null ? void 0 : r.nameTrimming) ?? !0;
290
- 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 h("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"));
291
297
  }
292
298
  _getParagraphFromBlock(e) {
293
299
  return e.querySelector("p");
@@ -295,30 +301,30 @@ class X extends U {
295
301
  _escapeRegex(e) {
296
302
  return e.replace(/[-\\^$*+?().|[\]{}]/g, "\\$&");
297
303
  }
298
- _removeCurrencySymbol(e, t) {
299
- const r = e || "";
300
- let i = r;
301
- if (t) {
302
- const n = new RegExp(`\\s*${this._escapeRegex(t)}\\s*`);
303
- i = r.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();
304
310
  } else {
305
- const n = r.match(/([^0-9.,\s]+)/);
311
+ const n = t.match(/([^0-9.,\s]+)/);
306
312
  if (n && n[1]) {
307
- const o = n[1].trim(), a = new RegExp(`\\s*${this._escapeRegex(o)}\\s*`);
308
- i = r.replace(a, "").trim();
313
+ const s = n[1].trim(), o = new RegExp(`\\s*${this._escapeRegex(s)}\\s*`);
314
+ i = t.replace(o, "").trim();
309
315
  }
310
316
  }
311
317
  return i;
312
318
  }
313
- _replacePriceNumber(e, t) {
314
- const r = /([0-9][0-9,.]*)/;
315
- return e.replace(r, t).trim();
319
+ _replacePriceNumber(e, r) {
320
+ const t = /([0-9][0-9,.]*)/;
321
+ return e.replace(t, r).trim();
316
322
  }
317
- _buildPriceContent(e, t, r) {
318
- return t ? r === "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;
319
325
  }
320
326
  }
321
327
  export {
322
- $ as CONTROL_BLOCK_ID,
323
- X as ItemsBlockControl
328
+ w as CONTROL_BLOCK_ID,
329
+ Z as ItemsBlockControl
324
330
  };
@@ -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
  };
@@ -2,8 +2,8 @@ import { BlockType as b, BlockAttr as N } from "../../../node_modules/@stripoinc
2
2
  import { ItemsBlockId as O } from "./enums/controlEnums.js";
3
3
  import { productPairs as A, templateFirstLine as C } from "./enums/productEnums.js";
4
4
  import { ItemInCartOptions as Y, SETTINGS_ENUMS as x, DefaultConfigValues as D } from "./enums/settingsEnums.js";
5
- import q from "./layouts/horizontal.html.js";
6
- import j from "./layouts/vertical.html.js";
5
+ import j from "./layouts/horizontal.html.js";
6
+ import q from "./layouts/vertical.html.js";
7
7
  import { escapeReplacement as V } from "./utils/nodeConfigUtils.js";
8
8
  let [g] = A.PAIRS_FOR_EXTENSION.imageSrc.CART_ITEMS.DEFAULT, [L] = A.PAIRS_FOR_EXTENSION.name.CART_ITEMS.DEFAULT, [m] = A.PAIRS_FOR_EXTENSION.price.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [S] = A.PAIRS_FOR_EXTENSION.originalPrice.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [M] = A.PAIRS_FOR_EXTENSION.quantity.CART_ITEMS.DEFAULT;
9
9
  const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCase().startsWith(e.toLowerCase())).join("; ").replace(/;\s*$/, ""), F = (s) => U(s, "text-align"), w = (s, e) => {
@@ -27,6 +27,7 @@ const U = (s, e) => s.split(";").map((r) => r.trim()).filter((r) => !r.toLowerCa
27
27
  target="_blank"
28
28
  href="#!">
29
29
  <img class="adapt-img document-node-component ng-star-inserted"
30
+ style="object-fit: contain;"
30
31
  src="${g}"
31
32
  alt="${L}"
32
33
  width="${i}"
@@ -402,7 +403,7 @@ function Tt({
402
403
  d ? (m = o ? T.DEFAULT_SINGLE_PRICE_FORMATTED : T.DEFAULT_SINGLE_PRICE, S = o ? I.DEFAULT_SINGLE_PRICE_FORMATTED : I.DEFAULT_SINGLE_PRICE) : (m = o ? T.DEFAULT_PRICE_FORMATTED : T.DEFAULT_PRICE, S = o ? I.DEFAULT_PRICE_FORMATTED : I.DEFAULT_PRICE), M = A.PAIRS_FOR_EXTENSION.quantity[e].DEFAULT;
403
404
  const h = P || (l == null ? void 0 : l.priceOrientation) || "horizontal";
404
405
  return s === x.ORIENTATION.VERTICAL ? z(
405
- j,
406
+ q,
406
407
  e,
407
408
  R,
408
409
  s,
@@ -422,7 +423,7 @@ function Tt({
422
423
  u,
423
424
  d
424
425
  ) : z(
425
- q,
426
+ j,
426
427
  e,
427
428
  R,
428
429
  s,