@useinsider/guido 3.17.0-beta.17c2940 → 3.17.0-beta.1f18d2d

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 (24) hide show
  1. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.js +6 -6
  2. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +40 -35
  3. package/dist/composables/useModuleRepair.js +33 -0
  4. package/dist/composables/useStripo.js +1 -1
  5. package/dist/config/i18n/en/labels.json.js +1 -1
  6. package/dist/extensions/Blocks/Items/block.js +118 -49
  7. package/dist/extensions/Blocks/Items/constants/currency.js +25 -0
  8. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
  9. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -11
  10. package/dist/extensions/Blocks/Items/template.js +153 -152
  11. package/dist/extensions/Blocks/Recommendation/block.js +12 -11
  12. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +14 -13
  13. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +107 -106
  14. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +9 -9
  15. package/dist/src/composables/useModuleRepair.d.ts +18 -0
  16. package/dist/src/extensions/Blocks/Items/block.d.ts +35 -0
  17. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +43 -0
  18. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +2 -0
  19. package/dist/src/utils/itemsCurrencyRepair.d.ts +17 -0
  20. package/dist/utils/itemsCurrencyRepair.js +39 -0
  21. package/dist/utils/pairProductVariables.js +58 -58
  22. package/package.json +1 -1
  23. package/dist/composables/useModuleDynamicContentRepair.js +0 -37
  24. package/dist/src/composables/useModuleDynamicContentRepair.d.ts +0 -13
@@ -1,17 +1,17 @@
1
- import r from "./RemoveStrategyModal.vue2.js";
2
- import s from "../../../../_virtual/_plugin-vue2_normalizer.js";
1
+ import s from "./RemoveStrategyModal.vue2.js";
2
+ import r from "../../../../_virtual/_plugin-vue2_normalizer.js";
3
3
  var a = function() {
4
4
  var t = this, o = t._self._c, e = t._self._setupProxy;
5
- return e.store.removeStrategyModalStatus ? o(e.WpModal, { attrs: { id: "guido__remove-strategy-modal", size: "X-small", "close-on-outside-click": !1, "footer-button-options": e.footerButtonOptions, title: e.trans("email-editor.remove-strategy-confirm-title") }, on: { close: e.close, "primary-action": e.handleConfirm, "secondary-action": e.close } }, [o("p", [t._v(t._s(e.trans("email-editor.remove-strategy-confirm-message", { strategyName: e.strategyName })))])]) : t._e();
6
- }, n = [], i = /* @__PURE__ */ s(
7
- r,
5
+ return e.store.removeStrategyModalStatus ? o(e.WpModal, { attrs: { id: "guido__remove-strategy-modal", size: "small", "close-on-outside-click": !1, "footer-button-options": e.footerButtonOptions, title: e.trans("email-editor.remove-strategy-confirm-title") }, on: { close: e.close, "primary-action": e.handleConfirm, "secondary-action": e.close } }, [o("p", [t._v(t._s(e.messageParts[0])), o("b", [t._v(t._s(e.strategyName))]), t._v(t._s(e.messageParts[1]))])]) : t._e();
6
+ }, n = [], _ = /* @__PURE__ */ r(
7
+ s,
8
8
  a,
9
9
  n,
10
10
  !1,
11
11
  null,
12
12
  null
13
13
  );
14
- const c = i.exports;
14
+ const c = _.exports;
15
15
  export {
16
16
  c as default
17
17
  };
@@ -1,52 +1,57 @@
1
- import { defineComponent as p, computed as m } from "vue";
2
- import u from "../../../wrappers/WpModal.vue.js";
3
- import { useToaster as y } from "../../../../composables/useToaster.js";
4
- import { useTranslations as f } from "../../../../composables/useTranslations.js";
5
- import { ToasterTypeOptions as g } from "../../../../enums/toaster.js";
6
- import { useRecommendationExtensionStore as v } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
1
+ import { defineComponent as u, computed as n } from "vue";
2
+ import y from "../../../wrappers/WpModal.vue.js";
3
+ import { useToaster as f } from "../../../../composables/useToaster.js";
4
+ import { useTranslations as _ } from "../../../../composables/useTranslations.js";
5
+ import { ToasterTypeOptions as v } from "../../../../enums/toaster.js";
6
+ import { useRecommendationExtensionStore as T } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
7
7
  import { commitBlockChangeOutsidePanel as h } from "../../../../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
