@useinsider/guido 2.1.0-beta.5160aec → 2.1.0-beta.587ec44

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 (69) hide show
  1. package/README.md +39 -1
  2. package/dist/@types/config/schemas.js +70 -65
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +69 -58
  5. package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
  6. package/dist/composables/useBlocksConfig.js +26 -16
  7. package/dist/composables/useSave.js +16 -12
  8. package/dist/composables/useStripo.js +58 -54
  9. package/dist/composables/useStripoEventHandler.js +27 -12
  10. package/dist/composables/useSyncModuleExtractor.js +45 -0
  11. package/dist/config/migrator/itemsBlockMigrator.js +140 -123
  12. package/dist/enums/defaults.js +8 -4
  13. package/dist/enums/unsubscribe.js +25 -21
  14. package/dist/extensions/Blocks/Items/block.js +19 -28
  15. package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
  16. package/dist/extensions/Blocks/Items/controls/cardComposition.js +124 -85
  17. package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
  18. package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
  19. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +35 -47
  20. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +49 -54
  21. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +42 -51
  22. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -36
  23. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
  24. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -60
  25. package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
  26. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
  27. package/dist/extensions/Blocks/Items/extension.js +8 -9
  28. package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
  29. package/dist/extensions/Blocks/Items/template.js +181 -175
  30. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  31. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +3 -3
  32. package/dist/extensions/Blocks/common-control.js +91 -92
  33. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  34. package/dist/guido.css +1 -1
  35. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +163 -95
  36. package/dist/services/stripoApi.js +48 -12
  37. package/dist/src/@types/config/schemas.d.ts +8 -0
  38. package/dist/src/@types/events.d.ts +38 -2
  39. package/dist/src/composables/useConfig.d.ts +4 -0
  40. package/dist/src/composables/useSyncModuleExtractor.d.ts +4 -0
  41. package/dist/src/enums/defaults.d.ts +4 -0
  42. package/dist/src/enums/unsubscribe.d.ts +3 -0
  43. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
  44. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
  45. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
  46. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
  47. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
  48. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
  49. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
  50. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
  51. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
  52. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
  53. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
  54. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
  55. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
  56. package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
  57. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  58. package/dist/src/mock/api/settings.d.ts +2 -0
  59. package/dist/src/services/stripoApi.d.ts +5 -0
  60. package/dist/src/stores/config.d.ts +36 -0
  61. package/dist/src/stores/editor.d.ts +23 -0
  62. package/dist/static/styles/components/notification.css.js +1 -0
  63. package/dist/static/styles/components/version-history.css.js +10 -2
  64. package/dist/static/styles/components/wide-panel.css.js +18 -2
  65. package/dist/stores/editor.js +2 -1
  66. package/dist/utils/templatePreparation.js +4 -4
  67. package/package.json +1 -1
  68. package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
  69. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
