@useinsider/guido 3.23.0-beta.31d0f5f → 3.23.0-beta.9f6bfbf

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 (42) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +17 -15
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +58 -56
  5. package/dist/composables/useModuleRepair.js +14 -12
  6. package/dist/config/migrator/index.js +16 -15
  7. package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
  8. package/dist/extensions/Blocks/Items/block.js +115 -77
  9. package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
  10. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +33 -22
  11. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
  12. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
  13. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
  14. package/dist/extensions/Blocks/Items/controls/priceFormat.js +145 -0
  15. package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
  16. package/dist/extensions/Blocks/Items/enums/controlEnums.js +1 -1
  17. package/dist/extensions/Blocks/Items/extension.js +9 -8
  18. package/dist/extensions/Blocks/Items/items.css.js +19 -0
  19. package/dist/extensions/Blocks/Items/settingsPanel.js +34 -25
  20. package/dist/extensions/Blocks/Items/template.js +250 -212
  21. package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
  22. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
  23. package/dist/guido.css +1 -1
  24. package/dist/package.json.js +1 -1
  25. package/dist/src/@types/config/schemas.d.ts +4 -0
  26. package/dist/src/composables/useConfig.d.ts +2 -0
  27. package/dist/src/config/migrator/index.d.ts +4 -1
  28. package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
  29. package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
  30. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
  31. package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +23 -0
  32. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
  33. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
  34. package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
  35. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
  36. package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +61 -0
  37. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
  38. package/dist/src/stores/config.d.ts +20 -0
  39. package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
  40. package/dist/utils/itemsCurrencyRepair.js +29 -24
  41. package/dist/utils/pairProductVariables.js +119 -99
  42. package/package.json +1 -1
@@ -1,33 +1,42 @@
1
1
  var k = Object.defineProperty;
