@useinsider/guido 3.24.0-beta.8e9f4e2 → 3.24.0-beta.9312ed2
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 +2 -0
- package/dist/@types/config/schemas.js +19 -15
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +79 -77
- package/dist/composables/useModuleRepair.js +14 -12
- package/dist/composables/useSave.js +57 -52
- package/dist/composables/useSaveValidation.js +118 -110
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +48 -33
- package/dist/config/migrator/index.js +16 -15
- package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
- package/dist/config/migrator/recommendationMigrator.js +63 -69
- package/dist/enums/save-validation.js +1 -1
- package/dist/extensions/Blocks/Items/block.js +115 -77
- package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
- package/dist/extensions/Blocks/Items/controls/blockBackground/index.js +11 -0
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -23
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
- package/dist/extensions/Blocks/Items/controls/priceFormat.js +135 -0
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
- package/dist/extensions/Blocks/Items/extension.js +15 -13
- package/dist/extensions/Blocks/Items/items.css.js +19 -0
- package/dist/extensions/Blocks/Items/settingsPanel.js +35 -25
- package/dist/extensions/Blocks/Items/template.js +250 -212
- package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
- package/dist/extensions/Blocks/controlFactories.js +104 -104
- package/dist/guido.css +1 -1
- package/dist/package.json.js +4 -4
- package/dist/src/@types/config/schemas.d.ts +8 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useSaveValidation.d.ts +1 -1
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +4 -0
- package/dist/src/config/migrator/index.d.ts +4 -1
- package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
- package/dist/src/config/migrator/recommendationMigrator.d.ts +5 -1
- package/dist/src/enums/save-validation.d.ts +2 -1
- package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
- package/dist/src/extensions/Blocks/Items/controls/blockBackground/index.d.ts +15 -0
- package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +24 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +66 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -1
- package/dist/src/stores/config.d.ts +40 -0
- package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
- package/dist/utils/itemsCurrencyRepair.js +29 -24
- package/dist/utils/pairProductVariables.js +119 -99
- package/package.json +1 -1
- package/dist/config/migrator/recommendation/inferLegacyConfig.js +0 -133
- package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +0 -6
|
@@ -1,63 +1,59 @@
|
|
|
1
|
-
import { BlockId as
|
|
2
|
-
import { DEFAULT_NODE_CONFIG as
|
|
3
|
-
import { ATTR_RECOMMENDATION_TITLE as
|
|
4
|
-
import { useTemplateStore as
|
|
5
|
-
import { mapComposition as
|
|
6
|
-
import { isPriceOnNextLine as
|
|
7
|
-
import { buildBlockHtml as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const t = F(e);
|
|
1
|
+
import { BlockId as b } from "../../enums/block.js";
|
|
2
|
+
import { DEFAULT_NODE_CONFIG as C } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
3
|
+
import { ATTR_RECOMMENDATION_TITLE as f } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useTemplateStore as M } from "../../stores/template.js";
|
|
5
|
+
import { mapComposition as x } from "./recommendation/compositionMapper.js";
|
|
6
|
+
import { isPriceOnNextLine as R, extractCurrencyFromBlock as h, isOldPriceFirst as S, withRenderedTextTheme as w, extractTitleText as E, hasEmptyTitle as L, hasVisibleTitle as B, extractCardBgColor as P, isPartnerManagedBlock as A, extractRenderedBlockPadding as H } from "./recommendation/extractors.js";
|
|
7
|
+
import { buildBlockHtml as N } from "./recommendation/htmlBuilder.js";
|
|
8
|
+
import { parseRecommendationId as O, parseLegacyConfig as F } from "./recommendation/parseLegacyConfig.js";
|
|
9
|
+
import { mapSettings as I } from "./recommendation/settingsMapper.js";
|
|
10
|
+
import { mapBlockPadding as _ } from "./recommendation/themeMapper.js";
|
|
11
|
+
const k = 'td[esd-dev-product-config][class*="ins-recommendation-v3-block-"]:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"][esd-dev-product-config]:not(.recommendation-block-v2)';
|
|
12
|
+
function $(c, e, m) {
|
|
13
|
+
var l, g, p;
|
|
14
|
+
const t = O(e);
|
|
16
15
|
if (t === null)
|
|
17
16
|
return console.warn(
|
|
18
17
|
"[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
|
|
19
18
|
), !1;
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
19
|
+
const r = F(e);
|
|
20
|
+
if (!r)
|
|
22
21
|
return console.warn(
|
|
23
|
-
`[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\`
|
|
22
|
+
`[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\` missing or unable to be parsed`
|
|
24
23
|
), !1;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
S(e) ? o.visibility[u] = !1 : o.titleVariable || (o.visibility[u] = w(e));
|
|
37
|
-
const C = N(e), v = {
|
|
38
|
-
...i,
|
|
24
|
+
const o = m[String(t)] ?? {}, n = {
|
|
25
|
+
...o,
|
|
26
|
+
currencySettings: o.currencySettings ?? h(e),
|
|
27
|
+
isPriceMovedToNextLine: o.isPriceMovedToNextLine ?? R(e)
|
|
28
|
+
}, a = I(n, r, t), i = x(
|
|
29
|
+
w((l = r.composition) == null ? void 0 : l.variables, e),
|
|
30
|
+
{ oldPriceFirst: S(e) }
|
|
31
|
+
), u = E(e);
|
|
32
|
+
L(e) ? i.visibility[f] = !1 : i.titleVariable || (i.visibility[f] = B(e));
|
|
33
|
+
const y = P(e), T = {
|
|
34
|
+
...a,
|
|
39
35
|
strategyId: "",
|
|
40
|
-
composition:
|
|
41
|
-
visibility:
|
|
42
|
-
previousTitleHtml:
|
|
43
|
-
textTrimming:
|
|
44
|
-
},
|
|
36
|
+
composition: i.composition,
|
|
37
|
+
visibility: i.visibility,
|
|
38
|
+
previousTitleHtml: C.previousTitleHtml,
|
|
39
|
+
textTrimming: i.anyTextTrimming
|
|
40
|
+
}, s = A(e), v = `
|
|
45
41
|
<table>
|
|
46
42
|
<tbody>
|
|
47
43
|
<tr>
|
|
48
44
|
<td class="esd-structure" align="left">
|
|
49
45
|
<table width="100%" cellpadding="0" cellspacing="0">
|
|
50
46
|
<tbody>
|
|
51
|
-
<tr>${
|
|
52
|
-
nodeConfig:
|
|
53
|
-
composition:
|
|
54
|
-
cardBg:
|
|
55
|
-
titleText:
|
|
47
|
+
<tr>${N({
|
|
48
|
+
nodeConfig: T,
|
|
49
|
+
composition: i,
|
|
50
|
+
cardBg: y,
|
|
51
|
+
titleText: u,
|
|
56
52
|
legacyId: e.getAttribute("id") ?? void 0,
|
|
57
53
|
legacyBgColor: e.getAttribute("bgcolor") ?? void 0,
|
|
58
|
-
preserveInnerHtml:
|
|
59
|
-
skipCompile:
|
|
60
|
-
blockPadding:
|
|
54
|
+
preserveInnerHtml: s ? e.innerHTML : void 0,
|
|
55
|
+
skipCompile: s,
|
|
56
|
+
blockPadding: _(((p = (g = r.theme) == null ? void 0 : g.blockPadding) == null ? void 0 : p.desktop) ?? H(e))
|
|
61
57
|
})}</tr>
|
|
62
58
|
</tbody>
|
|
63
59
|
</table>
|
|
@@ -65,42 +61,40 @@ function V(c, e, m) {
|
|
|
65
61
|
</tr>
|
|
66
62
|
</tbody>
|
|
67
63
|
</table>
|
|
68
|
-
`,
|
|
69
|
-
return !
|
|
64
|
+
`, d = c.parseFromString(v, "text/html").querySelector("td.esd-structure");
|
|
65
|
+
return !d || !e.parentNode ? (console.warn(
|
|
70
66
|
`[RecommendationMigrator] Aborting block id=${t} — failed to construct new HTML element`
|
|
71
|
-
), !1) : (e.parentNode.replaceChild(
|
|
67
|
+
), !1) : (e.parentNode.replaceChild(d, e), !0);
|
|
72
68
|
}
|
|
73
|
-
function
|
|
69
|
+
function X(c, e = {}) {
|
|
74
70
|
const m = new DOMParser();
|
|
75
71
|
let t;
|
|
76
72
|
try {
|
|
77
73
|
t = m.parseFromString(c, "text/html");
|
|
78
|
-
} catch (
|
|
79
|
-
return console.error("[RecommendationMigrator] Failed to parse template:",
|
|
74
|
+
} catch (n) {
|
|
75
|
+
return console.error("[RecommendationMigrator] Failed to parse template:", n), c;
|
|
80
76
|
}
|
|
81
|
-
const
|
|
82
|
-
var i;
|
|
83
|
-
return !((i = r.parentElement) != null && i.closest(".recommendation-block-v2")) && !s.some((o) => o !== r && o.contains(r));
|
|
84
|
-
});
|
|
85
|
-
let n = 0;
|
|
86
|
-
a.forEach((r) => {
|
|
87
|
-
try {
|
|
88
|
-
V(m, r, e) && (n += 1);
|
|
89
|
-
} catch (i) {
|
|
90
|
-
console.error("[RecommendationMigrator] Unexpected error migrating block:", i);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
77
|
+
const r = Array.from(t.querySelectorAll(k));
|
|
93
78
|
try {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
...
|
|
97
|
-
[
|
|
79
|
+
M().$patch((a) => {
|
|
80
|
+
a.migrations = {
|
|
81
|
+
...a.migrations,
|
|
82
|
+
[b.Recommendation]: r.length
|
|
98
83
|
};
|
|
99
84
|
});
|
|
100
85
|
} catch {
|
|
101
86
|
}
|
|
102
|
-
|
|
87
|
+
if (r.length === 0)
|
|
88
|
+
return c;
|
|
89
|
+
let o = 0;
|
|
90
|
+
return r.forEach((n) => {
|
|
91
|
+
try {
|
|
92
|
+
$(m, n, e) && (o += 1);
|
|
93
|
+
} catch (a) {
|
|
94
|
+
console.error("[RecommendationMigrator] Unexpected error migrating block:", a);
|
|
95
|
+
}
|
|
96
|
+
}), o > 0 && console.info(`[RecommendationMigrator] Migrated ${o} legacy Recommendation block(s)`), t.documentElement.outerHTML;
|
|
103
97
|
}
|
|
104
98
|
export {
|
|
105
|
-
|
|
99
|
+
X as migrateRecommendation
|
|
106
100
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var n = /* @__PURE__ */ ((s) => (s.CouponTagModified = "coupon-tag-modified", s.DuplicateUnsubBlock = "duplicate-unsub-block", s.UnsubBlockMissingTemplate = "unsub-block-missing-template", s.LiquidSyntax = "liquid-syntax", s.InvalidLinks = "invalid-links", s.LinkCheckInProgress = "link-check-in-progress", s.CustomFieldScript = "custom-field-script", s.EmptyHtml = "empty-html", s.MismatchedBraces = "mismatched-braces", s.InvalidDynamicTag = "invalid-dynamic-tag", s.InvalidCustomField = "invalid-custom-field", s.ConditionsSyntax = "conditions-syntax", s.WrongEqualityOperator = "wrong-equality-operator", s.MissingIfEndif = "missing-if-endif", s.ConditionTagSpacing = "condition-tag-spacing", s.BracesInsideIfTag = "braces-inside-if-tag", s.RecommendationRequiredFields = "recommendation-required-fields", s.RecommendationFilters = "recommendation-filters", s.InvalidImageType = "invalid-image-type", s.CheckboxUnsubGroup = "checkbox-unsub-group", s.RadioButtonUnsubGroup = "radio-button-unsub-group", s))(n || {});
|
|
1
|
+
var n = /* @__PURE__ */ ((s) => (s.CouponTagModified = "coupon-tag-modified", s.DuplicateUnsubBlock = "duplicate-unsub-block", s.UnsubBlockMissingTemplate = "unsub-block-missing-template", s.LiquidSyntax = "liquid-syntax", s.InvalidLinks = "invalid-links", s.LinkCheckInProgress = "link-check-in-progress", s.CustomFieldScript = "custom-field-script", s.EmptyHtml = "empty-html", s.MismatchedBraces = "mismatched-braces", s.InvalidDynamicTag = "invalid-dynamic-tag", s.InvalidCustomField = "invalid-custom-field", s.ConditionsSyntax = "conditions-syntax", s.WrongEqualityOperator = "wrong-equality-operator", s.MissingIfEndif = "missing-if-endif", s.ConditionTagSpacing = "condition-tag-spacing", s.BracesInsideIfTag = "braces-inside-if-tag", s.RecommendationRequiredFields = "recommendation-required-fields", s.RecommendationFilters = "recommendation-filters", s.InvalidImageType = "invalid-image-type", s.CheckboxUnsubGroup = "checkbox-unsub-group", s.RadioButtonUnsubGroup = "radio-button-unsub-group", s.ExternallyManagedUnsubscribe = "externally-managed-unsubscribe", s))(n || {});
|
|
2
2
|
export {
|
|
3
3
|
n as SaveValidationRule
|
|
4
4
|
};
|
|
@@ -1,33 +1,42 @@
|
|
|
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
|
-
|
|
2
|
+
var E = (h, d, t) => d in h ? k(h, d, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[d] = t;
|
|
3
|
+
var C = (h, d, t) => E(h, typeof d != "symbol" ? d + "" : d, t);
|
|
4
|
+
import { useConfig as P } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as H } from "../../../enums/block.js";
|
|
6
|
+
import { useOnboardingStore as N } from "../../../stores/onboarding.js";
|
|
7
|
+
import { getMigrationBannerHtml as R } from "../../../utils/migrationBannerHtml.js";
|
|
8
|
+
import { Block as M, BlockCompositionType as O, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
9
|
+
import { PRODUCT_WRAPPER_SELECTOR as w, isZeroWidthValue as g } from "./constants/cardWidth.js";
|
|
10
|
+
import { DEFAULT_ITEMS_PRICE_FORMAT as I, isNewPriceFormatRoot as v, currencyAttrTargets as B, ITEMS_CURRENCY_ATTR as y } from "./constants/currency.js";
|
|
11
|
+
import { ItemsBlockId as A } from "./enums/controlEnums.js";
|
|
12
|
+
import { SETTINGS_ENUMS as S, DefaultConfigValues as b } from "./enums/settingsEnums.js";
|
|
13
|
+
import { getDefaultTemplate as F } from "./template.js";
|
|
14
|
+
import { getItemsBlockContainer as T, getItemsBlockConfig as _, deriveItemNumber as L, generateBlockInstanceId as x, getDefaultItemsBlockConfig as V } from "./utils/nodeConfigUtils.js";
|
|
15
|
+
import { buildPriceFormatSnapshot as W, planPriceFormatOps as z, samePriceText as U, replacePriceText as Y, paragraphKindOf as j } from "./utils/priceFormatOps.js";
|
|
16
|
+
const D = H.Items, q = "Reconcile Items currency DOM attributes";
|
|
17
|
+
function K() {
|
|
18
|
+
return {
|
|
19
|
+
priceThousandSeparator: I.thousandSeparator,
|
|
20
|
+
priceDecimalSeparator: I.decimalSeparator,
|
|
21
|
+
priceDecimalCount: I.decimalCount
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
class at extends M {
|
|
16
25
|
constructor() {
|
|
17
26
|
super(...arguments);
|
|
18
27
|
/** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
|
|
19
|
-
|
|
28
|
+
C(this, "_currencyHealed", /* @__PURE__ */ new Set());
|
|
20
29
|
/** blockInstanceIds already claimed by a live block this session (SD-147588 collision detection). */
|
|
21
|
-
|
|
30
|
+
C(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
|
|
22
31
|
}
|
|
23
32
|
getId() {
|
|
24
|
-
return
|
|
33
|
+
return D;
|
|
25
34
|
}
|
|
26
35
|
getIcon() {
|
|
27
36
|
return "items-icon";
|
|
28
37
|
}
|
|
29
38
|
getBlockCompositionType() {
|
|
30
|
-
return
|
|
39
|
+
return O.CONTAINER;
|
|
31
40
|
}
|
|
32
41
|
getName() {
|
|
33
42
|
return this.api.translate("Items");
|
|
@@ -36,20 +45,21 @@ class $ extends H {
|
|
|
36
45
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
37
46
|
}
|
|
38
47
|
getSettingsPanelTitleHtml() {
|
|
39
|
-
return
|
|
40
|
-
|
|
48
|
+
return R(
|
|
49
|
+
D,
|
|
41
50
|
this.api.translate("Items"),
|
|
42
51
|
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.")
|
|
43
52
|
);
|
|
44
53
|
}
|
|
45
54
|
getTemplate() {
|
|
46
|
-
return
|
|
47
|
-
orientation:
|
|
48
|
-
itemsType:
|
|
55
|
+
return F({
|
|
56
|
+
orientation: S.ORIENTATION.VERTICAL,
|
|
57
|
+
itemsType: S.ITEMS_TYPE.CART_ITEMS,
|
|
49
58
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
50
|
-
currencySymbol:
|
|
51
|
-
currencyLocation:
|
|
52
|
-
formattedPrice:
|
|
59
|
+
currencySymbol: b.productPriceCurrencySymbolControlValue,
|
|
60
|
+
currencyLocation: b.productPriceCurrencyLocationControlValue,
|
|
61
|
+
formattedPrice: b.productPriceFormattedControlValue === "1",
|
|
62
|
+
priceFormat: this._isPriceFormattingEnabled() ? I : void 0
|
|
53
63
|
});
|
|
54
64
|
}
|
|
55
65
|
allowInnerBlocksDND() {
|
|
@@ -59,26 +69,29 @@ class $ extends H {
|
|
|
59
69
|
return !0;
|
|
60
70
|
}
|
|
61
71
|
onCreated(t) {
|
|
62
|
-
const e = this.api.getDocumentModifier(),
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
72
|
+
const e = this.api.getDocumentModifier(), s = this.api.getDocumentRootCssNode();
|
|
73
|
+
s.querySelector('[product-attr="imageSrc"] img') || e.modifyCss(s).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
74
|
+
const o = T(t);
|
|
75
|
+
if (!o)
|
|
66
76
|
return;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
if (!
|
|
70
|
-
const
|
|
71
|
-
|
|
77
|
+
const i = o.getNodeConfig(), c = i && Object.keys(i).length > 0, r = _(t);
|
|
78
|
+
if (r != null && r.initialized) {
|
|
79
|
+
if (!c) {
|
|
80
|
+
const l = this.api.getDocumentModifier();
|
|
81
|
+
l.modifyHtml(o).setNodeConfig(r), this._stampProductTdDomAttributes(o, r, l), this._healCollapsedWidths(o, l), this._shouldReconcileCurrency(r) && this._reconcileCurrencyDomAttributes(o, r, l), l.apply(new p("Migrate legacy config to nodeConfig")), this._markCurrencyHealed(r.blockInstanceId);
|
|
72
82
|
return;
|
|
73
83
|
}
|
|
74
84
|
} else {
|
|
75
|
-
const
|
|
76
|
-
|
|
85
|
+
const l = {
|
|
86
|
+
...V(),
|
|
87
|
+
...this._isPriceFormattingEnabled() ? K() : {}
|
|
88
|
+
}, f = this.api.getDocumentModifier();
|
|
89
|
+
f.modifyHtml(o).setNodeConfig(l), this._stampProductTdDomAttributes(o, l, f, !0), f.apply(new p("Initialize Items block with default configuration")), N().startOnboarding("itemsOnboarding");
|
|
77
90
|
return;
|
|
78
91
|
}
|
|
79
|
-
const
|
|
80
|
-
let
|
|
81
|
-
|
|
92
|
+
const n = this._resolveInstanceId(r.blockInstanceId), a = { ...r, blockInstanceId: n }, u = this.api.getDocumentModifier();
|
|
93
|
+
let m = !1;
|
|
94
|
+
n !== r.blockInstanceId && (u.modifyHtml(o).setNodeConfig(a), m = !0), !this._currencyHealed.has(n) && this._reconcileCurrencyDomAttributes(o, a, u) && (m = !0), this._healCollapsedWidths(o, u) && (m = !0), m && u.apply(new p("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(n);
|
|
82
95
|
}
|
|
83
96
|
/**
|
|
84
97
|
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
@@ -87,23 +100,23 @@ class $ extends H {
|
|
|
87
100
|
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
88
101
|
*/
|
|
89
102
|
onDocumentChanged(t) {
|
|
90
|
-
const e =
|
|
103
|
+
const e = T(t);
|
|
91
104
|
if (!e)
|
|
92
105
|
return;
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
this._reconcileCurrencyDomAttributes(e,
|
|
106
|
+
const s = e.getNodeConfig();
|
|
107
|
+
if (s && Object.keys(s).length > 0) {
|
|
108
|
+
const r = _(t);
|
|
109
|
+
if (r != null && r.initialized && this._shouldReconcileCurrency(r)) {
|
|
110
|
+
const n = this.api.getDocumentModifier();
|
|
111
|
+
this._reconcileCurrencyDomAttributes(e, r, n) && n.apply(new p(q)), this._markCurrencyHealed(r.blockInstanceId);
|
|
99
112
|
}
|
|
100
113
|
return;
|
|
101
114
|
}
|
|
102
|
-
const
|
|
103
|
-
if (!(
|
|
115
|
+
const i = _(t);
|
|
116
|
+
if (!(i != null && i.initialized))
|
|
104
117
|
return;
|
|
105
|
-
const
|
|
106
|
-
|
|
118
|
+
const c = this.api.getDocumentModifier();
|
|
119
|
+
c.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, c), this._healCollapsedWidths(e, c), this._shouldReconcileCurrency(i) && this._reconcileCurrencyDomAttributes(e, i, c), c.apply(new p("Recover Items block config from saved module")), this._markCurrencyHealed(i.blockInstanceId);
|
|
107
120
|
}
|
|
108
121
|
/**
|
|
109
122
|
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
|
|
@@ -113,21 +126,21 @@ class $ extends H {
|
|
|
113
126
|
* restored before export. The name `<a>` carries no data-type/data-number of its own and
|
|
114
127
|
* relies on this td-level fallback in pairProductVariables.
|
|
115
128
|
*/
|
|
116
|
-
_stampProductTdDomAttributes(t, e,
|
|
117
|
-
const
|
|
118
|
-
|
|
129
|
+
_stampProductTdDomAttributes(t, e, s, o = !1) {
|
|
130
|
+
const i = L(e.itemsSelectValue, e.type), c = (r, n) => {
|
|
131
|
+
o && t.getAttribute(r) || s.modifyHtml(t).setAttribute(r, n);
|
|
119
132
|
};
|
|
120
|
-
|
|
133
|
+
c("data-type", e.type), c("data-number", i), c("data-nodup", String(e.priceHideDiscount));
|
|
121
134
|
}
|
|
122
135
|
/**
|
|
123
136
|
* Repairs a saved module's collapsed card into the state the load migrator produces. Acts only
|
|
124
137
|
* on a zero width, so Stripo's non-zero drop-time width never triggers it and a healed block no-ops.
|
|
125
138
|
*/
|
|
126
139
|
_healCollapsedWidths(t, e) {
|
|
127
|
-
const
|
|
128
|
-
return !
|
|
129
|
-
const
|
|
130
|
-
(
|
|
140
|
+
const o = t.querySelectorAll(w).filter((i) => g(i.getAttribute("width")) || g(i.getStyle("width")));
|
|
141
|
+
return !g(t.getAttribute("width")) && !o.length ? !1 : (t.hasClass("esd-container-frame") && e.modifyHtml(t).removeClass("esd-container-frame"), t.getAttribute("width") !== null && e.modifyHtml(t).removeAttribute("width"), o.forEach((i) => {
|
|
142
|
+
const c = i.getAttribute("width");
|
|
143
|
+
(c === null || g(c)) && e.modifyHtml(i).setAttribute("width", "100%"), g(i.getStyle("width")) && e.modifyHtml(i).setStyle("width", "100%");
|
|
131
144
|
}), !0);
|
|
132
145
|
}
|
|
133
146
|
/**
|
|
@@ -156,30 +169,55 @@ class $ extends H {
|
|
|
156
169
|
let e = t;
|
|
157
170
|
if (!e || this._seenInstanceIds.has(e))
|
|
158
171
|
do
|
|
159
|
-
e =
|
|
172
|
+
e = x();
|
|
160
173
|
while (this._seenInstanceIds.has(e));
|
|
161
174
|
return this._seenInstanceIds.add(e), e;
|
|
162
175
|
}
|
|
163
176
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
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.
|
|
177
|
+
* Single self-heal slot: the flag only decides whether a legacy root is converted; a root
|
|
178
|
+
* already in the new format is reconciled from config regardless. Returns whether anything was queued.
|
|
173
179
|
*/
|
|
174
|
-
_reconcileCurrencyDomAttributes(t, e,
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
_reconcileCurrencyDomAttributes(t, e, s) {
|
|
181
|
+
const o = this._isPriceFormattingEnabled();
|
|
182
|
+
if (!o && !v(t))
|
|
183
|
+
return this._reconcileLegacyCurrencyAttributes(t, e, s);
|
|
184
|
+
const i = this._priceParagraphs(t), c = W({
|
|
185
|
+
rootAttr: (n) => t.getAttribute(n),
|
|
186
|
+
config: e,
|
|
187
|
+
paragraphs: i.map(({ kind: n, node: a }) => ({
|
|
188
|
+
kind: n,
|
|
189
|
+
attr: (u) => a.getAttribute(u),
|
|
190
|
+
text: a.getInnerText()
|
|
191
|
+
}))
|
|
192
|
+
}), r = z(c, { convertLegacy: o });
|
|
193
|
+
return r.changed ? (Object.entries(r.rootSet).forEach(([n, a]) => {
|
|
194
|
+
s.modifyHtml(t).setAttribute(n, a);
|
|
195
|
+
}), i.forEach(({ kind: n, node: a }) => {
|
|
196
|
+
var l;
|
|
197
|
+
r.paragraphRemove.filter((f) => a.getAttribute(f) !== null).forEach((f) => s.modifyHtml(a).removeAttribute(f));
|
|
198
|
+
const u = (l = r.texts) == null ? void 0 : l[n], m = a.getInnerText();
|
|
199
|
+
u !== void 0 && !U(m, u) && s.modifyHtml(a).setInnerHtml(Y(a.getInnerHTML(), m, u));
|
|
200
|
+
}), r.configPatch && s.modifyHtml(t).setNodeConfig({ ...e, ...r.configPatch }), !0) : !1;
|
|
201
|
+
}
|
|
202
|
+
/** Legacy `<p>` contract via `currencyAttrTargets`: position when recorded, symbol only when custom. */
|
|
203
|
+
_reconcileLegacyCurrencyAttributes(t, e, s) {
|
|
204
|
+
const { position: o, symbol: i } = B(e), c = t.querySelectorAll(`.${A.PRICE} p`);
|
|
205
|
+
let r = !1;
|
|
206
|
+
return c.forEach((n) => {
|
|
207
|
+
o !== void 0 && n.getAttribute(y.POSITION) !== o && (s.modifyHtml(n).setAttribute(y.POSITION, o), r = !0), i !== void 0 && n.getAttribute(y.SYMBOL) !== i && (s.modifyHtml(n).setAttribute(y.SYMBOL, i), r = !0);
|
|
208
|
+
}), r;
|
|
209
|
+
}
|
|
210
|
+
_priceParagraphs(t) {
|
|
211
|
+
return t.querySelectorAll(`.${A.PRICE} p`).flatMap((s) => {
|
|
212
|
+
const o = j(s.getAttribute("product-attr"));
|
|
213
|
+
return o ? [{ kind: o, node: s }] : [];
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
_isPriceFormattingEnabled() {
|
|
217
|
+
return P().isFeatureEnabled("itemsPriceFormatting");
|
|
180
218
|
}
|
|
181
219
|
}
|
|
182
220
|
export {
|
|
183
|
-
|
|
184
|
-
|
|
221
|
+
D as BLOCK_ID,
|
|
222
|
+
at as ItemsBlock
|
|
185
223
|
};
|
|
@@ -1,25 +1,70 @@
|
|
|
1
1
|
import { DefaultConfigValues as c } from "../enums/settingsEnums.js";
|
|
2
|
-
const
|
|
2
|
+
const n = {
|
|
3
3
|
POSITION: "data-curency",
|
|
4
4
|
SYMBOL: "data-currency_symbol"
|
|
5
5
|
};
|
|
6
|
-
function
|
|
7
|
-
return
|
|
6
|
+
function u(t) {
|
|
7
|
+
return t === "1" ? "after" : "before";
|
|
8
8
|
}
|
|
9
|
-
function i(
|
|
10
|
-
const
|
|
11
|
-
return
|
|
9
|
+
function i(t) {
|
|
10
|
+
const r = (t ?? "").trim();
|
|
11
|
+
return r !== "" && r !== c.productPriceCurrencySymbolControlValue;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
13
|
+
function p(t) {
|
|
14
|
+
const r = t.priceCurrencyLocation, e = typeof r == "string" && r.trim() !== "", a = (t.priceCurrencySymbol ?? "").trim();
|
|
15
15
|
return {
|
|
16
|
-
position:
|
|
17
|
-
symbol: i(
|
|
16
|
+
position: e ? u(r) : void 0,
|
|
17
|
+
symbol: i(a) ? a : 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
|
+
}
|
|
20
58
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
59
|
+
o as DEFAULT_ITEMS_PRICE_FORMAT,
|
|
60
|
+
n as ITEMS_CURRENCY_ATTR,
|
|
61
|
+
s as ITEMS_PRICE_FORMAT_ATTR,
|
|
62
|
+
C as LEGACY_PRICE_PARAGRAPH_ATTRS,
|
|
63
|
+
p as currencyAttrTargets,
|
|
64
|
+
u as currencyPositionFromLocation,
|
|
65
|
+
i as isCustomCurrencySymbol,
|
|
66
|
+
y as isNewPriceFormatConfig,
|
|
67
|
+
S as isNewPriceFormatRoot,
|
|
68
|
+
m as normalizeDecimalCount,
|
|
69
|
+
d as priceFormatFromConfig
|
|
25
70
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createBlockBackgroundColorControl as o } from "../../../controlFactories.js";
|
|
2
|
+
import { ItemsBlockControlId as r } from "../../enums/controlEnums.js";
|
|
3
|
+
import { ITEMS_BLOCK_SELECTOR as t } from "../../utils/constants.js";
|
|
4
|
+
const l = o(
|
|
5
|
+
r.BLOCK_BACKGROUND,
|
|
6
|
+
t,
|
|
7
|
+
"Background Color"
|
|
8
|
+
);
|
|
9
|
+
export {
|
|
10
|
+
l as ItemsBlockBackgroundControl
|
|
11
|
+
};
|