@@ -1,70 +1,58 @@
1
- var d = Object.defineProperty;
2
- var g = (i, t, e) => t in i ? d(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var s = (i, t, e) => g(i, typeof t != "symbol" ? t + "" : t, e);
4
- import { ModificationDescription as a, UIElementType as l, UEAttr as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as c } from "../../../common-control.js";
6
- import { ItemsBlockControlId as p } from "../../enums/controlEnums.js";
7
- import { SETTINGS_ENUMS as I } from "../../enums/settingsEnums.js";
8
- import { useItemsBlockStore as N } from "../../store/items-block.js";
9
- import { getItemsBlockConfig as f, setItemsBlockConfig as M } from "../../utils/nodeConfigUtils.js";
10
- const y = p.NAME_TRIMMING, m = {
1
+ import { ModificationDescription as s, UIElementType as a, UEAttr as T } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as d } from "../../../common-control.js";
3
+ import { ItemsBlockControlId as l } from "../../enums/controlEnums.js";
4
+ import { SETTINGS_ENUMS as h } from "../../enums/settingsEnums.js";
5
+ import { getItemsBlockConfig as r, setItemsBlockConfig as c } from "../../utils/nodeConfigUtils.js";
6
+ const I = l.NAME_TRIMMING, n = {
11
7
  TRIMMING: "trimming"
12
8
  };
13
- class _ extends c {
14
- constructor() {
15
- super(...arguments);
16
- s(this, "store", N());
17
- }
9
+ class S extends d {
18
10
  getId() {
19
- return y;
11
+ return I;
20
12
  }
21
13
  getTemplate() {
22
14
  return `
23
- <div class="container ${p.NAME_TRIMMING}">
15
+ <div class="container ${l.NAME_TRIMMING}">
24
16
  ${this._getTextTrimming()}
25
17
  </div>
26
18
  `;
27
19
  }
28
20
  onRender() {
29
- this.api.updateValues({ [m.TRIMMING]: this.store.nameTrimming }), this.api.onValueChanged(m.TRIMMING, (e) => {
30
- this._onTrimmingChange(e);
21
+ const e = r(this.currentNode);
22
+ this.api.updateValues({ [n.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(n.TRIMMING, (t) => {
23
+ this._onTrimmingChange(t);
31
24
  });
32
25
  }
33
26
  onTemplateNodeUpdated(e) {
34
- super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
35
- () => {
36
- const o = f(this.currentNode);
37
- o && this.store.setNameTrimming(o.nameTrimming ?? !0);
38
- },
39
- () => {
40
- this.api.updateValues({ [m.TRIMMING]: this.store.nameTrimming });
41
- }
42
- );
27
+ super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
28
+ const t = r(this.currentNode);
29
+ this.api.updateValues({ [n.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
30
+ });
43
31
  }
44
32
  _onTrimmingChange(e) {
45
- this.store.setNameTrimming(e), M(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [m.TRIMMING]: e }), this._applyTrimmingStyles(e);
33
+ c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [n.TRIMMING]: e }), this._applyTrimmingStyles(e);
46
34
  }
47
35
  _applyTrimmingStyles(e) {
48
- var r;
49
- const o = (r = this.currentNode) == null ? void 0 : r.querySelector("p > a");
50
- if (!o)
36
+ var m;
37
+ const t = (m = this.currentNode) == null ? void 0 : m.querySelector("p > a");
38
+ if (!t)
51
39
  return;
52
- const T = e !== void 0 ? e : this.store.nameTrimming, n = this.store.orientation === I.ORIENTATION.VERTICAL;
53
- T ? this.api.getDocumentModifier().modifyHtml(o).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", n ? "130px" : "520px").apply(new a("Text Trimming Enabled")) : this.api.getDocumentModifier().modifyHtml(o).removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow").removeStyle("max-width").setStyle("max-width", n ? "130px" : "520px").apply(new a("Text Trimming Disabled"));
40
+ const i = r(this.currentNode), p = e !== void 0 ? e : (i == null ? void 0 : i.nameTrimming) ?? !0, o = (i == null ? void 0 : i.orientation) === h.ORIENTATION.VERTICAL;
41
+ p ? this.api.getDocumentModifier().modifyHtml(t).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", o ? "130px" : "520px").apply(new s("Text Trimming Enabled")) : this.api.getDocumentModifier().modifyHtml(t).removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow").removeStyle("max-width").setStyle("max-width", o ? "130px" : "520px").apply(new s("Text Trimming Disabled"));
54
42
  }
55
43
  _getTextTrimming() {
56
44
  return `
57
45
  <div class="display-flex align-items-center justify-content-between">
58
- <${l.LABEL}
59
- ${h.LABEL.text}="${this.api.translate("Text Trimming")}"
46
+ <${a.LABEL}
47
+ ${T.LABEL.text}="${this.api.translate("Text Trimming")}"
60
48
  >
61
- </${l.LABEL}>
62
- ${this._GuToggle(m.TRIMMING)}
49
+ </${a.LABEL}>
50
+ ${this._GuToggle(n.TRIMMING)}
63
51
  </div>
64
52
  `;
65
53
  }
66
54
  }
67
55
  export {
68
- y as CONTROL_BLOCK_ID,
69
- _ as NameTrimmingControl
56
+ I as CONTROL_BLOCK_ID,
57
+ S as NameTrimmingControl
70
58
  };
@@ -1,62 +1,50 @@
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
- var p = (i, o, e) => R(i, typeof o != "symbol" ? o + "" : o, e);
4
- import { currencyLocationMaps as m } from "../../../../../enums/extensions/recommendationBlock.js";
5
- import { UEAttr as I, ModificationDescription as N } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
- import { CommonControl as T } from "../../../common-control.js";
7
- import { ItemsBlockControlId as h } from "../../enums/controlEnums.js";
8
- import { useItemsBlockStore as f } from "../../store/items-block.js";
9
- import { getItemsBlockConfig as E, setItemsBlockConfig as O } from "../../utils/nodeConfigUtils.js";
10
- const b = h.PRICE_CURRENCY_LOCATION, a = {
1
+ import { currencyLocationMaps as u } from "../../../../../enums/extensions/recommendationBlock.js";
2
+ import { UEAttr as R, ModificationDescription as L } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ import { CommonControl as N } from "../../../common-control.js";
4
+ import { ItemsBlockControlId as m } from "../../enums/controlEnums.js";
5
+ import { getItemsBlockConfig as C, setItemsBlockConfig as I, escapeReplacement as T } from "../../utils/nodeConfigUtils.js";
6
+ const E = m.PRICE_CURRENCY_LOCATION, c = {
11
7
  CURRENCY_LOCATION: "currencyLocation"
12
8
  };
13
- class B extends T {
14
- constructor() {
15
- super(...arguments);
16
- p(this, "store", f());
17
- }
9
+ class A extends N {
18
10
  getId() {
19
- return b;
11
+ return E;
20
12
  }
21
13
  getTemplate() {
22
14
  return `
23
- <div class="container ${h.PRICE_CURRENCY_LOCATION}">
15
+ <div class="container ${m.PRICE_CURRENCY_LOCATION}">
24
16
  ${this._getCurrencyLocation()}
25
17
  </div>
26
18
  `;
27
19
  }
28
20
  onRender() {
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) => {
30
- this._onCurrencyLocationChange(e);
21
+ const e = C(this.currentNode);
22
+ this.api.setUIEAttribute(c.CURRENCY_LOCATION, R.SELECTPICKER.items, u), this.api.updateValues({ [c.CURRENCY_LOCATION]: (e == null ? void 0 : e.priceCurrencyLocation) ?? "0" }), this.api.onValueChanged(c.CURRENCY_LOCATION, (t) => {
23
+ this._onCurrencyLocationChange(t);
31
24
  });
32
25
  }
33
26
  onTemplateNodeUpdated(e) {
34
- super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
35
- () => {
36
- const t = E(this.currentNode);
37
- t && this.store.setCurrencyLocation(t.priceCurrencyLocation || "0");
38
- },
39
- () => {
40
- this.api.updateValues({ [a.CURRENCY_LOCATION]: this.store.currencyLocation });
41
- }
42
- );
27
+ super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
28
+ const t = C(this.currentNode);
29
+ this.api.updateValues({ [c.CURRENCY_LOCATION]: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0" });
30
+ });
43
31
  }
44
32
  _onCurrencyLocationChange(e) {
45
- if (console.debug("Currency location changed to: ", e), this.store.setCurrencyLocation(e), O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
33
+ if (console.debug("Currency location changed to: ", e), I(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
46
34
  return;
47
35
  const t = this._getPriceBlocks();
48
36
  if (!t || t.length === 0)
49
37
  return;
50
- const r = e || "0", { currencySymbol: n } = this.store;
51
- t.forEach((c) => {
52
- const s = this._getParagraph(c);
38
+ const r = C(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", i = this.api.getDocumentModifier();
39
+ t.forEach((a) => {
40
+ const s = this._getParagraph(a);
53
41
  if (!s)
54
42
  return;
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(
57
- `Updated currency location to ${r === "1" ? "after" : "before"}`
58
- ));
59
- });
43
+ const h = s.getInnerHTML().trim() || "", l = s.getInnerText().trim() || "", p = (o == null ? void 0 : o.trim()) || "", d = this._removeCurrencySymbol(l, p), g = this._detectSymbolInText(l) || p, _ = this._buildPriceContent(d, g, n), y = h.replace(l, T(_));
44
+ i.modifyHtml(s).setInnerHtml(y);
45
+ }), i.apply(new L(
46
+ `Updated currency location to ${n === "1" ? "after" : "before"}`
47
+ ));
60
48
  }
61
49
  _getPriceBlocks() {
62
50
  var e, t;
@@ -72,13 +60,13 @@ class B extends T {
72
60
  const r = e || "";
73
61
  let n = r;
74
62
  if (t) {
75
- const c = new RegExp(`\\s*${this._escapeRegex(t)}\\s*`);
76
- n = r.replace(c, "").trim();
63
+ const o = new RegExp(`\\s*${this._escapeRegex(t)}\\s*`);
64
+ n = r.replace(o, "").trim();
77
65
  } else {
78
- const c = r.match(/([^0-9.,\s]+)/);
79
- if (c && c[1]) {
80
- const s = c[1].trim(), C = new RegExp(`\\s*${this._escapeRegex(s)}\\s*`);
81
- n = r.replace(C, "").trim();
66
+ const o = r.match(/([^0-9.,\s]+)/);
67
+ if (o && o[1]) {
68
+ const i = o[1].trim(), a = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
69
+ n = r.replace(a, "").trim();
82
70
  }
83
71
  }
84
72
  return n;
@@ -95,15 +83,15 @@ class B extends T {
95
83
  ${this._GuTwoColumns([
96
84
  this._GuLabel({ text: "Currency Location" }),
97
85
  this._GuSelect({
98
- name: a.CURRENCY_LOCATION,
86
+ name: c.CURRENCY_LOCATION,
99
87
  placeholder: "",
100
- options: m
88
+ options: u
101
89
  })
102
90
  ])}
103
91
  `;
104
92
  }
105
93
  }
106
94
  export {
107
- b as CONTROL_BLOCK_ID,
108
- B as PriceCurrencyLocationControl
95
+ E as CONTROL_BLOCK_ID,
96
+ A as PriceCurrencyLocationControl
109
97
  };
@@ -1,80 +1,75 @@
1
- var S = Object.defineProperty;
2
- var _ = (c, s, e) => s in c ? S(c, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[s] = e;
3
- var u = (c, s, e) => _(c, typeof s != "symbol" ? s + "" : s, e);
4
- import { ModificationDescription as b } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as R } from "../../../common-control.js";
6
- import { ItemsBlockControlId as h } from "../../enums/controlEnums.js";
7
- import { useItemsBlockStore as f } from "../../store/items-block.js";
8
- import { getItemsBlockConfig as B, setItemsBlockConfig as N } from "../../utils/nodeConfigUtils.js";
9
- const E = h.PRICE_CURRENCY_SYMBOL, m = {
1
+ var R = Object.defineProperty;
2
+ var N = (s, c, e) => c in s ? R(s, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[c] = e;
3
+ var h = (s, c, e) => N(s, typeof c != "symbol" ? c + "" : c, e);
4
+ import { ModificationDescription as B } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as E } from "../../../common-control.js";
6
+ import { ItemsBlockControlId as y } from "../../enums/controlEnums.js";
7
+ import { getItemsBlockConfig as p, setItemsBlockConfig as x, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
8
+ const I = y.PRICE_CURRENCY_SYMBOL, u = {
10
9
  CURRENCY_SYMBOL: "currencySymbol"
11
10
  };
12
- class M extends R {
11
+ class P extends E {
13
12
  constructor() {
14
13
  super(...arguments);
15
- u(this, "store", f());
16
- u(this, "originalPriceContents", /* @__PURE__ */ new Map());
14
+ h(this, "originalPriceContents", /* @__PURE__ */ new Map());
17
15
  }
18
16
  getId() {
19
- return E;
17
+ return I;
20
18
  }
21
19
  getTemplate() {
22
20
  return `
23
- <div class="container ${h.PRICE_CURRENCY_SYMBOL}">
21
+ <div class="container ${y.PRICE_CURRENCY_SYMBOL}">
24
22
  ${this._getCurrencySymbol()}
25
23
  </div>
26
24
  `;
27
25
  }
28
26
  onRender() {
29
- this.api.updateValues({ [m.CURRENCY_SYMBOL]: this.store.currencySymbol }), this._storeOriginalContents(), this.api.onValueChanged(m.CURRENCY_SYMBOL, (e) => {
30
- this._onCurrencySymbolChange(e);
27
+ const e = p(this.currentNode);
28
+ this.api.updateValues({ [u.CURRENCY_SYMBOL]: (e == null ? void 0 : e.priceCurrencySymbol) ?? "" }), this._storeOriginalContents(), this.api.onValueChanged(u.CURRENCY_SYMBOL, (t) => {
29
+ this._onCurrencySymbolChange(t);
31
30
  });
32
31
  }
33
32
  onDestroy() {
34
33
  super.onDestroy(), this.originalPriceContents.clear();
35
34
  }
36
35
  onTemplateNodeUpdated(e) {
37
- super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
38
- () => {
39
- const t = B(this.currentNode);
40
- t && this.store.setCurrencySymbol(t.priceCurrencySymbol || "");
41
- },
42
- () => {
43
- this.api.updateValues({ [m.CURRENCY_SYMBOL]: this.store.currencySymbol }), this._storeOriginalContents();
44
- }
45
- );
36
+ super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
37
+ const t = p(this.currentNode);
38
+ this.api.updateValues({ [u.CURRENCY_SYMBOL]: (t == null ? void 0 : t.priceCurrencySymbol) ?? "" }), this._storeOriginalContents();
39
+ });
46
40
  }
47
41
  _onCurrencySymbolChange(e) {
48
- var i;
42
+ var a;
49
43
  console.debug("Currency symbol changed to: ", e);
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)
44
+ const t = p(this.currentNode), o = ((a = t == null ? void 0 : t.priceCurrencySymbol) == null ? void 0 : a.trim()) || "";
45
+ if (x(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
52
46
  return;
53
47
  const r = this._getPriceBlocks();
54
48
  if (!r || r.length === 0)
55
49
  return;
56
- const o = (e == null ? void 0 : e.trim()) || "", { currencyLocation: n } = this.store;
57
- r.forEach((l) => {
58
- const a = this._getParagraph(l);
59
- if (!a)
50
+ const n = (e == null ? void 0 : e.trim()) || "", l = (t == null ? void 0 : t.priceCurrencyLocation) ?? "0", i = this.api.getDocumentModifier();
51
+ r.forEach((d) => {
52
+ const m = this._getParagraph(d);
53
+ if (!m)
60
54
  return;
61
- const y = a.getInnerHTML() || "", p = a.getInnerText() || "", C = this._removeCurrencySymbol(p, t), g = this._buildPriceContent(C, o, n), d = y.replace(p, g);
62
- this.api.getDocumentModifier().modifyHtml(a).setInnerHtml(d).apply(new b(
63
- `Updated currency symbol to ${o || "removed"}`
64
- ));
65
- });
55
+ const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, f(S));
56
+ i.modifyHtml(m).setInnerHtml(b);
57
+ }), i.apply(new B(
58
+ `Updated currency symbol to ${n || "removed"}`
59
+ ));
66
60
  }
67
61
  _storeOriginalContents() {
68
62
  if (!this.currentNode)
69
63
  return;
64
+ const e = p(this.currentNode);
70
65
  this.currentNode.querySelectorAll(
71
66
  ".items-block-price"
72
- ).forEach((t) => {
73
- var o;
74
- const r = t.querySelector("p");
67
+ ).forEach((o) => {
68
+ var n;
69
+ const r = o.querySelector("p");
75
70
  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);
71
+ const l = r.getInnerText() || "", i = ((n = e == null ? void 0 : e.priceCurrencySymbol) == null ? void 0 : n.trim()) || "", a = this._removeCurrencySymbol(l, i);
72
+ this.originalPriceContents.set(r, a);
78
73
  }
79
74
  });
80
75
  }
@@ -89,29 +84,29 @@ class M extends R {
89
84
  return e.replace(/[-\\^$*+?().|[\]{}]/g, "\\$&");
90
85
  }
91
86
  _removeCurrencySymbol(e, t) {
92
- const r = e || "";
93
- let o = r;
87
+ const o = e || "";
88
+ let r = o;
94
89
  if (t) {
95
90
  const n = new RegExp(`\\s*${this._escapeRegex(t)}\\s*`);
96
- o = r.replace(n, "").trim();
91
+ r = o.replace(n, "").trim();
97
92
  } else {
98
- const n = r.match(/([^0-9.,\s]+)/);
93
+ const n = o.match(/([^0-9.,\s]+)/);
99
94
  if (n && n[1]) {
100
- const i = n[1].trim(), l = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
101
- o = r.replace(l, "").trim();
95
+ const l = n[1].trim(), i = new RegExp(`\\s*${this._escapeRegex(l)}\\s*`);
96
+ r = o.replace(i, "").trim();
102
97
  }
103
98
  }
104
- return o;
99
+ return r;
105
100
  }
106
- _buildPriceContent(e, t, r) {
107
- return t ? r === "1" ? `${e}&nbsp;${t}` : `${t}&nbsp;${e}` : e;
101
+ _buildPriceContent(e, t, o) {
102
+ return t ? o === "1" ? `${e}&nbsp;${t}` : `${t}&nbsp;${e}` : e;
108
103
  }
109
104
  _getCurrencySymbol() {
110
105
  return `
111
106
  ${this._GuTwoColumns([
112
107
  this._GuLabel({ text: "Currency Symbol" }),
113
108
  this._GuTextInput({
114
- name: m.CURRENCY_SYMBOL,
109
+ name: u.CURRENCY_SYMBOL,
115
110
  placeholder: "Enter Currency Symbol",
116
111
  className: "es-180w"
117
112
  })
@@ -120,6 +115,6 @@ class M extends R {
120
115
  }
121
116
  }
122
117
  export {
123
- E as CONTROL_BLOCK_ID,
124
- M as PriceCurrencySymbolControl
118
+ I as CONTROL_BLOCK_ID,
119
+ P as PriceCurrencySymbolControl
125
120
  };
@@ -1,82 +1,73 @@
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";
1
+ import { ModificationDescription as L, UIElementType as P, UEAttr as D } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
2
  import { CommonControl as h } from "../../../common-control.js";
6
- import { ItemsBlockControlId as l, ItemsBlockId as D } from "../../enums/controlEnums.js";
3
+ import { ItemsBlockControlId as R, ItemsBlockId as _ } from "../../enums/controlEnums.js";
7
4
  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 = {
5
+ import { getItemsBlockConfig as d, setItemsBlockConfig as u, escapeReplacement as O } from "../../utils/nodeConfigUtils.js";
6
+ const g = R.PRICE_FORMATTED_PRICE, s = {
11
7
  FORMATTED_PRICE: "formattedPrice"
12
8
  };
13
- class y extends h {
14
- constructor() {
15
- super(...arguments);
16
- _(this, "store", O());
17
- }
9
+ class k extends h {
18
10
  getId() {
19
- return N;
11
+ return g;
20
12
  }
21
13
  getTemplate() {
22
14
  return `
23
- <div class="container ${l.PRICE_FORMATTED_PRICE}">
15
+ <div class="container ${R.PRICE_FORMATTED_PRICE}">
24
16
  ${this._getFormattedPrice()}
25
17
  </div>
26
18
  `;
27
19
  }
28
20
  onRender() {
29
- this.api.updateValues({ [c.FORMATTED_PRICE]: this.store.formattedPrice }), this.api.onValueChanged(c.FORMATTED_PRICE, (e) => {
21
+ const t = d(this.currentNode);
22
+ this.api.updateValues({ [s.FORMATTED_PRICE]: (t == null ? void 0 : t.priceFormatted) ?? !0 }), this.api.onValueChanged(s.FORMATTED_PRICE, (e) => {
30
23
  this._onFormattedPriceChange(e);
31
24
  });
32
25
  }
33
- onTemplateNodeUpdated(e) {
34
- super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
35
- () => {
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 });
41
- }
42
- );
26
+ onTemplateNodeUpdated(t) {
27
+ super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
28
+ const e = d(this.currentNode);
29
+ this.api.updateValues({ [s.FORMATTED_PRICE]: (e == null ? void 0 : e.priceFormatted) ?? !0 });
30
+ });
43
31
  }
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)
32
+ _onFormattedPriceChange(t) {
33
+ if (console.debug("Formatted price changed to: ", t), u(this.currentNode, this.api, { priceFormatted: t }), !this.currentNode)
46
34
  return;
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
35
+ const e = d(this.currentNode), n = (e == null ? void 0 : e.type) ?? "CART_ITEMS", i = (e == null ? void 0 : e.priceSinglePrice) ?? !1, r = I.PAIRS_FOR_EXTENSION.price[n], c = I.PAIRS_FOR_EXTENSION.originalPrice[n], [p, m] = t ? [
36
+ i ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE,
37
+ i ? r.DEFAULT_SINGLE_PRICE_FORMATTED : r.DEFAULT_PRICE_FORMATTED
50
38
  ] : [
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];
54
- this._updatePriceBlock(
55
- this.currentNode,
56
- E,
57
- R,
58
- "price"
59
- );
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");
39
+ i ? r.DEFAULT_SINGLE_PRICE_FORMATTED : r.DEFAULT_PRICE_FORMATTED,
40
+ i ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE
41
+ ], l = i ? c.DEFAULT_SINGLE_PRICE : c.DEFAULT_PRICE, T = i ? c.DEFAULT_SINGLE_PRICE_FORMATTED : c.DEFAULT_PRICE_FORMATTED, [F, A] = t ? [l, T] : [T, l], o = this.currentNode.closest(".items-block"), C = (o == null ? void 0 : o.querySelectorAll(
42
+ `[esd-extension-block-id="${_.PRICE}"]`
43
+ )) || [], E = this.api.getDocumentModifier();
44
+ C.forEach((a) => {
45
+ this._updatePriceBlock(E, a, p, m);
46
+ }), ((o == null ? void 0 : o.querySelectorAll(
47
+ `[esd-extension-block-id="${_.ORIGINAL_PRICE}"]`
48
+ )) || []).forEach((a) => {
49
+ this._updatePriceBlock(E, a, F, A);
50
+ }), E.apply(new L(
51
+ `Updated price to ${t ? "formatted" : "unformatted"}`
52
+ ));
62
53
  }
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));
54
+ _updatePriceBlock(t, e, n, i) {
55
+ const r = e.getInnerHTML().trim().replace(n, O(i));
56
+ t.modifyHtml(e).setInnerHtml(r);
66
57
  }
67
58
  _getFormattedPrice() {
68
59
  return `
69
60
  <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)")}"
61
+ <${P.LABEL}
62
+ ${D.LABEL.text}="${this.api.translate("Formatted Price (e.g. $9.90)")}"
72
63
  >
73
- </${m.LABEL}>
74
- ${this._GuToggle(c.FORMATTED_PRICE)}
64
+ </${P.LABEL}>
65
+ ${this._GuToggle(s.FORMATTED_PRICE)}
75
66
  </div>
76
67
  `;
77
68
  }
78
69
  }
79
70
  export {
80
- N as CONTROL_BLOCK_ID,
81
- y as PriceFormattedPriceControl
71
+ g as CONTROL_BLOCK_ID,
72
+ k as PriceFormattedPriceControl
82
73
  };
@@ -1,63 +1,50 @@
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
- import { CommonControl as u } from "../../../common-control.js";
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 = {
1
+ import { UIElementType as o, UEAttr as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as r } from "../../../common-control.js";
3
+ import { ItemsBlockControlId as n } from "../../enums/controlEnums.js";
4
+ import { getItemsBlockConfig as s, setItemsBlockConfig as a } from "../../utils/nodeConfigUtils.js";
5
+ const c = n.PRICE_HIDE_DISCOUNT, i = {
10
6
  HIDE_DISCOUNT: "hideDiscount"
11
7
  };
12
- class T extends u {
13
- constructor() {
14
- super(...arguments);
15
- n(this, "store", I());
16
- }
8
+ class C extends r {
17
9
  getId() {
18
- return l;
10
+ return c;
19
11
  }
20
12
  getTemplate() {
21
13
  return `
22
- <div class="container ${d.PRICE_HIDE_DISCOUNT}">
14
+ <div class="container ${n.PRICE_HIDE_DISCOUNT}">
23
15
  ${this._getHideDiscount()}
24
16
  </div>
25
17
  `;
26
18
  }
27
19
  onRender() {
28
- this.api.updateValues({ [s.HIDE_DISCOUNT]: this.store.hideDiscount }), this.api.onValueChanged(s.HIDE_DISCOUNT, (t) => {
20
+ const e = s(this.currentNode);
21
+ this.api.updateValues({ [i.HIDE_DISCOUNT]: (e == null ? void 0 : e.priceHideDiscount) ?? !0 }), this.api.onValueChanged(i.HIDE_DISCOUNT, (t) => {
29
22
  this._onHideDiscountChange(t);
30
23
  });
31
24
  }
32
- onTemplateNodeUpdated(t) {
33
- super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(
34
- () => {
35
- const o = p(this.currentNode);
36
- o && this.store.setHideDiscount(o.priceHideDiscount ?? !0);
37
- },
38
- () => {
39
- this.api.updateValues({ [s.HIDE_DISCOUNT]: this.store.hideDiscount });
40
- }
41
- );
25
+ onTemplateNodeUpdated(e) {
26
+ super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
27
+ const t = s(this.currentNode);
28
+ this.api.updateValues({ [i.HIDE_DISCOUNT]: (t == null ? void 0 : t.priceHideDiscount) ?? !0 });
29
+ });
42
30
  }
43
- _onHideDiscountChange(t) {
44
- this.store.setHideDiscount(t), h(this.currentNode, this.api, { priceHideDiscount: t }), this.api.updateValues({ [s.HIDE_DISCOUNT]: t });
31
+ _onHideDiscountChange(e) {
32
+ a(this.currentNode, this.api, { priceHideDiscount: e }), this.api.updateValues({ [i.HIDE_DISCOUNT]: e });
45
33
  }
46
34
  _getHideDiscount() {
47
35
  return `
48
-
49
36
  <div class="display-flex align-items-center justify-content-between">
50
- <${r.LABEL}
51
- ${D.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
37
+ <${o.LABEL}
38
+ ${d.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
52
39
  >
53
- </${r.LABEL}>
54
- ${this._GuToggle(s.HIDE_DISCOUNT)}
40
+ </${o.LABEL}>
41
+ ${this._GuToggle(i.HIDE_DISCOUNT)}
55
42
  </div>
56
43
  </div>
57
44
  `;
58
45
  }
59
46
  }
60
47
  export {
61
- l as CONTROL_BLOCK_ID,
62
- T as PriceHideDiscountControl
48
+ c as CONTROL_BLOCK_ID,
49
+ C as PriceHideDiscountControl
63
50
  };