@useinsider/guido 3.23.0-beta.9f6bfbf → 3.23.0-beta.df89564

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 (44) hide show
  1. package/README.md +6 -2
  2. package/dist/@types/config/schemas.js +15 -17
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +56 -58
  5. package/dist/composables/useModuleRepair.js +12 -14
  6. package/dist/composables/useStripo.js +70 -70
  7. package/dist/config/migrator/index.js +15 -16
  8. package/dist/extensions/Blocks/Items/block.js +77 -115
  9. package/dist/extensions/Blocks/Items/constants/currency.js +14 -59
  10. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +22 -33
  11. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +51 -62
  12. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +17 -18
  13. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +31 -42
  14. package/dist/extensions/Blocks/Items/controls/settingsControl.js +120 -141
  15. package/dist/extensions/Blocks/Items/enums/controlEnums.js +1 -1
  16. package/dist/extensions/Blocks/Items/extension.js +8 -9
  17. package/dist/extensions/Blocks/Items/items.css.js +0 -19
  18. package/dist/extensions/Blocks/Items/settingsPanel.js +25 -34
  19. package/dist/extensions/Blocks/Items/template.js +212 -250
  20. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +0 -1
  21. package/dist/guido.css +1 -1
  22. package/dist/package.json.js +1 -1
  23. package/dist/src/@types/config/schemas.d.ts +0 -4
  24. package/dist/src/composables/useConfig.d.ts +0 -2
  25. package/dist/src/composables/useStripo.d.ts +1 -1
  26. package/dist/src/config/migrator/index.d.ts +1 -4
  27. package/dist/src/extensions/Blocks/Items/block.d.ts +9 -6
  28. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +0 -32
  29. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -1
  30. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +0 -1
  31. package/dist/src/extensions/Blocks/Items/template.d.ts +1 -4
  32. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +0 -3
  33. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +0 -12
  34. package/dist/src/stores/config.d.ts +0 -20
  35. package/dist/src/utils/itemsCurrencyRepair.d.ts +1 -5
  36. package/dist/utils/itemsCurrencyRepair.js +24 -29
  37. package/dist/utils/pairProductVariables.js +99 -119
  38. package/package.json +1 -1
  39. package/dist/config/migrator/itemsPriceFormatMigrator.js +0 -20
  40. package/dist/extensions/Blocks/Items/controls/priceFormat.js +0 -145
  41. package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +0 -185
  42. package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +0 -1
  43. package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +0 -23
  44. package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +0 -61
