@useinsider/guido 2.0.0-beta.dd0d492 → 2.0.0-beta.faa7c5d

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 (84) hide show
  1. package/README.md +2 -0
  2. package/dist/@types/config/schemas.js +55 -39
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +15 -17
  5. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +2 -2
  6. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
  7. package/dist/components/organisms/header/LeftSlot.vue.js +12 -12
  8. package/dist/components/organisms/header/LeftSlot.vue2.js +6 -6
  9. package/dist/components/organisms/header/RightSlot.vue2.js +10 -10
  10. package/dist/composables/useConfig.js +29 -27
  11. package/dist/composables/useSave.js +13 -11
  12. package/dist/composables/useStripo.js +40 -40
  13. package/dist/config/migrator/index.js +9 -8
  14. package/dist/config/migrator/itemsBlockMigrator.js +342 -0
  15. package/dist/extensions/Blocks/CouponBlock/constants.js +4 -0
  16. package/dist/extensions/Blocks/CouponBlock/controls/index.js +29 -0
  17. package/dist/extensions/Blocks/CouponBlock/extension.js +5 -4
  18. package/dist/extensions/Blocks/CouponBlock/settingsPanel.js +20 -14
  19. package/dist/extensions/Blocks/CouponBlock/template.js +22 -11
  20. package/dist/extensions/Blocks/Items/block.js +39 -40
  21. package/dist/extensions/Blocks/Items/controls/button/link.js +22 -29
  22. package/dist/extensions/Blocks/Items/controls/cardComposition.js +66 -46
  23. package/dist/extensions/Blocks/Items/controls/image/link.js +23 -30
  24. package/dist/extensions/Blocks/Items/controls/name/trimming.js +25 -25
  25. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +19 -17
  26. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +31 -29
  27. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +36 -36
  28. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +21 -19
  29. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +29 -27
  30. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +93 -0
  31. package/dist/extensions/Blocks/Items/controls/settingsControl.js +152 -143
  32. package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
  33. package/dist/extensions/Blocks/Items/enums/productEnums.js +43 -45
  34. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +4 -3
  35. package/dist/extensions/Blocks/Items/extension.js +7 -6
  36. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +58 -49
  37. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +48 -59
  38. package/dist/extensions/Blocks/Items/settingsPanel.js +27 -26
  39. package/dist/extensions/Blocks/Items/store/items-block.js +11 -7
  40. package/dist/extensions/Blocks/Items/template.js +366 -129
  41. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +184 -0
  42. package/dist/extensions/Blocks/Recommendation/control.js +1 -1
  43. package/dist/extensions/Blocks/Unsubscribe/extension.js +9 -9
  44. package/dist/extensions/Blocks/common-control.js +29 -30
  45. package/dist/extensions/Blocks/controlFactories.js +139 -118
  46. package/dist/guido.css +1 -1
  47. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +370 -286
  48. package/dist/package.json.js +1 -1
  49. package/dist/services/stripoApi.js +6 -10
  50. package/dist/src/@types/config/index.d.ts +2 -2
  51. package/dist/src/@types/config/schemas.d.ts +30 -0
  52. package/dist/src/@types/config/types.d.ts +7 -1
  53. package/dist/src/composables/useConfig.d.ts +8 -0
  54. package/dist/src/config/migrator/itemsBlockMigrator.d.ts +6 -0
  55. package/dist/src/extensions/Blocks/CouponBlock/constants.d.ts +14 -0
  56. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +108 -0
  57. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +1 -1
  58. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -2
  59. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +9 -0
  60. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -2
  61. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -1
  62. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +18 -0
  63. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -4
  64. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
  65. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +24 -26
  66. package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +1 -0
  67. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +2 -0
  68. package/dist/src/extensions/Blocks/Items/template.d.ts +22 -1
  69. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +73 -0
  70. package/dist/src/extensions/Blocks/common-control.d.ts +9 -10
  71. package/dist/src/extensions/Blocks/controlFactories.d.ts +30 -7
  72. package/dist/src/stores/config.d.ts +164 -1
  73. package/dist/static/styles/components/button.css.js +1 -1
  74. package/dist/stores/config.js +7 -0
  75. package/dist/utils/pairProductVariables.js +61 -58
  76. package/package.json +3 -3
  77. package/dist/extensions/Blocks/Items/utils/configBlockUtils.js +0 -17
  78. package/dist/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.js +0 -28
  79. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +0 -76
  80. package/dist/extensions/Blocks/Items/utils/updateAttributes.js +0 -46
  81. package/dist/src/extensions/Blocks/Items/utils/configBlockUtils.d.ts +0 -23
  82. package/dist/src/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.d.ts +0 -32
  83. package/dist/src/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.d.ts +0 -50
  84. package/dist/src/extensions/Blocks/Items/utils/updateAttributes.d.ts +0 -8
