@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,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
+ };