8
- const O = /* @__PURE__ */ p({
8
+ import { escapeHtml as R } from "../../../../utils/htmlEscape.js";
9
+ const P = /* @__PURE__ */ u({
9
10
  __name: "RemoveStrategyModal",
10
- setup(_) {
11
- const o = f(), e = v(), { showToaster: n } = y(), c = m(() => ({
11
+ setup(S) {
12
+ const t = _(), e = T(), { showToaster: a } = f(), i = n(() => ({
12
13
  cancelOrBackButton: {
13
14
  type: "secondary",
14
- labelText: o("products.cancel"),
15
+ labelText: t("products.cancel"),
15
16
  styling: "ghost"
16
17
  },
17
18
  primaryButton: {
18
19
  type: "danger",
19
- labelText: o("discovery-strategy.remove")
20
+ labelText: t("discovery-strategy.remove")
20
21
  }
21
- })), s = m(() => {
22
- var t;
22
+ })), m = n(() => {
23
+ var o;
23
24
  const { strategyId: r } = e.recommendationConfigs;
24
- return ((t = e.assignedStrategy) == null ? void 0 : t.name) || `#${r}`;
25
- }), a = () => {
25
+ return ((o = e.assignedStrategy) == null ? void 0 : o.name) || `#${r}`;
26
+ }), s = "__STRATEGY_NAME__", d = n(() => t("email-editor.remove-strategy-confirm-message", { strategyName: s }).split(s)), c = () => {
26
27
  e.closeRemoveStrategyModal();
27
28
  };
28
- return { __sfc: !0, trans: o, store: e, showToaster: n, footerButtonOptions: c, strategyName: s, close: a, handleConfirm: async () => {
29
- const r = s.value, t = e.currentRecommendationId;
30
- if (e.removeStrategy(), a(), n({
31
- type: g.Success,
32
- message: o("email-editor.strategy-removed-success", { strategyName: r })
33
- }), t === null)
34
- return;
35
- try {
36
- await e.fetchRecommendationProducts();
37
- } catch (l) {
38
- console.error("[RemoveStrategyModal] product refetch failed", l);
29
+ return { __sfc: !0, trans: t, store: e, showToaster: a, footerButtonOptions: i, strategyName: m, NAME_TOKEN: s, messageParts: d, close: c, handleConfirm: async () => {
30
+ const r = m.value, o = e.currentRecommendationId;
31
+ e.removeStrategy(), c();
32
+ const { strategyId: l, size: g } = e.recommendationConfigs;
33
+ if (a({
34
+ type: v.Success,
35
+ // The toast renders through a sanitizing v-html, so the name is escaped first.
36
+ message: t("email-editor.strategy-removed-success", {
37
+ strategyName: `<b>${R(r)}</b>`
38
+ })
39
+ }), o !== null) {
40
+ try {
41
+ await e.fetchRecommendationProducts();
42
+ } catch (p) {
43
+ console.error("[RemoveStrategyModal] product refetch failed", p);
44
+ }
45
+ h(
46
+ o,
47
+ { strategyId: l, size: g },
48
+ e.recommendationProducts,
49
+ "Removed recommendation strategy"
50
+ );
39
51
  }
40
- const { strategyId: i, size: d } = e.recommendationConfigs;
41
- h(
42
- t,
43
- { strategyId: i, size: d },
44
- e.recommendationProducts,
45
- "Removed recommendation strategy"
46
- );
47
- }, WpModal: u };
52
+ }, WpModal: y };
48
53
  }
49
54
  });
50
55
  export {
51
- O as default
56
+ P as default
52
57
  };
@@ -0,0 +1,33 @@
1
+ import { useConfig as C } from "./useConfig.js";
2
+ import { useToaster as T } from "./useToaster.js";
3
+ import { useTranslations as g } from "./useTranslations.js";
4
+ import { ToasterTypeOptions as D } from "../enums/toaster.js";
5
+ import { buildDynamicContentLookup as f, convertModuleDynamicContent as h } from "../utils/dynamicContentConverter.js";
6
+ import { flattenDynamicContentList as O } from "../utils/genericUtil.js";
7
+ import { repairItemsCurrencyAttributes as M } from "../utils/itemsCurrencyRepair.js";
8
+ const N = "dynamic-content.unresolved-attributes-on-drop", R = () => {
9
+ const { template: p, isFeatureEnabled: m } = C(), { showToaster: a } = T(), y = g();
10
+ return { handleModuleAdd: (e, o) => {
11
+ var s, l, u;
12
+ try {
13
+ if ((e == null ? void 0 : e.action) !== "ADD" && (e == null ? void 0 : e.action) !== "COPY")
14
+ return;
15
+ const t = (s = o == null ? void 0 : o.getTargetNode) == null ? void 0 : s.call(o), r = (l = t == null ? void 0 : t.getOuterHTML) == null ? void 0 : l.call(t);
16
+ if (!t || typeof r != "string")
17
+ return;
18
+ let n = M(r);
19
+ const c = f(O((u = p.value) == null ? void 0 : u.dynamicContentList));
20
+ let i = [];
21
+ c.size > 0 && ({ html: n, unresolved: i } = h(n, c, m("liquidSyntax"))), n !== r && o.modifyHtml(t).replaceWith(n), i.length > 0 && a({
22
+ type: D.Warning,
23
+ message: y(N)
24
+ });
25
+ } catch (t) {
26
+ console.error("Failed to repair module on add:", t);
27
+ }
28
+ } };
29
+ };
30
+ export {
31
+ N as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
32
+ R as useModuleRepair
33
+ };
@@ -3,7 +3,7 @@ import { useBlocksConfig as O } from "./useBlocksConfig.js";
3
3
  import { useConfig as q } from "./useConfig.js";
4
4
  import { useCustomInterfaceAppearance as H } from "./useCustomInterfaceAppearance.js";
5
5
  import { useFullStoryBridge as N } from "./useFullStoryBridge.js";
6
- import { useModuleDynamicContentRepair as j } from "./useModuleDynamicContentRepair.js";
6
+ import { useModuleRepair as j } from "./useModuleRepair.js";
7
7
  import { useStripoEventHandler as z } from "./useStripoEventHandler.js";
8
8
  import { useStripoNotifications as $ } from "./useStripoNotifications.js";
9
9
  import { useToaster as G } from "./useToaster.js";
@@ -1,7 +1,7 @@
1
1
  const e = "Items", o = "Default", t = "Custom", s = {
2
2
  "Global Styles & Layout": "Global Styles and Layout",
3
3
  "Structures & Modules": "Structures and Modules",
4
- "Recommendation Block": "Recommendation",
4
+ "Recommendation Block": "Recommendation Block",
5
5
  Items: e,
6
6
  "This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.": "This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.",
7
7
  "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.": "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.",
@@ -1,20 +1,32 @@
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 {
1
+ var k = Object.defineProperty;
2
+ var D = (l, a, t) => a in l ? k(l, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[a] = t;
3
+ var y = (l, a, t) => D(l, typeof a != "symbol" ? a + "" : a, t);
4
+ import { BlockId as N } from "../../../enums/block.js";
5
+ import { useOnboardingStore as T } from "../../../stores/onboarding.js";
6
+ import { getMigrationBannerHtml as S } from "../../../utils/migrationBannerHtml.js";
7
+ import { Block as A, BlockCompositionType as M, ModificationDescription as u } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
8
+ import { currencyAttrTargets as H, ITEMS_CURRENCY_ATTR as m } from "./constants/currency.js";
9
+ import { ItemsBlockId as R } from "./enums/controlEnums.js";
10
+ import { SETTINGS_ENUMS as C, DefaultConfigValues as g } from "./enums/settingsEnums.js";
11
+ import { getDefaultTemplate as O } from "./template.js";
12
+ import { getItemsBlockContainer as b, getItemsBlockConfig as h, deriveItemNumber as B, generateBlockInstanceId as E, getDefaultItemsBlockConfig as w } from "./utils/nodeConfigUtils.js";
13
+ const _ = N.Items, P = "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
+ y(this, "_currencyHealed", /* @__PURE__ */ new Set());
19
+ /** blockInstanceIds already claimed by a live block this session (SD-147588 collision detection). */
20
+ y(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
21
+ }
10
22
  getId() {
11
- return p;
23
+ return _;
12
24
  }
13
25
  getIcon() {
14
26
  return "items-icon";
15
27
  }
16
28
  getBlockCompositionType() {
17
- return b.CONTAINER;
29
+ return M.CONTAINER;
18
30
  }
19
31
  getName() {
20
32
  return this.api.translate("Items");
@@ -23,20 +35,20 @@ class E extends C {
23
35
  return this.api.translate("Items lets you display personalized products based on user behavior.");
24
36
  }
25
37
  getSettingsPanelTitleHtml() {
26
- return I(
27
- p,
38
+ return S(
39
+ _,
28
40
  this.api.translate("Items"),
29
41
  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.")
30
42
  );
31
43
  }
32
44
  getTemplate() {
33
- return h({
34
- orientation: l.ORIENTATION.VERTICAL,
35
- itemsType: l.ITEMS_TYPE.CART_ITEMS,
45
+ return O({
46
+ orientation: C.ORIENTATION.VERTICAL,
47
+ itemsType: C.ITEMS_TYPE.CART_ITEMS,
36
48
  itemId: "{{Abandoned Cart Item (1) Url}}",
37
- currencySymbol: d.productPriceCurrencySymbolControlValue,
38
- currencyLocation: d.productPriceCurrencyLocationControlValue,
39
- formattedPrice: d.productPriceFormattedControlValue === "1"
49
+ currencySymbol: g.productPriceCurrencySymbolControlValue,
50
+ currencyLocation: g.productPriceCurrencyLocationControlValue,
51
+ formattedPrice: g.productPriceFormattedControlValue === "1"
40
52
  });
41
53
  }
42
54
  allowInnerBlocksDND() {
@@ -45,24 +57,27 @@ class E extends C {
45
57
  canBeSavedAsModule() {
46
58
  return !0;
47
59
  }
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)
60
+ onCreated(t) {
61
+ const o = this.api.getDocumentModifier(), c = this.api.getDocumentRootCssNode();
62
+ c.querySelector('[product-attr="imageSrc"] img') || o.modifyCss(c).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
63
+ const i = b(t);
64
+ if (!i)
53
65
  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"));
66
+ const r = i.getNodeConfig(), s = r && Object.keys(r).length > 0, e = h(t);
67
+ if (e != null && e.initialized) {
68
+ if (!s) {
69
+ const d = this.api.getDocumentModifier();
70
+ d.modifyHtml(i).setNodeConfig(e), this._stampProductTdDomAttributes(i, e, d), this._shouldReconcileCurrency(e) && this._reconcileCurrencyDomAttributes(i, e, d), d.apply(new u("Migrate legacy config to nodeConfig")), this._markCurrencyHealed(e.blockInstanceId);
71
+ return;
61
72
  }
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");
73
+ } else {
74
+ const d = w(), p = this.api.getDocumentModifier();
75
+ p.modifyHtml(i).setNodeConfig(d), this._stampProductTdDomAttributes(i, d, p, !0), p.apply(new u("Initialize Items block with default configuration")), T().startOnboarding("itemsOnboarding");
76
+ return;
65
77
  }
78
+ const n = this._resolveInstanceId(e.blockInstanceId), f = this.api.getDocumentModifier();
79
+ let I = !1;
80
+ n !== e.blockInstanceId && (f.modifyHtml(i).setNodeConfig({ ...e, blockInstanceId: n }), I = !0), !this._currencyHealed.has(n) && this._reconcileCurrencyDomAttributes(i, e, f) && (I = !0), I && f.apply(new u("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(n);
66
81
  }
67
82
  /**
68
83
  * Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
@@ -70,18 +85,24 @@ class E extends C {
70
85
  * into nodeConfig, so without this a reused module would reset to defaults.
71
86
  * Guarded to the nodeConfig-empty case so it runs once and never loops.
72
87
  */
73
- onDocumentChanged(n) {
74
- const t = u(n);
75
- if (!t)
88
+ onDocumentChanged(t) {
89
+ const o = b(t);
90
+ if (!o)
76
91
  return;
77
- const a = t.getNodeConfig();
78
- if (a && Object.keys(a).length > 0)
92
+ const c = o.getNodeConfig();
93
+ if (c && Object.keys(c).length > 0) {
94
+ const e = h(t);
95
+ if (e != null && e.initialized && this._shouldReconcileCurrency(e)) {
96
+ const n = this.api.getDocumentModifier();
97
+ this._reconcileCurrencyDomAttributes(o, e, n) && n.apply(new u(P)), this._markCurrencyHealed(e.blockInstanceId);
98
+ }
79
99
  return;
80
- const o = f(n);
81
- if (!(o != null && o.initialized))
100
+ }
101
+ const r = h(t);
102
+ if (!(r != null && r.initialized))
82
103
  return;
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
+ const s = this.api.getDocumentModifier();
105
+ s.modifyHtml(o).setNodeConfig(r), this._stampProductTdDomAttributes(o, r, s), this._shouldReconcileCurrency(r) && this._reconcileCurrencyDomAttributes(o, r, s), s.apply(new u("Recover Items block config from saved module")), this._markCurrencyHealed(r.blockInstanceId);
85
106
  }
86
107
  /**
87
108
  * Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
@@ -91,14 +112,62 @@ class E extends C {
91
112
  * restored before export. The name `<a>` carries no data-type/data-number of its own and
92
113
  * relies on this td-level fallback in pairProductVariables.
93
114
  */
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);
115
+ _stampProductTdDomAttributes(t, o, c, i = !1) {
116
+ const r = B(o.itemsSelectValue, o.type), s = (e, n) => {
117
+ i && t.getAttribute(e) || c.modifyHtml(t).setAttribute(e, n);
97
118
  };
98
- r("data-type", t.type), r("data-number", o), r("data-nodup", String(t.priceHideDiscount));
119
+ s("data-type", o.type), s("data-number", r), s("data-nodup", String(o.priceHideDiscount));
120
+ }
121
+ /**
122
+ * Whether a currency self-heal pass should run for this block (SD-147588). The only gate here is
123
+ * once-per-session: heal each instance at most once, so the auto-fix can't fight undo (undo
124
+ * re-drifts the attr, which would otherwise re-trigger the heal forever). The position-vs-symbol
125
+ * authority split lives in `_reconcileCurrencyDomAttributes` — position is always authoritative,
126
+ * the symbol write alone is skipped for the 'USD' sentinel — so we must NOT gate the whole pass
127
+ * on symbol customization here, or a default-symbol block with a toggled location never heals.
128
+ */
129
+ _shouldReconcileCurrency(t) {
130
+ return !t.blockInstanceId || !this._currencyHealed.has(t.blockInstanceId);
131
+ }
132
+ /** Marks a block instance's currency as reconciled so it is not healed again (undo-safe). */
133
+ _markCurrencyHealed(t) {
134
+ t && this._currencyHealed.add(t);
135
+ }
136
+ /**
137
+ * Resolves the id for a just-created block to one that is unique per live instance.
138
+ * A saved module serializes its blockInstanceId, so every re-drop of the same module
139
+ * arrives with an id already owned by a live instance — reusing it collides both the
140
+ * currency heal guard and settings-panel switch detection. Mint a fresh id on absence
141
+ * or collision, otherwise keep the existing one. Registers the result as claimed.
142
+ */
143
+ _resolveInstanceId(t) {
144
+ let o = t;
145
+ if (!o || this._seenInstanceIds.has(o))
146
+ do
147
+ o = E();
148
+ while (this._seenInstanceIds.has(o));
149
+ return this._seenInstanceIds.add(o), o;
150
+ }
151
+ /**
152
+ * Stamps the export-read currency attrs onto every price `<p>` from config, so a template whose
153
+ * attrs drifted (e.g. a location toggle before the sync fix) self-heals to match the editor.
154
+ * Config is the source of truth — never derive from visible text.
155
+ *
156
+ * Authority split lives in `currencyAttrTargets` (SD-147588) — position only when a location
157
+ * is recorded, symbol only when customized — so this heal and the module-drop repair can't drift.
158
+ *
159
+ * Returns true only when an attr actually changed, so the caller can skip an empty apply that
160
+ * would otherwise re-trigger onDocumentChanged and loop.
161
+ */
162
+ _reconcileCurrencyDomAttributes(t, o, c) {
163
+ const { position: i, symbol: r } = H(o), s = t.querySelectorAll(`.${R.PRICE} p`);
164
+ let e = !1;
165
+ return s.forEach((n) => {
166
+ i !== void 0 && n.getAttribute(m.POSITION) !== i && (c.modifyHtml(n).setAttribute(m.POSITION, i), e = !0), r !== void 0 && n.getAttribute(m.SYMBOL) !== r && (c.modifyHtml(n).setAttribute(m.SYMBOL, r), e = !0);
167
+ }), e;
99
168
  }
100
169
  }
101
170
  export {
102
- p as BLOCK_ID,
103
- E as ItemsBlock
171
+ _ as BLOCK_ID,
172
+ K as ItemsBlock
104
173
  };
@@ -0,0 +1,25 @@
1
+ import { DefaultConfigValues as c } from "../enums/settingsEnums.js";
2
+ const s = {
3
+ POSITION: "data-curency",
4
+ SYMBOL: "data-currency_symbol"
5
+ };
6
+ function e(r) {
7
+ return r === "1" ? "after" : "before";
8
+ }
9
+ function i(r) {
10
+ const o = (r ?? "").trim();
11
+ return o !== "" && o !== c.productPriceCurrencySymbolControlValue;
12
+ }
13
+ function a(r) {
14
+ const o = r.priceCurrencyLocation, n = typeof o == "string" && o.trim() !== "", t = (r.priceCurrencySymbol ?? "").trim();
15
+ return {
16
+ position: n ? e(o) : void 0,
17
+ symbol: i(t) ? t : void 0
18
+ };
19
+ }
20
+ export {
21
+ s as ITEMS_CURRENCY_ATTR,
22
+ a as currencyAttrTargets,
23
+ e as currencyPositionFromLocation,
24
+ i as isCustomCurrencySymbol
25
+ };
@@ -1,14 +1,15 @@
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";
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";
4
5
  import { ItemsBlockControlId as m } from "../../enums/controlEnums.js";
5
- import { getItemsBlockConfig as C, setItemsBlockConfig as I, escapeReplacement as T } from "../../utils/nodeConfigUtils.js";
6
- const E = m.PRICE_CURRENCY_LOCATION, c = {
6
+ import { getItemsBlockConfig as l, setItemsBlockConfig as O, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
7
+ const b = m.PRICE_CURRENCY_LOCATION, c = {
7
8
  CURRENCY_LOCATION: "currencyLocation"
8
9
  };
9
- class A extends N {
10
+ class Y extends L {
10
11
  getId() {
11
- return E;
12
+ return b;
12
13
  }
13
14
  getTemplate() {
14
15
  return `
@@ -18,32 +19,32 @@ class A extends N {
18
19
  `;
19
20
  }
20
21
  onRender() {
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) => {
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) => {
23
24
  this._onCurrencyLocationChange(t);
24
25
  });
25
26
  }
26
27
  onTemplateNodeUpdated(e) {
27
28
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
28
- const t = C(this.currentNode);
29
+ const t = l(this.currentNode);
29
30
  this.api.updateValues({ [c.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), I(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
34
+ if (console.debug("Currency location changed to: ", e), O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
34
35
  return;
35
36
  const t = this._getPriceBlocks();
36
37
  if (!t || t.length === 0)
37
38
  return;
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)
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)
42
43
  return;
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"}`
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}`
47
48
  ));
48
49
  }
49
50
  _getPriceBlocks() {
@@ -65,8 +66,8 @@ class A extends N {
65
66
  } else {
66
67
  const o = r.match(/([^0-9.,\s]+)/);
67
68
  if (o && o[1]) {
68
- const i = o[1].trim(), a = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
69
- n = r.replace(a, "").trim();
69
+ const i = o[1].trim(), s = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
70
+ n = r.replace(s, "").trim();
70
71
  }
71
72
  }
72
73
  return n;
@@ -85,13 +86,13 @@ class A extends N {
85
86
  this._GuSelect({
86
87
  name: c.CURRENCY_LOCATION,
87
88
  placeholder: "",
88
- options: u
89
+ options: p
89
90
  })
90
91
  ])}
91
92
  `;
92
93
  }
93
94
  }
94
95
  export {
95
- E as CONTROL_BLOCK_ID,
96
- A as PriceCurrencyLocationControl
96
+ b as CONTROL_BLOCK_ID,
97
+ Y as PriceCurrencyLocationControl
97
98
  };
@@ -1,20 +1,21 @@
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 B } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as E } from "../../../common-control.js";
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";
6
7
  import { ItemsBlockControlId as y } from "../../enums/controlEnums.js";
7
- import { getItemsBlockConfig as p, setItemsBlockConfig as x, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
8
- const I = y.PRICE_CURRENCY_SYMBOL, u = {
8
+ import { getItemsBlockConfig as p, setItemsBlockConfig as Y, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
9
+ const x = y.PRICE_CURRENCY_SYMBOL, u = {
9
10
  CURRENCY_SYMBOL: "currencySymbol"
10
11
  };
11
- class P extends E {
12
+ class $ extends B {
12
13
  constructor() {
13
14
  super(...arguments);
14
15
  h(this, "originalPriceContents", /* @__PURE__ */ new Map());
15
16
  }
16
17
  getId() {
17
- return I;
18
+ return x;
18
19
  }
19
20
  getTemplate() {
20
21
  return `
@@ -42,7 +43,7 @@ class P extends E {
42
43
  var a;
43
44
  console.debug("Currency symbol changed to: ", e);
44
45
  const t = p(this.currentNode), o = ((a = t == null ? void 0 : t.priceCurrencySymbol) == null ? void 0 : a.trim()) || "";
45
- if (x(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
46
+ if (Y(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
46
47
  return;
47
48
  const r = this._getPriceBlocks();
48
49
  if (!r || r.length === 0)
@@ -53,8 +54,8 @@ class P extends E {
53
54
  if (!m)
54
55
  return;
55
56
  const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, f(S));
56
- i.modifyHtml(m).setInnerHtml(b).setAttribute("data-currency_symbol", n);
57
- }), i.apply(new B(
57
+ i.modifyHtml(m).setInnerHtml(b).setAttribute(T.SYMBOL, n);
58
+ }), i.apply(new E(
58
59
  `Updated currency symbol to ${n || "removed"}`
59
60
  ));
60
61
  }
@@ -115,6 +116,6 @@ class P extends E {
115
116
  }
116
117
  }
117
118
  export {
118
- I as CONTROL_BLOCK_ID,
119
- P as PriceCurrencySymbolControl
119
+ x as CONTROL_BLOCK_ID,
120
+ $ as PriceCurrencySymbolControl
120
121
  };