@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.
- package/dist/composables/useSave.js +30 -29
- package/dist/composables/useSyncModuleExtractor.js +15 -13
- package/dist/composables/validators/useSyncModuleBlockValidator.js +24 -0
- package/dist/extensions/Blocks/Items/block.js +49 -105
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +24 -25
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +11 -12
- package/dist/extensions/Blocks/Items/template.js +152 -153
- package/dist/extensions/Blocks/Items/utils/constants.js +4 -0
- package/dist/extensions/Blocks/Recommendation/utils/recommendationBlockCount.js +10 -6
- package/dist/src/composables/useSyncModuleExtractor.d.ts +2 -0
- package/dist/src/composables/validators/useSyncModuleBlockValidator.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +0 -29
- package/dist/src/extensions/Blocks/Items/utils/constants.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/recommendationBlockCount.d.ts +6 -2
- package/dist/utils/pairProductVariables.js +58 -58
- package/package.json +1 -1
- package/dist/extensions/Blocks/Items/constants/currency.js +0 -17
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +0 -26
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useSaveStart as
|
|
4
|
-
import { useSyncModuleExtractor as
|
|
5
|
-
import { ToasterTypeOptions as
|
|
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
|
|
12
|
-
import { useLiquidValidator as
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
-
const { prepareTemplateDetails:
|
|
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 (
|
|
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 =
|
|
28
|
+
if ((r = a.value) != null && r.externalValidation && !await a.value.externalValidation(t))
|
|
28
29
|
return;
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
if (!
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
type:
|
|
36
|
-
message:
|
|
37
|
-
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
|
|
44
|
+
if (!await b())
|
|
44
45
|
return;
|
|
45
|
-
const { unsubscribePayload:
|
|
46
|
-
return await
|
|
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
|
-
|
|
51
|
+
it as useSave
|
|
51
52
|
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { UNSUBSCRIBE_SYNC_MODULE_TYPES as
|
|
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
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
return { extractSyncModuleData: (
|
|
7
|
-
const
|
|
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 (!
|
|
12
|
-
return
|
|
13
|
-
const b = new DOMParser().parseFromString(
|
|
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(
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
11
|
+
return p;
|
|
22
12
|
}
|
|
23
13
|
getIcon() {
|
|
24
14
|
return "items-icon";
|
|
25
15
|
}
|
|
26
16
|
getBlockCompositionType() {
|
|
27
|
-
return
|
|
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
|
|
37
|
-
|
|
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
|
|
44
|
-
orientation:
|
|
45
|
-
itemsType:
|
|
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:
|
|
48
|
-
currencyLocation:
|
|
49
|
-
formattedPrice:
|
|
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(
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
if (!
|
|
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
|
|
65
|
-
if (
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
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(
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
73
|
+
onDocumentChanged(n) {
|
|
74
|
+
const t = u(n);
|
|
75
|
+
if (!t)
|
|
89
76
|
return;
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
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
|
-
|
|
100
|
-
if (!(i != null && i.initialized))
|
|
80
|
+
const o = f(n);
|
|
81
|
+
if (!(o != null && o.initialized))
|
|
101
82
|
return;
|
|
102
|
-
const
|
|
103
|
-
|
|
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(
|
|
114
|
-
const
|
|
115
|
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
-
|
|
102
|
+
p as BLOCK_ID,
|
|
103
|
+
E as ItemsBlock
|
|
160
104
|
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { currencyLocationMaps as
|
|
2
|
-
import { UEAttr as
|
|
3
|
-
import { CommonControl as
|
|
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
|
|
7
|
-
const
|
|
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
|
|
9
|
+
class A extends N {
|
|
11
10
|
getId() {
|
|
12
|
-
return
|
|
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 =
|
|
23
|
-
this.api.setUIEAttribute(c.CURRENCY_LOCATION,
|
|
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 =
|
|
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),
|
|
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 =
|
|
40
|
-
t.forEach((
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
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
|
|
45
|
-
|
|
46
|
-
}),
|
|
47
|
-
`Updated currency location to ${
|
|
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(),
|
|
70
|
-
n = r.replace(
|
|
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:
|
|
88
|
+
options: u
|
|
90
89
|
})
|
|
91
90
|
])}
|
|
92
91
|
`;
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
94
|
export {
|
|
96
|
-
|
|
97
|
-
|
|
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
|
|
5
|
-
import { CommonControl as
|
|
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
|
|
9
|
-
const
|
|
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
|
|
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
|
|
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 (
|
|
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(
|
|
58
|
-
}), i.apply(new
|
|
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
|
-
|
|
120
|
-
|
|
118
|
+
I as CONTROL_BLOCK_ID,
|
|
119
|
+
P as PriceCurrencySymbolControl
|
|
121
120
|
};
|