@useinsider/guido 3.24.0-beta.0abeefe → 3.24.0-beta.0c16173

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 (121) hide show
  1. package/README.md +7 -2
  2. package/dist/@types/config/schemas.js +40 -40
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +81 -85
  5. package/dist/composables/useActionsApi.js +2 -2
  6. package/dist/composables/useBlocksConfig.js +20 -31
  7. package/dist/composables/useEditorTrackingIds.js +49 -0
  8. package/dist/composables/useHtmlCompiler.js +2 -0
  9. package/dist/composables/useModuleRepair.js +14 -12
  10. package/dist/composables/useStripo.js +70 -70
  11. package/dist/composables/useTranslations.js +1 -2
  12. package/dist/config/compiler/htmlCompilerRules.js +14 -6
  13. package/dist/config/compiler/utils/itemsCompilerUtils.js +42 -43
  14. package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -67
  15. package/dist/config/migrator/index.js +16 -15
  16. package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
  17. package/dist/enums/academy.js +0 -1
  18. package/dist/extensions/Blocks/Items/block.js +115 -77
  19. package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
  20. package/dist/extensions/Blocks/Items/controls/blockBackground/index.js +11 -0
  21. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -23
  22. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
  23. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
  24. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
  25. package/dist/extensions/Blocks/Items/controls/priceFormat.js +135 -0
  26. package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
  27. package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
  28. package/dist/extensions/Blocks/Items/extension.js +15 -13
  29. package/dist/extensions/Blocks/Items/items.css.js +19 -0
  30. package/dist/extensions/Blocks/Items/settingsPanel.js +35 -25
  31. package/dist/extensions/Blocks/Items/template.js +250 -212
  32. package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
  33. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
  34. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
  35. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
  36. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
  37. package/dist/extensions/Blocks/controlFactories.js +104 -104
  38. package/dist/guido.css +1 -1
  39. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +92 -93
  40. package/dist/node_modules/valibot/dist/index.js +261 -297
  41. package/dist/package.json.js +6 -6
  42. package/dist/services/templateLibraryApi.js +39 -36
  43. package/dist/src/@types/config/schemas.d.ts +4 -4
  44. package/dist/src/composables/useConfig.d.ts +2 -2
  45. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  46. package/dist/src/composables/useStripo.d.ts +1 -1
  47. package/dist/src/config/migrator/index.d.ts +4 -1
  48. package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
  49. package/dist/src/enums/academy.d.ts +0 -1
  50. package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
  51. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
  52. package/dist/src/extensions/Blocks/Items/controls/blockBackground/index.d.ts +15 -0
  53. package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +24 -0
  54. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
  55. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +2 -0
  56. package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
  57. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
  58. package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +66 -0
  59. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  60. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
  61. package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -1
  62. package/dist/src/stores/config.d.ts +20 -167
  63. package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
  64. package/dist/src/utils/linkTrackingIds.d.ts +24 -22
  65. package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
  66. package/dist/stores/config.js +6 -13
  67. package/dist/utils/itemsCurrencyRepair.js +29 -24
  68. package/dist/utils/linkTrackingIds.js +72 -72
  69. package/dist/utils/pairProductVariables.js +119 -100
  70. package/dist/utils/templatePreparation.js +59 -72
  71. package/dist/utils/trimHrefWhitespace.js +10 -0
  72. package/package.json +1 -1
  73. package/dist/@types/display-condition.js +0 -25
  74. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +0 -17
  75. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +0 -41
  76. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +0 -30
  77. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +0 -81
  78. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue.js +0 -17
  79. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue2.js +0 -45
  80. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +0 -36
  81. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +0 -63
  82. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +0 -17
  83. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +0 -22
  84. package/dist/composables/useDisplayConditions.js +0 -117
  85. package/dist/enums/display-condition.js +0 -12
  86. package/dist/extensions/DisplayConditions/bridge.js +0 -25
  87. package/dist/extensions/DisplayConditions/constants.js +0 -26
  88. package/dist/extensions/DisplayConditions/control.js +0 -215
  89. package/dist/extensions/DisplayConditions/display-conditions.css.js +0 -226
  90. package/dist/extensions/DisplayConditions/extension.js +0 -28
  91. package/dist/extensions/DisplayConditions/iconsRegistry.js +0 -20
  92. package/dist/extensions/DisplayConditions/library.js +0 -30
  93. package/dist/extensions/DisplayConditions/settingsPanel.js +0 -17
  94. package/dist/extensions/LinkTracking/extension.js +0 -17
  95. package/dist/extensions/LinkTracking/writer.js +0 -41
  96. package/dist/services/displayConditionApi.js +0 -39
  97. package/dist/src/@types/display-condition.d.ts +0 -60
  98. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +0 -43
  99. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +0 -2
  100. package/dist/src/components/organisms/display-conditions/DisplayConditionListState.vue.d.ts +0 -18
  101. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +0 -2
  102. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +0 -2
  103. package/dist/src/composables/useDisplayConditions.d.ts +0 -18
  104. package/dist/src/enums/display-condition.d.ts +0 -15
  105. package/dist/src/extensions/DisplayConditions/bridge.d.ts +0 -7
  106. package/dist/src/extensions/DisplayConditions/constants.d.ts +0 -23
  107. package/dist/src/extensions/DisplayConditions/control.d.ts +0 -25
  108. package/dist/src/extensions/DisplayConditions/extension.d.ts +0 -2
  109. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +0 -4
  110. package/dist/src/extensions/DisplayConditions/library.d.ts +0 -8
  111. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +0 -5
  112. package/dist/src/extensions/LinkTracking/extension.d.ts +0 -2
  113. package/dist/src/extensions/LinkTracking/writer.d.ts +0 -13
  114. package/dist/src/mock/api/display-conditions.d.ts +0 -2
  115. package/dist/src/services/displayConditionApi.d.ts +0 -8
  116. package/dist/src/stores/display-condition.d.ts +0 -84
  117. package/dist/src/utils/displayCondition.d.ts +0 -11
  118. package/dist/src/utils/protectTableText.d.ts +0 -2
  119. package/dist/stores/display-condition.js +0 -29
  120. package/dist/utils/displayCondition.js +0 -26
  121. package/dist/utils/protectTableText.js +0 -22
