@useinsider/guido 3.23.0-beta.9f6bfbf → 3.23.0-beta.a35efcf
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/README.md +9 -1
- package/dist/@types/config/schemas.js +26 -26
- package/dist/components/Guido.vue.js +5 -5
- package/dist/components/Guido.vue2.js +88 -86
- package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.js +17 -0
- package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue2.js +30 -0
- package/dist/composables/useModuleRepair.js +30 -23
- package/dist/config/migrator/index.js +16 -16
- package/dist/config/migrator/legacyUnsubscribeTextMigrator.js +16 -0
- package/dist/enums/academy.js +2 -1
- package/dist/extensions/Blocks/Items/block.js +77 -115
- package/dist/extensions/Blocks/Items/constants/currency.js +14 -59
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +22 -33
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +51 -62
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +17 -18
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +31 -42
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +120 -141
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +1 -1
- package/dist/extensions/Blocks/Items/extension.js +8 -9
- package/dist/extensions/Blocks/Items/items.css.js +0 -19
- package/dist/extensions/Blocks/Items/settingsPanel.js +25 -34
- package/dist/extensions/Blocks/Items/template.js +212 -250
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +0 -1
- package/dist/guido.css +1 -1
- package/dist/package.json.js +2 -2
- package/dist/src/@types/config/schemas.d.ts +4 -4
- package/dist/src/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +2 -2
- package/dist/src/composables/useModuleRepair.d.ts +2 -11
- package/dist/src/config/migrator/index.d.ts +1 -4
- package/dist/src/config/migrator/legacyUnsubscribeTextMigrator.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +9 -6
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +0 -32
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/template.d.ts +1 -4
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +0 -3
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +0 -12
- package/dist/src/stores/config.d.ts +20 -20
- package/dist/src/stores/editor.d.ts +25 -0
- package/dist/src/utils/itemsCurrencyRepair.d.ts +1 -5
- package/dist/src/utils/legacyUnsubscribeConversion.d.ts +10 -0
- package/dist/static/stripo-runtime-manifest.json.js +1 -1
- package/dist/stores/editor.js +15 -14
- package/dist/utils/itemsCurrencyRepair.js +24 -29
- package/dist/utils/legacyUnsubscribeConversion.js +49 -0
- package/dist/utils/pairProductVariables.js +99 -119
- package/package.json +2 -2
- package/dist/config/migrator/itemsPriceFormatMigrator.js +0 -20
- package/dist/extensions/Blocks/Items/controls/priceFormat.js +0 -145
- package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +0 -185
- package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +0 -23
- package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +0 -61
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
2
|
-
import { migrateCouponBlock as
|
|
3
|
-
import { migrateFullStoryScripts as
|
|
4
|
-
import { migrateItemsBlock as
|
|
5
|
-
import {
|
|
6
|
-
import { migrateProductNameLink as
|
|
7
|
-
import { migrateRadioButton as
|
|
8
|
-
import { migrateRecommendation as
|
|
9
|
-
import { migrateRecommendationPartnerScope as
|
|
10
|
-
import { migrateRecommendationTitle as
|
|
11
|
-
import { migrateSocialIcons as
|
|
12
|
-
import { migrateUnsubscribe as
|
|
13
|
-
const
|
|
14
|
-
let m =
|
|
15
|
-
return 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 c } from "./itemsBlockMigrator.js";
|
|
5
|
+
import { migrateLegacyUnsubscribeText as g } from "./legacyUnsubscribeTextMigrator.js";
|
|
6
|
+
import { migrateProductNameLink as n } from "./productNameLinkMigrator.js";
|
|
7
|
+
import { migrateRadioButton as p } from "./radioButtonMigrator.js";
|
|
8
|
+
import { migrateRecommendation as f } from "./recommendationMigrator.js";
|
|
9
|
+
import { migrateRecommendationPartnerScope as s } from "./recommendationPartnerMigrator.js";
|
|
10
|
+
import { migrateRecommendationTitle as l } from "./recommendationTitleMigrator.js";
|
|
11
|
+
import { migrateSocialIcons as u } from "./socialIconMigrator.js";
|
|
12
|
+
import { migrateUnsubscribe as d } from "./unsubscribeMigrator.js";
|
|
13
|
+
const U = async (o, t = {}, r) => {
|
|
14
|
+
let m = o;
|
|
15
|
+
return m = i(m), m = p(m), m = g(m), m = await d(m), m = e(m), m = f(m, t), r && (m = s(m, r)), m = l(m), m = c(m), m = n(m), m = u(m), m = a(m), m;
|
|
16
16
|
};
|
|
17
17
|
export {
|
|
18
|
-
|
|
18
|
+
U as migrate
|
|
19
19
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useConfigStore as o } from "../../stores/config.js";
|
|
2
|
+
import { useEditorStore as s } from "../../stores/editor.js";
|
|
3
|
+
import { hasLegacyUnsubscribeClass as c, convertLegacyUnsubscribeInDocumentHtml as i } from "../../utils/legacyUnsubscribeConversion.js";
|
|
4
|
+
const b = (e) => {
|
|
5
|
+
try {
|
|
6
|
+
if (!c(e) || !o().isFeatureEnabled("legacyUnsubscribeConversion"))
|
|
7
|
+
return e;
|
|
8
|
+
const { html: r, converted: t } = i(e);
|
|
9
|
+
return t && (s().isLegacyUnsubscribeModalRequested = !0), r;
|
|
10
|
+
} catch (r) {
|
|
11
|
+
return console.error("LegacyUnsubscribeTextMigrator failed:", r), e;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
b as migrateLegacyUnsubscribeText
|
|
16
|
+
};
|
package/dist/enums/academy.js
CHANGED
|
@@ -2,7 +2,8 @@ const e = "https://academy.insiderone.com", o = {
|
|
|
2
2
|
EMAIL_EDITOR: `${e}/docs/email-drag-and-drop-editor`,
|
|
3
3
|
GLOBAL_UNSUBSCRIBE: `${e}/docs/global-unsubscribe-preference-center`,
|
|
4
4
|
AMP_FOR_EMAILS: `${e}/docs/amp-for-emails`,
|
|
5
|
-
EMAIL_RECOMMENDATION_BLOCK: `${e}/docs/new-editor-email-recommendation-block
|
|
5
|
+
EMAIL_RECOMMENDATION_BLOCK: `${e}/docs/new-editor-email-recommendation-block`,
|
|
6
|
+
LEGACY_UNSUBSCRIBE_MODULE: `${e}/docs/new-editor-add-unsubscribe-pages-into-emails`
|
|
6
7
|
};
|
|
7
8
|
export {
|
|
8
9
|
o as ACADEMY_LINKS
|
|
@@ -1,42 +1,33 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
+
g(this, "_currencyHealed", /* @__PURE__ */ new Set());
|
|
29
20
|
/** blockInstanceIds already claimed by a live block this session (SD-147588 collision detection). */
|
|
30
|
-
|
|
21
|
+
g(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
|
|
31
22
|
}
|
|
32
23
|
getId() {
|
|
33
|
-
return
|
|
24
|
+
return A;
|
|
34
25
|
}
|
|
35
26
|
getIcon() {
|
|
36
27
|
return "items-icon";
|
|
37
28
|
}
|
|
38
29
|
getBlockCompositionType() {
|
|
39
|
-
return
|
|
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
|
|
49
|
-
|
|
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
|
|
56
|
-
orientation:
|
|
57
|
-
itemsType:
|
|
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:
|
|
60
|
-
currencyLocation:
|
|
61
|
-
formattedPrice:
|
|
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(),
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
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
|
|
78
|
-
if (
|
|
79
|
-
if (!
|
|
80
|
-
const
|
|
81
|
-
|
|
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
|
|
86
|
-
|
|
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
|
|
93
|
-
let
|
|
94
|
-
|
|
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 =
|
|
90
|
+
const e = _(t);
|
|
104
91
|
if (!e)
|
|
105
92
|
return;
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
const
|
|
111
|
-
this._reconcileCurrencyDomAttributes(e,
|
|
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
|
|
116
|
-
if (!(
|
|
102
|
+
const o = C(t);
|
|
103
|
+
if (!(o != null && o.initialized))
|
|
117
104
|
return;
|
|
118
|
-
const
|
|
119
|
-
|
|
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,
|
|
130
|
-
const
|
|
131
|
-
|
|
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
|
-
|
|
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
|
|
141
|
-
return !
|
|
142
|
-
const
|
|
143
|
-
(
|
|
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 =
|
|
159
|
+
e = P();
|
|
173
160
|
while (this._seenInstanceIds.has(e));
|
|
174
161
|
return this._seenInstanceIds.add(e), e;
|
|
175
162
|
}
|
|
176
163
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
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,
|
|
181
|
-
const o =
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
222
|
-
|
|
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
|
|
2
|
+
const s = {
|
|
3
3
|
POSITION: "data-curency",
|
|
4
4
|
SYMBOL: "data-currency_symbol"
|
|
5
5
|
};
|
|
6
|
-
function
|
|
7
|
-
return
|
|
6
|
+
function e(r) {
|
|
7
|
+
return r === "1" ? "after" : "before";
|
|
8
8
|
}
|
|
9
|
-
function i(
|
|
10
|
-
const
|
|
11
|
-
return
|
|
9
|
+
function i(r) {
|
|
10
|
+
const o = (r ?? "").trim();
|
|
11
|
+
return o !== "" && o !== c.productPriceCurrencySymbolControlValue;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
13
|
+
function a(r) {
|
|
14
|
+
const o = r.priceCurrencyLocation, n = typeof o == "string" && o.trim() !== "", t = (r.priceCurrencySymbol ?? "").trim();
|
|
15
15
|
return {
|
|
16
|
-
position:
|
|
17
|
-
symbol: i(
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
2
|
-
import { UEAttr as I, ModificationDescription as
|
|
3
|
-
import { CommonControl as
|
|
4
|
-
import { ITEMS_CURRENCY_ATTR as
|
|
5
|
-
import { ItemsBlockControlId as
|
|
6
|
-
import { getItemsBlockConfig as
|
|
7
|
-
|
|
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
|
|
10
|
+
class B extends N {
|
|
12
11
|
getId() {
|
|
13
|
-
return
|
|
12
|
+
return b;
|
|
14
13
|
}
|
|
15
14
|
getTemplate() {
|
|
16
15
|
return `
|
|
17
|
-
<div class="container ${
|
|
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,
|
|
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 =
|
|
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
|
-
|
|
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 =
|
|
50
|
-
t.forEach((
|
|
51
|
-
const s = this._getParagraph(
|
|
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
|
|
55
|
-
i.modifyHtml(s).setInnerHtml(R).setAttribute(
|
|
56
|
-
}), i.apply(new
|
|
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:
|
|
88
|
+
options: m
|
|
100
89
|
})
|
|
101
90
|
])}
|
|
102
91
|
`;
|
|
103
92
|
}
|
|
104
93
|
}
|
|
105
94
|
export {
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
b as CONTROL_BLOCK_ID,
|
|
96
|
+
B as PriceCurrencyLocationControl
|
|
108
97
|
};
|