@useinsider/guido 3.17.0-beta.ab974c6 → 3.17.0-beta.b16151a

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.
@@ -1,51 +1,52 @@
1
- import { useActionsApi as T } from "./useActionsApi.js";
2
- import { useConfig as k } from "./useConfig.js";
3
- import { useSaveStart as B, useSaveComplete as E } from "./useGuidoActions.js";
4
- import { useSyncModuleExtractor as q } from "./useSyncModuleExtractor.js";
5
- import { ToasterTypeOptions as C } from "../enums/toaster.js";
1
+ import { useActionsApi as x } from "./useActionsApi.js";
2
+ import { useConfig as T } from "./useConfig.js";
3
+ import { useSaveStart as E, useSaveComplete as q } from "./useGuidoActions.js";
4
+ import { useSyncModuleExtractor as C } from "./useSyncModuleExtractor.js";
5
+ import { ToasterTypeOptions as M } from "../enums/toaster.js";
6
6
  import { useStripoApi as D } from "../services/stripoApi.js";
7
7
  import { useTemplatePreparation as L } from "../utils/templatePreparation.js";
8
8
  import { useAllowlist as P } from "./useAllowlist.js";
9
9
  import { useHtmlValidator as U } from "./useHtmlValidator.js";
10
10
  import { useToaster as A } from "./useToaster.js";