2
- var S = (d, l, t) => l in d ? k(d, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[l] = t;
3
- var g = (d, l, t) => S(d, typeof l != "symbol" ? l + "" : l, t);
4
- import { BlockId as D } from "../../../enums/block.js";
5
- import { useOnboardingStore as T } from "../../../stores/onboarding.js";
6
- import { getMigrationBannerHtml as N } from "../../../utils/migrationBannerHtml.js";
7
- import { Block as H, BlockCompositionType as R, ModificationDescription as u } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
8
- import { PRODUCT_WRAPPER_SELECTOR as M, isZeroWidthValue as m } from "./constants/cardWidth.js";
9
- import { currencyAttrTargets as w, ITEMS_CURRENCY_ATTR as y } from "./constants/currency.js";
10
- import { ItemsBlockId as E } from "./enums/controlEnums.js";
11
- import { SETTINGS_ENUMS as b, DefaultConfigValues as p } from "./enums/settingsEnums.js";
12
- import { getDefaultTemplate as O } from "./template.js";
13
- import { getItemsBlockContainer as _, getItemsBlockConfig as C, deriveItemNumber as B, generateBlockInstanceId as P, getDefaultItemsBlockConfig as v } from "./utils/nodeConfigUtils.js";
14
- const A = D.Items, V = "Reconcile Items currency DOM attributes";
15
- class $ extends H {
2
+ var E = (h, d, t) => d in h ? k(h, d, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[d] = t;
3
+ var C = (h, d, t) => E(h, typeof d != "symbol" ? d + "" : d, t);
4
+ import { useConfig as P } from "../../../composables/useConfig.js";
5
+ import { BlockId as H } from "../../../enums/block.js";
6
+ import { useOnboardingStore as N } from "../../../stores/onboarding.js";
7
+ import { getMigrationBannerHtml as R } from "../../../utils/migrationBannerHtml.js";
8
+ import { Block as M, BlockCompositionType as O, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
9
+ import { PRODUCT_WRAPPER_SELECTOR as w, isZeroWidthValue as g } from "./constants/cardWidth.js";
10
+ import { DEFAULT_ITEMS_PRICE_FORMAT as I, isNewPriceFormatRoot as v, currencyAttrTargets as B, ITEMS_CURRENCY_ATTR as y } from "./constants/currency.js";
11
+ import { ItemsBlockId as A } from "./enums/controlEnums.js";
12
+ import { SETTINGS_ENUMS as S, DefaultConfigValues as b } from "./enums/settingsEnums.js";
13
+ import { getDefaultTemplate as F } from "./template.js";
14
+ import { getItemsBlockContainer as T, getItemsBlockConfig as _, deriveItemNumber as L, generateBlockInstanceId as x, getDefaultItemsBlockConfig as V } from "./utils/nodeConfigUtils.js";
15
+ import { buildPriceFormatSnapshot as W, planPriceFormatOps as z, samePriceText as U, replacePriceText as Y, paragraphKindOf as j } from "./utils/priceFormatOps.js";
16
+ const D = H.Items, q = "Reconcile Items currency DOM attributes";
17
+ function K() {
18
+ return {
19
+ priceThousandSeparator: I.thousandSeparator,
20
+ priceDecimalSeparator: I.decimalSeparator,
21
+ priceDecimalCount: I.decimalCount
22
+ };
23
+ }
24
+ class at extends M {
16
25
  constructor() {
17
26
  super(...arguments);
18
27
  /** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
19
- g(this, "_currencyHealed", /* @__PURE__ */ new Set());
28
+ C(this, "_currencyHealed", /* @__PURE__ */ new Set());
20
29
  /** blockInstanceIds already claimed by a live block this session (SD-147588 collision detection). */
21
- g(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
30
+ C(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
22
31
  }
23
32
  getId() {
24
- return A;
33
+ return D;
25
34
  }
26
35
  getIcon() {
27
36
  return "items-icon";
28
37
  }
29
38
  getBlockCompositionType() {
30
- return R.CONTAINER;
39
+ return O.CONTAINER;
31
40
  }
32
41
  getName() {
33
42
  return this.api.translate("Items");
@@ -36,20 +45,21 @@ class $ extends H {
36
45
  return this.api.translate("Items lets you display personalized products based on user behavior.");
37
46
  }
38
47
  getSettingsPanelTitleHtml() {
39
- return N(
40
- A,
48
+ return R(
49
+ D,
41
50
  this.api.translate("Items"),
42
51
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
43
52
  );
44
53
  }
45
54
  getTemplate() {
46
- return O({
47
- orientation: b.ORIENTATION.VERTICAL,
48
- itemsType: b.ITEMS_TYPE.CART_ITEMS,
55
+ return F({
56
+ orientation: S.ORIENTATION.VERTICAL,
57
+ itemsType: S.ITEMS_TYPE.CART_ITEMS,
49
58
  itemId: "{{Abandoned Cart Item (1) Url}}",
50
- currencySymbol: p.productPriceCurrencySymbolControlValue,
51
- currencyLocation: p.productPriceCurrencyLocationControlValue,
52
- formattedPrice: p.productPriceFormattedControlValue === "1"
59
+ currencySymbol: b.productPriceCurrencySymbolControlValue,
60
+ currencyLocation: b.productPriceCurrencyLocationControlValue,
61
+ formattedPrice: b.productPriceFormattedControlValue === "1",
62
+ priceFormat: this._isPriceFormattingEnabled() ? I : void 0
53
63
  });
54
64
  }
55
65
  allowInnerBlocksDND() {
@@ -59,26 +69,29 @@ class $ extends H {
59
69
  return !0;
60
70
  }
61
71
  onCreated(t) {
62
- const e = this.api.getDocumentModifier(), c = this.api.getDocumentRootCssNode();
63
- c.querySelector('[product-attr="imageSrc"] img') || e.modifyCss(c).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
64
- const r = _(t);
65
- if (!r)
72
+ const e = this.api.getDocumentModifier(), s = this.api.getDocumentRootCssNode();
73
+ s.querySelector('[product-attr="imageSrc"] img') || e.modifyCss(s).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
74
+ const o = T(t);
75
+ if (!o)
66
76
  return;
67
- const o = r.getNodeConfig(), n = o && Object.keys(o).length > 0, i = C(t);
68
- if (i != null && i.initialized) {
69
- if (!n) {
70
- const a = this.api.getDocumentModifier();
71
- a.modifyHtml(r).setNodeConfig(i), this._stampProductTdDomAttributes(r, i, a), this._healCollapsedWidths(r, a), this._shouldReconcileCurrency(i) && this._reconcileCurrencyDomAttributes(r, i, a), a.apply(new u("Migrate legacy config to nodeConfig")), this._markCurrencyHealed(i.blockInstanceId);
77
+ const i = o.getNodeConfig(), c = i && Object.keys(i).length > 0, r = _(t);
78
+ if (r != null && r.initialized) {
79
+ if (!c) {
80
+ const l = this.api.getDocumentModifier();
81
+ l.modifyHtml(o).setNodeConfig(r), this._stampProductTdDomAttributes(o, r, l), this._healCollapsedWidths(o, l), this._shouldReconcileCurrency(r) && this._reconcileCurrencyDomAttributes(o, r, l), l.apply(new p("Migrate legacy config to nodeConfig")), this._markCurrencyHealed(r.blockInstanceId);
72
82
  return;
73
83
  }
74
84
  } else {
75
- const a = v(), I = this.api.getDocumentModifier();
76
- I.modifyHtml(r).setNodeConfig(a), this._stampProductTdDomAttributes(r, a, I, !0), I.apply(new u("Initialize Items block with default configuration")), T().startOnboarding("itemsOnboarding");
85
+ const l = {
86
+ ...V(),
87
+ ...this._isPriceFormattingEnabled() ? K() : {}
88
+ }, f = this.api.getDocumentModifier();
89
+ f.modifyHtml(o).setNodeConfig(l), this._stampProductTdDomAttributes(o, l, f, !0), f.apply(new p("Initialize Items block with default configuration")), N().startOnboarding("itemsOnboarding");
77
90
  return;
78
91
  }
79
- const s = this._resolveInstanceId(i.blockInstanceId), f = this.api.getDocumentModifier();
80
- let h = !1;
81
- s !== i.blockInstanceId && (f.modifyHtml(r).setNodeConfig({ ...i, blockInstanceId: s }), h = !0), !this._currencyHealed.has(s) && this._reconcileCurrencyDomAttributes(r, i, f) && (h = !0), this._healCollapsedWidths(r, f) && (h = !0), h && f.apply(new u("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(s);
92
+ const n = this._resolveInstanceId(r.blockInstanceId), a = { ...r, blockInstanceId: n }, u = this.api.getDocumentModifier();
93
+ let m = !1;
94
+ n !== r.blockInstanceId && (u.modifyHtml(o).setNodeConfig(a), m = !0), !this._currencyHealed.has(n) && this._reconcileCurrencyDomAttributes(o, a, u) && (m = !0), this._healCollapsedWidths(o, u) && (m = !0), m && u.apply(new p("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(n);
82
95
  }
83
96
  /**
84
97
  * Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
@@ -87,23 +100,23 @@ class $ extends H {
87
100
  * Guarded to the nodeConfig-empty case so it runs once and never loops.
88
101
  */
89
102
  onDocumentChanged(t) {
90
- const e = _(t);
103
+ const e = T(t);
91
104
  if (!e)
92
105
  return;
93
- const c = e.getNodeConfig();
94
- if (c && Object.keys(c).length > 0) {
95
- const i = C(t);
96
- if (i != null && i.initialized && this._shouldReconcileCurrency(i)) {
97
- const s = this.api.getDocumentModifier();
98
- this._reconcileCurrencyDomAttributes(e, i, s) && s.apply(new u(V)), this._markCurrencyHealed(i.blockInstanceId);
106
+ const s = e.getNodeConfig();
107
+ if (s && Object.keys(s).length > 0) {
108
+ const r = _(t);
109
+ if (r != null && r.initialized && this._shouldReconcileCurrency(r)) {
110
+ const n = this.api.getDocumentModifier();
111
+ this._reconcileCurrencyDomAttributes(e, r, n) && n.apply(new p(q)), this._markCurrencyHealed(r.blockInstanceId);
99
112
  }
100
113
  return;
101
114
  }
102
- const o = C(t);
103
- if (!(o != null && o.initialized))
115
+ const i = _(t);
116
+ if (!(i != null && i.initialized))
104
117
  return;
105
- const n = this.api.getDocumentModifier();
106
- n.modifyHtml(e).setNodeConfig(o), this._stampProductTdDomAttributes(e, o, n), this._healCollapsedWidths(e, n), this._shouldReconcileCurrency(o) && this._reconcileCurrencyDomAttributes(e, o, n), n.apply(new u("Recover Items block config from saved module")), this._markCurrencyHealed(o.blockInstanceId);
118
+ const c = this.api.getDocumentModifier();
119
+ c.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, c), this._healCollapsedWidths(e, c), this._shouldReconcileCurrency(i) && this._reconcileCurrencyDomAttributes(e, i, c), c.apply(new p("Recover Items block config from saved module")), this._markCurrencyHealed(i.blockInstanceId);
107
120
  }
108
121
  /**
109
122
  * Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
@@ -113,21 +126,21 @@ class $ extends H {
113
126
  * restored before export. The name `<a>` carries no data-type/data-number of its own and
114
127
  * relies on this td-level fallback in pairProductVariables.
115
128
  */
116
- _stampProductTdDomAttributes(t, e, c, r = !1) {
117
- const o = B(e.itemsSelectValue, e.type), n = (i, s) => {
118
- r && t.getAttribute(i) || c.modifyHtml(t).setAttribute(i, s);
129
+ _stampProductTdDomAttributes(t, e, s, o = !1) {
130
+ const i = L(e.itemsSelectValue, e.type), c = (r, n) => {
131
+ o && t.getAttribute(r) || s.modifyHtml(t).setAttribute(r, n);
119
132
  };
120
- n("data-type", e.type), n("data-number", o), n("data-nodup", String(e.priceHideDiscount));
133
+ c("data-type", e.type), c("data-number", i), c("data-nodup", String(e.priceHideDiscount));
121
134
  }
122
135
  /**
123
136
  * Repairs a saved module's collapsed card into the state the load migrator produces. Acts only
124
137
  * on a zero width, so Stripo's non-zero drop-time width never triggers it and a healed block no-ops.
125
138
  */
126
139
  _healCollapsedWidths(t, e) {
127
- const r = t.querySelectorAll(M).filter((o) => m(o.getAttribute("width")) || m(o.getStyle("width")));
128
- return !m(t.getAttribute("width")) && !r.length ? !1 : (t.hasClass("esd-container-frame") && e.modifyHtml(t).removeClass("esd-container-frame"), t.getAttribute("width") !== null && e.modifyHtml(t).removeAttribute("width"), r.forEach((o) => {
129
- const n = o.getAttribute("width");
130
- (n === null || m(n)) && e.modifyHtml(o).setAttribute("width", "100%"), m(o.getStyle("width")) && e.modifyHtml(o).setStyle("width", "100%");
140
+ const o = t.querySelectorAll(w).filter((i) => g(i.getAttribute("width")) || g(i.getStyle("width")));
141
+ return !g(t.getAttribute("width")) && !o.length ? !1 : (t.hasClass("esd-container-frame") && e.modifyHtml(t).removeClass("esd-container-frame"), t.getAttribute("width") !== null && e.modifyHtml(t).removeAttribute("width"), o.forEach((i) => {
142
+ const c = i.getAttribute("width");
143
+ (c === null || g(c)) && e.modifyHtml(i).setAttribute("width", "100%"), g(i.getStyle("width")) && e.modifyHtml(i).setStyle("width", "100%");
131
144
  }), !0);
132
145
  }
133
146
  /**
@@ -156,30 +169,55 @@ class $ extends H {
156
169
  let e = t;
157
170
  if (!e || this._seenInstanceIds.has(e))
158
171
  do
159
- e = P();
172
+ e = x();
160
173
  while (this._seenInstanceIds.has(e));
161
174
  return this._seenInstanceIds.add(e), e;
162
175
  }
163
176
  /**
164
- * Stamps the export-read currency attrs onto every price `<p>` from config, so a template whose
165
- * attrs drifted (e.g. a location toggle before the sync fix) self-heals to match the editor.
166
- * Config is the source of truth — never derive from visible text.
167
- *
168
- * Authority split lives in `currencyAttrTargets` (SD-147588) — position only when a location
169
- * is recorded, symbol only when customized — so this heal and the module-drop repair can't drift.
170
- *
171
- * Returns true only when an attr actually changed, so the caller can skip an empty apply that
172
- * would otherwise re-trigger onDocumentChanged and loop.
177
+ * Single self-heal slot: the flag only decides whether a legacy root is converted; a root
178
+ * already in the new format is reconciled from config regardless. Returns whether anything was queued.
173
179
  */
174
- _reconcileCurrencyDomAttributes(t, e, c) {
175
- const { position: r, symbol: o } = w(e), n = t.querySelectorAll(`.${E.PRICE} p`);
176
- let i = !1;
177
- return n.forEach((s) => {
178
- r !== void 0 && s.getAttribute(y.POSITION) !== r && (c.modifyHtml(s).setAttribute(y.POSITION, r), i = !0), o !== void 0 && s.getAttribute(y.SYMBOL) !== o && (c.modifyHtml(s).setAttribute(y.SYMBOL, o), i = !0);
179
- }), i;
180
+ _reconcileCurrencyDomAttributes(t, e, s) {
181
+ const o = this._isPriceFormattingEnabled();
182
+ if (!o && !v(t))
183
+ return this._reconcileLegacyCurrencyAttributes(t, e, s);
184
+ const i = this._priceParagraphs(t), c = W({
185
+ rootAttr: (n) => t.getAttribute(n),
186
+ config: e,
187
+ paragraphs: i.map(({ kind: n, node: a }) => ({
188
+ kind: n,
189
+ attr: (u) => a.getAttribute(u),
190
+ text: a.getInnerText()
191
+ }))
192
+ }), r = z(c, { convertLegacy: o });
193
+ return r.changed ? (Object.entries(r.rootSet).forEach(([n, a]) => {
194
+ s.modifyHtml(t).setAttribute(n, a);
195
+ }), i.forEach(({ kind: n, node: a }) => {
196
+ var l;
197
+ r.paragraphRemove.filter((f) => a.getAttribute(f) !== null).forEach((f) => s.modifyHtml(a).removeAttribute(f));
198
+ const u = (l = r.texts) == null ? void 0 : l[n], m = a.getInnerText();
199
+ u !== void 0 && !U(m, u) && s.modifyHtml(a).setInnerHtml(Y(a.getInnerHTML(), m, u));
200
+ }), r.configPatch && s.modifyHtml(t).setNodeConfig({ ...e, ...r.configPatch }), !0) : !1;
201
+ }
202
+ /** Legacy `<p>` contract via `currencyAttrTargets`: position when recorded, symbol only when custom. */
203
+ _reconcileLegacyCurrencyAttributes(t, e, s) {
204
+ const { position: o, symbol: i } = B(e), c = t.querySelectorAll(`.${A.PRICE} p`);
205
+ let r = !1;
206
+ return c.forEach((n) => {
207
+ o !== void 0 && n.getAttribute(y.POSITION) !== o && (s.modifyHtml(n).setAttribute(y.POSITION, o), r = !0), i !== void 0 && n.getAttribute(y.SYMBOL) !== i && (s.modifyHtml(n).setAttribute(y.SYMBOL, i), r = !0);
208
+ }), r;
209
+ }
210
+ _priceParagraphs(t) {
211
+ return t.querySelectorAll(`.${A.PRICE} p`).flatMap((s) => {
212
+ const o = j(s.getAttribute("product-attr"));
213
+ return o ? [{ kind: o, node: s }] : [];
214
+ });
215
+ }
216
+ _isPriceFormattingEnabled() {
217
+ return P().isFeatureEnabled("itemsPriceFormatting");
180
218
  }
181
219
  }
182
220
  export {
183
- A as BLOCK_ID,
184
- $ as ItemsBlock
221
+ D as BLOCK_ID,
222
+ at as ItemsBlock
185
223
  };
@@ -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
  };
@@ -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.setUIEAttribute(a.CURRENCY_LOCATION, I.SELECTPICKER.items, u), 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
+ const t = C(this.currentNode);
29
30
  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
  };