@@ -1,25 +1,70 @@
1
1
  import { DefaultConfigValues as c } from "../enums/settingsEnums.js";
2
- const s = {
2
+ const n = {
3
3
  POSITION: "data-curency",
4
4
  SYMBOL: "data-currency_symbol"
5
5
  };
6
- function e(r) {
7
- return r === "1" ? "after" : "before";
6
+ function u(t) {
7
+ return t === "1" ? "after" : "before";
8
8
  }
9
- function i(r) {
10
- const o = (r ?? "").trim();
11
- return o !== "" && o !== c.productPriceCurrencySymbolControlValue;
9
+ function i(t) {
10
+ const r = (t ?? "").trim();
11
+ return r !== "" && r !== c.productPriceCurrencySymbolControlValue;
12
12
  }
13
- function a(r) {
14
- const o = r.priceCurrencyLocation, n = typeof o == "string" && o.trim() !== "", t = (r.priceCurrencySymbol ?? "").trim();
13
+ function p(t) {
14
+ const r = t.priceCurrencyLocation, e = typeof r == "string" && r.trim() !== "", a = (t.priceCurrencySymbol ?? "").trim();
15
15
  return {
16
- position: n ? e(o) : void 0,
17
- symbol: i(t) ? t : void 0
16
+ position: e ? u(r) : void 0,
17
+ symbol: i(a) ? a : void 0
18
18
  };
19
19
  }
20
+ const s = {
21
+ SYMBOL: "currency-symbol",
22
+ ALIGNMENT: "currency-alignment",
23
+ THOUSAND_SEPARATOR: "currency-thousand-separator",
24
+ DECIMAL_SEPARATOR: "currency-decimal-separator",
25
+ DECIMAL_COUNT: "currency-decimal-count",
26
+ SINGLE_PRICE: "data-single_price"
27
+ }, C = [
28
+ "data-formated",
29
+ "data-single_price",
30
+ n.POSITION,
31
+ n.SYMBOL
32
+ ], o = {
33
+ thousandSeparator: ",",
34
+ decimalSeparator: ".",
35
+ decimalCount: 2
36
+ };
37
+ function m(t) {
38
+ const r = typeof t == "string" ? parseInt(t) : t;
39
+ return typeof r == "number" && Number.isFinite(r) && r >= 0 ? Math.trunc(r) : o.decimalCount;
40
+ }
41
+ function d(t) {
42
+ const r = t == null ? void 0 : t.priceThousandSeparator, e = t == null ? void 0 : t.priceDecimalSeparator;
43
+ return {
44
+ thousandSeparator: typeof r == "string" && r !== "" ? r : o.thousandSeparator,
45
+ decimalSeparator: typeof e == "string" && e !== "" ? e : o.decimalSeparator,
46
+ decimalCount: (t == null ? void 0 : t.priceDecimalCount) === void 0 ? o.decimalCount : m(t.priceDecimalCount)
47
+ };
48
+ }
49
+ function y(t) {
50
+ return typeof (t == null ? void 0 : t.priceDecimalCount) == "number";
51
+ }
52
+ function S(t) {
53
+ if (!t || typeof t.getAttribute != "function")
54
+ return !1;
55
+ const r = t.getAttribute(s.DECIMAL_COUNT);
56
+ return r != null;
57
+ }
20
58
  export {
21
- s as ITEMS_CURRENCY_ATTR,
22
- a as currencyAttrTargets,
23
- e as currencyPositionFromLocation,
24
- i as isCustomCurrencySymbol
59
+ o as DEFAULT_ITEMS_PRICE_FORMAT,
60
+ n as ITEMS_CURRENCY_ATTR,
61
+ s as ITEMS_PRICE_FORMAT_ATTR,
62
+ C as LEGACY_PRICE_PARAGRAPH_ATTRS,
63
+ p as currencyAttrTargets,
64
+ u as currencyPositionFromLocation,
65
+ i as isCustomCurrencySymbol,
66
+ y as isNewPriceFormatConfig,
67
+ S as isNewPriceFormatRoot,
68
+ m as normalizeDecimalCount,
69
+ d as priceFormatFromConfig
25
70
  };
@@ -0,0 +1,11 @@
1
+ import { createBlockBackgroundColorControl as o } from "../../../controlFactories.js";
2
+ import { ItemsBlockControlId as r } from "../../enums/controlEnums.js";
3
+ import { ITEMS_BLOCK_SELECTOR as t } from "../../utils/constants.js";
4
+ const l = o(
5
+ r.BLOCK_BACKGROUND,
6
+ t,
7
+ "Background Color"
8
+ );
9
+ export {
10
+ l as ItemsBlockBackgroundControl
11
+ };
@@ -1,48 +1,59 @@
1
- import { currencyLocationMaps as m } from "../../../../../enums/extensions/recommendationBlock.js";
2
- import { UEAttr as I, 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 { ITEMS_CURRENCY_ATTR as T, currencyPositionFromLocation as E } from "../../constants/currency.js";
5
- import { ItemsBlockControlId as p } from "../../enums/controlEnums.js";
6
- import { getItemsBlockConfig as u, setItemsBlockConfig as O, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
7
- const b = p.PRICE_CURRENCY_LOCATION, a = {
1
+ import { currencyLocationMaps as u } from "../../../../../enums/extensions/recommendationBlock.js";
2
+ import { UEAttr as I, ModificationDescription as T } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ import { CommonControl as E } from "../../../common-control.js";
4
+ import { ITEMS_CURRENCY_ATTR as f, currencyPositionFromLocation as h } from "../../constants/currency.js";
5
+ import { ItemsBlockControlId as d } from "../../enums/controlEnums.js";
6
+ import { getItemsBlockConfig as C, setItemsBlockConfig as O, escapeReplacement as P } from "../../utils/nodeConfigUtils.js";
7
+ import { isNewPriceFormatBlock as b, applyPriceFormatChange as U } from "../priceFormat.js";
8
+ const x = d.PRICE_CURRENCY_LOCATION, a = {
8
9
  CURRENCY_LOCATION: "currencyLocation"
9
10
  };
10
- class B extends N {
11
+ class H extends E {
11
12
  getId() {
12
- return b;
13
+ return x;
13
14
  }
14
15
  getTemplate() {
15
16
  return `
16
- <div class="container ${p.PRICE_CURRENCY_LOCATION}">
17
+ <div class="container ${d.PRICE_CURRENCY_LOCATION}">
17
18
  ${this._getCurrencyLocation()}
18
19
  </div>
19
20
  `;
20
21
  }
21
22
  onRender() {
22
- this.forgetLastPanelNode(), this.api.setUIEAttribute(a.CURRENCY_LOCATION, I.SELECTPICKER.items, m), this.api.onValueChanged(a.CURRENCY_LOCATION, (e) => {
23
+ this.forgetLastPanelNode(), this.api.onValueChanged(a.CURRENCY_LOCATION, (e) => {
23
24
  this._onCurrencyLocationChange(e);
24
25
  });
25
26
  }
26
27
  onTemplateNodeUpdated(e) {
27
28
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
28
- const t = u(this.currentNode);
29
- this.api.updateValues({ [a.CURRENCY_LOCATION]: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0" });
29
+ const t = C(this.currentNode);
30
+ this.api.setUIEAttribute(a.CURRENCY_LOCATION, I.SELECTPICKER.items, u), this.api.updateValues({ [a.CURRENCY_LOCATION]: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0" });
30
31
  });
31
32
  }
32
33
  _onCurrencyLocationChange(e) {
33
- if (console.debug("Currency location changed to: ", e), O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
34
+ var l;
35
+ if (console.debug("Currency location changed to: ", e), b(this.currentNode)) {
36
+ ((l = C(this.currentNode)) == null ? void 0 : l.priceCurrencyLocation) !== e && U(
37
+ this.currentNode,
38
+ this.api,
39
+ { priceCurrencyLocation: e },
40
+ `Updated currency location to ${h(e)}`
41
+ );
42
+ return;
43
+ }
44
+ if (O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
34
45
  return;
35
46
  const t = this._getPriceBlocks();
36
47
  if (!t || t.length === 0)
37
48
  return;
38
- const r = u(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", c = E(n), i = this.api.getDocumentModifier();
39
- t.forEach((h) => {
40
- const s = this._getParagraph(h);
49
+ const r = C(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", c = h(n), i = this.api.getDocumentModifier();
50
+ t.forEach((g) => {
51
+ const s = this._getParagraph(g);
41
52
  if (!s)
42
53
  return;
43
- const d = s.getInnerHTML().trim() || "", l = s.getInnerText().trim() || "", C = (o == null ? void 0 : o.trim()) || "", g = this._removeCurrencySymbol(l, C), _ = this._detectSymbolInText(l) || C, y = this._buildPriceContent(g, _, n), R = d.replace(l, f(y));
44
- i.modifyHtml(s).setInnerHtml(R).setAttribute(T.POSITION, c);
45
- }), i.apply(new L(
54
+ const _ = s.getInnerHTML().trim() || "", p = s.getInnerText().trim() || "", m = (o == null ? void 0 : o.trim()) || "", y = this._removeCurrencySymbol(p, m), N = this._detectSymbolInText(p) || m, L = this._buildPriceContent(y, N, n), R = _.replace(p, P(L));
55
+ i.modifyHtml(s).setInnerHtml(R).setAttribute(f.POSITION, c);
56
+ }), i.apply(new T(
46
57
  `Updated currency location to ${c}`
47
58
  ));
48
59
  }
@@ -85,13 +96,13 @@ class B extends N {
85
96
  this._GuSelect({
86
97
  name: a.CURRENCY_LOCATION,
87
98
  placeholder: "",
88
- options: m
99
+ options: u
89
100
  })
90
101
  ])}
91
102
  `;
92
103
  }
93
104
  }
94
105
  export {
95
- b as CONTROL_BLOCK_ID,
96
- B as PriceCurrencyLocationControl
106
+ x as CONTROL_BLOCK_ID,
107
+ H as PriceCurrencyLocationControl
97
108
  };
@@ -1,25 +1,28 @@
1
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 E } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as f } from "../../../common-control.js";
6
- import { ITEMS_CURRENCY_ATTR as B } from "../../constants/currency.js";
7
- import { ItemsBlockControlId as y } from "../../enums/controlEnums.js";
8
- import { getItemsBlockConfig as p, setItemsBlockConfig as T, escapeReplacement as x } from "../../utils/nodeConfigUtils.js";
9
- const I = y.PRICE_CURRENCY_SYMBOL, u = {
2
+ var f = (i, c, e) => c in i ? R(i, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[c] = e;
3
+ var y = (i, c, e) => f(i, typeof c != "symbol" ? c + "" : c, e);
4
+ import { useConfig as E } from "../../../../../composables/useConfig.js";
5
+ import { ModificationDescription as B } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { CommonControl as P } from "../../../common-control.js";
7
+ import { ITEMS_CURRENCY_ATTR as T } from "../../constants/currency.js";
8
+ import { ItemsBlockControlId as d } from "../../enums/controlEnums.js";
9
+ import { getItemsBlockConfig as p, setItemsBlockConfig as x, escapeReplacement as I } from "../../utils/nodeConfigUtils.js";
10
+ import { isNewPriceFormatBlock as L, applyPriceFormatChange as M } from "../priceFormat.js";
11
+ const Y = d.PRICE_CURRENCY_SYMBOL, u = {
10
12
  CURRENCY_SYMBOL: "currencySymbol"
11
13
  };
12
- class $ extends f {
14
+ class A extends P {
13
15
  constructor() {
14
16
  super(...arguments);
15
- h(this, "originalPriceContents", /* @__PURE__ */ new Map());
17
+ y(this, "originalPriceContents", /* @__PURE__ */ new Map());
16
18
  }
17
19
  getId() {
18
- return I;
20
+ return Y;
19
21
  }
20
22
  getTemplate() {
23
+ const e = E().isFeatureEnabled("itemsPriceFormatting") ? " no-separator" : "";
21
24
  return `
22
- <div class="container ${y.PRICE_CURRENCY_SYMBOL}">
25
+ <div class="container ${d.PRICE_CURRENCY_SYMBOL}${e}">
23
26
  ${this._getCurrencySymbol()}
24
27
  </div>
25
28
  `;
@@ -34,28 +37,36 @@ class $ extends f {
34
37
  }
35
38
  onTemplateNodeUpdated(e) {
36
39
  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();
40
+ const r = p(this.currentNode);
41
+ this.api.updateValues({ [u.CURRENCY_SYMBOL]: (r == null ? void 0 : r.priceCurrencySymbol) ?? "" }), this._storeOriginalContents();
39
42
  });
40
43
  }
41
44
  _onCurrencySymbolChange(e) {
42
- var a;
43
- console.debug("Currency symbol changed to: ", e);
44
- const t = p(this.currentNode), o = ((a = t == null ? void 0 : t.priceCurrencySymbol) == null ? void 0 : a.trim()) || "";
45
- if (T(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
45
+ var m, C;
46
+ if (console.debug("Currency symbol changed to: ", e), L(this.currentNode)) {
47
+ ((m = p(this.currentNode)) == null ? void 0 : m.priceCurrencySymbol) !== e && M(
48
+ this.currentNode,
49
+ this.api,
50
+ { priceCurrencySymbol: e },
51
+ `Updated currency symbol to ${(e == null ? void 0 : e.trim()) || "removed"}`
52
+ );
46
53
  return;
47
- const r = this._getPriceBlocks();
48
- if (!r || r.length === 0)
54
+ }
55
+ const r = p(this.currentNode), n = ((C = r == null ? void 0 : r.priceCurrencySymbol) == null ? void 0 : C.trim()) || "";
56
+ if (x(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
57
+ return;
58
+ const t = this._getPriceBlocks();
59
+ if (!t || t.length === 0)
49
60
  return;
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)
61
+ const o = (e == null ? void 0 : e.trim()) || "", a = (r == null ? void 0 : r.priceCurrencyLocation) ?? "0", s = this.api.getDocumentModifier();
62
+ t.forEach((g) => {
63
+ const l = this._getParagraph(g);
64
+ if (!l)
54
65
  return;
55
- const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, x(S));
56
- i.modifyHtml(m).setInnerHtml(b).setAttribute(B.SYMBOL, n);
57
- }), i.apply(new E(
58
- `Updated currency symbol to ${n || "removed"}`
66
+ const S = l.getInnerHTML().trim() || "", h = l.getInnerText().trim() || "", _ = this._removeCurrencySymbol(h, n), b = this._buildPriceContent(_, o, a), N = S.replace(h, I(b));
67
+ s.modifyHtml(l).setInnerHtml(N).setAttribute(T.SYMBOL, o);
68
+ }), s.apply(new B(
69
+ `Updated currency symbol to ${o || "removed"}`
59
70
  ));
60
71
  }
61
72
  _storeOriginalContents() {
@@ -64,18 +75,18 @@ class $ extends f {
64
75
  const e = p(this.currentNode);
65
76
  this.currentNode.querySelectorAll(
66
77
  ".items-block-price"
67
- ).forEach((o) => {
68
- var n;
69
- const r = o.querySelector("p");
70
- if (r && !this.originalPriceContents.has(r)) {
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
+ ).forEach((n) => {
79
+ var o;
80
+ const t = n.querySelector("p");
81
+ if (t && !this.originalPriceContents.has(t)) {
82
+ const a = t.getInnerText() || "", s = ((o = e == null ? void 0 : e.priceCurrencySymbol) == null ? void 0 : o.trim()) || "", m = this._removeCurrencySymbol(a, s);
83
+ this.originalPriceContents.set(t, m);
73
84
  }
74
85
  });
75
86
  }
76
87
  _getPriceBlocks() {
77
- var e, t;
78
- return ((t = (e = this.currentNode) == null ? void 0 : e.closest(".items-block")) == null ? void 0 : t.querySelectorAll(".items-block-price")) || [];
88
+ var e, r;
89
+ return ((r = (e = this.currentNode) == null ? void 0 : e.closest(".items-block")) == null ? void 0 : r.querySelectorAll(".items-block-price")) || [];
79
90
  }
80
91
  _getParagraph(e) {
81
92
  return e.querySelector("p");
@@ -83,23 +94,23 @@ class $ extends f {
83
94
  _escapeRegex(e) {
84
95
  return e.replace(/[-\\^$*+?().|[\]{}]/g, "\\$&");
85
96
  }
86
- _removeCurrencySymbol(e, t) {
87
- const o = e || "";
88
- let r = o;
89
- if (t) {
90
- const n = new RegExp(`\\s*${this._escapeRegex(t)}\\s*`);
91
- r = o.replace(n, "").trim();
97
+ _removeCurrencySymbol(e, r) {
98
+ const n = e || "";
99
+ let t = n;
100
+ if (r) {
101
+ const o = new RegExp(`\\s*${this._escapeRegex(r)}\\s*`);
102
+ t = n.replace(o, "").trim();
92
103
  } else {
93
- const n = o.match(/([^0-9.,\s]+)/);
94
- if (n && n[1]) {
95
- const l = n[1].trim(), i = new RegExp(`\\s*${this._escapeRegex(l)}\\s*`);
96
- r = o.replace(i, "").trim();
104
+ const o = n.match(/([^0-9.,\s]+)/);
105
+ if (o && o[1]) {
106
+ const a = o[1].trim(), s = new RegExp(`\\s*${this._escapeRegex(a)}\\s*`);
107
+ t = n.replace(s, "").trim();
97
108
  }
98
109
  }
99
- return r;
110
+ return t;
100
111
  }
101
- _buildPriceContent(e, t, o) {
102
- return t ? o === "1" ? `${e}&nbsp;${t}` : `${t}&nbsp;${e}` : e;
112
+ _buildPriceContent(e, r, n) {
113
+ return r ? n === "1" ? `${e}&nbsp;${r}` : `${r}&nbsp;${e}` : e;
103
114
  }
104
115
  _getCurrencySymbol() {
105
116
  return `
@@ -115,6 +126,6 @@ class $ extends f {
115
126
  }
116
127
  }
117
128
  export {
118
- I as CONTROL_BLOCK_ID,
119
- $ as PriceCurrencySymbolControl
129
+ Y as CONTROL_BLOCK_ID,
130
+ A as PriceCurrencySymbolControl
120
131
  };
@@ -1,18 +1,19 @@
1
1
  import { ModificationDescription as C, UIElementType as T, UEAttr as L } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
2
  import { CommonControl as g } from "../../../common-control.js";
3
- import { ItemsBlockControlId as R, ItemsBlockId as _ } from "../../enums/controlEnums.js";
3
+ import { ItemsBlockControlId as p, ItemsBlockId as _ } from "../../enums/controlEnums.js";
4
4
  import { productPairs as I } from "../../enums/productEnums.js";
5
- import { getItemsBlockConfig as p, setItemsBlockConfig as D, escapeReplacement as h } from "../../utils/nodeConfigUtils.js";
6
- const O = R.PRICE_FORMATTED_PRICE, d = {
5
+ import { getItemsBlockConfig as m, setItemsBlockConfig as D, escapeReplacement as h } from "../../utils/nodeConfigUtils.js";
6
+ import { isNewPriceFormatBlock as O } from "../priceFormat.js";
7
+ const N = p.PRICE_FORMATTED_PRICE, d = {
7
8
  FORMATTED_PRICE: "formattedPrice"
8
9
  };
9
- class k extends g {
10
+ class G extends g {
10
11
  getId() {
11
- return O;
12
+ return N;
12
13
  }
13
14
  getTemplate() {
14
15
  return `
15
- <div class="container ${R.PRICE_FORMATTED_PRICE}">
16
+ <div class="container ${p.PRICE_FORMATTED_PRICE}">
16
17
  ${this._getFormattedPrice()}
17
18
  </div>
18
19
  `;
@@ -24,14 +25,14 @@ class k extends g {
24
25
  }
25
26
  onTemplateNodeUpdated(e) {
26
27
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
27
- const t = p(this.currentNode);
28
+ const t = m(this.currentNode);
28
29
  this.api.updateValues({ [d.FORMATTED_PRICE]: (t == null ? void 0 : t.priceFormatted) ?? !0 });
29
30
  });
30
31
  }
31
32
  _onFormattedPriceChange(e) {
32
- if (console.debug("Formatted price changed to: ", e), !this.currentNode)
33
+ if (console.debug("Formatted price changed to: ", e), !this.currentNode || O(this.currentNode))
33
34
  return;
34
- const t = p(this.currentNode), c = (t == null ? void 0 : t.type) ?? "CART_ITEMS", o = (t == null ? void 0 : t.priceSinglePrice) ?? !1, r = I.PAIRS_FOR_EXTENSION.price[c], i = I.PAIRS_FOR_EXTENSION.originalPrice[c], [a, m] = e ? [
35
+ const t = m(this.currentNode), n = (t == null ? void 0 : t.type) ?? "CART_ITEMS", o = (t == null ? void 0 : t.priceSinglePrice) ?? !1, r = I.PAIRS_FOR_EXTENSION.price[n], i = I.PAIRS_FOR_EXTENSION.originalPrice[n], [a, R] = e ? [
35
36
  o ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE,
36
37
  o ? r.DEFAULT_SINGLE_PRICE_FORMATTED : r.DEFAULT_PRICE_FORMATTED
37
38
  ] : [
@@ -39,12 +40,12 @@ class k extends g {
39
40
  o ? r.DEFAULT_SINGLE_PRICE : r.DEFAULT_PRICE
40
41
  ], l = o ? i.DEFAULT_SINGLE_PRICE : i.DEFAULT_PRICE, P = o ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_PRICE_FORMATTED, [F, A] = e ? [l, P] : [P, l], s = this.api.getDocumentModifier();
41
42
  D(this.currentNode, this.api, { priceFormatted: e }, s);
42
- const n = this.currentNode.closest(".items-block");
43
- ((n == null ? void 0 : n.querySelectorAll(
43
+ const c = this.currentNode.closest(".items-block");
44
+ ((c == null ? void 0 : c.querySelectorAll(
44
45
  `[esd-extension-block-id="${_.PRICE}"]`
45
46
  )) || []).forEach((E) => {
46
- this._updatePriceBlock(s, E, a, m, e);
47
- }), ((n == null ? void 0 : n.querySelectorAll(
47
+ this._updatePriceBlock(s, E, a, R, e);
48
+ }), ((c == null ? void 0 : c.querySelectorAll(
48
49
  `[esd-extension-block-id="${_.ORIGINAL_PRICE}"]`
49
50
  )) || []).forEach((E) => {
50
51
  this._updatePriceBlock(s, E, F, A, e);
@@ -52,8 +53,8 @@ class k extends g {
52
53
  `Updated price to ${e ? "formatted" : "unformatted"}`
53
54
  ));
54
55
  }
55
- _updatePriceBlock(e, t, c, o, r) {
56
- const i = `data-formated="${r ? "true" : "false"}"`, a = t.getInnerHTML().trim().replace(c, h(o)).replace(/data-formated=(?:"[^"]*"|'[^']*')/g, i);
56
+ _updatePriceBlock(e, t, n, o, r) {
57
+ const i = `data-formated="${r ? "true" : "false"}"`, a = t.getInnerHTML().trim().replace(n, h(o)).replace(/data-formated=(?:"[^"]*"|'[^']*')/g, i);
57
58
  e.modifyHtml(t).setInnerHtml(a);
58
59
  }
59
60
  _getFormattedPrice() {
@@ -69,6 +70,6 @@ class k extends g {
69
70
  }
70
71
  }
71
72
  export {
72
- O as CONTROL_BLOCK_ID,
73
- k as PriceFormattedPriceControl
73
+ N as CONTROL_BLOCK_ID,
74
+ G as PriceFormattedPriceControl
74
75
  };
@@ -1,74 +1,85 @@
1
- import { ModificationDescription as S, UIElementType as _, UEAttr as m } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CommonControl as A } from "../../../common-control.js";
3
- import { ItemsBlockControlId as T, ItemsBlockId as d } from "../../enums/controlEnums.js";
4
- import { productPairs as p } from "../../enums/productEnums.js";
5
- import { getItemsBlockConfig as g, setItemsBlockConfig as N, escapeReplacement as h } from "../../utils/nodeConfigUtils.js";
6
- const u = T.PRICE_SINGLE_PRICE, a = {
1
+ import { ModificationDescription as S, UIElementType as _, UEAttr as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as N } from "../../../common-control.js";
3
+ import { ItemsBlockControlId as L, ItemsBlockId as g } from "../../enums/controlEnums.js";
4
+ import { productPairs as T } from "../../enums/productEnums.js";
5
+ import { getItemsBlockConfig as a, setItemsBlockConfig as A, escapeReplacement as F } from "../../utils/nodeConfigUtils.js";
6
+ import { isNewPriceFormatBlock as u, applyPriceFormatChange as D } from "../priceFormat.js";
7
+ const f = L.PRICE_SINGLE_PRICE, P = {
7
8
  SINGLE_PRICE: "singlePrice"
8
9
  };
9
- class k extends A {
10
+ class x extends N {
10
11
  getId() {
11
- return u;
12
+ return f;
12
13
  }
13
14
  getTemplate() {
14
15
  return `
15
- <div class="container ${T.PRICE_SINGLE_PRICE}">
16
+ <div class="container ${L.PRICE_SINGLE_PRICE}">
16
17
  ${this._getSinglePrice()}
17
18
  </div>
18
19
  `;
19
20
  }
20
21
  onRender() {
21
- this.forgetLastPanelNode(), this.api.onValueChanged(a.SINGLE_PRICE, (e) => {
22
+ this.forgetLastPanelNode(), this.api.onValueChanged(P.SINGLE_PRICE, (e) => {
22
23
  this._onSinglePriceChange(e);
23
24
  });
24
25
  }
25
26
  onTemplateNodeUpdated(e) {
26
27
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
27
- const t = g(this.currentNode);
28
- this.api.updateValues({ [a.SINGLE_PRICE]: (t == null ? void 0 : t.priceSinglePrice) ?? !1 });
28
+ const i = a(this.currentNode);
29
+ this.api.updateValues({ [P.SINGLE_PRICE]: (i == null ? void 0 : i.priceSinglePrice) ?? !1 });
29
30
  });
30
31
  }
31
32
  _onSinglePriceChange(e) {
32
- if (console.debug("Single price changed to: ", e), !this.currentNode)
33
+ var I;
34
+ if (console.debug("Single price changed to: ", e), u(this.currentNode)) {
35
+ ((I = a(this.currentNode)) == null ? void 0 : I.priceSinglePrice) !== e && D(
36
+ this.currentNode,
37
+ this.api,
38
+ { priceSinglePrice: e },
39
+ `Updated price to ${e ? "single" : "total"} price`
40
+ );
33
41
  return;
34
- const t = g(this.currentNode), c = (t == null ? void 0 : t.type) ?? "CART_ITEMS", r = (t == null ? void 0 : t.priceFormatted) ?? !1, i = p.PAIRS_FOR_EXTENSION.price[c], n = p.PAIRS_FOR_EXTENSION.originalPrice[c], [l, L] = e ? [
35
- r ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE,
36
- r ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE
42
+ }
43
+ if (!this.currentNode)
44
+ return;
45
+ const i = a(this.currentNode), c = (i == null ? void 0 : i.type) ?? "CART_ITEMS", r = (i == null ? void 0 : i.priceFormatted) ?? !1, t = T.PAIRS_FOR_EXTENSION.price[c], n = T.PAIRS_FOR_EXTENSION.originalPrice[c], [l, R] = e ? [
46
+ r ? t.DEFAULT_PRICE_FORMATTED : t.DEFAULT_PRICE,
47
+ r ? t.DEFAULT_SINGLE_PRICE_FORMATTED : t.DEFAULT_SINGLE_PRICE
37
48
  ] : [
38
- r ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE,
39
- r ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE
40
- ], I = r ? n.DEFAULT_PRICE_FORMATTED : n.DEFAULT_PRICE, P = r ? n.DEFAULT_SINGLE_PRICE_FORMATTED : n.DEFAULT_SINGLE_PRICE, [R, C] = e ? [I, P] : [P, I], s = this.api.getDocumentModifier();
41
- N(this.currentNode, this.api, { priceSinglePrice: e }, s);
49
+ r ? t.DEFAULT_SINGLE_PRICE_FORMATTED : t.DEFAULT_SINGLE_PRICE,
50
+ r ? t.DEFAULT_PRICE_FORMATTED : t.DEFAULT_PRICE
51
+ ], p = r ? n.DEFAULT_PRICE_FORMATTED : n.DEFAULT_PRICE, d = r ? n.DEFAULT_SINGLE_PRICE_FORMATTED : n.DEFAULT_SINGLE_PRICE, [C, m] = e ? [p, d] : [d, p], s = this.api.getDocumentModifier();
52
+ A(this.currentNode, this.api, { priceSinglePrice: e }, s);
42
53
  const o = this.currentNode.closest(".items-block");
43
54
  ((o == null ? void 0 : o.querySelectorAll(
44
- `[esd-extension-block-id="${d.PRICE}"]`
55
+ `[esd-extension-block-id="${g.PRICE}"]`
45
56
  )) || []).forEach((E) => {
46
- this._updatePriceBlock(s, E, l, L, e);
57
+ this._updatePriceBlock(s, E, l, R, e);
47
58
  }), ((o == null ? void 0 : o.querySelectorAll(
48
- `[esd-extension-block-id="${d.ORIGINAL_PRICE}"]`
59
+ `[esd-extension-block-id="${g.ORIGINAL_PRICE}"]`
49
60
  )) || []).forEach((E) => {
50
- this._updatePriceBlock(s, E, R, C, e);
61
+ this._updatePriceBlock(s, E, C, m, e);
51
62
  }), s.apply(new S(
52
63
  `Updated price to ${e ? "single" : "total"} price`
53
64
  ));
54
65
  }
55
- _updatePriceBlock(e, t, c, r, i) {
56
- const n = `data-single_price="${i ? "true" : "false"}"`, l = t.getInnerHTML().trim().replace(c, h(r)).replace(/data-single_price=(?:"[^"]*"|'[^']*')/g, n);
57
- e.modifyHtml(t).setInnerHtml(l);
66
+ _updatePriceBlock(e, i, c, r, t) {
67
+ const n = `data-single_price="${t ? "true" : "false"}"`, l = i.getInnerHTML().trim().replace(c, F(r)).replace(/data-single_price=(?:"[^"]*"|'[^']*')/g, n);
68
+ e.modifyHtml(i).setInnerHtml(l);
58
69
  }
59
70
  _getSinglePrice() {
60
71
  return `
61
72
  <div class="display-flex align-items-center justify-content-between">
62
73
  <${_.LABEL}
63
- ${m.LABEL.text}="${this.api.translate("Show Single Product Price")}"
74
+ ${h.LABEL.text}="${this.api.translate("Show Single Product Price")}"
64
75
  >
65
76
  </${_.LABEL}>
66
- ${this._GuToggle(a.SINGLE_PRICE)}
77
+ ${this._GuToggle(P.SINGLE_PRICE)}
67
78
  </div>
68
79
  `;
69
80
  }
70
81
  }
71
82
  export {
72
- u as CONTROL_BLOCK_ID,
73
- k as PriceSinglePriceControl
83
+ f as CONTROL_BLOCK_ID,
84
+ x as PriceSinglePriceControl
74
85
  };