@@ -1,46 +1,48 @@
1
- var L = Object.defineProperty;
2
- var R = (i, o, e) => o in i ? L(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
1
+ var y = Object.defineProperty;
2
+ var R = (i, o, e) => o in i ? y(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
3
3
  var p = (i, o, e) => R(i, typeof o != "symbol" ? o + "" : o, e);
4
4
  import { currencyLocationMaps as m } from "../../../../../enums/extensions/recommendationBlock.js";
5
- import { UEAttr as N, ModificationDescription as I } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { UEAttr as I, ModificationDescription as N } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
6
  import { CommonControl as T } from "../../../common-control.js";
7
7
  import { ItemsBlockControlId as h } from "../../enums/controlEnums.js";
8
- import { useItemsBlockStore as E } from "../../store/items-block.js";
9
- import { syncCurrencyLocationFromAttributes as f } from "../../utils/syncAttributesFromConfigBlock.js";
10
- import { updateConfigBlockAttributes as O } from "../../utils/updateAttributes.js";
8
+ import { useItemsBlockStore as f } from "../../store/items-block.js";
9
+ import { getItemsBlockConfig as E, setItemsBlockConfig as O } from "../../utils/nodeConfigUtils.js";
11
10
  const b = h.PRICE_CURRENCY_LOCATION, a = {
12
11
  CURRENCY_LOCATION: "currencyLocation"
13
12
  };
14
- class Y extends T {
13
+ class B extends T {
15
14
  constructor() {
16
15
  super(...arguments);
17
- p(this, "store", E());
16
+ p(this, "store", f());
18
17
  }
19
18
  getId() {
20
19
  return b;
21
20
  }
22
21
  getTemplate() {
23
22
  return `
24
- <div class="${h.PRICE_CURRENCY_LOCATION}">
23
+ <div class="container ${h.PRICE_CURRENCY_LOCATION}">
25
24
  ${this._getCurrencyLocation()}
26
25
  </div>
27
26
  `;
28
27
  }
29
28
  onRender() {
30
- this.api.setUIEAttribute(a.CURRENCY_LOCATION, N.SELECTPICKER.items, m), this.api.updateValues({ [a.CURRENCY_LOCATION]: this.store.currencyLocation }), this.api.onValueChanged(a.CURRENCY_LOCATION, (e) => {
29
+ this.api.setUIEAttribute(a.CURRENCY_LOCATION, I.SELECTPICKER.items, m), this.api.updateValues({ [a.CURRENCY_LOCATION]: this.store.currencyLocation }), this.api.onValueChanged(a.CURRENCY_LOCATION, (e) => {
31
30
  this._onCurrencyLocationChange(e);
32
31
  });
33
32
  }
34
33
  onTemplateNodeUpdated(e) {
35
34
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
36
- () => f(this.currentNode),
35
+ () => {
36
+ const t = E(this.currentNode);
37
+ t && this.store.setCurrencyLocation(t.priceCurrencyLocation || "0");
38
+ },
37
39
  () => {
38
40
  this.api.updateValues({ [a.CURRENCY_LOCATION]: this.store.currencyLocation });
39
41
  }
40
42
  );
41
43
  }
42
44
  _onCurrencyLocationChange(e) {
43
- if (console.debug("Currency location changed to: ", e), this.store.setCurrencyLocation(e), O(this.currentNode, this.api), !this.currentNode)
45
+ if (console.debug("Currency location changed to: ", e), this.store.setCurrencyLocation(e), O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
44
46
  return;
45
47
  const t = this._getPriceBlocks();
46
48
  if (!t || t.length === 0)
@@ -50,8 +52,8 @@ class Y extends T {
50
52
  const s = this._getParagraph(c);
51
53
  if (!s)
52
54
  return;
53
- const u = s.getInnerHTML() || "", l = s.getInnerText() || "", C = (n == null ? void 0 : n.trim()) || "", d = this._removeCurrencySymbol(l, C), g = this._detectSymbolInText(l) || C, _ = this._buildPriceContent(d, g, r), y = u.replace(l, _);
54
- this.api.getDocumentModifier().modifyHtml(s).setInnerHtml(y).apply(new I(
55
+ const C = s.getInnerHTML() || "", l = s.getInnerText() || "", u = (n == null ? void 0 : n.trim()) || "", d = this._removeCurrencySymbol(l, u), g = this._detectSymbolInText(l) || u, _ = this._buildPriceContent(d, g, r), L = C.replace(l, _);
56
+ this.api.getDocumentModifier().modifyHtml(s).setInnerHtml(L).apply(new N(
55
57
  `Updated currency location to ${r === "1" ? "after" : "before"}`
56
58
  ));
57
59
  });
@@ -75,8 +77,8 @@ class Y extends T {
75
77
  } else {
76
78
  const c = r.match(/([^0-9.,\s]+)/);
77
79
  if (c && c[1]) {
78
- const s = c[1].trim(), u = new RegExp(`\\s*${this._escapeRegex(s)}\\s*`);
79
- n = r.replace(u, "").trim();
80
+ const s = c[1].trim(), C = new RegExp(`\\s*${this._escapeRegex(s)}\\s*`);
81
+ n = r.replace(C, "").trim();
80
82
  }
81
83
  }
82
84
  return n;
@@ -103,5 +105,5 @@ class Y extends T {
103
105
  }
104
106
  export {
105
107
  b as CONTROL_BLOCK_ID,
106
- Y as PriceCurrencyLocationControl
108
+ B as PriceCurrencyLocationControl
107
109
  };
@@ -5,12 +5,11 @@ import { ModificationDescription as b } from "../../../../../node_modules/@strip
5
5
  import { CommonControl as R } from "../../../common-control.js";
6
6
  import { ItemsBlockControlId as h } from "../../enums/controlEnums.js";
7
7
  import { useItemsBlockStore as f } from "../../store/items-block.js";
8
- import { syncCurrencySymbolFromAttributes as N } from "../../utils/syncAttributesFromConfigBlock.js";
9
- import { updateConfigBlockAttributes as B } from "../../utils/updateAttributes.js";
8
+ import { getItemsBlockConfig as B, setItemsBlockConfig as N } from "../../utils/nodeConfigUtils.js";
10
9
  const E = h.PRICE_CURRENCY_SYMBOL, m = {
11
10
  CURRENCY_SYMBOL: "currencySymbol"
12
11
  };
13
- class P extends R {
12
+ class M extends R {
14
13
  constructor() {
15
14
  super(...arguments);
16
15
  u(this, "store", f());
@@ -21,7 +20,7 @@ class P extends R {
21
20
  }
22
21
  getTemplate() {
23
22
  return `
24
- <div class="${h.PRICE_CURRENCY_SYMBOL}">
23
+ <div class="container ${h.PRICE_CURRENCY_SYMBOL}">
25
24
  ${this._getCurrencySymbol()}
26
25
  </div>
27
26
  `;
@@ -36,7 +35,10 @@ class P extends R {
36
35
  }
37
36
  onTemplateNodeUpdated(e) {
38
37
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
39
- () => N(this.currentNode),
38
+ () => {
39
+ const t = B(this.currentNode);
40
+ t && this.store.setCurrencySymbol(t.priceCurrencySymbol || "");
41
+ },
40
42
  () => {
41
43
  this.api.updateValues({ [m.CURRENCY_SYMBOL]: this.store.currencySymbol }), this._storeOriginalContents();
42
44
  }
@@ -45,18 +47,18 @@ class P extends R {
45
47
  _onCurrencySymbolChange(e) {
46
48
  var i;
47
49
  console.debug("Currency symbol changed to: ", e);
48
- const r = ((i = this.store.currencySymbol) == null ? void 0 : i.trim()) || "";
49
- if (this.store.setCurrencySymbol(e), B(this.currentNode, this.api), !this.currentNode)
50
+ const t = ((i = this.store.currencySymbol) == null ? void 0 : i.trim()) || "";
51
+ if (this.store.setCurrencySymbol(e), N(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
50
52
  return;
51
- const t = this._getPriceBlocks();
52
- if (!t || t.length === 0)
53
+ const r = this._getPriceBlocks();
54
+ if (!r || r.length === 0)
53
55
  return;
54
56
  const o = (e == null ? void 0 : e.trim()) || "", { currencyLocation: n } = this.store;
55
- t.forEach((l) => {
57
+ r.forEach((l) => {
56
58
  const a = this._getParagraph(l);
57
59
  if (!a)
58
60
  return;
59
- const y = a.getInnerHTML() || "", p = a.getInnerText() || "", C = this._removeCurrencySymbol(p, r), g = this._buildPriceContent(C, o, n), d = y.replace(p, g);
61
+ const y = a.getInnerHTML() || "", p = a.getInnerText() || "", C = this._removeCurrencySymbol(p, t), g = this._buildPriceContent(C, o, n), d = y.replace(p, g);
60
62
  this.api.getDocumentModifier().modifyHtml(a).setInnerHtml(d).apply(new b(
61
63
  `Updated currency symbol to ${o || "removed"}`
62
64
  ));
@@ -67,18 +69,18 @@ class P extends R {
67
69
  return;
68
70
  this.currentNode.querySelectorAll(
69
71
  ".items-block-price"
70
- ).forEach((r) => {
72
+ ).forEach((t) => {
71
73
  var o;
72
- const t = r.querySelector("p");
73
- if (t && !this.originalPriceContents.has(t)) {
74
- const n = t.getInnerText() || "", i = ((o = this.store.currencySymbol) == null ? void 0 : o.trim()) || "", l = this._removeCurrencySymbol(n, i);
75
- this.originalPriceContents.set(t, l);
74
+ const r = t.querySelector("p");
75
+ if (r && !this.originalPriceContents.has(r)) {
76
+ const n = r.getInnerText() || "", i = ((o = this.store.currencySymbol) == null ? void 0 : o.trim()) || "", l = this._removeCurrencySymbol(n, i);
77
+ this.originalPriceContents.set(r, l);
76
78
  }
77
79
  });
78
80
  }
79
81
  _getPriceBlocks() {
80
- var e, r;
81
- return ((r = (e = this.currentNode) == null ? void 0 : e.closest(".items-block")) == null ? void 0 : r.querySelectorAll(".items-block-price")) || [];
82
+ var e, t;
83
+ return ((t = (e = this.currentNode) == null ? void 0 : e.closest(".items-block")) == null ? void 0 : t.querySelectorAll(".items-block-price")) || [];
82
84
  }
83
85
  _getParagraph(e) {
84
86
  return e.querySelector("p");
@@ -86,23 +88,23 @@ class P extends R {
86
88
  _escapeRegex(e) {
87
89
  return e.replace(/[-\\^$*+?().|[\]{}]/g, "\\$&");
88
90
  }
89
- _removeCurrencySymbol(e, r) {
90
- const t = e || "";
91
- let o = t;
92
- if (r) {
93
- const n = new RegExp(`\\s*${this._escapeRegex(r)}\\s*`);
94
- o = t.replace(n, "").trim();
91
+ _removeCurrencySymbol(e, t) {
92
+ const r = e || "";
93
+ let o = r;
94
+ if (t) {
95
+ const n = new RegExp(`\\s*${this._escapeRegex(t)}\\s*`);
96
+ o = r.replace(n, "").trim();
95
97
  } else {
96
- const n = t.match(/([^0-9.,\s]+)/);
98
+ const n = r.match(/([^0-9.,\s]+)/);
97
99
  if (n && n[1]) {
98
100
  const i = n[1].trim(), l = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
99
- o = t.replace(l, "").trim();
101
+ o = r.replace(l, "").trim();
100
102
  }
101
103
  }
102
104
  return o;
103
105
  }
104
- _buildPriceContent(e, r, t) {
105
- return r ? t === "1" ? `${e}&nbsp;${r}` : `${r}&nbsp;${e}` : e;
106
+ _buildPriceContent(e, t, r) {
107
+ return t ? r === "1" ? `${e}&nbsp;${t}` : `${t}&nbsp;${e}` : e;
106
108
  }
107
109
  _getCurrencySymbol() {
108
110
  return `
@@ -119,5 +121,5 @@ class P extends R {
119
121
  }
120
122
  export {
121
123
  E as CONTROL_BLOCK_ID,
122
- P as PriceCurrencySymbolControl
124
+ M as PriceCurrencySymbolControl
123
125
  };
@@ -1,76 +1,76 @@
1
- var _ = Object.defineProperty;
2
- var I = (r, e, t) => e in r ? _(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var P = (r, e, t) => I(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { ModificationDescription as F, UIElementType as m, UEAttr as C } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
1
+ var R = Object.defineProperty;
2
+ var _ = (i, t, e) => t in i ? R(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
+ var m = (i, t, e) => _(i, typeof t != "symbol" ? t + "" : t, e);
4
+ import { ModificationDescription as F, UIElementType as P, UEAttr as C } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
5
  import { CommonControl as h } from "../../../common-control.js";
6
- import { ItemsBlockControlId as l, ItemsBlockId as A } from "../../enums/controlEnums.js";
6
+ import { ItemsBlockControlId as p, ItemsBlockId as g } from "../../enums/controlEnums.js";
7
7
  import { productPairs as T } from "../../enums/productEnums.js";
8
- import { useItemsBlockStore as u } from "../../store/items-block.js";
9
- import { syncFormattedPriceFromAttributes as g } from "../../utils/syncAttributesFromConfigBlock.js";
10
- import { updateConfigBlockAttributes as D } from "../../utils/updateAttributes.js";
11
- const f = l.PRICE_FORMATTED_PRICE, n = {
8
+ import { useItemsBlockStore as A } from "../../store/items-block.js";
9
+ import { getItemsBlockConfig as f, setItemsBlockConfig as u } from "../../utils/nodeConfigUtils.js";
10
+ const D = p.PRICE_FORMATTED_PRICE, n = {
12
11
  FORMATTED_PRICE: "formattedPrice"
13
12
  };
14
- class y extends h {
13
+ class k extends h {
15
14
  constructor() {
16
15
  super(...arguments);
17
- P(this, "store", u());
16
+ m(this, "store", A());
18
17
  }
19
18
  getId() {
20
- return f;
19
+ return D;
21
20
  }
22
21
  getTemplate() {
23
22
  return `
24
- <div class="${l.PRICE_FORMATTED_PRICE}">
23
+ <div class="container ${p.PRICE_FORMATTED_PRICE}">
25
24
  ${this._getFormattedPrice()}
26
25
  </div>
27
26
  `;
28
27
  }
29
28
  onRender() {
30
- this.api.updateValues({ [n.FORMATTED_PRICE]: this.store.formattedPrice }), this.api.onValueChanged(n.FORMATTED_PRICE, (t) => {
31
- this._onFormattedPriceChange(t);
29
+ this.api.updateValues({ [n.FORMATTED_PRICE]: this.store.formattedPrice }), this.api.onValueChanged(n.FORMATTED_PRICE, (e) => {
30
+ this._onFormattedPriceChange(e);
32
31
  });
33
32
  }
34
- onTemplateNodeUpdated(t) {
35
- super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(
36
- () => g(this.currentNode),
33
+ onTemplateNodeUpdated(e) {
34
+ super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
35
+ () => {
36
+ const r = f(this.currentNode);
37
+ r && this.store.setFormattedPrice(r.priceFormatted ?? !0);
38
+ },
37
39
  () => {
38
40
  this.api.updateValues({ [n.FORMATTED_PRICE]: this.store.formattedPrice });
39
41
  }
40
42
  );
41
43
  }
42
- _onFormattedPriceChange(t) {
43
- if (console.debug("Formatted price changed to: ", t), this.store.setFormattedPrice(t), D(this.currentNode, this.api), !this.currentNode)
44
+ _onFormattedPriceChange(e) {
45
+ if (console.debug("Formatted price changed to: ", e), this.store.setFormattedPrice(e), u(this.currentNode, this.api, { priceFormatted: e }), !this.currentNode)
44
46
  return;
45
- const { itemsType: s } = this.store, i = T.PAIRS_FOR_EXTENSION.price[s], o = T.PAIRS_FOR_EXTENSION.originalPrice[s], [c, a] = t ? [i.DEFAULT_PRICE, i.DEFAULT_PRICE_FORMATTED] : [i.DEFAULT_PRICE_FORMATTED, i.DEFAULT_PRICE], [p, R] = t ? [o.DEFAULT_PRICE, o.DEFAULT_PRICE_FORMATTED] : [o.DEFAULT_PRICE_FORMATTED, o.DEFAULT_PRICE];
47
+ const { itemsType: r } = this.store, o = T.PAIRS_FOR_EXTENSION.price[r], s = T.PAIRS_FOR_EXTENSION.originalPrice[r], [c, a] = e ? [o.DEFAULT_PRICE, o.DEFAULT_PRICE_FORMATTED] : [o.DEFAULT_PRICE_FORMATTED, o.DEFAULT_PRICE], [l, I] = e ? [s.DEFAULT_PRICE, s.DEFAULT_PRICE_FORMATTED] : [s.DEFAULT_PRICE_FORMATTED, s.DEFAULT_PRICE];
46
48
  this._updatePriceBlock(
47
49
  this.currentNode,
48
50
  c,
49
51
  a,
50
52
  "price"
51
53
  );
52
- const d = this.currentNode.closest(".items-block"), E = d == null ? void 0 : d.querySelector(`[esd-extension-block-id="${A.ORIGINAL_PRICE}"]`);
53
- E && this._updatePriceBlock(E, p, R, "original price");
54
+ const d = this.currentNode.closest(".items-block"), E = d == null ? void 0 : d.querySelector(`[esd-extension-block-id="${g.ORIGINAL_PRICE}"]`);
55
+ E && this._updatePriceBlock(E, l, I, "original price");
54
56
  }
55
- _updatePriceBlock(t, s, i, o) {
56
- const c = t.getInnerHTML().replace(s, i), a = `Updated ${o} to ${this.store.formattedPrice ? "formatted" : "unformatted"}`;
57
- this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(c).apply(new F(a));
57
+ _updatePriceBlock(e, r, o, s) {
58
+ const c = e.getInnerHTML().replace(r, o), a = `Updated ${s} to ${this.store.formattedPrice ? "formatted" : "unformatted"}`;
59
+ this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(c).apply(new F(a));
58
60
  }
59
61
  _getFormattedPrice() {
60
62
  return `
61
- <div class="container">
62
- <div class="display-flex align-items-center justify-content-between">
63
- <${m.LABEL}
64
- ${C.LABEL.text}="${this.api.translate("Formatted Price (e.g. $9.90)")}"
65
- >
66
- </${m.LABEL}>
67
- ${this._GuToggle(n.FORMATTED_PRICE)}
68
- </div>
63
+ <div class="display-flex align-items-center justify-content-between">
64
+ <${P.LABEL}
65
+ ${C.LABEL.text}="${this.api.translate("Formatted Price (e.g. $9.90)")}"
66
+ >
67
+ </${P.LABEL}>
68
+ ${this._GuToggle(n.FORMATTED_PRICE)}
69
69
  </div>
70
70
  `;
71
71
  }
72
72
  }
73
73
  export {
74
- f as CONTROL_BLOCK_ID,
75
- y as PriceFormattedPriceControl
74
+ D as CONTROL_BLOCK_ID,
75
+ k as PriceFormattedPriceControl
76
76
  };
@@ -1,26 +1,25 @@
1
- var d = Object.defineProperty;
2
- var a = (i, e, t) => e in i ? d(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var o = (i, e, t) => a(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { UIElementType as n, UEAttr as c } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
1
+ var c = Object.defineProperty;
2
+ var a = (i, e, t) => e in i ? c(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var n = (i, e, t) => a(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { UIElementType as r, UEAttr as D } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
5
  import { CommonControl as u } from "../../../common-control.js";
6
- import { ItemsBlockControlId as r } from "../../enums/controlEnums.js";
7
- import { useItemsBlockStore as D } from "../../store/items-block.js";
8
- import { syncHideDiscountFromAttributes as p } from "../../utils/syncAttributesFromConfigBlock.js";
9
- import { updateConfigBlockAttributes as I } from "../../utils/updateAttributes.js";
10
- const l = r.PRICE_HIDE_DISCOUNT, s = {
6
+ import { ItemsBlockControlId as d } from "../../enums/controlEnums.js";
7
+ import { useItemsBlockStore as I } from "../../store/items-block.js";
8
+ import { getItemsBlockConfig as p, setItemsBlockConfig as h } from "../../utils/nodeConfigUtils.js";
9
+ const l = d.PRICE_HIDE_DISCOUNT, s = {
11
10
  HIDE_DISCOUNT: "hideDiscount"
12
11
  };
13
- class N extends u {
12
+ class T extends u {
14
13
  constructor() {
15
14
  super(...arguments);
16
- o(this, "store", D());
15
+ n(this, "store", I());
17
16
  }
18
17
  getId() {
19
18
  return l;
20
19
  }
21
20
  getTemplate() {
22
21
  return `
23
- <div class="${r.PRICE_HIDE_DISCOUNT}">
22
+ <div class="container ${d.PRICE_HIDE_DISCOUNT}">
24
23
  ${this._getHideDiscount()}
25
24
  </div>
26
25
  `;
@@ -32,23 +31,26 @@ class N extends u {
32
31
  }
33
32
  onTemplateNodeUpdated(t) {
34
33
  super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(
35
- () => p(this.currentNode),
34
+ () => {
35
+ const o = p(this.currentNode);
36
+ o && this.store.setHideDiscount(o.priceHideDiscount ?? !0);
37
+ },
36
38
  () => {
37
39
  this.api.updateValues({ [s.HIDE_DISCOUNT]: this.store.hideDiscount });
38
40
  }
39
41
  );
40
42
  }
41
43
  _onHideDiscountChange(t) {
42
- this.store.setHideDiscount(t), I(this.currentNode, this.api), this.api.updateValues({ [s.HIDE_DISCOUNT]: t });
44
+ this.store.setHideDiscount(t), h(this.currentNode, this.api, { priceHideDiscount: t }), this.api.updateValues({ [s.HIDE_DISCOUNT]: t });
43
45
  }
44
46
  _getHideDiscount() {
45
47
  return `
46
- <div class="container">
48
+
47
49
  <div class="display-flex align-items-center justify-content-between">
48
- <${n.LABEL}
49
- ${c.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
50
+ <${r.LABEL}
51
+ ${D.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
50
52
  >
51
- </${n.LABEL}>
53
+ </${r.LABEL}>
52
54
  ${this._GuToggle(s.HIDE_DISCOUNT)}
53
55
  </div>
54
56
  </div>
@@ -57,5 +59,5 @@ class N extends u {
57
59
  }
58
60
  export {
59
61
  l as CONTROL_BLOCK_ID,
60
- N as PriceHideDiscountControl
62
+ T as PriceHideDiscountControl
61
63
  };
@@ -1,43 +1,43 @@
1
1
  var I = Object.defineProperty;
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";
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";
6
6
  import { ItemsBlockControlId as O } from "../../enums/controlEnums.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";
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";
11
10
  const _ = O.PRICE_ORIENTATION, p = {
12
11
  PRICE_ORIENTATION: "priceOrientation"
13
- }, C = [
12
+ }, P = [
14
13
  { icon: "vertical-orientation", value: "vertical" },
15
14
  { icon: "horizontal-orientation", value: "horizontal" }
16
15
  ];
17
- class v extends E {
16
+ class H extends y {
18
17
  constructor() {
19
18
  super(...arguments);
20
- m(this, "store", f());
19
+ m(this, "store", N());
21
20
  }
22
21
  getId() {
23
22
  return _;
24
23
  }
25
24
  getTemplate() {
26
25
  return `
27
- <div class="${O.PRICE_ORIENTATION}">
26
+ <div class="container ${O.PRICE_ORIENTATION}">
28
27
  ${this._getPriceOrientation()}
29
28
  </div>
30
29
  `;
31
30
  }
32
31
  onRender() {
33
32
  this.api.updateValues({ [p.PRICE_ORIENTATION]: this.store.priceOrientation }), this.api.onValueChanged(p.PRICE_ORIENTATION, (t) => {
34
- this._onPriceOrientationChange(t);
33
+ typeof t == "string" && this._onPriceOrientationChange(t);
35
34
  });
36
35
  }
37
36
  onTemplateNodeUpdated(t) {
38
37
  super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(
39
38
  () => {
40
- T(this.currentNode);
39
+ const i = T(this.currentNode);
40
+ i && this.store.setPriceOrientation(i.priceOrientation || "horizontal");
41
41
  },
42
42
  () => {
43
43
  this.api.updateValues({ [p.PRICE_ORIENTATION]: this.store.priceOrientation });
@@ -45,24 +45,26 @@ class v extends E {
45
45
  );
46
46
  }
47
47
  _onPriceOrientationChange(t) {
48
- if (console.debug("Price orientation changed to: ", t), this.store.setPriceOrientation(t), P(this.currentNode, this.api), !this.currentNode)
48
+ if (this.store.setPriceOrientation(t), C(this.currentNode, this.api, {
49
+ priceOrientation: t
50
+ }), !this.currentNode)
49
51
  return;
50
- const { orientation: i } = this.store, r = i === N.ORIENTATION.VERTICAL, e = t === "horizontal";
52
+ const { orientation: i } = this.store, r = i === E.ORIENTATION.VERTICAL, e = t === "horizontal";
51
53
  r ? this._updateVerticalLayout(e) : this._updateHorizontalLayout(e);
52
54
  }
53
- _updateHorizontalLayout(t) {
55
+ _updateVerticalLayout(t) {
54
56
  var c, l, d, a;
55
57
  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")) || [];
56
58
  if (!i || !r)
57
59
  return;
58
60
  const e = t ? "50%" : "100%", s = this.api.getDocumentModifier();
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}`));
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}`));
64
66
  }
65
- _updateVerticalLayout(t) {
67
+ _updateHorizontalLayout(t) {
66
68
  var s, c, l, d;
67
69
  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");
68
70
  if (!i || !r || i.length === 0)
@@ -70,9 +72,9 @@ class v extends E {
70
72
  const e = this.api.getDocumentModifier();
71
73
  t ? (i.forEach((a) => {
72
74
  e.modifyHtml(a).setStyle("display", "table-cell");
73
- }), e.modifyHtml(r).setStyle("display", "none").apply(new h("Hide vertical price element"))) : (i.forEach((a) => {
75
+ }), e.modifyHtml(r).setStyle("display", "none"), e.apply(new u("Show horizontal price orientation"))) : (i.forEach((a) => {
74
76
  e.modifyHtml(a).setStyle("display", "none");
75
- }), e.modifyHtml(r).setStyle("display", "table-cell").apply(new h("Show vertical price element")));
77
+ }), e.modifyHtml(r).setStyle("display", "table-cell"), e.apply(new u("Show vertical price orientation")));
76
78
  }
77
79
  _getPriceOrientation() {
78
80
  return `
@@ -80,7 +82,7 @@ class v extends E {
80
82
  this._GuLabel({ text: "Price Orientation" }),
81
83
  this._GuRadioButton({
82
84
  name: p.PRICE_ORIENTATION,
83
- buttons: C
85
+ buttons: P
84
86
  })
85
87
  ])}
86
88
  `;
@@ -88,5 +90,5 @@ class v extends E {
88
90
  }
89
91
  export {
90
92
  _ as CONTROL_BLOCK_ID,
91
- v as PriceOrientationControl
93
+ H as PriceOrientationControl
92
94
  };
@@ -0,0 +1,93 @@
1
+ var C = Object.defineProperty;
2
+ var R = (n, r, e) => r in n ? C(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e;
3
+ var d = (n, r, e) => R(n, typeof r != "symbol" ? r + "" : r, e);
4
+ import { ModificationDescription as _, UIElementType as g, UEAttr as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as u } from "../../../common-control.js";
6
+ import { ItemsBlockControlId as m, ItemsBlockId as N } from "../../enums/controlEnums.js";
7
+ import { productPairs as S } from "../../enums/productEnums.js";
8
+ import { useItemsBlockStore as A } from "../../store/items-block.js";
9
+ import { setItemsBlockConfig as f } from "../../utils/nodeConfigUtils.js";
10
+ const D = m.PRICE_SINGLE_PRICE, l = {
11
+ SINGLE_PRICE: "singlePrice"
12
+ };
13
+ class k extends u {
14
+ constructor() {
15
+ super(...arguments);
16
+ d(this, "store", A());
17
+ }
18
+ getId() {
19
+ return D;
20
+ }
21
+ getTemplate() {
22
+ return `
23
+ <div class="container ${m.PRICE_SINGLE_PRICE}">
24
+ ${this._getSinglePrice()}
25
+ </div>
26
+ `;
27
+ }
28
+ onRender() {
29
+ this.api.updateValues({ [l.SINGLE_PRICE]: this.store.singlePrice }), this.api.onValueChanged(l.SINGLE_PRICE, (e) => {
30
+ this._onSinglePriceChange(e);
31
+ });
32
+ }
33
+ onTemplateNodeUpdated(e) {
34
+ super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
35
+ () => this._syncSinglePriceFromNodeConfig(),
36
+ () => {
37
+ this.api.updateValues({ [l.SINGLE_PRICE]: this.store.singlePrice });
38
+ }
39
+ );
40
+ }
41
+ /**
42
+ * Syncs single price state from nodeConfig.
43
+ */
44
+ _syncSinglePriceFromNodeConfig() {
45
+ var i;
46
+ const e = (i = this.currentNode) == null ? void 0 : i.closest(".items-block");
47
+ if (!e)
48
+ return;
49
+ const o = e.getNodeConfig(), t = (o == null ? void 0 : o.priceSinglePrice) ?? !1;
50
+ this.store.setSinglePrice(t);
51
+ }
52
+ _onSinglePriceChange(e) {
53
+ if (console.debug("Single price changed to: ", e), this.store.setSinglePrice(e), f(this.currentNode, this.api, { priceSinglePrice: e }), !this.currentNode)
54
+ return;
55
+ const { itemsType: o, formattedPrice: t } = this.store, i = S.PAIRS_FOR_EXTENSION.price[o], c = S.PAIRS_FOR_EXTENSION.originalPrice[o], [E, a] = e ? [
56
+ t ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE,
57
+ t ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE
58
+ ] : [
59
+ t ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE,
60
+ t ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE
61
+ ], P = t ? c.DEFAULT_PRICE_FORMATTED : c.DEFAULT_PRICE, s = t ? c.DEFAULT_SINGLE_PRICE_FORMATTED : c.DEFAULT_SINGLE_PRICE, [L, T] = e ? [P, s] : [s, P];
62
+ this._updatePriceBlock(
63
+ this.currentNode,
64
+ E,
65
+ a,
66
+ e,
67
+ "price"
68
+ );
69
+ const p = this.currentNode.closest(".items-block"), I = p == null ? void 0 : p.querySelector(`[esd-extension-block-id="${N.ORIGINAL_PRICE}"]`);
70
+ I && this._updatePriceBlock(I, L, T, e, "original price");
71
+ }
72
+ _updatePriceBlock(e, o, t, i, c) {
73
+ const E = e.getInnerHTML().replace(o, t), a = `Updated ${c} to ${i ? "single" : "total"} price`;
74
+ this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(E).apply(new _(a));
75
+ const s = e.querySelector('[product-attr="price"], [product-attr="originalPrice"]');
76
+ s && this.api.getDocumentModifier().modifyHtml(s).setAttribute("data-single_price", i ? "true" : "false").apply(new _("Update single price attribute"));
77
+ }
78
+ _getSinglePrice() {
79
+ return `
80
+ <div class="display-flex align-items-center justify-content-between">
81
+ <${g.LABEL}
82
+ ${h.LABEL.text}="${this.api.translate("Show Single Product Price")}"
83
+ >
84
+ </${g.LABEL}>
85
+ ${this._GuToggle(l.SINGLE_PRICE)}
86
+ </div>
87
+ `;
88
+ }
89
+ }
90
+ export {
91
+ D as CONTROL_BLOCK_ID,
92
+ k as PriceSinglePriceControl
93
+ };