@useinsider/guido 3.2.0-beta.87303ed → 3.2.0-beta.895a145
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 +92 -0
- package/dist/@types/config/schemas.js +150 -94
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +88 -87
- package/dist/composables/useRecommendation.js +46 -26
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +104 -71
- package/dist/config/migrator/index.js +9 -9
- package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
- package/dist/config/migrator/recommendation/extractors.js +27 -0
- package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
- package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
- package/dist/config/migrator/recommendation/settingsMapper.js +70 -0
- package/dist/config/migrator/recommendation/themeMapper.js +93 -0
- package/dist/config/migrator/recommendationMigrator.js +74 -290
- package/dist/enums/extensions/recommendationBlock.js +43 -96
- package/dist/enums/unsubscribe.js +24 -25
- package/dist/extensions/Blocks/Checkbox/control.js +23 -23
- package/dist/extensions/Blocks/RadioButton/control.js +15 -15
- package/dist/extensions/Blocks/Recommendation/block.js +35 -32
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +25 -24
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
- package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +130 -90
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +19 -10
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +25 -15
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +21 -0
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
- package/dist/guido.css +1 -1
- package/dist/node_modules/valibot/dist/index.js +450 -235
- package/dist/src/@types/config/defaults.d.ts +5 -1
- package/dist/src/@types/config/index.d.ts +3 -3
- package/dist/src/@types/config/schemas.d.ts +213 -0
- package/dist/src/@types/config/types.d.ts +9 -1
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +56 -0
- package/dist/src/composables/useRecommendation.d.ts +10 -1
- package/dist/src/composables/useRecommendation.test.d.ts +1 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
- package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
- package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
- package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
- package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -5
- package/dist/src/enums/unsubscribe.d.ts +3 -8
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +34 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +21 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
- package/dist/src/library.d.ts +1 -1
- package/dist/src/stores/config.d.ts +504 -0
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/src/utils/htmlEscape.test.d.ts +1 -0
- package/dist/utils/htmlEscape.js +13 -0
- package/dist/utils/templatePreparation.js +72 -32
- package/package.json +5 -1
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
|
@@ -1,131 +1,132 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { provideGuidoActions as
|
|
3
|
-
import { usePartner as
|
|
4
|
-
import { useStripo as
|
|
1
|
+
import { defineComponent as J, defineAsyncComponent as I, ref as W, computed as B, watch as Q, onMounted as X, onUnmounted as Y } from "vue";
|
|
2
|
+
import { provideGuidoActions as Z } from "../composables/useGuidoActions.js";
|
|
3
|
+
import { usePartner as ee } from "../composables/usePartner.js";
|
|
4
|
+
import { useStripo as oe } from "../composables/useStripo.js";
|
|
5
5
|
import { useTimerClone as te } from "../composables/useTimerClone.js";
|
|
6
|
-
import { migrate as
|
|
7
|
-
import { ModuleFolderDefaults as
|
|
8
|
-
import { RIBBON_SELECTOR as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { useStripoApi as
|
|
16
|
-
import { useConfigStore as
|
|
17
|
-
import { useDynamicContentStore as
|
|
18
|
-
import { useEditorStore as
|
|
19
|
-
import { usePreviewStore as
|
|
20
|
-
import { useUnsubscribeStore as
|
|
21
|
-
const
|
|
6
|
+
import { migrate as H } from "../config/migrator/index.js";
|
|
7
|
+
import { ModuleFolderDefaults as x } from "../enums/defaults.js";
|
|
8
|
+
import { RIBBON_SELECTOR as ne } from "../enums/onboarding.js";
|
|
9
|
+
import se from "./organisms/base/Toaster.vue.js";
|
|
10
|
+
import re from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
|
|
11
|
+
import ce from "./organisms/header/HeaderWrapper.vue.js";
|
|
12
|
+
import ae from "./organisms/LoadingWrapper.vue.js";
|
|
13
|
+
import ie from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
|
|
14
|
+
import me from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
|
|
15
|
+
import { useStripoApi as de } from "../services/stripoApi.js";
|
|
16
|
+
import { useConfigStore as le } from "../stores/config.js";
|
|
17
|
+
import { useDynamicContentStore as ue } from "../stores/dynamic-content.js";
|
|
18
|
+
import { useEditorStore as pe } from "../stores/editor.js";
|
|
19
|
+
import { usePreviewStore as fe } from "../stores/preview.js";
|
|
20
|
+
import { useUnsubscribeStore as ve } from "../stores/unsubscribe.js";
|
|
21
|
+
const Ae = /* @__PURE__ */ J({
|
|
22
22
|
__name: "Guido",
|
|
23
23
|
props: {
|
|
24
24
|
config: null
|
|
25
25
|
},
|
|
26
26
|
emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
|
|
27
|
-
setup(
|
|
28
|
-
const
|
|
27
|
+
setup(G, { expose: z, emit: n }) {
|
|
28
|
+
const g = G, q = I(
|
|
29
29
|
() => import("./organisms/email-preview/PreviewContainer.vue.js")
|
|
30
|
-
),
|
|
30
|
+
), K = I(
|
|
31
31
|
() => import("./organisms/onboarding/OnboardingWrapper.vue.js")
|
|
32
|
-
),
|
|
33
|
-
|
|
34
|
-
const
|
|
32
|
+
), w = W(), u = W(), p = ue(), E = ve(), i = le();
|
|
33
|
+
i.init(g.config);
|
|
34
|
+
const f = pe(), V = fe(), m = B(() => f.hasChanges), { isTestPartner: $ } = ee(), D = () => {
|
|
35
35
|
var e;
|
|
36
|
-
return (e =
|
|
36
|
+
return (e = w.value) == null ? void 0 : e.handleSave(!0);
|
|
37
37
|
}, {
|
|
38
|
-
templateId:
|
|
39
|
-
userId:
|
|
40
|
-
partnerName:
|
|
41
|
-
username:
|
|
42
|
-
template:
|
|
38
|
+
templateId: v,
|
|
39
|
+
userId: C,
|
|
40
|
+
partnerName: T,
|
|
41
|
+
username: k,
|
|
42
|
+
template: o,
|
|
43
43
|
editor: r
|
|
44
|
-
} =
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
emailId:
|
|
48
|
-
userId:
|
|
49
|
-
username:
|
|
50
|
-
partnerName:
|
|
51
|
-
savedModulesFolderName:
|
|
52
|
-
defaultModulesFolderName:
|
|
53
|
-
},
|
|
54
|
-
preselectedDynamicContentList:
|
|
44
|
+
} = i, d = (o == null ? void 0 : o.html) || "", F = (o == null ? void 0 : o.css) || "", y = (o == null ? void 0 : o.preselectedDynamicContent) || [], L = (r == null ? void 0 : r.savedModulesFolderName) || x.SAVED_MODULES, U = (r == null ? void 0 : r.defaultModulesFolderName) || x.DEFAULT_MODULES;
|
|
45
|
+
f.templateId = v;
|
|
46
|
+
const h = {
|
|
47
|
+
emailId: v,
|
|
48
|
+
userId: C,
|
|
49
|
+
username: k,
|
|
50
|
+
partnerName: T,
|
|
51
|
+
savedModulesFolderName: L,
|
|
52
|
+
defaultModulesFolderName: U
|
|
53
|
+
}, _ = {
|
|
54
|
+
preselectedDynamicContentList: y,
|
|
55
55
|
onReady: () => {
|
|
56
|
-
console.debug("guido:ready"),
|
|
56
|
+
console.debug("guido:ready"), n("ready");
|
|
57
57
|
}
|
|
58
|
-
}, { initPlugin:
|
|
58
|
+
}, { initPlugin: M } = oe(h, _), { getDefaultTemplate: O } = de(), { cloneTimersOnSave: P, hasTimerBlocks: N } = te(), j = B(() => {
|
|
59
59
|
var e;
|
|
60
|
-
return !((e =
|
|
60
|
+
return !((e = i.ui) != null && e.showHeader);
|
|
61
61
|
});
|
|
62
|
-
|
|
62
|
+
Z({
|
|
63
63
|
onBack: () => {
|
|
64
|
-
console.debug("guido:back"),
|
|
64
|
+
console.debug("guido:back"), n("back");
|
|
65
65
|
},
|
|
66
66
|
onSaveStart: () => {
|
|
67
|
-
console.debug("guido:save:start"),
|
|
67
|
+
console.debug("guido:save:start"), n("save:start");
|
|
68
68
|
},
|
|
69
69
|
onSaveComplete: (e) => {
|
|
70
|
-
const
|
|
71
|
-
console.debug("guido:save:complete",
|
|
70
|
+
const t = { ...e, metadata: h };
|
|
71
|
+
console.debug("guido:save:complete", t), n("save:complete", t);
|
|
72
72
|
},
|
|
73
73
|
onTestEmailClick: () => {
|
|
74
|
-
console.debug("guido:test-email:click"),
|
|
74
|
+
console.debug("guido:test-email:click"), n("test-email:click");
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
|
-
const
|
|
78
|
-
console.debug("dynamic-content:close", e),
|
|
79
|
-
},
|
|
77
|
+
const R = (e) => {
|
|
78
|
+
console.debug("dynamic-content:close", e), p.setSelectedDynamicContent(e), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: e }));
|
|
79
|
+
}, A = () => {
|
|
80
80
|
console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
|
|
81
81
|
};
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
Q(() => m.value, () => {
|
|
83
|
+
n("on-change", m.value);
|
|
84
84
|
});
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
console.debug("dynamic-content:open",
|
|
85
|
+
const b = (e) => {
|
|
86
|
+
const t = e, { attribute: l, position: a } = t.detail;
|
|
87
|
+
console.debug("dynamic-content:open", t.detail), n("dynamic-content:open", l, a);
|
|
88
88
|
};
|
|
89
89
|
let c = null;
|
|
90
|
-
const
|
|
91
|
-
var
|
|
92
|
-
const e = document.querySelector(
|
|
93
|
-
(
|
|
90
|
+
const S = () => {
|
|
91
|
+
var t;
|
|
92
|
+
const e = document.querySelector(ne);
|
|
93
|
+
(t = u.value) == null || t.style.setProperty("--ribbon-offset", `${(e == null ? void 0 : e.offsetHeight) ?? 0}px`);
|
|
94
94
|
};
|
|
95
|
-
return
|
|
96
|
-
var
|
|
97
|
-
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"),
|
|
98
|
-
const e = (
|
|
99
|
-
e && (c = new ResizeObserver(
|
|
95
|
+
return X(async () => {
|
|
96
|
+
var t, l;
|
|
97
|
+
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), S();
|
|
98
|
+
const e = (t = u.value) == null ? void 0 : t.parentElement;
|
|
99
|
+
e && (c = new ResizeObserver(S), c.observe(e));
|
|
100
100
|
try {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
E.selectedUnsubscribePages = (o == null ? void 0 : o.selectedUnsubscribePages) || [];
|
|
102
|
+
const a = ((l = o == null ? void 0 : o.migration) == null ? void 0 : l.recommendationConfigs) ?? {};
|
|
103
|
+
let s = {
|
|
104
|
+
html: d && await H(d, a),
|
|
105
|
+
css: F
|
|
105
106
|
};
|
|
106
|
-
|
|
107
|
-
} catch (
|
|
108
|
-
console.error("Failed to initialize Stripo editor:",
|
|
107
|
+
s.html || (s = await O(), s.html = await H(s.html, a)), N(s.html) && (s.html = await P(s.html)), await M(s), p.selectedDynamicContentList = y;
|
|
108
|
+
} catch (a) {
|
|
109
|
+
console.error("Failed to initialize Stripo editor:", a);
|
|
109
110
|
}
|
|
110
|
-
document.addEventListener("dynamic-content:open",
|
|
111
|
-
}),
|
|
112
|
-
c == null || c.disconnect(), document.removeEventListener("dynamic-content:open",
|
|
111
|
+
document.addEventListener("dynamic-content:open", b);
|
|
112
|
+
}), Y(() => {
|
|
113
|
+
c == null || c.disconnect(), document.removeEventListener("dynamic-content:open", b);
|
|
113
114
|
try {
|
|
114
115
|
window.UIEditor.removeEditor();
|
|
115
116
|
} catch {
|
|
116
117
|
console.debug("Failed to remove Stripo editor: No editor found");
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
-
}),
|
|
119
|
+
i.reset();
|
|
120
|
+
}), z({
|
|
120
121
|
dynamicContent: {
|
|
121
|
-
insert:
|
|
122
|
-
close:
|
|
122
|
+
insert: R,
|
|
123
|
+
close: A
|
|
123
124
|
},
|
|
124
|
-
hasChanges:
|
|
125
|
-
saveSilent:
|
|
126
|
-
}), { __sfc: !0, PreviewContainer:
|
|
125
|
+
hasChanges: m,
|
|
126
|
+
saveSilent: D
|
|
127
|
+
}), { __sfc: !0, PreviewContainer: q, OnboardingWrapper: K, headerWrapperRef: w, wrapperRef: u, dynamicContentStore: p, unsubscribeStore: E, props: g, configStore: i, editorStore: f, previewStore: V, hasChanges: m, isTestPartner: $, saveSilent: D, templateId: v, userId: C, partnerName: T, username: k, templateConfig: o, editorConfig: r, html: d, css: F, preselectedDynamicContentList: y, savedModulesFolderName: L, defaultModulesFolderName: U, emit: n, metadata: h, options: _, initPlugin: M, getDefaultTemplate: O, cloneTimersOnSave: P, hasTimerBlocks: N, noHeader: j, insertDynamicContent: R, closeDynamicContent: A, handleDynamicContentOpen: b, ribbonObserver: c, updateRibbonOffset: S, Toaster: se, FilterSelectionDrawer: re, HeaderWrapper: ce, LoadingWrapper: ae, SaveAsTemplateDrawer: ie, UnsubscribeWrapper: me };
|
|
127
128
|
}
|
|
128
129
|
});
|
|
129
130
|
export {
|
|
130
|
-
|
|
131
|
+
Ae as default
|
|
131
132
|
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RecommendationFeedSourceMaps as I, URLS as C } from "../enums/extensions/recommendationBlock.js";
|
|
2
2
|
import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
4
|
-
import { generateCompleteFilterQuery as
|
|
5
|
-
import { useConfigStore as
|
|
6
|
-
const
|
|
3
|
+
import { useRecommendationExtensionStore as m } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
|
+
import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
5
|
+
import { useConfigStore as x } from "../stores/config.js";
|
|
6
|
+
const w = () => ({
|
|
7
7
|
calculateCardWidth: ({
|
|
8
|
-
mobileLeftPadding:
|
|
9
|
-
mobileRightPadding:
|
|
10
|
-
cardsInRow:
|
|
11
|
-
unresponsive:
|
|
8
|
+
mobileLeftPadding: s,
|
|
9
|
+
mobileRightPadding: a,
|
|
10
|
+
cardsInRow: c,
|
|
11
|
+
unresponsive: n
|
|
12
12
|
}) => {
|
|
13
|
-
const r =
|
|
13
|
+
const r = n ? c : 1, e = s + a + (r - 1) * b;
|
|
14
14
|
return (R - e) / r;
|
|
15
15
|
},
|
|
16
|
-
getRecommendationCampaignData: (
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
16
|
+
getRecommendationCampaignData: (s) => {
|
|
17
|
+
const a = m(), c = Number(s), n = a.blockStates[c];
|
|
18
|
+
if (!n)
|
|
19
19
|
return {
|
|
20
20
|
textTrimming: !1,
|
|
21
21
|
orientation: "vertical",
|
|
@@ -28,7 +28,7 @@ const N = () => ({
|
|
|
28
28
|
discountBeforeTextValue: "",
|
|
29
29
|
discountAfterTextValue: ""
|
|
30
30
|
};
|
|
31
|
-
const { recommendationConfigs: r } =
|
|
31
|
+
const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
|
|
32
32
|
return {
|
|
33
33
|
textTrimming: r.textTrimming,
|
|
34
34
|
orientation: e,
|
|
@@ -42,19 +42,39 @@ const N = () => ({
|
|
|
42
42
|
discountAfterTextValue: ""
|
|
43
43
|
};
|
|
44
44
|
},
|
|
45
|
-
buildCampaignUrl: (
|
|
46
|
-
var
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
buildCampaignUrl: (s, a) => {
|
|
46
|
+
var l;
|
|
47
|
+
const c = m(), n = x(), r = Number(s);
|
|
48
|
+
let e;
|
|
49
|
+
if (a)
|
|
50
|
+
e = a;
|
|
51
|
+
else {
|
|
52
|
+
const i = c.blockStates[r];
|
|
53
|
+
if (!i)
|
|
54
|
+
return "";
|
|
55
|
+
const { recommendationConfigs: o } = i;
|
|
56
|
+
e = {
|
|
57
|
+
strategy: o.strategy,
|
|
58
|
+
language: o.language,
|
|
59
|
+
currencyCode: o.currencySettings.value,
|
|
60
|
+
size: o.size,
|
|
61
|
+
productIds: o.productIds,
|
|
62
|
+
filters: o.filters,
|
|
63
|
+
shuffleProducts: o.shuffleProducts
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const f = ((l = I.find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
|
|
67
|
+
if (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") {
|
|
68
|
+
const i = parseInt(e.size) || 6;
|
|
69
|
+
t.set("productId", e.productIds.slice(0, i).join(","));
|
|
70
|
+
} else e.strategy === "similarViewed" && t.set("productId", "{itemId}");
|
|
71
|
+
e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
72
|
+
const g = e.filters.filter((i) => i.isValid), d = h(g);
|
|
73
|
+
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true");
|
|
74
|
+
const p = decodeURIComponent(t.toString()), u = `${C.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
|
|
75
|
+
return c.recommendationCampaignUrls[s] = u, u;
|
|
56
76
|
}
|
|
57
77
|
});
|
|
58
78
|
export {
|
|
59
|
-
|
|
79
|
+
w as useRecommendation
|
|
60
80
|
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
4
|
-
function y(
|
|
5
|
-
const n = `{{${s}${
|
|
1
|
+
import { useConfig as g } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as S } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { useRecommendationExtensionStore as _ } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
|
+
function y(r, c, e, o, s = "") {
|
|
5
|
+
const n = `{{${s}${r}_${c}_${e}}}`, t = `{{${s}${r}_${c}_currency}}`;
|
|
6
6
|
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
switch (
|
|
8
|
+
function f(r, c, e, o, s, n) {
|
|
9
|
+
switch (c) {
|
|
10
10
|
case "productImage": {
|
|
11
|
-
const t =
|
|
12
|
-
t && (t.setAttribute("src", `{{${n}${
|
|
13
|
-
const
|
|
14
|
-
|
|
11
|
+
const t = r.querySelector("img");
|
|
12
|
+
t && (t.setAttribute("src", `{{${n}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${e}_${o}_name}}`));
|
|
13
|
+
const i = r.querySelector("a");
|
|
14
|
+
i && i.setAttribute("href", `{{${n}${e}_${o}_url}}`);
|
|
15
15
|
break;
|
|
16
16
|
}
|
|
17
17
|
case "productName": {
|
|
18
|
-
const t =
|
|
18
|
+
const t = r.querySelector("p");
|
|
19
19
|
if (t) {
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const i = t.querySelector("strong") || t;
|
|
21
|
+
i.textContent = `{{${n}${e}_${o}_name}}`;
|
|
22
22
|
}
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
25
|
case "productPrice": {
|
|
26
|
-
const t =
|
|
26
|
+
const t = r.querySelector("p");
|
|
27
27
|
if (t) {
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const i = t.querySelector("strong") || t;
|
|
29
|
+
i.textContent = y(e, o, "price", s, n);
|
|
30
30
|
}
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
33
33
|
case "productOldPrice": {
|
|
34
|
-
const t =
|
|
34
|
+
const t = r.querySelector("p");
|
|
35
35
|
if (t) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const i = t.querySelector("strong") || t;
|
|
37
|
+
i.textContent = y(
|
|
38
|
+
e,
|
|
39
39
|
o,
|
|
40
40
|
"original_price",
|
|
41
41
|
s,
|
|
@@ -45,94 +45,127 @@ function m(e, u, r, o, s, n) {
|
|
|
45
45
|
break;
|
|
46
46
|
}
|
|
47
47
|
case "productButton": {
|
|
48
|
-
const t =
|
|
49
|
-
t && t.setAttribute("href", `{{${n}${
|
|
48
|
+
const t = r.querySelector("a");
|
|
49
|
+
t && t.setAttribute("href", `{{${n}${e}_${o}_url}}`);
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
52
|
case "productOmnibusPrice": {
|
|
53
|
-
const t =
|
|
53
|
+
const t = r.querySelector(".omnibus-price-value");
|
|
54
54
|
if (t) {
|
|
55
|
-
t.textContent = `{{${n}${
|
|
56
|
-
const
|
|
57
|
-
|
|
55
|
+
t.textContent = `{{${n}${e}_${o}_omnibus_price}}`;
|
|
56
|
+
const i = t.closest("p");
|
|
57
|
+
i && (i.setAttribute("product-attr", "omnibus_price"), i.setAttribute("composition", "true"));
|
|
58
58
|
}
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
61
|
case "productOmnibusDiscount": {
|
|
62
|
-
const t =
|
|
62
|
+
const t = r.querySelector(".omnibus-discount-value");
|
|
63
63
|
if (t) {
|
|
64
|
-
t.textContent = `{{${n}${
|
|
65
|
-
const
|
|
66
|
-
|
|
64
|
+
t.textContent = `{{${n}${e}_${o}_omnibus_discount}}`;
|
|
65
|
+
const i = t.closest("p");
|
|
66
|
+
i && (i.setAttribute("product-attr", "omnibus_discount"), i.setAttribute("composition", "true"));
|
|
67
67
|
}
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
default: {
|
|
71
|
-
const t =
|
|
71
|
+
const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
|
|
72
72
|
if (t) {
|
|
73
|
-
const
|
|
73
|
+
const i = t.getAttribute("product-attr"), a = t.querySelector("p");
|
|
74
74
|
if (a) {
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const u = a.querySelector("strong") || a;
|
|
76
|
+
u.textContent = `{{${n}${e}_${o}_${i}}}`;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
break;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
function q(
|
|
84
|
-
|
|
83
|
+
function q(r, c, e, o) {
|
|
84
|
+
r.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
85
85
|
n.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}) :
|
|
86
|
+
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
87
|
+
p.length > 0 ? p.forEach((l) => {
|
|
88
|
+
f(l, u, c, t, e, o);
|
|
89
|
+
}) : f(a, u, c, t, e, o);
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
const s =
|
|
93
|
+
function w(r, c, e, o) {
|
|
94
|
+
const s = r.querySelectorAll(".recommendation-product-row");
|
|
95
95
|
if (!s.length)
|
|
96
96
|
return;
|
|
97
|
-
const [n] = s, t = n.querySelector("[data-attribute-type]"),
|
|
98
|
-
s.forEach((a,
|
|
99
|
-
a.querySelectorAll("[data-attribute-type]").forEach((
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
97
|
+
const [n] = s, t = n.querySelector("[data-attribute-type]"), i = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
98
|
+
s.forEach((a, u) => {
|
|
99
|
+
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
100
|
+
const d = l.getAttribute("data-attribute-type") || "";
|
|
101
|
+
l.querySelectorAll(".attribute-cell").forEach((A, h) => {
|
|
102
|
+
const $ = u * i + h;
|
|
103
|
+
f(A, d, c, $, e, o);
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
function E(r, c, e, o) {
|
|
109
|
+
r.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
110
|
+
w(n, c, e, o);
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
function C(
|
|
114
|
-
const o =
|
|
115
|
-
o === "list" ? q(
|
|
113
|
+
function C(r, c, e) {
|
|
114
|
+
const o = r.getAttribute("data-layout") || "grid", s = r.getAttribute("currency-alignment") || "after";
|
|
115
|
+
o === "list" ? q(r, c, s, e) : E(r, c, s, e);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
return
|
|
120
|
-
` : "") + u.documentElement.outerHTML;
|
|
117
|
+
function b(r, c, e) {
|
|
118
|
+
const o = new RegExp(`${c}\\s*:\\s*(\\d+)\\s*px`, "i"), s = r.match(o);
|
|
119
|
+
return s ? parseInt(s[1]) : e;
|
|
121
120
|
}
|
|
122
|
-
function
|
|
123
|
-
|
|
121
|
+
function P(r, c) {
|
|
122
|
+
let e = r.parentElement;
|
|
123
|
+
for (; e && e !== c; ) {
|
|
124
|
+
if (e.tagName === "TD") {
|
|
125
|
+
const o = e.getAttribute("width");
|
|
126
|
+
if (o && o.endsWith("%") && parseFloat(o) < 100)
|
|
127
|
+
return e;
|
|
128
|
+
}
|
|
129
|
+
e = e.parentElement;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
function R(r) {
|
|
134
|
+
const c = r.getAttribute("style") || "", e = b(c, "width", 600), o = b(c, "padding", 0) * 2, s = Math.max(0, e - o);
|
|
135
|
+
s !== 0 && r.querySelectorAll("img.adapt-img").forEach((n) => {
|
|
136
|
+
if (n.hasAttribute("width"))
|
|
137
|
+
return;
|
|
138
|
+
const t = P(n, r);
|
|
139
|
+
if (!t)
|
|
140
|
+
return;
|
|
141
|
+
const i = t.getAttribute("width"), a = parseFloat(i), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(s * a / 100), l = Math.max(1, p - u);
|
|
142
|
+
n.setAttribute("width", String(l));
|
|
143
|
+
const d = n.getAttribute("style") || "";
|
|
144
|
+
if (!/\bwidth\s*:\s*\d/i.test(d)) {
|
|
145
|
+
const m = d && !d.trim().endsWith(";") ? "; " : "";
|
|
146
|
+
n.setAttribute("style", `${d}${m}width: ${l}px`);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function v(r, c) {
|
|
151
|
+
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
152
|
+
return (e ? `${e[0]}
|
|
153
|
+
` : "") + c.documentElement.outerHTML;
|
|
154
|
+
}
|
|
155
|
+
function O(r) {
|
|
156
|
+
const c = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(c, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
124
157
|
if (!o.length)
|
|
125
|
-
return
|
|
126
|
-
const { buildCampaignUrl: s } =
|
|
158
|
+
return r;
|
|
159
|
+
const { buildCampaignUrl: s } = S(), n = _();
|
|
127
160
|
n.recommendationCampaignUrls = {};
|
|
128
|
-
const { isFeatureEnabled: t } =
|
|
129
|
-
return o.forEach((
|
|
130
|
-
var
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
}),
|
|
161
|
+
const { isFeatureEnabled: t } = g(), i = t("liquidSyntax") ? "reco_" : "";
|
|
162
|
+
return o.forEach((u) => {
|
|
163
|
+
var l, d;
|
|
164
|
+
const p = u.getAttribute("recommendation-id");
|
|
165
|
+
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), s(p), C(u, p, i), R(u));
|
|
166
|
+
}), v(c, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
134
167
|
}
|
|
135
168
|
export {
|
|
136
169
|
y as formatPriceVariable,
|
|
137
|
-
|
|
170
|
+
O as prepareRecommendationBlocks
|
|
138
171
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
2
|
-
import { migrateCouponBlock as
|
|
3
|
-
import { migrateItemsBlock as
|
|
4
|
-
import { migrateRadioButton as
|
|
5
|
-
import { migrateRecommendation as
|
|
6
|
-
import { migrateUnsubscribe as
|
|
7
|
-
const
|
|
1
|
+
import { migrateCheckbox as o } from "./checkboxMigrator.js";
|
|
2
|
+
import { migrateCouponBlock as i } from "./couponBlockMigrator.js";
|
|
3
|
+
import { migrateItemsBlock as e } from "./itemsBlockMigrator.js";
|
|
4
|
+
import { migrateRadioButton as a } from "./radioButtonMigrator.js";
|
|
5
|
+
import { migrateRecommendation as g } from "./recommendationMigrator.js";
|
|
6
|
+
import { migrateUnsubscribe as n } from "./unsubscribeMigrator.js";
|
|
7
|
+
const b = async (r, t = {}) => {
|
|
8
8
|
let m = r;
|
|
9
|
-
return m =
|
|
9
|
+
return m = o(m), m = a(m), m = await n(m), m = i(m), m = g(m, t), m = e(m), m;
|
|
10
10
|
};
|
|
11
11
|
export {
|
|
12
|
-
|
|
12
|
+
b as migrate
|
|
13
13
|
};
|