@@ -1,19 +1,18 @@
1
- import { migrateCheckbox as e } from "./checkboxMigrator.js";
2
- import { migrateCouponBlock as a } from "./couponBlockMigrator.js";
3
- import { migrateFullStoryScripts as c } from "./fullStoryScriptMigrator.js";
4
- import { migrateItemsBlock as g } from "./itemsBlockMigrator.js";
5
- import { migrateItemsPriceFormat as n } from "./itemsPriceFormatMigrator.js";
6
- import { migrateProductNameLink as p } from "./productNameLinkMigrator.js";
7
- import { migrateRadioButton as f } from "./radioButtonMigrator.js";
8
- import { migrateRecommendation as l } from "./recommendationMigrator.js";
9
- import { migrateRecommendationPartnerScope as d } from "./recommendationPartnerMigrator.js";
10
- import { migrateRecommendationTitle as s } from "./recommendationTitleMigrator.js";
11
- import { migrateSocialIcons as k } from "./socialIconMigrator.js";
12
- import { migrateUnsubscribe as P } from "./unsubscribeMigrator.js";
13
- const H = async (t, i = {}, r, o) => {
14
- let m = t;
15
- return m = e(m), m = f(m), m = await P(m), m = a(m), m = l(m, i), r && (m = d(m, r)), m = s(m), m = g(m), o != null && o.itemsPriceFormatting && (m = n(m)), m = p(m), m = k(m), m = c(m), m;
1
+ import { migrateCheckbox as i } from "./checkboxMigrator.js";
2
+ import { migrateCouponBlock as e } from "./couponBlockMigrator.js";
3
+ import { migrateFullStoryScripts as a } from "./fullStoryScriptMigrator.js";
4
+ import { migrateItemsBlock as n } from "./itemsBlockMigrator.js";
5
+ import { migrateProductNameLink as c } from "./productNameLinkMigrator.js";
6
+ import { migrateRadioButton as g } from "./radioButtonMigrator.js";
7
+ import { migrateRecommendation as p } from "./recommendationMigrator.js";
8
+ import { migrateRecommendationPartnerScope as f } from "./recommendationPartnerMigrator.js";
9
+ import { migrateRecommendationTitle as l } from "./recommendationTitleMigrator.js";
10
+ import { migrateSocialIcons as s } from "./socialIconMigrator.js";
11
+ import { migrateUnsubscribe as d } from "./unsubscribeMigrator.js";
12
+ const h = async (o, t = {}, r) => {
13
+ let m = o;
14
+ return m = i(m), m = g(m), m = await d(m), m = e(m), m = p(m, t), r && (m = f(m, r)), m = l(m), m = n(m), m = c(m), m = s(m), m = a(m), m;
16
15
  };
17
16
  export {
18
- H as migrate
17
+ h as migrate
19
18
  };
@@ -1,42 +1,33 @@
1
1
  var k = Object.defineProperty;
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 {
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 {
25
16
  constructor() {
26
17
  super(...arguments);
27
18
  /** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
28
- C(this, "_currencyHealed", /* @__PURE__ */ new Set());
19
+ g(this, "_currencyHealed", /* @__PURE__ */ new Set());
29
20
  /** blockInstanceIds already claimed by a live block this session (SD-147588 collision detection). */
30
- C(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
21
+ g(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
31
22
  }
32
23
  getId() {
33
- return D;
24
+ return A;
34
25
  }
35
26
  getIcon() {
36
27
  return "items-icon";
37
28
  }
38
29
  getBlockCompositionType() {
39
- return O.CONTAINER;
30
+ return R.CONTAINER;
40
31
  }
41
32
  getName() {
42
33
  return this.api.translate("Items");
@@ -45,21 +36,20 @@ class at extends M {
45
36
  return this.api.translate("Items lets you display personalized products based on user behavior.");
46
37
  }
47
38
  getSettingsPanelTitleHtml() {
48
- return R(
49
- D,
39
+ return N(
40
+ A,
50
41
  this.api.translate("Items"),
51
42
  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.")
52
43
  );
53
44
  }
54
45
  getTemplate() {
55
- return F({
56
- orientation: S.ORIENTATION.VERTICAL,
57
- itemsType: S.ITEMS_TYPE.CART_ITEMS,
46
+ return O({
47
+ orientation: b.ORIENTATION.VERTICAL,
48
+ itemsType: b.ITEMS_TYPE.CART_ITEMS,
58
49
  itemId: "{{Abandoned Cart Item (1) Url}}",
59
- currencySymbol: b.productPriceCurrencySymbolControlValue,
60
- currencyLocation: b.productPriceCurrencyLocationControlValue,
61
- formattedPrice: b.productPriceFormattedControlValue === "1",
62
- priceFormat: this._isPriceFormattingEnabled() ? I : void 0
50
+ currencySymbol: p.productPriceCurrencySymbolControlValue,
51
+ currencyLocation: p.productPriceCurrencyLocationControlValue,
52
+ formattedPrice: p.productPriceFormattedControlValue === "1"
63
53
  });
64
54
  }
65
55
  allowInnerBlocksDND() {
@@ -69,29 +59,26 @@ class at extends M {
69
59
  return !0;
70
60
  }
71
61
  onCreated(t) {
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)
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)
76
66
  return;
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);
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);
82
72
  return;
83
73
  }
84
74
  } else {
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");
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");
90
77
  return;
91
78
  }
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);
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);
95
82
  }
96
83
  /**
97
84
  * Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
@@ -100,23 +87,23 @@ class at extends M {
100
87
  * Guarded to the nodeConfig-empty case so it runs once and never loops.
101
88
  */
102
89
  onDocumentChanged(t) {
103
- const e = T(t);
90
+ const e = _(t);
104
91
  if (!e)
105
92
  return;
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);
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);
112
99
  }
113
100
  return;
114
101
  }
115
- const i = _(t);
116
- if (!(i != null && i.initialized))
102
+ const o = C(t);
103
+ if (!(o != null && o.initialized))
117
104
  return;
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);
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);
120
107
  }
121
108
  /**
122
109
  * Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
@@ -126,21 +113,21 @@ class at extends M {
126
113
  * restored before export. The name `<a>` carries no data-type/data-number of its own and
127
114
  * relies on this td-level fallback in pairProductVariables.
128
115
  */
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);
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);
132
119
  };
133
- c("data-type", e.type), c("data-number", i), c("data-nodup", String(e.priceHideDiscount));
120
+ n("data-type", e.type), n("data-number", o), n("data-nodup", String(e.priceHideDiscount));
134
121
  }
135
122
  /**
136
123
  * Repairs a saved module's collapsed card into the state the load migrator produces. Acts only
137
124
  * on a zero width, so Stripo's non-zero drop-time width never triggers it and a healed block no-ops.
138
125
  */
139
126
  _healCollapsedWidths(t, e) {
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%");
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%");
144
131
  }), !0);
145
132
  }
