@useinsider/guido 2.0.0-beta.c588e27 → 2.0.0-beta.c6d6ca6

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