@useinsider/guido 2.0.0-beta.b46bbf6 → 2.0.0-beta.b889d81

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