146
133
  /**
@@ -169,55 +156,30 @@ class at extends M {
169
156
  let e = t;
170
157
  if (!e || this._seenInstanceIds.has(e))
171
158
  do
172
- e = x();
159
+ e = P();
173
160
  while (this._seenInstanceIds.has(e));
174
161
  return this._seenInstanceIds.add(e), e;
175
162
  }
176
163
  /**
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.
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.
179
173
  */
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");
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;
218
180
  }
219
181
  }
220
182
  export {
221
- D as BLOCK_ID,
222
- at as ItemsBlock
183
+ A as BLOCK_ID,
184
+ $ as ItemsBlock
223
185
  };
@@ -1,70 +1,25 @@
1
1
  import { DefaultConfigValues as c } from "../enums/settingsEnums.js";
2
- const n = {
2
+ const s = {
3
3
  POSITION: "data-curency",
4
4
  SYMBOL: "data-currency_symbol"
5
5
  };
6
- function u(t) {
7
- return t === "1" ? "after" : "before";
6
+ function e(r) {
7
+ return r === "1" ? "after" : "before";
8
8
  }
9
- function i(t) {
10
- const r = (t ?? "").trim();
11
- return r !== "" && r !== c.productPriceCurrencySymbolControlValue;
9
+ function i(r) {
10
+ const o = (r ?? "").trim();
11
+ return o !== "" && o !== c.productPriceCurrencySymbolControlValue;
12
12
  }
13
- function p(t) {
14
- const r = t.priceCurrencyLocation, e = typeof r == "string" && r.trim() !== "", a = (t.priceCurrencySymbol ?? "").trim();
13
+ function a(r) {
14
+ const o = r.priceCurrencyLocation, n = typeof o == "string" && o.trim() !== "", t = (r.priceCurrencySymbol ?? "").trim();
15
15
  return {
16
- position: e ? u(r) : void 0,
17
- symbol: i(a) ? a : void 0
16
+ position: n ? e(o) : void 0,
17
+ symbol: i(t) ? t : 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
- }
58
20
  export {
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
21
+ s as ITEMS_CURRENCY_ATTR,
22
+ a as currencyAttrTargets,
23
+ e as currencyPositionFromLocation,
24
+ i as isCustomCurrencySymbol
70
25
  };
@@ -1,59 +1,48 @@
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 = {
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 = {
9
8
  CURRENCY_LOCATION: "currencyLocation"
10
9
  };
11
- class H extends E {
10
+ class B extends N {
12
11
  getId() {
13
- return x;
12
+ return b;
14
13
  }
15
14
  getTemplate() {
16
15
  return `
17
- <div class="container ${d.PRICE_CURRENCY_LOCATION}">
16
+ <div class="container ${p.PRICE_CURRENCY_LOCATION}">
18
17
  ${this._getCurrencyLocation()}
19
18
  </div>
20
19
  `;
21
20
  }
22
21
  onRender() {
23
- this.forgetLastPanelNode(), this.api.setUIEAttribute(a.CURRENCY_LOCATION, I.SELECTPICKER.items, u), this.api.onValueChanged(a.CURRENCY_LOCATION, (e) => {
22
+ this.forgetLastPanelNode(), this.api.setUIEAttribute(a.CURRENCY_LOCATION, I.SELECTPICKER.items, m), this.api.onValueChanged(a.CURRENCY_LOCATION, (e) => {
24
23
  this._onCurrencyLocationChange(e);
25
24
  });
26
25
  }
27
26
  onTemplateNodeUpdated(e) {
28
27
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
29
- const t = C(this.currentNode);
28
+ const t = u(this.currentNode);
30
29
  this.api.updateValues({ [a.CURRENCY_LOCATION]: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0" });
31
30
  });
32
31
  }
33
32
  _onCurrencyLocationChange(e) {
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)
33
+ if (console.debug("Currency location changed to: ", e), O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
45
34
  return;
46
35
  const t = this._getPriceBlocks();
47
36
  if (!t || t.length === 0)
48
37
  return;
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);
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);
52
41
  if (!s)
53
42
  return;
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(
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(
57
46
  `Updated currency location to ${c}`
58
47
  ));
59
48
  }
@@ -96,13 +85,13 @@ class H extends E {
96
85
  this._GuSelect({
97
86
  name: a.CURRENCY_LOCATION,
98
87
  placeholder: "",
99
- options: u
88
+ options: m
100
89
  })
101
90
  ])}
102
91
  `;
103
92
  }
104
93
  }
105
94
  export {
106
- x as CONTROL_BLOCK_ID,
107
- H as PriceCurrencyLocationControl
95
+ b as CONTROL_BLOCK_ID,
96
+ B as PriceCurrencyLocationControl
108
97
  };