@useinsider/guido 2.0.0-beta.5ccd854 → 2.0.0-beta.689d09e

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 (77) 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/header/LeftSlot.vue.js +12 -12
  6. package/dist/components/organisms/header/LeftSlot.vue2.js +6 -6
  7. package/dist/components/organisms/header/RightSlot.vue2.js +10 -10
  8. package/dist/composables/useConfig.js +29 -27
  9. package/dist/composables/useSave.js +13 -11
  10. package/dist/composables/useStripo.js +42 -40
  11. package/dist/config/migrator/itemsBlockMigrator.js +184 -125
  12. package/dist/extensions/Blocks/CouponBlock/constants.js +4 -0
  13. package/dist/extensions/Blocks/CouponBlock/controls/index.js +29 -0
  14. package/dist/extensions/Blocks/CouponBlock/extension.js +5 -4
  15. package/dist/extensions/Blocks/CouponBlock/settingsPanel.js +20 -14
  16. package/dist/extensions/Blocks/CouponBlock/template.js +22 -11
  17. package/dist/extensions/Blocks/Items/block.js +1 -1
  18. package/dist/extensions/Blocks/Items/controls/button/link.js +22 -29
  19. package/dist/extensions/Blocks/Items/controls/cardComposition.js +59 -36
  20. package/dist/extensions/Blocks/Items/controls/image/link.js +23 -30
  21. package/dist/extensions/Blocks/Items/controls/name/trimming.js +25 -25
  22. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +19 -17
  23. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +31 -29
  24. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +44 -38
  25. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +21 -19
  26. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +1 -1
  27. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +93 -0
  28. package/dist/extensions/Blocks/Items/controls/settingsControl.js +99 -95
  29. package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
  30. package/dist/extensions/Blocks/Items/enums/productEnums.js +43 -45
  31. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -1
  32. package/dist/extensions/Blocks/Items/extension.js +7 -6
  33. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +0 -1
  34. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +0 -1
  35. package/dist/extensions/Blocks/Items/settingsPanel.js +27 -26
  36. package/dist/extensions/Blocks/Items/store/items-block.js +9 -5
  37. package/dist/extensions/Blocks/Items/template.js +285 -221
  38. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +94 -82
  39. package/dist/extensions/Blocks/Unsubscribe/extension.js +9 -9
  40. package/dist/extensions/Blocks/common-control.js +45 -57
  41. package/dist/extensions/Blocks/controlFactories.js +139 -118
  42. package/dist/guido.css +1 -1
  43. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +53 -48
  44. package/dist/package.json.js +7 -0
  45. package/dist/services/stripoApi.js +6 -10
  46. package/dist/src/@types/config/index.d.ts +2 -2
  47. package/dist/src/@types/config/schemas.d.ts +30 -0
  48. package/dist/src/@types/config/types.d.ts +7 -1
  49. package/dist/src/composables/useConfig.d.ts +8 -0
  50. package/dist/src/extensions/Blocks/CouponBlock/constants.d.ts +14 -0
  51. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +108 -0
  52. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +1 -1
  53. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -2
  54. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +9 -0
  55. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -2
  56. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +18 -0
  57. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
  58. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +24 -26
  59. package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +1 -0
  60. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +2 -0
  61. package/dist/src/extensions/Blocks/Items/template.d.ts +3 -1
  62. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +4 -2
  63. package/dist/src/extensions/Blocks/common-control.d.ts +1 -7
  64. package/dist/src/extensions/Blocks/controlFactories.d.ts +30 -7
  65. package/dist/src/stores/config.d.ts +164 -1
  66. package/dist/static/styles/components/button.css.js +1 -1
  67. package/dist/stores/config.js +7 -0
  68. package/dist/utils/pairProductVariables.js +61 -58
  69. package/package.json +1 -1
  70. package/dist/extensions/Blocks/Items/utils/configBlockUtils.js +0 -17
  71. package/dist/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.js +0 -28
  72. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +0 -67
  73. package/dist/extensions/Blocks/Items/utils/updateAttributes.js +0 -46
  74. package/dist/src/extensions/Blocks/Items/utils/configBlockUtils.d.ts +0 -23
  75. package/dist/src/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.d.ts +0 -32
  76. package/dist/src/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.d.ts +0 -50
  77. 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,82 @@
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 C = Object.defineProperty;
2
+ var A = (n, r, e) => r in n ? C(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e;
3
+ var _ = (n, r, e) => A(n, typeof r != "symbol" ? r + "" : r, e);
4
+ import { ModificationDescription as L, UIElementType as m, UEAttr as g } 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";
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 = {
6
+ import { ItemsBlockControlId as l, ItemsBlockId as D } from "../../enums/controlEnums.js";
7
+ import { productPairs as I } from "../../enums/productEnums.js";
8
+ import { useItemsBlockStore as O } from "../../store/items-block.js";
9
+ import { getItemsBlockConfig as u, setItemsBlockConfig as f } from "../../utils/nodeConfigUtils.js";
10
+ const N = l.PRICE_FORMATTED_PRICE, c = {
12
11
  FORMATTED_PRICE: "formattedPrice"
13
12
  };
14
13
  class y extends h {
15
14
  constructor() {
16
15
  super(...arguments);
17
- P(this, "store", u());
16
+ _(this, "store", O());
18
17
  }
19
18
  getId() {
20
- return f;
19
+ return N;
21
20
  }
22
21
  getTemplate() {
23
22
  return `
24
- <div class="${l.PRICE_FORMATTED_PRICE}">
23
+ <div class="container ${l.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({ [c.FORMATTED_PRICE]: this.store.formattedPrice }), this.api.onValueChanged(c.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(
37
35
  () => {
38
- this.api.updateValues({ [n.FORMATTED_PRICE]: this.store.formattedPrice });
36
+ const o = u(this.currentNode);
37
+ o && this.store.setFormattedPrice(o.priceFormatted ?? !0);
38
+ },
39
+ () => {
40
+ this.api.updateValues({ [c.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), f(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: o, singlePrice: i } = this.store, t = I.PAIRS_FOR_EXTENSION.price[o], s = I.PAIRS_FOR_EXTENSION.originalPrice[o], [E, R] = e ? [
48
+ i ? t.DEFAULT_SINGLE_PRICE : t.DEFAULT_PRICE,
49
+ i ? t.DEFAULT_SINGLE_PRICE_FORMATTED : t.DEFAULT_PRICE_FORMATTED
50
+ ] : [
51
+ i ? t.DEFAULT_SINGLE_PRICE_FORMATTED : t.DEFAULT_PRICE_FORMATTED,
52
+ i ? t.DEFAULT_SINGLE_PRICE : t.DEFAULT_PRICE
53
+ ], d = i ? s.DEFAULT_SINGLE_PRICE : s.DEFAULT_PRICE, P = i ? s.DEFAULT_SINGLE_PRICE_FORMATTED : s.DEFAULT_PRICE_FORMATTED, [p, F] = e ? [d, P] : [P, d];
46
54
  this._updatePriceBlock(
47
55
  this.currentNode,
48
- c,
49
- a,
56
+ E,
57
+ R,
50
58
  "price"
51
59
  );
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");
60
+ const a = this.currentNode.closest(".items-block"), T = a == null ? void 0 : a.querySelector(`[esd-extension-block-id="${D.ORIGINAL_PRICE}"]`);
61
+ T && this._updatePriceBlock(T, p, F, "original price");
54
62
  }
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));
63
+ _updatePriceBlock(e, o, i, t) {
64
+ const s = e.getInnerHTML().replace(o, i), E = `Updated ${t} to ${this.store.formattedPrice ? "formatted" : "unformatted"}`;
65
+ this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(s).apply(new L(E));
58
66
  }
59
67
  _getFormattedPrice() {
60
68
  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>
69
+ <div class="display-flex align-items-center justify-content-between">
70
+ <${m.LABEL}
71
+ ${g.LABEL.text}="${this.api.translate("Formatted Price (e.g. $9.90)")}"
72
+ >
73
+ </${m.LABEL}>
74
+ ${this._GuToggle(c.FORMATTED_PRICE)}
69
75
  </div>
70
76
  `;
71
77
  }
72
78
  }
73
79
  export {
74
- f as CONTROL_BLOCK_ID,
80
+ N as CONTROL_BLOCK_ID,
75
81
  y as PriceFormattedPriceControl
76
82
  };
@@ -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
  };
@@ -23,7 +23,7 @@ class H extends y {
23
23
  }
24
24
  getTemplate() {
25
25
  return `
26
- <div class="${O.PRICE_ORIENTATION}">
26
+ <div class="container ${O.PRICE_ORIENTATION}">
27
27
  ${this._getPriceOrientation()}
28
28
  </div>
29
29
  `;
@@ -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
+ };