@useinsider/guido 2.1.0-beta.eea3958 → 2.1.0-beta.f1f7f05
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/components/Guido.vue.js +3 -3
- package/dist/components/Guido.vue2.js +68 -66
- package/dist/components/organisms/base/Toaster.vue.js +6 -6
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +15 -14
- package/dist/composables/useHtmlValidator.js +114 -104
- package/dist/composables/useRecommendation.js +54 -21
- package/dist/composables/useStripo.js +23 -25
- package/dist/config/compiler/recommendationCompilerRules.js +45 -39
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
- package/dist/config/migrator/itemsBlockMigrator.js +101 -97
- package/dist/config/migrator/recommendationMigrator.js +2 -2
- package/dist/enums/extensions/recommendationBlock.js +1 -1
- package/dist/enums/recommendation.js +16 -15
- package/dist/extensions/Blocks/Recommendation/block.js +133 -9
- package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +66 -0
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +22 -0
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -0
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +92 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +102 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +209 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +52 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +250 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +70 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +160 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +67 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +307 -0
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +108 -0
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +14 -12
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +222 -0
- package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
- package/dist/extensions/Blocks/Recommendation/services/configService.js +240 -0
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +254 -207
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +228 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +66 -0
- package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +169 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +134 -0
- package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +26 -15
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
- package/dist/extensions/Blocks/controlFactories.js +125 -93
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +242 -186
- package/dist/services/recommendationApi.js +11 -8
- package/dist/services/templateLibraryApi.js +16 -13
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
- package/dist/src/composables/useRecommendation.d.ts +1 -0
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +67 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +41 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
- package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
- package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +52 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +79 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +60 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +221 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +34 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +83 -0
- package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
- package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +138 -468
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +41 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +66 -0
- package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +166 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
- package/dist/static/styles/components/notification.css.js +0 -8
- package/dist/static/styles/customEditorStyle.css.js +35 -11
- package/dist/static/styles/variables.css.js +0 -1
- package/dist/utils/pairProductVariables.js +57 -56
- package/dist/utils/templatePreparation.js +15 -14
- package/package.json +1 -1
- package/dist/config/localePatch/index.js +0 -13
- package/dist/config/localePatch/labels.json.js +0 -7
- package/dist/config/localePatch/toasters.json.js +0 -48
- package/dist/config/localePatch/tooltips.json.js +0 -82
- package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
- package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
- package/dist/extensions/Blocks/Recommendation/control.js +0 -336
- package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
- package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
- package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
- package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
- package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
- package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
- package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
- package/dist/src/config/localePatch/index.d.ts +0 -139
- package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
- package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
|
@@ -1,27 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { RecommendationFeedSourceMaps as g, URLS as p } from "../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
|
|
3
|
+
import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
|
+
import { generateCompleteFilterQuery as x } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
5
|
+
import { useConfigStore as C } from "../stores/config.js";
|
|
6
|
+
const N = () => ({
|
|
3
7
|
calculateCardWidth: ({
|
|
4
|
-
mobileLeftPadding:
|
|
5
|
-
mobileRightPadding:
|
|
6
|
-
cardsInRow:
|
|
7
|
-
unresponsive:
|
|
8
|
+
mobileLeftPadding: i,
|
|
9
|
+
mobileRightPadding: n,
|
|
10
|
+
cardsInRow: o,
|
|
11
|
+
unresponsive: a
|
|
8
12
|
}) => {
|
|
9
|
-
const
|
|
10
|
-
return (
|
|
13
|
+
const r = a ? o : 1, e = i + n + (r - 1) * b;
|
|
14
|
+
return (R - e) / r;
|
|
11
15
|
},
|
|
12
|
-
getRecommendationCampaignData: (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
getRecommendationCampaignData: (i) => {
|
|
17
|
+
const n = l(), o = Number(i), a = n.blockStates[o];
|
|
18
|
+
if (!a)
|
|
19
|
+
return {
|
|
20
|
+
textTrimming: !1,
|
|
21
|
+
orientation: "vertical",
|
|
22
|
+
mobileLeftPadding: 0,
|
|
23
|
+
mobileRightPadding: 0,
|
|
24
|
+
cardsInRow: 2,
|
|
25
|
+
unresponsive: !1,
|
|
26
|
+
priceBeforeTextValue: "",
|
|
27
|
+
priceAfterTextValue: "",
|
|
28
|
+
discountBeforeTextValue: "",
|
|
29
|
+
discountAfterTextValue: ""
|
|
30
|
+
};
|
|
31
|
+
const { recommendationConfigs: r } = a, e = r.orientation === "grid" ? "vertical" : "horizontal";
|
|
32
|
+
return {
|
|
33
|
+
textTrimming: r.textTrimming,
|
|
34
|
+
orientation: e,
|
|
35
|
+
mobileLeftPadding: 0,
|
|
36
|
+
mobileRightPadding: 0,
|
|
37
|
+
cardsInRow: r.cardsInRow,
|
|
38
|
+
unresponsive: r.unresponsive,
|
|
39
|
+
priceBeforeTextValue: "",
|
|
40
|
+
priceAfterTextValue: "",
|
|
41
|
+
discountBeforeTextValue: "",
|
|
42
|
+
discountAfterTextValue: ""
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
buildCampaignUrl: (i) => {
|
|
46
|
+
var d;
|
|
47
|
+
const n = l(), o = C(), a = Number(i), r = n.blockStates[a];
|
|
48
|
+
if (!r)
|
|
49
|
+
return "";
|
|
50
|
+
const { recommendationConfigs: e } = r, u = ((d = g.find((s) => s.key === e.strategy)) == null ? void 0 : d.path) || "", t = new URLSearchParams();
|
|
51
|
+
t.set("locale", e.language), t.set("currency", e.currencySettings.value), t.set("partnerName", o.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", o.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}");
|
|
52
|
+
const f = e.filters.filter((s) => s.isValid), c = x(f);
|
|
53
|
+
c && t.set("filter", c), e.shuffleProducts && t.set("shuffle", "true");
|
|
54
|
+
const m = `${p.RECOMMENDATION_API_URL}/v2/${u}?${t.toString()}`;
|
|
55
|
+
return n.recommendationCampaignUrls[i] = m, m;
|
|
56
|
+
}
|
|
24
57
|
});
|
|
25
58
|
export {
|
|
26
|
-
|
|
59
|
+
N as useRecommendation
|
|
27
60
|
};
|
|
@@ -4,22 +4,21 @@ import { useConfig as v } from "./useConfig.js";
|
|
|
4
4
|
import { useCustomInterfaceAppearance as A } from "./useCustomInterfaceAppearance.js";
|
|
5
5
|
import { useStripoEventHandler as F } from "./useStripoEventHandler.js";
|
|
6
6
|
import { useToaster as D } from "./useToaster.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import P from "../
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const o = R(), { html: n, css: p } = i, { baseBlocks: s, extensions: t } = await h(), a = ((m = l.value) == null ? void 0 : m.displayConditions) ?? !0, k = ((f = l.value) == null ? void 0 : f.modulesDisabled) ?? !1, T = ((g = y.value) == null ? void 0 : g.forceRecreate) ?? !1;
|
|
7
|
+
import { displayConditions as I } from "../enums/displayConditions.js";
|
|
8
|
+
import { useStripoApi as M } from "../services/stripoApi.js";
|
|
9
|
+
import U from "../static/styles/customEditorStyle.css.js";
|
|
10
|
+
import { useEditorStore as P } from "../stores/editor.js";
|
|
11
|
+
import { dynamicContentToMergeTags as R } from "../utils/genericUtil.js";
|
|
12
|
+
import H from "../package.json.js";
|
|
13
|
+
const W = (c) => {
|
|
14
|
+
const { features: l, template: y } = v(), { handleError: u } = D(), { getToken: C, getCustomFonts: S } = M(), { handleEvent: E } = F(), { getStripoBlocksConfig: h } = B(), w = async (i, n = []) => {
|
|
15
|
+
var m, g, f;
|
|
16
|
+
const o = P(), { html: r, css: p } = i, { baseBlocks: s, extensions: t } = await h(), a = ((m = l.value) == null ? void 0 : m.displayConditions) ?? !0, k = ((g = l.value) == null ? void 0 : g.modulesDisabled) ?? !1, T = ((f = y.value) == null ? void 0 : f.forceRecreate) ?? !1;
|
|
18
17
|
window.UIEditor.initEditor(
|
|
19
18
|
document.querySelector("#guido-editor"),
|
|
20
19
|
{
|
|
21
20
|
metadata: c,
|
|
22
|
-
html:
|
|
21
|
+
html: r,
|
|
23
22
|
css: p,
|
|
24
23
|
forceRecreate: T,
|
|
25
24
|
locale: "en",
|
|
@@ -31,10 +30,10 @@ const Z = (c) => {
|
|
|
31
30
|
customAppearanceMergetags: !0,
|
|
32
31
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
33
32
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
34
|
-
customViewStyles:
|
|
33
|
+
customViewStyles: U,
|
|
35
34
|
conditionsEnabled: a,
|
|
36
35
|
customConditionsEnabled: a,
|
|
37
|
-
conditionCategories:
|
|
36
|
+
conditionCategories: I,
|
|
38
37
|
enableXSSSecurity: !0,
|
|
39
38
|
modulesDisabled: k,
|
|
40
39
|
messageSettingsEnabled: !0,
|
|
@@ -47,11 +46,11 @@ const Z = (c) => {
|
|
|
47
46
|
editorFonts: {
|
|
48
47
|
showDefaultStandardFonts: !0,
|
|
49
48
|
showDefaultNotStandardFonts: !0,
|
|
50
|
-
customFonts:
|
|
49
|
+
customFonts: n
|
|
51
50
|
},
|
|
52
51
|
mergeTags: [
|
|
53
52
|
{
|
|
54
|
-
entries:
|
|
53
|
+
entries: R(c.preselectedDynamicContentList)
|
|
55
54
|
}
|
|
56
55
|
],
|
|
57
56
|
async onTokenRefreshRequest(e) {
|
|
@@ -90,30 +89,29 @@ const Z = (c) => {
|
|
|
90
89
|
".in-on-board-wrapper",
|
|
91
90
|
".in-drawer__container"
|
|
92
91
|
],
|
|
93
|
-
extensions: t
|
|
94
|
-
localePatch: I
|
|
92
|
+
extensions: t
|
|
95
93
|
}
|
|
96
94
|
);
|
|
97
|
-
}, b = (i) => new Promise((
|
|
95
|
+
}, b = (i) => new Promise((n, o) => {
|
|
98
96
|
var a;
|
|
99
97
|
if (document.getElementById("UiEditorScript")) {
|
|
100
|
-
i(),
|
|
98
|
+
i(), n();
|
|
101
99
|
return;
|
|
102
100
|
}
|
|
103
|
-
const
|
|
101
|
+
const r = H.guido, s = `https://email-static.useinsider.com/guido/${(a = r == null ? void 0 : r.stripo) == null ? void 0 : a.version}/UIEditor.js`, t = document.createElement("script");
|
|
104
102
|
t.id = "UiEditorScript", t.type = "module", t.src = s, t.onload = () => {
|
|
105
|
-
i(),
|
|
103
|
+
i(), n();
|
|
106
104
|
}, t.onerror = () => {
|
|
107
105
|
o(new Error(`Failed to load Stripo UIEditor script from S3: ${s}`));
|
|
108
106
|
}, document.body.appendChild(t);
|
|
109
107
|
});
|
|
110
108
|
return { initPlugin: async (i) => {
|
|
111
109
|
await b(async () => {
|
|
112
|
-
const
|
|
113
|
-
await w(i,
|
|
110
|
+
const n = await S();
|
|
111
|
+
await w(i, n);
|
|
114
112
|
});
|
|
115
113
|
} };
|
|
116
114
|
};
|
|
117
115
|
export {
|
|
118
|
-
|
|
116
|
+
W as useStripo
|
|
119
117
|
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as P, REGEX as
|
|
3
|
-
|
|
1
|
+
import { useRecommendation as f } from "../../composables/useRecommendation.js";
|
|
2
|
+
import { DUMMY_IMAGE_MAPPINGS as P, REGEX as m, VerticalOrientation as g, CSS as e, ATTRIBUTES as a, CONDITIONS as A, HTML as h } from "../../enums/recommendation.js";
|
|
3
|
+
import { prepareRecommendationBlocks as D } from "./utils/recommendationCompilerUtils.js";
|
|
4
|
+
const G = [
|
|
4
5
|
{
|
|
5
6
|
id: "replace-images-with-variable-names",
|
|
6
7
|
description: "Replacing dummy images with variable names in recommendation module",
|
|
7
8
|
type: "custom",
|
|
8
|
-
processor: (
|
|
9
|
-
let t =
|
|
10
|
-
return Object.entries(P).forEach(([,
|
|
11
|
-
Object.entries(
|
|
12
|
-
t = t.replaceAll(o, `{{${
|
|
9
|
+
processor: (s) => {
|
|
10
|
+
let t = s;
|
|
11
|
+
return Object.entries(P).forEach(([, l]) => {
|
|
12
|
+
Object.entries(l).forEach(([n, o]) => {
|
|
13
|
+
t = t.replaceAll(o, `{{${n}}}`);
|
|
13
14
|
});
|
|
14
15
|
}), t;
|
|
15
16
|
},
|
|
@@ -28,17 +29,17 @@ const H = [
|
|
|
28
29
|
id: "add-recommendation-unresponsive-css",
|
|
29
30
|
description: "Adding recommendation unresponsive css",
|
|
30
31
|
type: "custom",
|
|
31
|
-
processor: (
|
|
32
|
-
const {
|
|
33
|
-
let n =
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
t(
|
|
40
|
-
}),
|
|
41
|
-
const c = `width:${Math.min(...
|
|
32
|
+
processor: (s) => {
|
|
33
|
+
const { calculateCardWidth: t, getRecommendationCampaignData: l } = f();
|
|
34
|
+
let n = s;
|
|
35
|
+
const o = n.match(m.ID);
|
|
36
|
+
if (o) {
|
|
37
|
+
const d = [];
|
|
38
|
+
if (o.forEach((c) => {
|
|
39
|
+
const E = /recommendation-id="(.*?)"/i.exec(c), I = E ? E[1].trim() : "", p = l(I);
|
|
40
|
+
p.textTrimming && p.orientation === g && d.push(t(p));
|
|
41
|
+
}), d.length) {
|
|
42
|
+
const c = `width:${Math.min(...d)}px!important;`;
|
|
42
43
|
n = n.replace(e.REGULAR_NAME_HEIGHT, `${e.TRIMMED_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.REGULAR_NAME_CONTAINER_HEIGHT, e.TRIMMED_NAME_CONTAINER_CSS).replace(e.RESPONSIVE_NAME_SIZE, `${e.RESPONSIVE_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.RESPONSIVE_NAME_CONTAINER_HEIGHT, e.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -46,32 +47,37 @@ const H = [
|
|
|
46
47
|
},
|
|
47
48
|
priority: 52
|
|
48
49
|
},
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
{
|
|
51
|
+
id: "prepare-recommendations",
|
|
52
|
+
description: "Replacing product data with template variables in recommendation blocks",
|
|
53
|
+
type: "custom",
|
|
54
|
+
processor: (s) => D(s),
|
|
55
|
+
priority: 48
|
|
56
|
+
},
|
|
51
57
|
{
|
|
52
58
|
id: "add-discount-conditions",
|
|
53
59
|
description: "Adding discount conditions to the recommendation block",
|
|
54
60
|
type: "custom",
|
|
55
|
-
processor: (
|
|
56
|
-
let t =
|
|
57
|
-
const
|
|
58
|
-
return
|
|
59
|
-
const
|
|
60
|
-
if (!
|
|
61
|
+
processor: (s) => {
|
|
62
|
+
let t = s;
|
|
63
|
+
const l = t.match(m.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = f();
|
|
64
|
+
return l !== null && l.forEach((o) => {
|
|
65
|
+
const d = o.match(m.CUSTOM_FIELD);
|
|
66
|
+
if (!d)
|
|
61
67
|
return;
|
|
62
|
-
const [
|
|
63
|
-
if (!
|
|
68
|
+
const [c] = d, E = c.match(m.CUSTOM_FIELD_INDEXES_PART), I = c.match(m.CUSTOM_FIELD_NAME_PART), p = o.match(m.ATTRIBUTE_PARAGRAPH_START_TAG);
|
|
69
|
+
if (!E || !I || !p)
|
|
64
70
|
return;
|
|
65
|
-
const [
|
|
66
|
-
let
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
|
|
71
|
+
const [u] = E, [R] = I, [_] = p, T = R.substring(1, R.length - 2), S = _.match(m.COMPOSITION) !== null;
|
|
72
|
+
let i = c;
|
|
73
|
+
if (S) {
|
|
74
|
+
const $ = u.substring(2, u.length - 3), r = n($);
|
|
75
|
+
T === a.OMNIBUS_PRICE && (r.priceBeforeTextValue && (i = `${r.priceBeforeTextValue}${i}`), r.priceAfterTextValue && (i = `${i}${r.priceAfterTextValue}`)), T === a.OMNIBUS_DISCOUNT && (r.discountBeforeTextValue && (i = `${r.discountBeforeTextValue}${i}`), r.discountAfterTextValue && (i = `${i}${r.discountAfterTextValue}`));
|
|
70
76
|
}
|
|
71
|
-
const
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
const
|
|
77
|
+
const N = u.substring(2);
|
|
78
|
+
let M = "";
|
|
79
|
+
T in A.IF && (M = A.IF[T].replaceAll(`{${a.DISCOUNT}}`, `${N}${a.DISCOUNT}`).replaceAll(`{${a.OMNIBUS_DISCOUNT}}`, `${N}${a.OMNIBUS_DISCOUNT}`).replaceAll(`{${a.OMNIBUS_PRICE}}`, `${N}${a.OMNIBUS_PRICE}`));
|
|
80
|
+
const O = `${_}${i}${h.PARAGRAPH_END_TAG}`, C = `${M}${S ? O : o}${A.ELSE}${_}${h.PARAGRAPH_END_TAG}${A.END_IF}`;
|
|
75
81
|
t = t.replace(o, C);
|
|
76
82
|
}), t;
|
|
77
83
|
},
|
|
@@ -79,5 +85,5 @@ const H = [
|
|
|
79
85
|
}
|
|
80
86
|
];
|
|
81
87
|
export {
|
|
82
|
-
|
|
88
|
+
G as recommendationCompilerRules
|
|
83
89
|
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
|
|
2
|
+
function b(e, u, r, o) {
|
|
3
|
+
const n = `{{${e}_${u}_${r}}}`, t = `{{${e}_${u}_currency}}`;
|
|
4
|
+
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
5
|
+
}
|
|
6
|
+
function p(e, u, r, o, n) {
|
|
7
|
+
switch (u) {
|
|
8
|
+
case "productImage": {
|
|
9
|
+
const t = e.querySelector("img");
|
|
10
|
+
t && (t.setAttribute("src", `{{${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${r}_${o}_name}}`));
|
|
11
|
+
const c = e.querySelector("a");
|
|
12
|
+
c && c.setAttribute("href", `{{${r}_${o}_url}}`);
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
case "productName": {
|
|
16
|
+
const t = e.querySelector("p");
|
|
17
|
+
if (t) {
|
|
18
|
+
const c = t.querySelector("strong") || t;
|
|
19
|
+
c.textContent = `{{${r}_${o}_name}}`;
|
|
20
|
+
}
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
case "productPrice": {
|
|
24
|
+
const t = e.querySelector("p");
|
|
25
|
+
if (t) {
|
|
26
|
+
const c = t.querySelector("strong") || t;
|
|
27
|
+
c.textContent = b(r, o, "price", n);
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case "productOldPrice": {
|
|
32
|
+
const t = e.querySelector("p");
|
|
33
|
+
if (t) {
|
|
34
|
+
const c = t.querySelector("strong") || t;
|
|
35
|
+
c.textContent = b(
|
|
36
|
+
r,
|
|
37
|
+
o,
|
|
38
|
+
"original_price",
|
|
39
|
+
n
|
|
40
|
+
), t.setAttribute("product-attr", "discount");
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case "productButton": {
|
|
45
|
+
const t = e.querySelector("a");
|
|
46
|
+
t && t.setAttribute("href", `{{${r}_${o}_url}}`);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case "productOmnibusPrice": {
|
|
50
|
+
const t = e.querySelector(".omnibus-price-value");
|
|
51
|
+
if (t) {
|
|
52
|
+
t.textContent = `{{${r}_${o}_omnibus_price}}`;
|
|
53
|
+
const c = t.closest("p");
|
|
54
|
+
c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case "productOmnibusDiscount": {
|
|
59
|
+
const t = e.querySelector(".omnibus-discount-value");
|
|
60
|
+
if (t) {
|
|
61
|
+
t.textContent = `{{${r}_${o}_omnibus_discount}}`;
|
|
62
|
+
const c = t.closest("p");
|
|
63
|
+
c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function $(e, u, r) {
|
|
70
|
+
e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
71
|
+
n.querySelectorAll("[data-attribute-type]").forEach((s) => {
|
|
72
|
+
const i = s.getAttribute("data-attribute-type") || "", a = s.querySelectorAll(".attribute-cell");
|
|
73
|
+
a.length > 0 ? a.forEach((l) => {
|
|
74
|
+
p(l, i, u, t, r);
|
|
75
|
+
}) : p(s, i, u, t, r);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function S(e, u, r) {
|
|
80
|
+
const o = e.querySelectorAll(".recommendation-product-row");
|
|
81
|
+
if (!o.length)
|
|
82
|
+
return;
|
|
83
|
+
const [n] = o, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
84
|
+
o.forEach((s, i) => {
|
|
85
|
+
s.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
86
|
+
const f = l.getAttribute("data-attribute-type") || "";
|
|
87
|
+
l.querySelectorAll(".attribute-cell").forEach((y, m) => {
|
|
88
|
+
const A = i * c + m;
|
|
89
|
+
p(y, f, u, A, r);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function q(e, u, r) {
|
|
95
|
+
e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
96
|
+
S(n, u, r);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function d(e, u) {
|
|
100
|
+
const r = e.getAttribute("data-layout") || "grid", o = e.getAttribute("currency-alignment") || "after";
|
|
101
|
+
r === "list" ? $(e, u, o) : q(e, u, o);
|
|
102
|
+
}
|
|
103
|
+
function h(e, u) {
|
|
104
|
+
const r = e.match(/<!DOCTYPE[^>]*>/i);
|
|
105
|
+
return (r ? `${r[0]}
|
|
106
|
+
` : "") + u.documentElement.outerHTML;
|
|
107
|
+
}
|
|
108
|
+
function w(e) {
|
|
109
|
+
const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".ins-recommendation-v3-block-v2");
|
|
110
|
+
if (!o.length)
|
|
111
|
+
return e;
|
|
112
|
+
const { buildCampaignUrl: n } = _();
|
|
113
|
+
return o.forEach((c) => {
|
|
114
|
+
const s = c.getAttribute("recommendation-id");
|
|
115
|
+
s && (n(s), d(c, s));
|
|
116
|
+
}), h(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
b as formatPriceVariable,
|
|
120
|
+
w as prepareRecommendationBlocks
|
|
121
|
+
};
|