11
- import { useCouponBlockValidator as M } from "./validators/useCouponBlockValidator.js";
12
- import { useLiquidValidator as h } from "./validators/useLiquidValidator.js";
13
- import { useUnsubscribeBlockValidator as F } from "./validators/useUnsubscribeBlockValidator.js";
14
- const $ = () => {
15
- const n = B(), l = E(), { validateHtml: c } = U(), { validateLiquidSyntax: d } = h(), { validateCouponBlockTags: m } = M(), { validateUnsubscribeBlockUniqueness: u, validateUnsubscribeBlockHasTemplate: p } = F(), { callbacks: e, isFeatureEnabled: a } = k(), { extractSyncModuleData: f } = q(), { setSyncModuleUnsubscriptionPages: v } = D(), { editorSave: S } = T(), { showToaster: b } = A(), { getBlockedDomains: w, resolveToast: V } = P();
16
- return { save: async (y = !1, s = !1) => {
11
+ import { useCouponBlockValidator as h } from "./validators/useCouponBlockValidator.js";
12
+ import { useLiquidValidator as F } from "./validators/useLiquidValidator.js";
13
+ import { useSyncModuleBlockValidator as O } from "./validators/useSyncModuleBlockValidator.js";
14
+ import { useUnsubscribeBlockValidator as W } from "./validators/useUnsubscribeBlockValidator.js";
15
+ const it = () => {
16
+ const l = E(), n = q(), { validateHtml: c } = U(), { validateLiquidSyntax: d } = F(), { validateCouponBlockTags: m } = h(), { validateUnsubscribeBlockUniqueness: u, validateUnsubscribeBlockHasTemplate: p } = W(), { validateSyncModuleBlocks: f } = O(), { callbacks: a, isFeatureEnabled: s } = T(), { extractSyncModuleData: v } = C(), { setSyncModuleUnsubscriptionPages: S } = D(), { editorSave: b } = x(), { showToaster: w } = A(), { getBlockedDomains: V, resolveToast: y } = P();
17
+ return { save: async (H = !1, e = !1) => {
17
18
  var r;
18
- n();
19
- const { prepareTemplateDetails: H } = L(), t = await H();
20
- if (!m(t.compiledHtml) || !u(t.compiledHtml) || !p(t.compiledHtml))
19
+ l();
20
+ const { prepareTemplateDetails: k } = L(), t = await k();
21
+ if (!f(t.rawHtml, e) || !m(t.compiledHtml) || !u(t.compiledHtml) || !p(t.compiledHtml))
21
22
  return;
22
- if (a("liquidSyntax")) {
23
+ if (s("liquidSyntax")) {
23
24
  if (!await d(t.compiledHtml))
24
25
  return;
25
26
  } else if (!await c(t.compiledHtml, t.dynamicContentList, !0))
26
27
  return;
27
- if ((r = e.value) != null && r.externalValidation && !await e.value.externalValidation(t))
28
+ if ((r = a.value) != null && r.externalValidation && !await a.value.externalValidation(t))
28
29
  return;
29
- if (a("allowlistEnabled")) {
30
- const i = await w(t.compiledHtml, t.css);
31
- if (i.length) {
32
- if (!s) {
33
- const o = await V(i);
34
- o != null && o.message && b({
35
- type: C.Warning,
36
- message: o.message,
37
- actionButton: o.actionButton
30
+ if (s("allowlistEnabled")) {
31
+ const o = await V(t.compiledHtml, t.css);
32
+ if (o.length) {
33
+ if (!e) {
34
+ const i = await y(o);
35
+ i != null && i.message && w({
36
+ type: M.Warning,
37
+ message: i.message,
38
+ actionButton: i.actionButton
38
39
  });
39
40
  }
40
41
  return;
41
42
  }
42
43
  }
43
- if (!await S())
44
+ if (!await b())
44
45
  return;
45
- const { unsubscribePayload: g, stripoModules: x } = f(t.rawHtml);
46
- return await v(g), t.modules = x, y || l({ ...t, silent: s }), t;
46
+ const { unsubscribePayload: B, stripoModules: g } = v(t.rawHtml);
47
+ return await S(B), t.modules = g, H || n({ ...t, silent: e }), t;
47
48
  } };
48
49
  };
49
50
  export {
50
- $ as useSave
51
+ it as useSave
51
52
  };
@@ -1,21 +1,21 @@
1
- import { UNSUBSCRIBE_SYNC_MODULE_TYPES as T } from "../enums/unsubscribe.js";
1
+ import { UNSUBSCRIBE_SYNC_MODULE_TYPES as A } from "../enums/unsubscribe.js";
2
2
  import { DATA_ATTRIBUTES as p } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
3
- import { useEditorStore as f } from "../stores/editor.js";
4
- const y = ".esd-synchronizable-module", A = '[esd-extension-block-id="unsubscribe-block"]', _ = "esd-custom-block-id", B = () => {
5
- const d = f();
6
- return { extractSyncModuleData: (E) => {
7
- const S = {
3
+ import { useEditorStore as T } from "../stores/editor.js";
4
+ const _ = "esd-synchronizable-module", f = `.${_}`, y = '[esd-extension-block-id="unsubscribe-block"]', M = "esd-custom-block-id", N = () => {
5
+ const S = T();
6
+ return { extractSyncModuleData: (d) => {
7
+ const E = {
8
8
  unsubscribePayload: [],
9
9
  stripoModules: []
10
10
  };
11
- if (!d.syncModulesEnabled)
12
- return S;
13
- const b = new DOMParser().parseFromString(E, "text/html").querySelectorAll(y), r = [], s = [];
11
+ if (!S.syncModulesEnabled)
12
+ return E;
13
+ const b = new DOMParser().parseFromString(d, "text/html").querySelectorAll(f), r = [], s = [];
14
14
  return b.forEach((o) => {
15
- const t = o.getAttribute(_);
15
+ const t = o.getAttribute(M);
16
16
  if (!t)
17
17
  return;
18
- const n = o.querySelectorAll(A);
18
+ const n = o.querySelectorAll(y);
19
19
  if (n.length === 0) {
20
20
  s.push(Number(t));
21
21
  return;
@@ -24,7 +24,7 @@ const y = ".esd-synchronizable-module", A = '[esd-extension-block-id="unsubscrib
24
24
  const u = c.getAttribute(p.PAGE_LIST), i = c.getAttribute(p.PAGE_TYPE);
25
25
  if (!u || !i)
26
26
  return;
27
- const m = parseInt(i), a = T[m];
27
+ const m = parseInt(i), a = A[m];
28
28
  if (!a)
29
29
  return;
30
30
  const l = u.split(",").map((e) => parseInt(e.trim())).filter((e) => !Number.isNaN(e));
@@ -41,5 +41,7 @@ const y = ".esd-synchronizable-module", A = '[esd-extension-block-id="unsubscrib
41
41
  } };
42
42
  };
43
43
  export {
44
- B as useSyncModuleExtractor
44
+ _ as SYNC_MODULE_CLASS,
45
+ f as SYNC_MODULE_SELECTOR,
46
+ N as useSyncModuleExtractor
45
47
  };
@@ -0,0 +1,24 @@
1
+ import { SYNC_MODULE_CLASS as l, SYNC_MODULE_SELECTOR as a } from "../useSyncModuleExtractor.js";
2
+ import { ToasterTypeOptions as m } from "../../enums/toaster.js";
3
+ import { ITEMS_BLOCK_SELECTOR as d } from "../../extensions/Blocks/Items/utils/constants.js";
4
+ import { RECOMMENDATION_BLOCK_SELECTOR as t, isLiveRecommendationBlock as E } from "../../extensions/Blocks/Recommendation/utils/recommendationBlockCount.js";
5
+ import { useEditorStore as u } from "../../stores/editor.js";
6
+ import { useToaster as S } from "../useToaster.js";
7
+ import { useTranslations as f } from "../useTranslations.js";
8
+ const O = `${d}, ${t}`, p = "email-editor.sync-module-dynamic-block-not-allowed", C = (o) => !o.matches(t) || E(o), D = () => {
9
+ const o = u(), { showToaster: s } = S(), n = f();
10
+ return { validateSyncModuleBlocks: (e, i = !1) => {
11
+ if (!o.syncModulesEnabled || !e.includes(l))
12
+ return !0;
13
+ const c = new DOMParser().parseFromString(e, "text/html");
14
+ return Array.from(c.querySelectorAll(O)).some(
15
+ (r) => r.closest(a) !== null && C(r)
16
+ ) ? (i || s({
17
+ type: m.Error,
18
+ message: n(p)
19
+ }), !1) : !0;
20
+ } };
21
+ };
22
+ export {
23
+ D as useSyncModuleBlockValidator
24
+ };
@@ -1,30 +1,20 @@
1
- var D = Object.defineProperty;
2
- var S = (m, u, e) => u in m ? D(m, u, { enumerable: !0, configurable: !0, writable: !0, value: e }) : m[u] = e;
3
- var I = (m, u, e) => S(m, typeof u != "symbol" ? u + "" : u, e);
4
- import { BlockId as _ } from "../../../enums/block.js";
5
- import { useOnboardingStore as N } from "../../../stores/onboarding.js";
6
- import { getMigrationBannerHtml as T } from "../../../utils/migrationBannerHtml.js";
7
- import { Block as A, BlockCompositionType as M, ModificationDescription as f } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
8
- import { isCustomCurrencySymbol as R, ITEMS_CURRENCY_ATTR as y, currencyPositionFromLocation as H } from "./constants/currency.js";
9
- import { ItemsBlockId as O } from "./enums/controlEnums.js";
10
- import { SETTINGS_ENUMS as h, DefaultConfigValues as C } from "./enums/settingsEnums.js";
11
- import { getDefaultTemplate as E } from "./template.js";
12
- import { getItemsBlockContainer as b, getItemsBlockConfig as g, deriveItemNumber as B, getDefaultItemsBlockConfig as P } from "./utils/nodeConfigUtils.js";
13
- const k = _.Items, w = "Reconcile Items currency DOM attributes";
14
- class K extends A {
15
- constructor() {
16
- super(...arguments);
17
- /** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
18
- I(this, "_currencyHealed", /* @__PURE__ */ new Set());
19
- }
1
+ import { BlockId as g } from "../../../enums/block.js";
2
+ import { useOnboardingStore as y } from "../../../stores/onboarding.js";
3
+ import { getMigrationBannerHtml as I } from "../../../utils/migrationBannerHtml.js";
4
+ import { Block as C, BlockCompositionType as b, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { SETTINGS_ENUMS as l, DefaultConfigValues as d } from "./enums/settingsEnums.js";
6
+ import { getDefaultTemplate as h } from "./template.js";
7
+ import { getItemsBlockContainer as u, getItemsBlockConfig as f, deriveItemNumber as D, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
8
+ const p = g.Items;
9
+ class E extends C {
20
10
  getId() {
21
- return k;
11
+ return p;
22
12
  }
23
13
  getIcon() {
24
14
  return "items-icon";
25
15
  }
26
16
  getBlockCompositionType() {
27
- return M.CONTAINER;
17
+ return b.CONTAINER;
28
18
  }
29
19
  getName() {
30
20
  return this.api.translate("Items");
@@ -33,20 +23,20 @@ class K extends A {
33
23
  return this.api.translate("Items lets you display personalized products based on user behavior.");
34
24
  }
35
25
  getSettingsPanelTitleHtml() {
36
- return T(
37
- k,
26
+ return I(
27
+ p,
38
28
  this.api.translate("Items"),
39
29
  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.")
40
30
  );
41
31
  }
42
32
  getTemplate() {
43
- return E({
44
- orientation: h.ORIENTATION.VERTICAL,
45
- itemsType: h.ITEMS_TYPE.CART_ITEMS,
33
+ return h({
34
+ orientation: l.ORIENTATION.VERTICAL,
35
+ itemsType: l.ITEMS_TYPE.CART_ITEMS,
46
36
  itemId: "{{Abandoned Cart Item (1) Url}}",
47
- currencySymbol: C.productPriceCurrencySymbolControlValue,
48
- currencyLocation: C.productPriceCurrencyLocationControlValue,
49
- formattedPrice: C.productPriceFormattedControlValue === "1"
37
+ currencySymbol: d.productPriceCurrencySymbolControlValue,
38
+ currencyLocation: d.productPriceCurrencyLocationControlValue,
39
+ formattedPrice: d.productPriceFormattedControlValue === "1"
50
40
  });
51
41
  }
52
42
  allowInnerBlocksDND() {
@@ -55,27 +45,24 @@ class K extends A {
55
45
  canBeSavedAsModule() {
56
46
  return !0;
57
47
  }
58
- onCreated(e) {
59
- const r = this.api.getDocumentModifier(), s = this.api.getDocumentRootCssNode();
60
- s.querySelector('[product-attr="imageSrc"] img') || r.modifyCss(s).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
61
- const o = b(e);
62
- if (!o)
48
+ onCreated(n) {
49
+ const t = this.api.getDocumentModifier(), a = this.api.getDocumentRootCssNode();
50
+ a.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(a).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
51
+ const e = u(n);
52
+ if (!e)
63
53
  return;
64
- const i = o.getNodeConfig(), n = i && Object.keys(i).length > 0, t = g(e);
65
- if (t != null && t.initialized) {
66
- if (!n) {
67
- const c = this.api.getDocumentModifier();
68
- c.modifyHtml(o).setNodeConfig(t), this._stampProductTdDomAttributes(o, t, c), this._shouldReconcileCurrency(t) && this._reconcileCurrencyDomAttributes(o, t, c), c.apply(new f("Migrate legacy config to nodeConfig")), this._markCurrencyHealed(t.blockInstanceId);
69
- return;
54
+ const o = e.getNodeConfig(), r = o && Object.keys(o).length > 0, i = f(n);
55
+ if (i != null && i.initialized)
56
+ if (r)
57
+ i.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...i, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
58
+ else {
59
+ const s = this.api.getDocumentModifier();
60
+ s.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, s), s.apply(new c("Migrate legacy config to nodeConfig"));
70
61
  }
71
- } else {
72
- const c = P(), p = this.api.getDocumentModifier();
73
- p.modifyHtml(o).setNodeConfig(c), this._stampProductTdDomAttributes(o, c, p, !0), p.apply(new f("Initialize Items block with default configuration")), N().startOnboarding("itemsOnboarding");
74
- return;
62
+ else {
63
+ const s = N(), m = this.api.getDocumentModifier();
64
+ m.modifyHtml(e).setNodeConfig(s), this._stampProductTdDomAttributes(e, s, m, !0), m.apply(new c("Initialize Items block with default configuration")), y().startOnboarding("itemsOnboarding");
75
65
  }
76
- const a = t.blockInstanceId || String(Date.now()), d = this.api.getDocumentModifier();
77
- let l = !1;
78
- t.blockInstanceId || (d.modifyHtml(o).setNodeConfig({ ...t, blockInstanceId: a }), l = !0), this._shouldReconcileCurrency(t) && this._reconcileCurrencyDomAttributes(o, t, d) && (l = !0), l && d.apply(new f("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(a);
79
66
  }
80
67
  /**
81
68
  * Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
@@ -83,24 +70,18 @@ class K extends A {
83
70
  * into nodeConfig, so without this a reused module would reset to defaults.
84
71
  * Guarded to the nodeConfig-empty case so it runs once and never loops.
85
72
  */
86
- onDocumentChanged(e) {
87
- const r = b(e);
88
- if (!r)
73
+ onDocumentChanged(n) {
74
+ const t = u(n);
75
+ if (!t)
89
76
  return;
90
- const s = r.getNodeConfig();
91
- if (s && Object.keys(s).length > 0) {
92
- const t = g(e);
93
- if (t != null && t.initialized && this._shouldReconcileCurrency(t)) {
94
- const a = this.api.getDocumentModifier();
95
- this._reconcileCurrencyDomAttributes(r, t, a) && a.apply(new f(w)), this._markCurrencyHealed(t.blockInstanceId);
96
- }
77
+ const a = t.getNodeConfig();
78
+ if (a && Object.keys(a).length > 0)
97
79
  return;
98
- }
99
- const i = g(e);
100
- if (!(i != null && i.initialized))
80
+ const o = f(n);
81
+ if (!(o != null && o.initialized))
101
82
  return;
102
- const n = this.api.getDocumentModifier();
103
- n.modifyHtml(r).setNodeConfig(i), this._stampProductTdDomAttributes(r, i, n), this._shouldReconcileCurrency(i) && this._reconcileCurrencyDomAttributes(r, i, n), n.apply(new f("Recover Items block config from saved module")), this._markCurrencyHealed(i.blockInstanceId);
83
+ const r = this.api.getDocumentModifier();
84
+ r.modifyHtml(t).setNodeConfig(o), this._stampProductTdDomAttributes(t, o, r), r.apply(new c("Recover Items block config from saved module"));
104
85
  }
105
86
  /**
106
87
  * Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
@@ -110,51 +91,14 @@ class K extends A {
110
91
  * restored before export. The name `<a>` carries no data-type/data-number of its own and
111
92
  * relies on this td-level fallback in pairProductVariables.
112
93
  */
113
- _stampProductTdDomAttributes(e, r, s, o = !1) {
114
- const i = B(r.itemsSelectValue, r.type), n = (t, a) => {
115
- o && e.getAttribute(t) || s.modifyHtml(e).setAttribute(t, a);
94
+ _stampProductTdDomAttributes(n, t, a, e = !1) {
95
+ const o = D(t.itemsSelectValue, t.type), r = (i, s) => {
96
+ e && n.getAttribute(i) || a.modifyHtml(n).setAttribute(i, s);
116
97
  };
117
- n("data-type", r.type), n("data-number", i), n("data-nodup", String(r.priceHideDiscount));
118
- }
119
- /**
120
- * Whether a currency self-heal pass should run for this block (SD-147588). The only gate here is
121
- * once-per-session: heal each instance at most once, so the auto-fix can't fight undo (undo
122
- * re-drifts the attr, which would otherwise re-trigger the heal forever). The position-vs-symbol
123
- * authority split lives in `_reconcileCurrencyDomAttributes` — position is always authoritative,
124
- * the symbol write alone is skipped for the 'USD' sentinel — so we must NOT gate the whole pass
125
- * on symbol customization here, or a default-symbol block with a toggled location never heals.
126
- */
127
- _shouldReconcileCurrency(e) {
128
- return !e.blockInstanceId || !this._currencyHealed.has(e.blockInstanceId);
129
- }
130
- /** Marks a block instance's currency as reconciled so it is not healed again (undo-safe). */
131
- _markCurrencyHealed(e) {
132
- e && this._currencyHealed.add(e);
133
- }
134
- /**
135
- * Stamps the export-read currency attrs onto every price `<p>` from config, so a template whose
136
- * attrs drifted (e.g. a location toggle before the sync fix) self-heals to match the editor.
137
- * Config is the source of truth — never derive from visible text.
138
- *
139
- * Position and symbol differ in authority (SD-147588):
140
- * - `data-curency` (position) comes from `priceCurrencyLocation`, captured independently of the
141
- * symbol, so it is ALWAYS authoritative and healed whenever it drifts — even with a default
142
- * symbol (otherwise the default-symbol + toggled-location case stays broken on export).
143
- * - `data-currency_symbol` is stamped only for a customized symbol; the 'USD' sentinel may be a
144
- * migrator default, so we trust the DOM's real value over it and never overwrite.
145
- *
146
- * Returns true only when an attr actually changed, so the caller can skip an empty apply that
147
- * would otherwise re-trigger onDocumentChanged and loop.
148
- */
149
- _reconcileCurrencyDomAttributes(e, r, s) {
150
- const o = r.priceCurrencyLocation, i = o != null && String(o).trim() !== "", n = H(o), t = (r.priceCurrencySymbol ?? "").trim(), a = R(t), d = e.querySelectorAll(`.${O.PRICE} p`);
151
- let l = !1;
152
- return d.forEach((c) => {
153
- i && c.getAttribute(y.POSITION) !== n && (s.modifyHtml(c).setAttribute(y.POSITION, n), l = !0), a && c.getAttribute(y.SYMBOL) !== t && (s.modifyHtml(c).setAttribute(y.SYMBOL, t), l = !0);
154
- }), l;
98
+ r("data-type", t.type), r("data-number", o), r("data-nodup", String(t.priceHideDiscount));
155
99
  }
156
100
  }
157
101
  export {
158
- k as BLOCK_ID,
159
- K as ItemsBlock
102
+ p as BLOCK_ID,
103
+ E as ItemsBlock
160
104
  };
@@ -1,15 +1,14 @@
1
- import { currencyLocationMaps as p } from "../../../../../enums/extensions/recommendationBlock.js";
2
- import { UEAttr as N, ModificationDescription as I } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
- import { CommonControl as L } from "../../../common-control.js";
4
- import { ITEMS_CURRENCY_ATTR as T, currencyPositionFromLocation as E } from "../../constants/currency.js";
1
+ import { currencyLocationMaps as u } from "../../../../../enums/extensions/recommendationBlock.js";
2
+ import { UEAttr as R, ModificationDescription as L } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ import { CommonControl as N } from "../../../common-control.js";
5
4
  import { ItemsBlockControlId as m } from "../../enums/controlEnums.js";
6
- import { getItemsBlockConfig as l, setItemsBlockConfig as O, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
7
- const b = m.PRICE_CURRENCY_LOCATION, c = {
5
+ import { getItemsBlockConfig as C, setItemsBlockConfig as I, escapeReplacement as T } from "../../utils/nodeConfigUtils.js";
6
+ const E = m.PRICE_CURRENCY_LOCATION, c = {
8
7
  CURRENCY_LOCATION: "currencyLocation"
9
8
  };
10
- class Y extends L {
9
+ class A extends N {
11
10
  getId() {
12
- return b;
11
+ return E;
13
12
  }
14
13
  getTemplate() {
15
14
  return `
@@ -19,32 +18,32 @@ class Y extends L {
19
18
  `;
20
19
  }
21
20
  onRender() {
22
- const e = l(this.currentNode);
23
- this.api.setUIEAttribute(c.CURRENCY_LOCATION, N.SELECTPICKER.items, p), this.api.updateValues({ [c.CURRENCY_LOCATION]: (e == null ? void 0 : e.priceCurrencyLocation) ?? "0" }), this.api.onValueChanged(c.CURRENCY_LOCATION, (t) => {
21
+ const e = C(this.currentNode);
22
+ this.api.setUIEAttribute(c.CURRENCY_LOCATION, R.SELECTPICKER.items, u), this.api.updateValues({ [c.CURRENCY_LOCATION]: (e == null ? void 0 : e.priceCurrencyLocation) ?? "0" }), this.api.onValueChanged(c.CURRENCY_LOCATION, (t) => {
24
23
  this._onCurrencyLocationChange(t);
25
24
  });
26
25
  }
27
26
  onTemplateNodeUpdated(e) {
28
27
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
29
- const t = l(this.currentNode);
28
+ const t = C(this.currentNode);
30
29
  this.api.updateValues({ [c.CURRENCY_LOCATION]: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0" });
31
30
  });
32
31
  }
33
32
  _onCurrencyLocationChange(e) {
34
- if (console.debug("Currency location changed to: ", e), O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
33
+ if (console.debug("Currency location changed to: ", e), I(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
35
34
  return;
36
35
  const t = this._getPriceBlocks();
37
36
  if (!t || t.length === 0)
38
37
  return;
39
- const r = l(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", i = E(n), s = this.api.getDocumentModifier();
40
- t.forEach((h) => {
41
- const a = this._getParagraph(h);
42
- if (!a)
38
+ const r = C(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", i = this.api.getDocumentModifier();
39
+ t.forEach((a) => {
40
+ const s = this._getParagraph(a);
41
+ if (!s)
43
42
  return;
44
- const d = a.getInnerHTML().trim() || "", C = a.getInnerText().trim() || "", u = (o == null ? void 0 : o.trim()) || "", _ = this._removeCurrencySymbol(C, u), g = this._detectSymbolInText(C) || u, R = this._buildPriceContent(_, g, n), y = d.replace(C, f(R));
45
- s.modifyHtml(a).setInnerHtml(y).setAttribute(T.POSITION, i);
46
- }), s.apply(new I(
47
- `Updated currency location to ${i}`
43
+ const h = s.getInnerHTML().trim() || "", l = s.getInnerText().trim() || "", p = (o == null ? void 0 : o.trim()) || "", d = this._removeCurrencySymbol(l, p), g = this._detectSymbolInText(l) || p, _ = this._buildPriceContent(d, g, n), y = h.replace(l, T(_));
44
+ i.modifyHtml(s).setInnerHtml(y);
45
+ }), i.apply(new L(
46
+ `Updated currency location to ${n === "1" ? "after" : "before"}`
48
47
  ));
49
48
  }
50
49
  _getPriceBlocks() {
@@ -66,8 +65,8 @@ class Y extends L {
66
65
  } else {
67
66
  const o = r.match(/([^0-9.,\s]+)/);
68
67
  if (o && o[1]) {
69
- const i = o[1].trim(), s = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
70
- n = r.replace(s, "").trim();
68
+ const i = o[1].trim(), a = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
69
+ n = r.replace(a, "").trim();
71
70
  }
72
71
  }
73
72
  return n;
@@ -86,13 +85,13 @@ class Y extends L {
86
85
  this._GuSelect({
87
86
  name: c.CURRENCY_LOCATION,
88
87
  placeholder: "",
89
- options: p
88
+ options: u
90
89
  })
91
90
  ])}
92
91
  `;
93
92
  }
94
93
  }
95
94
  export {
96
- b as CONTROL_BLOCK_ID,
97
- Y as PriceCurrencyLocationControl
95
+ E as CONTROL_BLOCK_ID,
96
+ A as PriceCurrencyLocationControl
98
97
  };
@@ -1,21 +1,20 @@
1
1
  var R = Object.defineProperty;
2
2
  var N = (s, c, e) => c in s ? R(s, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[c] = e;
3
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 B } from "../../../common-control.js";
6
- import { ITEMS_CURRENCY_ATTR as T } from "../../constants/currency.js";
4
+ import { ModificationDescription as B } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as E } from "../../../common-control.js";
7
6
  import { ItemsBlockControlId as y } from "../../enums/controlEnums.js";
8
- import { getItemsBlockConfig as p, setItemsBlockConfig as Y, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
9
- const x = y.PRICE_CURRENCY_SYMBOL, u = {
7
+ import { getItemsBlockConfig as p, setItemsBlockConfig as x, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
8
+ const I = y.PRICE_CURRENCY_SYMBOL, u = {
10
9
  CURRENCY_SYMBOL: "currencySymbol"
11
10
  };
12
- class $ extends B {
11
+ class P extends E {
13
12
  constructor() {
14
13
  super(...arguments);
15
14
  h(this, "originalPriceContents", /* @__PURE__ */ new Map());
16
15
  }
17
16
  getId() {
18
- return x;
17
+ return I;
19
18
  }
20
19
  getTemplate() {
21
20
  return `
@@ -43,7 +42,7 @@ class $ extends B {
43
42
  var a;
44
43
  console.debug("Currency symbol changed to: ", e);
45
44
  const t = p(this.currentNode), o = ((a = t == null ? void 0 : t.priceCurrencySymbol) == null ? void 0 : a.trim()) || "";
46
- if (Y(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
45
+ if (x(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
47
46
  return;
48
47
  const r = this._getPriceBlocks();
49
48
  if (!r || r.length === 0)
@@ -54,8 +53,8 @@ class $ extends B {
54
53
  if (!m)
55
54
  return;
56
55
  const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, f(S));
57
- i.modifyHtml(m).setInnerHtml(b).setAttribute(T.SYMBOL, n);
58
- }), i.apply(new E(
56
+ i.modifyHtml(m).setInnerHtml(b).setAttribute("data-currency_symbol", n);
57
+ }), i.apply(new B(
59
58
  `Updated currency symbol to ${n || "removed"}`
60
59
  ));
61
60
  }
@@ -116,6 +115,6 @@ class $ extends B {
116
115
  }
117
116
  }
118
117
  export {
119
- x as CONTROL_BLOCK_ID,
120
- $ as PriceCurrencySymbolControl
118
+ I as CONTROL_BLOCK_ID,
119
+ P as PriceCurrencySymbolControl
121
120
  };