@useinsider/guido 3.17.0-beta.ddd4dde → 3.17.0-beta.e23d5cd
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 +1 -0
- package/dist/@types/config/schemas.js +7 -6
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +77 -73
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +106 -0
- package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
- package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +63 -0
- package/dist/composables/useCustomInterfaceAppearance.js +52 -38
- package/dist/composables/useRecommendation.js +41 -34
- package/dist/config/migrator/recommendation/settingsMapper.js +17 -17
- package/dist/config/migrator/recommendationMigrator.js +5 -4
- package/dist/enums/academy.js +2 -1
- package/dist/enums/date.js +5 -3
- package/dist/enums/extensions/recommendationBlock.js +3 -1
- package/dist/extensions/Blocks/Items/block.js +49 -98
- 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/Recommendation/block.js +26 -21
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +34 -34
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +96 -95
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +238 -185
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +124 -0
- package/dist/extensions/Blocks/Recommendation/services/configService.js +54 -36
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +165 -79
- package/dist/extensions/Blocks/common-control.js +22 -19
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +69 -30
- package/dist/src/@types/config/schemas.d.ts +2 -0
- package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
- package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +15 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useRecommendation.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/date.d.ts +1 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +0 -21
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +2 -6
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +44 -8
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +16 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +12 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +150 -10
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
- package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
- package/dist/src/services/recommendationApi.d.ts +4 -1
- package/dist/src/stores/config.d.ts +18 -0
- package/dist/src/stores/save-as-template.d.ts +4 -3
- package/dist/src/utils/genericUtil.d.ts +5 -0
- package/dist/static/assets/icons/line-change.svg.js +5 -0
- package/dist/static/assets/icons/line-delete.svg.js +5 -0
- package/dist/static/assets/icons/line-plus.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +155 -0
- package/dist/utils/dateUtil.js +23 -10
- package/dist/utils/genericUtil.js +28 -27
- package/dist/utils/pairProductVariables.js +59 -60
- package/dist/utils/templatePreparation.js +35 -34
- package/package.json +2 -1
- package/dist/extensions/Blocks/Items/constants/currency.js +0 -11
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +0 -19
|
@@ -1,53 +1,67 @@
|
|
|
1
|
-
import S from "../static/
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import w from "../static/styles/components/
|
|
17
|
-
import y from "../static/styles/components/
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import S from "../static/assets/icons/line-change.svg.js";
|
|
2
|
+
import i from "../static/assets/icons/line-delete.svg.js";
|
|
3
|
+
import n from "../static/assets/icons/line-plus.svg.js";
|
|
4
|
+
import p from "../static/styles/base.css.js";
|
|
5
|
+
import s from "../static/styles/components/alert-message.css.js";
|
|
6
|
+
import C from "../static/styles/components/amp-block.css.js";
|
|
7
|
+
import a from "../static/styles/components/base-input.css.js";
|
|
8
|
+
import f from "../static/styles/components/button-group.css.js";
|
|
9
|
+
import c from "../static/styles/components/button.css.js";
|
|
10
|
+
import u from "../static/styles/components/combobox.css.js";
|
|
11
|
+
import l from "../static/styles/components/counter.css.js";
|
|
12
|
+
import d from "../static/styles/components/dropdown-menu.css.js";
|
|
13
|
+
import h from "../static/styles/components/loader.css.js";
|
|
14
|
+
import g from "../static/styles/components/narrow-panel.css.js";
|
|
15
|
+
import I from "../static/styles/components/popup.css.js";
|
|
16
|
+
import w from "../static/styles/components/recommendation-strategy.css.js";
|
|
17
|
+
import y from "../static/styles/components/switcher.css.js";
|
|
18
|
+
import b from "../static/styles/components/tabs.css.js";
|
|
19
|
+
import B from "../static/styles/components/tools.css.js";
|
|
20
|
+
import $ from "../static/styles/components/version-history.css.js";
|
|
21
|
+
import P from "../static/styles/components/wide-panel.css.js";
|
|
22
|
+
import x from "../static/styles/variables.css.js";
|
|
23
|
+
function r(t, o) {
|
|
24
|
+
return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(o.trim())}");`;
|
|
25
|
+
}
|
|
26
|
+
const A = `:host {
|
|
27
|
+
${r("line-change", S)}
|
|
28
|
+
${r("line-delete", i)}
|
|
29
|
+
${r("line-plus", n)}
|
|
30
|
+
}`, R = [
|
|
31
|
+
x,
|
|
23
32
|
// Must be on top
|
|
24
|
-
|
|
25
|
-
e,
|
|
26
|
-
i,
|
|
33
|
+
A,
|
|
27
34
|
p,
|
|
28
|
-
|
|
35
|
+
// Must be on top
|
|
29
36
|
s,
|
|
30
37
|
C,
|
|
31
|
-
f,
|
|
32
38
|
a,
|
|
33
|
-
|
|
39
|
+
f,
|
|
34
40
|
c,
|
|
35
|
-
|
|
41
|
+
u,
|
|
36
42
|
l,
|
|
43
|
+
d,
|
|
37
44
|
h,
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
g,
|
|
46
|
+
I,
|
|
47
|
+
y,
|
|
48
|
+
b,
|
|
49
|
+
B,
|
|
50
|
+
$,
|
|
51
|
+
P,
|
|
52
|
+
w
|
|
53
|
+
// Last: overrides button.css / wide-panel.css defaults
|
|
40
54
|
].join(`
|
|
41
55
|
|
|
42
|
-
`),
|
|
56
|
+
`), Y = () => ({ importCss: () => {
|
|
43
57
|
const o = new CSSStyleSheet();
|
|
44
|
-
o.replaceSync(
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
58
|
+
o.replaceSync(R);
|
|
59
|
+
const e = document.querySelector("ui-editor");
|
|
60
|
+
if (!e)
|
|
47
61
|
return;
|
|
48
|
-
const
|
|
49
|
-
|
|
62
|
+
const m = e.shadowRoot;
|
|
63
|
+
m && (m.adoptedStyleSheets = [o]);
|
|
50
64
|
} });
|
|
51
65
|
export {
|
|
52
|
-
|
|
66
|
+
Y as useCustomInterfaceAppearance
|
|
53
67
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { getRecommendationFeedSourceMaps as
|
|
2
|
-
import { MinDeviceViewport as C, DefaultPadding as
|
|
1
|
+
import { getRecommendationFeedSourceMaps as y, URLS as I } from "../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { MinDeviceViewport as C, DefaultPadding as R } from "../enums/recommendation.js";
|
|
3
3
|
import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
|
-
import { generateCompleteFilterQuery as
|
|
5
|
-
import { getPartnerRecommendationParams as
|
|
4
|
+
import { generateCompleteFilterQuery as b } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
5
|
+
import { getPartnerRecommendationParams as h } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
|
|
6
6
|
import { sanitizeProductIds as x } from "../extensions/Blocks/Recommendation/utils/productIds.js";
|
|
7
7
|
import { useConfigStore as P } from "../stores/config.js";
|
|
8
8
|
const B = () => ({
|
|
9
9
|
calculateCardWidth: ({
|
|
10
|
-
mobileLeftPadding:
|
|
11
|
-
mobileRightPadding:
|
|
12
|
-
cardsInRow:
|
|
10
|
+
mobileLeftPadding: i,
|
|
11
|
+
mobileRightPadding: c,
|
|
12
|
+
cardsInRow: s,
|
|
13
13
|
unresponsive: n
|
|
14
14
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
return (C - e) /
|
|
15
|
+
const o = n ? s : 1, e = i + c + (o - 1) * R;
|
|
16
|
+
return (C - e) / o;
|
|
17
17
|
},
|
|
18
|
-
getRecommendationCampaignData: (
|
|
19
|
-
const
|
|
18
|
+
getRecommendationCampaignData: (i) => {
|
|
19
|
+
const c = l(), s = Number(i), n = c.blockStates[s];
|
|
20
20
|
if (!n)
|
|
21
21
|
return {
|
|
22
22
|
textTrimming: !1,
|
|
@@ -30,47 +30,54 @@ const B = () => ({
|
|
|
30
30
|
discountBeforeTextValue: "",
|
|
31
31
|
discountAfterTextValue: ""
|
|
32
32
|
};
|
|
33
|
-
const { recommendationConfigs:
|
|
33
|
+
const { recommendationConfigs: o } = n, e = o.orientation === "grid" ? "vertical" : "horizontal";
|
|
34
34
|
return {
|
|
35
|
-
textTrimming:
|
|
35
|
+
textTrimming: o.textTrimming,
|
|
36
36
|
orientation: e,
|
|
37
37
|
mobileLeftPadding: 0,
|
|
38
38
|
mobileRightPadding: 0,
|
|
39
|
-
cardsInRow:
|
|
40
|
-
unresponsive:
|
|
39
|
+
cardsInRow: o.cardsInRow,
|
|
40
|
+
unresponsive: o.unresponsive,
|
|
41
41
|
priceBeforeTextValue: "",
|
|
42
42
|
priceAfterTextValue: "",
|
|
43
43
|
discountBeforeTextValue: "",
|
|
44
44
|
discountAfterTextValue: ""
|
|
45
45
|
};
|
|
46
46
|
},
|
|
47
|
-
buildCampaignUrl: (
|
|
47
|
+
buildCampaignUrl: (i, c) => {
|
|
48
48
|
var m;
|
|
49
|
-
const
|
|
49
|
+
const s = l(), n = P(), o = Number(i);
|
|
50
50
|
let e;
|
|
51
|
-
if (
|
|
52
|
-
e =
|
|
51
|
+
if (c)
|
|
52
|
+
e = c;
|
|
53
53
|
else {
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
54
|
+
const a = s.blockStates[o];
|
|
55
|
+
if (!a)
|
|
56
56
|
return "";
|
|
57
|
-
const { recommendationConfigs:
|
|
57
|
+
const { recommendationConfigs: r } = a;
|
|
58
58
|
e = {
|
|
59
|
-
strategy:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
strategy: r.strategy,
|
|
60
|
+
strategyId: r.strategyId,
|
|
61
|
+
language: r.language,
|
|
62
|
+
currencyCode: r.currencySettings.value,
|
|
63
|
+
size: r.size,
|
|
64
|
+
productIds: r.productIds,
|
|
65
|
+
filters: r.filters,
|
|
66
|
+
shuffleProducts: r.shuffleProducts
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
if (e.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy"))
|
|
70
|
+
return s.recommendationCampaignUrls[i] = {
|
|
71
|
+
strategyId: e.strategyId,
|
|
72
|
+
locale: e.language,
|
|
73
|
+
currency: e.currencyCode
|
|
74
|
+
}, "";
|
|
75
|
+
const g = ((m = y().find((a) => a.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
|
|
69
76
|
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising" ? t.set("productId", x(e.productIds)) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
70
|
-
const
|
|
71
|
-
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(
|
|
72
|
-
const p = decodeURIComponent(t.toString()), u = `${
|
|
73
|
-
return
|
|
77
|
+
const f = e.filters.filter((a) => a.isValid), d = b(f);
|
|
78
|
+
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(h(n.partnerName, e.strategy)).forEach(([a, r]) => t.set(a, r));
|
|
79
|
+
const p = decodeURIComponent(t.toString()), u = `${I.RECOMMENDATION_API_URL}/v2/${g}?${p}`;
|
|
80
|
+
return s.recommendationCampaignUrls[i] = u, u;
|
|
74
81
|
}
|
|
75
82
|
});
|
|
76
83
|
export {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DEFAULT_CARDS_IN_ROW as m, DEFAULT_MOBILE_ROW_SPACING as p, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as
|
|
1
|
+
import { PRE_RRS_CONFIG_VERSION as s, DEFAULT_CURRENCY as i } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
2
|
+
import { DEFAULT_CARDS_IN_ROW as m, DEFAULT_MOBILE_ROW_SPACING as p, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as S, DEFAULT_COLUMN_SPACING as f, DEFAULT_MOBILE_CARDS_IN_ROW as a } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
|
|
3
3
|
import { mapLegacyStrategy as l } from "../../../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
|
|
4
4
|
function c(t) {
|
|
5
5
|
return t === "0" || t === 0 ? "before" : "after";
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function _(t) {
|
|
8
8
|
if (typeof t == "number" && Number.isFinite(t))
|
|
9
9
|
return t;
|
|
10
10
|
if (typeof t == "string") {
|
|
@@ -14,13 +14,13 @@ function I(t) {
|
|
|
14
14
|
}
|
|
15
15
|
return i.decimalCount;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function I(t) {
|
|
18
18
|
return t === "." || t === "," || t === " " || t === "" ? t : ",";
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function A(t) {
|
|
21
21
|
return t === "." || t === "," || t === " " ? t : ".";
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function L(t) {
|
|
24
24
|
if (!t || typeof t != "object")
|
|
25
25
|
return { ...i };
|
|
26
26
|
const o = t, n = o.value ?? o.name ?? i.code, r = o.symbol ?? n;
|
|
@@ -28,18 +28,18 @@ function A(t) {
|
|
|
28
28
|
code: n,
|
|
29
29
|
symbol: r,
|
|
30
30
|
alignment: c(o.alignment),
|
|
31
|
-
decimalCount:
|
|
32
|
-
decimalSeparator:
|
|
33
|
-
thousandSeparator:
|
|
31
|
+
decimalCount: _(o.decimalCount),
|
|
32
|
+
decimalSeparator: A(o.decimalSeparator),
|
|
33
|
+
thousandSeparator: I(o.thousandSeparator)
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function N(t) {
|
|
37
37
|
return t === "horizontal" || t === "list" ? "list" : "grid";
|
|
38
38
|
}
|
|
39
39
|
function R(t) {
|
|
40
40
|
return l(t) || "mostPopular";
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function O(t, o, n) {
|
|
43
43
|
const r = o.rowCount ?? t.cardsInRow ?? m, u = o.totalCount ?? (typeof t.size == "string" ? parseInt(t.size) : t.size) ?? 6;
|
|
44
44
|
return {
|
|
45
45
|
recommendationId: n,
|
|
@@ -48,15 +48,15 @@ function U(t, o, n) {
|
|
|
48
48
|
size: String(u),
|
|
49
49
|
shuffleProducts: !!t.shuffleProducts,
|
|
50
50
|
language: t.language ?? "en_US",
|
|
51
|
-
currency:
|
|
51
|
+
currency: L(t.currencySettings),
|
|
52
52
|
filters: (t.filters ?? []).map((e) => ({ ...e })),
|
|
53
|
-
layout:
|
|
53
|
+
layout: N(t.orientation ?? o.orientation),
|
|
54
54
|
cardsInRow: r,
|
|
55
55
|
mobileCardsInRow: a,
|
|
56
56
|
mobileLayoutEnabled: !1,
|
|
57
57
|
previousMobileCardsInRow: a,
|
|
58
|
-
columnSpacing:
|
|
59
|
-
rowSpacing:
|
|
58
|
+
columnSpacing: f,
|
|
59
|
+
rowSpacing: S,
|
|
60
60
|
mobileColumnSpacing: d,
|
|
61
61
|
mobileRowSpacing: p,
|
|
62
62
|
omnibusPrice: { textBefore: "", textAfter: "" },
|
|
@@ -70,6 +70,6 @@ function U(t, o, n) {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
L as mapCurrency,
|
|
74
|
+
O as mapSettings
|
|
75
75
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BlockId as f } from "../../enums/block.js";
|
|
2
|
-
import { useTemplateStore as
|
|
3
|
-
import { mapComposition as
|
|
2
|
+
import { useTemplateStore as y } from "../../stores/template.js";
|
|
3
|
+
import { mapComposition as b } from "./recommendation/compositionMapper.js";
|
|
4
4
|
import { extractCurrencyFromBlock as v, extractTitleText as C, extractCardBgColor as M, isPartnerManagedBlock as S } from "./recommendation/extractors.js";
|
|
5
5
|
import { buildBlockHtml as w } from "./recommendation/htmlBuilder.js";
|
|
6
6
|
import { parseRecommendationId as x, parseLegacyConfig as R } from "./recommendation/parseLegacyConfig.js";
|
|
@@ -20,8 +20,9 @@ function B(i, t, a) {
|
|
|
20
20
|
), !1;
|
|
21
21
|
const n = a[String(o)] ?? {
|
|
22
22
|
currencySettings: v(t)
|
|
23
|
-
}, c = T(n, r, o), e =
|
|
23
|
+
}, c = T(n, r, o), e = b((d = r.composition) == null ? void 0 : d.variables), l = C(t), g = M(t), p = {
|
|
24
24
|
...c,
|
|
25
|
+
strategyId: "",
|
|
25
26
|
composition: e.composition,
|
|
26
27
|
visibility: e.visibility,
|
|
27
28
|
textTrimming: e.anyTextTrimming
|
|
@@ -56,7 +57,7 @@ function B(i, t, a) {
|
|
|
56
57
|
function q(i, t = {}) {
|
|
57
58
|
const a = new DOMParser(), o = a.parseFromString(i, "text/html"), r = Array.from(o.querySelectorAll(h));
|
|
58
59
|
try {
|
|
59
|
-
|
|
60
|
+
y().$patch((e) => {
|
|
60
61
|
e.migrations = {
|
|
61
62
|
...e.migrations,
|
|
62
63
|
[f.Recommendation]: r.length
|
package/dist/enums/academy.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
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
|
-
AMP_FOR_EMAILS: `${e}/docs/amp-for-emails
|
|
4
|
+
AMP_FOR_EMAILS: `${e}/docs/amp-for-emails`,
|
|
5
|
+
EMAIL_RECOMMENDATION_BLOCK: `${e}/docs/new-editor-email-recommendation-block`
|
|
5
6
|
};
|
|
6
7
|
export {
|
|
7
8
|
o as ACADEMY_LINKS
|
package/dist/enums/date.js
CHANGED
|
@@ -2,7 +2,9 @@ import { useTranslations as r } from "../../composables/useTranslations.js";
|
|
|
2
2
|
const l = {
|
|
3
3
|
RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com",
|
|
4
4
|
// Relative path → same-origin as the embedding inone dashboard.
|
|
5
|
-
PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes"
|
|
5
|
+
PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes",
|
|
6
|
+
RECOMMENDATION_STRATEGIES_PATH: "/api/recommendation-strategies",
|
|
7
|
+
RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies"
|
|
6
8
|
}, c = {
|
|
7
9
|
CLIENT_ID: "clientId"
|
|
8
10
|
}, d = () => {
|
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { SETTINGS_ENUMS as b, DefaultConfigValues as f } from "./enums/settingsEnums.js";
|
|
11
|
-
import { getDefaultTemplate as E } from "./template.js";
|
|
12
|
-
import { getItemsBlockContainer as h, getItemsBlockConfig as C, deriveItemNumber as H, getDefaultItemsBlockConfig as B } from "./utils/nodeConfigUtils.js";
|
|
13
|
-
const S = N.Items, P = "Reconcile Items currency DOM attributes";
|
|
14
|
-
class G 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 G 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 G 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 n = e.blockInstanceId || String(Date.now()), p = this.api.getDocumentModifier();
|
|
77
|
-
let y = !1;
|
|
78
|
-
e.blockInstanceId || (p.modifyHtml(r).setNodeConfig({ ...e, blockInstanceId: n }), y = !0), this._shouldReconcileCurrency(e) && this._reconcileCurrencyDomAttributes(r, e, p) && (y = !0), y && p.apply(new m("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(n);
|
|
79
66
|
}
|
|
80
67
|
/**
|
|
81
68
|
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
@@ -83,24 +70,18 @@ class G 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 e = C(t);
|
|
93
|
-
if (e != null && e.initialized && this._shouldReconcileCurrency(e)) {
|
|
94
|
-
const n = this.api.getDocumentModifier();
|
|
95
|
-
this._reconcileCurrencyDomAttributes(o, e, n) && n.apply(new m(P)), this._markCurrencyHealed(e.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,44 +91,14 @@ class G 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 the currency self-heal should run for this block. Two guards (SD-147588):
|
|
121
|
-
* 1. Config is only authoritative when the symbol was actually customized — a symbol still at
|
|
122
|
-
* the 'USD' sentinel may be a migrator default, so we trust the DOM's real value over a
|
|
123
|
-
* defaulted config and never overwrite it.
|
|
124
|
-
* 2. Heal each instance at most once per session, so the auto-fix can't fight undo (undo
|
|
125
|
-
* re-drifts the attr, which would otherwise re-trigger the heal forever).
|
|
126
|
-
*/
|
|
127
|
-
_shouldReconcileCurrency(t) {
|
|
128
|
-
const o = (t.priceCurrencySymbol ?? "").trim();
|
|
129
|
-
return !o || o === f.productPriceCurrencySymbolControlValue ? !1 : !t.blockInstanceId || !this._currencyHealed.has(t.blockInstanceId);
|
|
130
|
-
}
|
|
131
|
-
/** Marks a block instance's currency as reconciled so it is not healed again (undo-safe). */
|
|
132
|
-
_markCurrencyHealed(t) {
|
|
133
|
-
t && this._currencyHealed.add(t);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Stamps the export-read currency attrs onto every price `<p>` from config, so a template whose
|
|
137
|
-
* attrs drifted (e.g. a location toggle before the sync fix) self-heals to match the editor.
|
|
138
|
-
* Config is the source of truth — never derive from visible text. Callers gate this with
|
|
139
|
-
* `_shouldReconcileCurrency`. Returns true only when an attr actually changed, so the caller can
|
|
140
|
-
* skip an empty apply that would otherwise re-trigger onDocumentChanged and loop (SD-147588).
|
|
141
|
-
*/
|
|
142
|
-
_reconcileCurrencyDomAttributes(t, o, s) {
|
|
143
|
-
const r = O(o.priceCurrencyLocation), i = (o.priceCurrencySymbol ?? "").trim(), c = t.querySelectorAll(`.${R.PRICE} p`);
|
|
144
|
-
let e = !1;
|
|
145
|
-
return c.forEach((n) => {
|
|
146
|
-
n.getAttribute(d.POSITION) !== r && (s.modifyHtml(n).setAttribute(d.POSITION, r), e = !0), i && n.getAttribute(d.SYMBOL) !== i && (s.modifyHtml(n).setAttribute(d.SYMBOL, i), e = !0);
|
|
147
|
-
}), e;
|
|
98
|
+
r("data-type", t.type), r("data-number", o), r("data-nodup", String(t.priceHideDiscount));
|
|
148
99
|
}
|
|
149
100
|
}
|
|
150
101
|
export {
|
|
151
|
-
|
|
152
|
-
|
|
102
|
+
p as BLOCK_ID,
|
|
103
|
+
E as ItemsBlock
|
|
153
104
|
};
|