@useinsider/guido 3.2.0-beta.8e8f902 → 3.2.0-beta.8f147c3
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 -25
- package/dist/@types/config/schemas.js +163 -109
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +77 -77
- package/dist/components/organisms/header/RightSlot.vue.js +8 -8
- package/dist/components/organisms/header/RightSlot.vue2.js +8 -9
- package/dist/composables/useSave.js +15 -15
- 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 +486 -0
- package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
- package/dist/config/migrator/recommendation/settingsMapper.js +78 -0
- package/dist/config/migrator/recommendation/themeMapper.js +93 -0
- package/dist/config/migrator/recommendationMigrator.js +60 -290
- package/dist/enums/extensions/recommendationBlock.js +2 -1
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
- package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
- 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/services/templateLibraryApi.js +4 -5
- 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 -4
- package/dist/src/@types/config/types.d.ts +9 -1
- package/dist/src/components/Guido.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +56 -2
- package/dist/src/composables/useSave.d.ts +1 -1
- 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/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/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
- package/dist/src/stores/config.d.ts +504 -18
- package/dist/src/stores/editor.d.ts +0 -23
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/stores/editor.js +1 -3
- package/dist/utils/htmlEscape.js +13 -0
- package/dist/utils/pairProductVariables.js +88 -89
- package/package.json +5 -1
- package/dist/components/organisms/AutoSaveController.vue.js +0 -17
- package/dist/components/organisms/AutoSaveController.vue2.js +0 -13
- package/dist/components/organisms/header/AutoSaveToggle.vue.js +0 -22
- package/dist/components/organisms/header/AutoSaveToggle.vue2.js +0 -19
- package/dist/composables/useAutoSave.js +0 -71
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
- package/dist/src/components/organisms/AutoSaveController.vue.d.ts +0 -2
- package/dist/src/components/organisms/header/AutoSaveToggle.vue.d.ts +0 -2
- package/dist/src/composables/useAutoSave.d.ts +0 -3
- package/dist/src/stores/autosave.d.ts +0 -12
- package/dist/src/utils/timeUtil.d.ts +0 -8
- package/dist/stores/autosave.js +0 -17
- package/dist/utils/timeUtil.js +0 -19
|
@@ -1,14 +1,13 @@
|
|
|
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 re from "./organisms/
|
|
11
|
-
import se from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
|
|
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";
|
|
12
11
|
import ce from "./organisms/header/HeaderWrapper.vue.js";
|
|
13
12
|
import ae from "./organisms/LoadingWrapper.vue.js";
|
|
14
13
|
import ie from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
|
|
@@ -19,114 +18,115 @@ import { useDynamicContentStore as ue } from "../stores/dynamic-content.js";
|
|
|
19
18
|
import { useEditorStore as pe } from "../stores/editor.js";
|
|
20
19
|
import { usePreviewStore as fe } from "../stores/preview.js";
|
|
21
20
|
import { useUnsubscribeStore as ve } from "../stores/unsubscribe.js";
|
|
22
|
-
const
|
|
21
|
+
const Ae = /* @__PURE__ */ J({
|
|
23
22
|
__name: "Guido",
|
|
24
23
|
props: {
|
|
25
24
|
config: null
|
|
26
25
|
},
|
|
27
26
|
emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
|
|
28
|
-
setup(
|
|
29
|
-
const
|
|
27
|
+
setup(G, { expose: z, emit: n }) {
|
|
28
|
+
const g = G, q = I(
|
|
30
29
|
() => import("./organisms/email-preview/PreviewContainer.vue.js")
|
|
31
|
-
),
|
|
30
|
+
), K = I(
|
|
32
31
|
() => import("./organisms/onboarding/OnboardingWrapper.vue.js")
|
|
33
|
-
),
|
|
34
|
-
|
|
35
|
-
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 = () => {
|
|
36
35
|
var e;
|
|
37
|
-
return (e =
|
|
36
|
+
return (e = w.value) == null ? void 0 : e.handleSave(!0);
|
|
38
37
|
}, {
|
|
39
|
-
templateId:
|
|
40
|
-
userId:
|
|
41
|
-
partnerName:
|
|
42
|
-
username:
|
|
43
|
-
template:
|
|
44
|
-
editor:
|
|
45
|
-
} =
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
emailId:
|
|
49
|
-
userId:
|
|
50
|
-
username:
|
|
51
|
-
partnerName:
|
|
52
|
-
savedModulesFolderName:
|
|
53
|
-
defaultModulesFolderName:
|
|
54
|
-
},
|
|
55
|
-
preselectedDynamicContentList:
|
|
38
|
+
templateId: v,
|
|
39
|
+
userId: C,
|
|
40
|
+
partnerName: T,
|
|
41
|
+
username: k,
|
|
42
|
+
template: o,
|
|
43
|
+
editor: r
|
|
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,
|
|
56
55
|
onReady: () => {
|
|
57
|
-
console.debug("guido:ready"),
|
|
56
|
+
console.debug("guido:ready"), n("ready");
|
|
58
57
|
}
|
|
59
|
-
}, { initPlugin:
|
|
58
|
+
}, { initPlugin: M } = oe(h, _), { getDefaultTemplate: O } = de(), { cloneTimersOnSave: P, hasTimerBlocks: N } = te(), j = B(() => {
|
|
60
59
|
var e;
|
|
61
|
-
return !((e =
|
|
60
|
+
return !((e = i.ui) != null && e.showHeader);
|
|
62
61
|
});
|
|
63
|
-
|
|
62
|
+
Z({
|
|
64
63
|
onBack: () => {
|
|
65
|
-
console.debug("guido:back"),
|
|
64
|
+
console.debug("guido:back"), n("back");
|
|
66
65
|
},
|
|
67
66
|
onSaveStart: () => {
|
|
68
|
-
console.debug("guido:save:start"),
|
|
67
|
+
console.debug("guido:save:start"), n("save:start");
|
|
69
68
|
},
|
|
70
69
|
onSaveComplete: (e) => {
|
|
71
|
-
const
|
|
72
|
-
console.debug("guido:save:complete",
|
|
70
|
+
const t = { ...e, metadata: h };
|
|
71
|
+
console.debug("guido:save:complete", t), n("save:complete", t);
|
|
73
72
|
},
|
|
74
73
|
onTestEmailClick: () => {
|
|
75
|
-
console.debug("guido:test-email:click"),
|
|
74
|
+
console.debug("guido:test-email:click"), n("test-email:click");
|
|
76
75
|
}
|
|
77
76
|
});
|
|
78
|
-
const
|
|
79
|
-
console.debug("dynamic-content:close", e),
|
|
77
|
+
const R = (e) => {
|
|
78
|
+
console.debug("dynamic-content:close", e), p.setSelectedDynamicContent(e), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: e }));
|
|
80
79
|
}, A = () => {
|
|
81
80
|
console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
|
|
82
81
|
};
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
Q(() => m.value, () => {
|
|
83
|
+
n("on-change", m.value);
|
|
85
84
|
});
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
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);
|
|
89
88
|
};
|
|
90
89
|
let c = null;
|
|
91
|
-
const
|
|
92
|
-
var
|
|
93
|
-
const e = document.querySelector(
|
|
94
|
-
(
|
|
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`);
|
|
95
94
|
};
|
|
96
|
-
return
|
|
97
|
-
var
|
|
98
|
-
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"),
|
|
99
|
-
const e = (
|
|
100
|
-
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));
|
|
101
100
|
try {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
|
106
106
|
};
|
|
107
|
-
|
|
108
|
-
} catch (
|
|
109
|
-
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);
|
|
110
110
|
}
|
|
111
|
-
document.addEventListener("dynamic-content:open",
|
|
112
|
-
}),
|
|
113
|
-
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);
|
|
114
114
|
try {
|
|
115
115
|
window.UIEditor.removeEditor();
|
|
116
116
|
} catch {
|
|
117
117
|
console.debug("Failed to remove Stripo editor: No editor found");
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
}),
|
|
119
|
+
i.reset();
|
|
120
|
+
}), z({
|
|
121
121
|
dynamicContent: {
|
|
122
|
-
insert:
|
|
122
|
+
insert: R,
|
|
123
123
|
close: A
|
|
124
124
|
},
|
|
125
|
-
hasChanges:
|
|
126
|
-
saveSilent:
|
|
127
|
-
}), { __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 };
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
130
|
export {
|
|
131
|
-
|
|
131
|
+
Ae as default
|
|
132
132
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
return e("div", { staticClass: "d-f a-i-c" }, [t.
|
|
6
|
-
}, a = [], n = /* @__PURE__ */
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import i from "./RightSlot.vue2.js";
|
|
2
|
+
import r from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
3
|
+
var o = function() {
|
|
4
|
+
var s = this, e = s._self._c, t = s._self._setupProxy;
|
|
5
|
+
return e("div", { staticClass: "d-f a-i-c" }, [t.isLiquidEnabled && !t.editorStore.isVersionHistoryOpen ? e(t.InChips, { staticClass: "mr-3", attrs: { id: "guido__liquid-tag-chip", styles: "stroke", type: "default", value: "liquid-tags", "close-button": !1, "disabled-status": t.editorStore.loadingStatus, interactive: !1, text: t.trans("email-editor.liquid-tags-enabled") } }) : s._e(), t.editorStore.isVersionHistoryOpen ? e(t.RestoreButton) : e(t.EditorActions, { ref: "editorActionsRef" })], 1);
|
|
6
|
+
}, a = [], n = /* @__PURE__ */ r(
|
|
7
|
+
i,
|
|
8
|
+
o,
|
|
9
9
|
a,
|
|
10
10
|
!1,
|
|
11
11
|
null,
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { defineComponent as a, ref as f, computed as p } from "vue";
|
|
2
2
|
import { useConfig as u } from "../../../composables/useConfig.js";
|
|
3
3
|
import { useTranslations as d } from "../../../composables/useTranslations.js";
|
|
4
|
-
import { useEditorStore as
|
|
5
|
-
import { InChips as
|
|
6
|
-
import _ from "./
|
|
7
|
-
import S from "./
|
|
8
|
-
|
|
9
|
-
const T = /* @__PURE__ */ a({
|
|
4
|
+
import { useEditorStore as c } from "../../../stores/editor.js";
|
|
5
|
+
import { InChips as l } from "@useinsider/design-system-vue";
|
|
6
|
+
import _ from "./EditorActions.vue.js";
|
|
7
|
+
import S from "./version-history/RestoreButton.vue.js";
|
|
8
|
+
const x = /* @__PURE__ */ a({
|
|
10
9
|
__name: "RightSlot",
|
|
11
10
|
setup(h, { expose: r }) {
|
|
12
|
-
const { isFeatureEnabled: o } = u(),
|
|
11
|
+
const { isFeatureEnabled: o } = u(), n = d(), i = c(), t = f(null), s = p(() => o("liquidSyntax"));
|
|
13
12
|
return r({
|
|
14
13
|
handleSave: (m) => {
|
|
15
14
|
var e;
|
|
16
15
|
return (e = t.value) == null ? void 0 : e.handleSave(m);
|
|
17
16
|
}
|
|
18
|
-
}), { __sfc: !0, isFeatureEnabled: o, trans:
|
|
17
|
+
}), { __sfc: !0, isFeatureEnabled: o, trans: n, editorStore: i, editorActionsRef: t, isLiquidEnabled: s, InChips: l, EditorActions: _, RestoreButton: S };
|
|
19
18
|
}
|
|
20
19
|
});
|
|
21
20
|
export {
|
|
22
|
-
|
|
21
|
+
x as default
|
|
23
22
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useSaveStart as
|
|
4
|
-
import { useSyncModuleExtractor as
|
|
5
|
-
import { useStripoApi as
|
|
6
|
-
import { useTemplatePreparation as
|
|
7
|
-
import { useHtmlValidator as
|
|
8
|
-
import { useLiquidValidator as
|
|
9
|
-
const
|
|
10
|
-
const o =
|
|
11
|
-
return { save: async (m = !1
|
|
1
|
+
import { useActionsApi as S } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as V } from "./useConfig.js";
|
|
3
|
+
import { useSaveStart as x, useSaveComplete as y } from "./useGuidoActions.js";
|
|
4
|
+
import { useSyncModuleExtractor as w } from "./useSyncModuleExtractor.js";
|
|
5
|
+
import { useStripoApi as b } from "../services/stripoApi.js";
|
|
6
|
+
import { useTemplatePreparation as q } from "../utils/templatePreparation.js";
|
|
7
|
+
import { useHtmlValidator as H } from "./useHtmlValidator.js";
|
|
8
|
+
import { useLiquidValidator as L } from "./validators/useLiquidValidator.js";
|
|
9
|
+
const F = () => {
|
|
10
|
+
const o = x(), s = y(), { validateHtml: r } = H(), { validateLiquidSyntax: n } = L(), { callbacks: a, isFeatureEnabled: l } = V(), { extractSyncModuleData: d } = w(), { setSyncModuleUnsubscriptionPages: u } = b(), { editorSave: c } = S();
|
|
11
|
+
return { save: async (m = !1) => {
|
|
12
12
|
var i;
|
|
13
13
|
o();
|
|
14
|
-
const { prepareTemplateDetails:
|
|
14
|
+
const { prepareTemplateDetails: p } = q(), t = await p();
|
|
15
15
|
if (l("liquidSyntax")) {
|
|
16
16
|
if (!await n(t.compiledHtml))
|
|
17
17
|
return;
|
|
@@ -20,10 +20,10 @@ const U = () => {
|
|
|
20
20
|
if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t))
|
|
21
21
|
return;
|
|
22
22
|
await c();
|
|
23
|
-
const { unsubscribePayload:
|
|
24
|
-
return await u(
|
|
23
|
+
const { unsubscribePayload: f, stripoModules: v } = d(t.rawHtml);
|
|
24
|
+
return await u(f), t.modules = v, m || s(t), t;
|
|
25
25
|
} };
|
|
26
26
|
};
|
|
27
27
|
export {
|
|
28
|
-
|
|
28
|
+
F as useSave
|
|
29
29
|
};
|
|
@@ -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
|
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { DEFAULT_COMPOSITION as d, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
2
|
+
import { ATTR_CUSTOM_PREFIX as l, ATTR_PRODUCT_BUTTON as k, ATTR_PRODUCT_OMNIBUS_DISCOUNT as A, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_NAME as h, ATTR_PRODUCT_IMAGE as y } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
3
|
+
import { mapTextTheme as E, mapButtonTheme as O, mapImageTheme as b } from "./themeMapper.js";
|
|
4
|
+
const C = "__title__", a = "product_attribute.";
|
|
5
|
+
function N(r) {
|
|
6
|
+
const t = r.variable ?? "";
|
|
7
|
+
switch (t) {
|
|
8
|
+
case "p_recommendation_title":
|
|
9
|
+
return { key: C, kind: "title" };
|
|
10
|
+
case "p_image":
|
|
11
|
+
return { key: y, kind: "image" };
|
|
12
|
+
case "p_name":
|
|
13
|
+
return { key: h, kind: "text" };
|
|
14
|
+
case "p_price":
|
|
15
|
+
return { key: R, kind: "text" };
|
|
16
|
+
case "p_original_price":
|
|
17
|
+
return { key: f, kind: "text" };
|
|
18
|
+
case "p_omnibus_price":
|
|
19
|
+
return { key: x, kind: "text" };
|
|
20
|
+
case "p_omnibus_discount":
|
|
21
|
+
return { key: A, kind: "text" };
|
|
22
|
+
case "p_button":
|
|
23
|
+
return { key: k, kind: "button" };
|
|
24
|
+
default:
|
|
25
|
+
if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
|
|
26
|
+
const s = r.value ?? "", o = s.startsWith(a) ? s.slice(a.length) : s;
|
|
27
|
+
return o ? {
|
|
28
|
+
key: `${l}${o}`,
|
|
29
|
+
kind: "custom",
|
|
30
|
+
customAttrName: o,
|
|
31
|
+
customAttrValue: s || `${a}${o}`
|
|
32
|
+
} : null;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function p(r) {
|
|
38
|
+
const t = d.indexOf(r);
|
|
39
|
+
return t === -1 ? Number.POSITIVE_INFINITY : t;
|
|
40
|
+
}
|
|
41
|
+
function S(r) {
|
|
42
|
+
const t = {
|
|
43
|
+
composition: [],
|
|
44
|
+
visibility: { ...I },
|
|
45
|
+
customAttributes: [],
|
|
46
|
+
customAttrValues: {},
|
|
47
|
+
perElementStyles: {},
|
|
48
|
+
anyTextTrimming: !1
|
|
49
|
+
};
|
|
50
|
+
if (!r || r.length === 0)
|
|
51
|
+
return t.composition = [...d], t;
|
|
52
|
+
const s = [];
|
|
53
|
+
r.forEach((e, i) => {
|
|
54
|
+
const n = N(e);
|
|
55
|
+
if (n) {
|
|
56
|
+
if (n.kind === "title") {
|
|
57
|
+
t.titleVariable = e;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
s.push({
|
|
61
|
+
key: n.key,
|
|
62
|
+
kind: n.kind,
|
|
63
|
+
hidden: e.hidden === !0,
|
|
64
|
+
positionIdx: typeof e.positionIdx == "number" ? e.positionIdx : Number.MAX_SAFE_INTEGER,
|
|
65
|
+
legacy: e,
|
|
66
|
+
customAttrName: n.customAttrName,
|
|
67
|
+
customAttrValue: n.customAttrValue,
|
|
68
|
+
originalIndex: i
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}), s.sort((e, i) => {
|
|
72
|
+
if (e.positionIdx !== i.positionIdx)
|
|
73
|
+
return e.positionIdx - i.positionIdx;
|
|
74
|
+
const n = p(e.key), u = p(i.key);
|
|
75
|
+
return n !== u ? n - u : e.originalIndex - i.originalIndex;
|
|
76
|
+
});
|
|
77
|
+
const o = {};
|
|
78
|
+
return s.forEach((e) => {
|
|
79
|
+
const { key: i, kind: n, hidden: u, legacy: m, customAttrName: c, customAttrValue: T } = e;
|
|
80
|
+
switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && c && T && (t.customAttributes.includes(c) || t.customAttributes.push(c), t.customAttrValues[i] = T), n) {
|
|
81
|
+
case "image":
|
|
82
|
+
o[i] = b(m.theme);
|
|
83
|
+
break;
|
|
84
|
+
case "button":
|
|
85
|
+
o[i] = O(m.theme);
|
|
86
|
+
break;
|
|
87
|
+
case "text":
|
|
88
|
+
case "custom": {
|
|
89
|
+
const _ = E(m.theme);
|
|
90
|
+
o[i] = _, _.textTrimming && (t.anyTextTrimming = !0);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}), t.perElementStyles = o, t;
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
S as mapComposition
|
|
98
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const i = "You May Also Like!";
|
|
2
|
+
function s(r) {
|
|
3
|
+
var e;
|
|
4
|
+
const o = r.querySelector(".ext-recommendation-title");
|
|
5
|
+
if (!o)
|
|
6
|
+
return i;
|
|
7
|
+
const t = (e = o.textContent) == null ? void 0 : e.trim();
|
|
8
|
+
return t && t.length > 0 ? t : i;
|
|
9
|
+
}
|
|
10
|
+
function u(r) {
|
|
11
|
+
const o = [
|
|
12
|
+
r,
|
|
13
|
+
...Array.from(r.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
14
|
+
];
|
|
15
|
+
let t = "";
|
|
16
|
+
return o.some((e) => {
|
|
17
|
+
const n = e.getAttribute("bgcolor");
|
|
18
|
+
if (n && n.trim())
|
|
19
|
+
return t = n.trim(), !0;
|
|
20
|
+
const c = (e.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
|
|
21
|
+
return c && c[1] ? (t = c[1].trim(), !0) : !1;
|
|
22
|
+
}), t;
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
u as extractCardBgColor,
|
|
26
|
+
s as extractTitleText
|
|
27
|
+
};
|