@useinsider/guido 3.18.1-beta.6ae01b1 → 3.18.1-beta.8d3bf29
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/@types/config/schemas.js +3 -1
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +55 -53
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -7
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +82 -57
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -24
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +46 -0
- package/dist/composables/useCustomInterfaceAppearance.js +46 -42
- package/dist/composables/useLegacyStrategyConversion.js +54 -0
- package/dist/enums/extensions/recommendationBlock.js +2 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +70 -69
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +67 -28
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +98 -56
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +58 -0
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +61 -52
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +54 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +39 -0
- package/dist/src/services/recommendationApi.d.ts +2 -1
- package/dist/src/stores/config.d.ts +160 -0
- package/dist/src/stores/onboarding.d.ts +808 -10
- package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
- package/dist/static/assets/icons/line-info.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +70 -5
- package/dist/stores/config.js +66 -59
- package/dist/stores/onboarding.js +46 -36
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineComponent as d, computed as g, watch as l } from "vue";
|
|
2
|
+
import { useRibbonOffset as b } from "../../../composables/useRibbonOffset.js";
|
|
3
|
+
import { useTranslations as p } from "../../../composables/useTranslations.js";
|
|
4
|
+
import { ACADEMY_LINKS as u } from "../../../enums/academy.js";
|
|
5
|
+
import { useOnboardingStore as y } from "../../../stores/onboarding.js";
|
|
6
|
+
import { InOnboard as f } from "@useinsider/design-system-vue";
|
|
7
|
+
const A = /* @__PURE__ */ d({
|
|
8
|
+
__name: "RecommendationLegacyStrategyOnboarding",
|
|
9
|
+
setup(O) {
|
|
10
|
+
const n = "recommendationLegacyStrategyOnboarding", o = p(), t = y(), { getTopPosition: i } = b(), r = `<a href="${u.EMAIL_RECOMMENDATION_BLOCK}" target="_blank" rel="noopener noreferrer">${o("action-builder.visit-academy")}</a>`, a = () => [
|
|
11
|
+
{
|
|
12
|
+
classes: "guido-recommendation-legacy-strategy-onboarding",
|
|
13
|
+
right: "40px",
|
|
14
|
+
top: i(485),
|
|
15
|
+
position: "Top Right",
|
|
16
|
+
title: o("email-editor.onboarding-recommendation-strategy-legacy-title"),
|
|
17
|
+
description: o("email-editor.onboarding-recommendation-strategy-legacy-description", {
|
|
18
|
+
academyLink: r
|
|
19
|
+
}),
|
|
20
|
+
imageSource: "",
|
|
21
|
+
backButtonClick: () => {
|
|
22
|
+
},
|
|
23
|
+
nextButtonType: "text",
|
|
24
|
+
nextButtonText: o("action-builder.ok"),
|
|
25
|
+
nextButtonClick: () => {
|
|
26
|
+
t.close(n);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
], s = g(
|
|
30
|
+
() => t.onboardings.recommendationLegacyStrategyOnboarding.config.length > 0 && t.onboardings.recommendationLegacyStrategyOnboarding.isActive
|
|
31
|
+
), m = () => {
|
|
32
|
+
var e, c;
|
|
33
|
+
(c = (e = t.getRecommendationLegacyStrategyCurrentCard) == null ? void 0 : e.nextButtonClick) == null || c.call(e);
|
|
34
|
+
};
|
|
35
|
+
return l(
|
|
36
|
+
() => t.isActive(n),
|
|
37
|
+
(e) => {
|
|
38
|
+
e && t.setConfig(n, a());
|
|
39
|
+
},
|
|
40
|
+
{ immediate: !0 }
|
|
41
|
+
), { __sfc: !0, ONBOARDING_TYPE: n, trans: o, onboardingStore: t, getTopPosition: i, academyLink: r, buildOnboardingCards: a, isVisible: s, handleNext: m, InOnboard: f };
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
export {
|
|
45
|
+
A as default
|
|
46
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import d from "./RecommendationStrategyOnboarding.vue2.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import g from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
4
|
+
var m = function() {
|
|
5
|
+
var e, n, r, a, i;
|
|
6
|
+
var t = this, s = t._self._c, o = t._self._setupProxy;
|
|
7
|
+
return o.isVisible ? s(o.InOnboard, { key: "guido__recommendation-strategy-onboard", staticClass: "w-21-s p-a z-11", class: (e = o.onboardingStore.getRecommendationStrategyCurrentCard) == null ? void 0 : e.classes, attrs: { id: "guido__recommendation-strategy-onboard", "is-multiple-page": "", visible: "", "image-source": "", title: "", "left-position": (n = o.onboardingStore.getRecommendationStrategyCurrentCard) == null ? void 0 : n.left, "pages-config": o.onboardingStore.onboardings.recommendationStrategyOnboarding.config, "pointer-position": (r = o.onboardingStore.getRecommendationStrategyCurrentCard) == null ? void 0 : r.position, "right-position": (a = o.onboardingStore.getRecommendationStrategyCurrentCard) == null ? void 0 : a.right, "top-position": (i = o.onboardingStore.getRecommendationStrategyCurrentCard) == null ? void 0 : i.top }, on: { close: function(p) {
|
|
8
|
+
return o.onboardingStore.close(o.ONBOARDING_TYPE);
|
|
9
|
+
}, nextButtonClick: o.handleNext } }) : t._e();
|
|
10
|
+
}, c = [], _ = /* @__PURE__ */ g(
|
|
11
|
+
d,
|
|
12
|
+
m,
|
|
13
|
+
c,
|
|
14
|
+
!1,
|
|
15
|
+
null,
|
|
16
|
+
"1f4a4044"
|
|
17
|
+
);
|
|
18
|
+
const S = _.exports;
|
|
19
|
+
export {
|
|
20
|
+
S as default
|
|
21
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineComponent as c, computed as g, watch as b } from "vue";
|
|
2
|
+
import { useRibbonOffset as p } from "../../../composables/useRibbonOffset.js";
|
|
3
|
+
import { useTranslations as u } from "../../../composables/useTranslations.js";
|
|
4
|
+
import { ACADEMY_LINKS as l } from "../../../enums/academy.js";
|
|
5
|
+
import { useOnboardingStore as f } from "../../../stores/onboarding.js";
|
|
6
|
+
import { InOnboard as O } from "@useinsider/design-system-vue";
|
|
7
|
+
const B = /* @__PURE__ */ c({
|
|
8
|
+
__name: "RecommendationStrategyOnboarding",
|
|
9
|
+
setup(_) {
|
|
10
|
+
const e = "recommendationStrategyOnboarding", n = u(), t = f(), { getTopPosition: i } = p(), r = `<a href="${l.EMAIL_RECOMMENDATION_BLOCK}" target="_blank" rel="noopener noreferrer">${n("action-builder.visit-academy")}</a>`, a = () => [
|
|
11
|
+
{
|
|
12
|
+
classes: "guido-recommendation-strategy-onboarding",
|
|
13
|
+
// Sits in the gap left of the settings panel and points at the strategy section, which
|
|
14
|
+
// starts 208px down: the panel header and its tab row are fixed chrome above it.
|
|
15
|
+
right: "426px",
|
|
16
|
+
top: i(208),
|
|
17
|
+
position: "Right Top",
|
|
18
|
+
title: n("email-editor.onboarding-recommendation-strategy-title"),
|
|
19
|
+
description: n("email-editor.onboarding-recommendation-strategy-description", {
|
|
20
|
+
academyLink: r
|
|
21
|
+
}),
|
|
22
|
+
imageSource: "",
|
|
23
|
+
backButtonClick: () => {
|
|
24
|
+
},
|
|
25
|
+
nextButtonType: "text",
|
|
26
|
+
nextButtonText: n("action-builder.ok"),
|
|
27
|
+
nextButtonClick: () => {
|
|
28
|
+
t.close(e);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
], m = g(() => t.onboardings.recommendationStrategyOnboarding.config.length > 0 && t.onboardings.recommendationStrategyOnboarding.isActive), d = () => {
|
|
32
|
+
var o, s;
|
|
33
|
+
(s = (o = t.getRecommendationStrategyCurrentCard) == null ? void 0 : o.nextButtonClick) == null || s.call(o);
|
|
34
|
+
};
|
|
35
|
+
return b(
|
|
36
|
+
() => t.isActive(e),
|
|
37
|
+
(o) => {
|
|
38
|
+
o && t.setConfig(e, a());
|
|
39
|
+
},
|
|
40
|
+
{ immediate: !0 }
|
|
41
|
+
), { __sfc: !0, ONBOARDING_TYPE: e, trans: n, onboardingStore: t, getTopPosition: i, academyLink: r, buildOnboardingCards: a, isVisible: m, handleNext: d, InOnboard: O };
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
export {
|
|
45
|
+
B as default
|
|
46
|
+
};
|
|
@@ -1,67 +1,71 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import p from "../static/
|
|
5
|
-
import s from "../static/
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import c from "../static/styles/components/
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import d from "../static/styles/components/
|
|
1
|
+
import i from "../static/assets/icons/filled-arrow-rising.svg.js";
|
|
2
|
+
import n from "../static/assets/icons/line-change.svg.js";
|
|
3
|
+
import S from "../static/assets/icons/line-delete.svg.js";
|
|
4
|
+
import p from "../static/assets/icons/line-info.svg.js";
|
|
5
|
+
import s from "../static/assets/icons/line-plus.svg.js";
|
|
6
|
+
import f from "../static/styles/base.css.js";
|
|
7
|
+
import C from "../static/styles/components/alert-message.css.js";
|
|
8
|
+
import a from "../static/styles/components/amp-block.css.js";
|
|
9
|
+
import c from "../static/styles/components/base-input.css.js";
|
|
10
|
+
import l from "../static/styles/components/button-group.css.js";
|
|
11
|
+
import u from "../static/styles/components/button.css.js";
|
|
12
|
+
import d from "../static/styles/components/combobox.css.js";
|
|
13
|
+
import I from "../static/styles/components/counter.css.js";
|
|
14
|
+
import g from "../static/styles/components/dropdown-menu.css.js";
|
|
13
15
|
import h from "../static/styles/components/loader.css.js";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
16
|
+
import w from "../static/styles/components/narrow-panel.css.js";
|
|
17
|
+
import $ from "../static/styles/components/popup.css.js";
|
|
18
|
+
import y from "../static/styles/components/recommendation-strategy.css.js";
|
|
19
|
+
import b from "../static/styles/components/switcher.css.js";
|
|
20
|
+
import B from "../static/styles/components/tabs.css.js";
|
|
21
|
+
import A from "../static/styles/components/tools.css.js";
|
|
22
|
+
import P from "../static/styles/components/version-history.css.js";
|
|
23
|
+
import R from "../static/styles/components/wide-panel.css.js";
|
|
22
24
|
import x from "../static/styles/variables.css.js";
|
|
23
|
-
function
|
|
24
|
-
return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(
|
|
25
|
+
function o(t, r) {
|
|
26
|
+
return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(r.trim())}");`;
|
|
25
27
|
}
|
|
26
|
-
const
|
|
27
|
-
${
|
|
28
|
-
${
|
|
29
|
-
${
|
|
30
|
-
}
|
|
28
|
+
const V = `:host {
|
|
29
|
+
${o("line-change", n)}
|
|
30
|
+
${o("line-delete", S)}
|
|
31
|
+
${o("filled-arrow-rising", i)}
|
|
32
|
+
${o("line-info", p)}
|
|
33
|
+
${o("line-plus", s)}
|
|
34
|
+
}`, D = [
|
|
31
35
|
x,
|
|
32
36
|
// Must be on top
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
V,
|
|
38
|
+
f,
|
|
35
39
|
// Must be on top
|
|
36
|
-
s,
|
|
37
40
|
C,
|
|
38
41
|
a,
|
|
39
|
-
f,
|
|
40
42
|
c,
|
|
41
|
-
u,
|
|
42
43
|
l,
|
|
44
|
+
u,
|
|
43
45
|
d,
|
|
44
|
-
h,
|
|
45
|
-
g,
|
|
46
46
|
I,
|
|
47
|
-
|
|
47
|
+
g,
|
|
48
|
+
h,
|
|
49
|
+
w,
|
|
50
|
+
$,
|
|
48
51
|
b,
|
|
49
52
|
B,
|
|
50
|
-
|
|
53
|
+
A,
|
|
51
54
|
P,
|
|
52
|
-
|
|
55
|
+
R,
|
|
56
|
+
y
|
|
53
57
|
// Last: overrides button.css / wide-panel.css defaults
|
|
54
58
|
].join(`
|
|
55
59
|
|
|
56
|
-
`),
|
|
57
|
-
const
|
|
58
|
-
|
|
60
|
+
`), ro = () => ({ importCss: () => {
|
|
61
|
+
const r = new CSSStyleSheet();
|
|
62
|
+
r.replaceSync(D);
|
|
59
63
|
const e = document.querySelector("ui-editor");
|
|
60
64
|
if (!e)
|
|
61
65
|
return;
|
|
62
66
|
const m = e.shadowRoot;
|
|
63
|
-
m && (m.adoptedStyleSheets = [
|
|
67
|
+
m && (m.adoptedStyleSheets = [r]);
|
|
64
68
|
} });
|
|
65
69
|
export {
|
|
66
|
-
|
|
70
|
+
ro as useCustomInterfaceAppearance
|
|
67
71
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useRecommendation as f } from "./useRecommendation.js";
|
|
2
|
+
import { useToaster as p } from "./useToaster.js";
|
|
3
|
+
import { useTranslations as S } from "./useTranslations.js";
|
|
4
|
+
import { ToasterTypeOptions as C } from "../enums/toaster.js";
|
|
5
|
+
import "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
6
|
+
import { CURRENT_CONFIG_VERSION as I } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
7
|
+
import { useRecommendationExtensionStore as L } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
8
|
+
import { buildLegacyMigrationPayload as v } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
|
|
9
|
+
import { commitBlockChangeOutsidePanel as R } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
|
|
10
|
+
import { useConfigStore as b } from "../stores/config.js";
|
|
11
|
+
const F = () => {
|
|
12
|
+
const t = L(), n = b(), { buildCampaignUrl: c } = f(), { showToaster: s } = p(), m = S();
|
|
13
|
+
return { convertLegacyStrategy: async () => {
|
|
14
|
+
const o = t.currentRecommendationId;
|
|
15
|
+
if (o === null || !t.isLegacyStrategyBlock || t.legacyConversionLoading)
|
|
16
|
+
return "";
|
|
17
|
+
const { strategy: g, productIds: d, filters: y } = t.recommendationConfigs, l = v({
|
|
18
|
+
blockId: o,
|
|
19
|
+
url: c(String(o)),
|
|
20
|
+
campaignId: n.campaignId,
|
|
21
|
+
variationId: n.variationId,
|
|
22
|
+
strategy: g,
|
|
23
|
+
productIds: d,
|
|
24
|
+
filters: y,
|
|
25
|
+
attributes: t.getFilterList
|
|
26
|
+
});
|
|
27
|
+
let e;
|
|
28
|
+
try {
|
|
29
|
+
e = await t.convertLegacyStrategy(l);
|
|
30
|
+
} catch (r) {
|
|
31
|
+
return console.error("[useLegacyStrategyConversion] migration failed", r), s({
|
|
32
|
+
type: C.Error,
|
|
33
|
+
message: m("email-editor.legacy-strategy-update-failed")
|
|
34
|
+
}), "";
|
|
35
|
+
}
|
|
36
|
+
const a = t.currentRecommendationId === o;
|
|
37
|
+
if (a)
|
|
38
|
+
try {
|
|
39
|
+
await t.fetchRecommendationProducts();
|
|
40
|
+
} catch (r) {
|
|
41
|
+
console.error("[useLegacyStrategyConversion] product refetch failed", r);
|
|
42
|
+
}
|
|
43
|
+
const i = t.blockStates[o], { size: u } = i.recommendationConfigs;
|
|
44
|
+
return R(
|
|
45
|
+
o,
|
|
46
|
+
{ strategyId: e, size: u, configVersion: I },
|
|
47
|
+
i.recommendationProducts,
|
|
48
|
+
"Converted legacy recommendation strategy"
|
|
49
|
+
), a && t.openLegacyStrategyUpdatedModal(), e;
|
|
50
|
+
} };
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
F as useLegacyStrategyConversion
|
|
54
|
+
};
|
|
@@ -4,7 +4,8 @@ const l = {
|
|
|
4
4
|
// Relative path → same-origin as the embedding inone dashboard.
|
|
5
5
|
PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes",
|
|
6
6
|
RECOMMENDATION_STRATEGIES_PATH: "/api/recommendation-strategies",
|
|
7
|
-
RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies"
|
|
7
|
+
RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies",
|
|
8
|
+
NEWSLETTER_RECOMMENDATIONS_PATH: "/newsletter/recommendations"
|
|
8
9
|
}, c = {
|
|
9
10
|
CLIENT_ID: "clientId"
|
|
10
11
|
}, d = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var C = (
|
|
3
|
-
var
|
|
2
|
+
var C = (g, l, t) => l in g ? m(g, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[l] = t;
|
|
3
|
+
var r = (g, l, t) => C(g, typeof l != "symbol" ? l + "" : l, t);
|
|
4
4
|
import { useConfig as p } from "../../../../../composables/useConfig.js";
|
|
5
5
|
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { CommonControl as N } from "../../../common-control.js";
|
|
@@ -12,9 +12,9 @@ import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
|
12
12
|
import { AlgorithmControl as T } from "./algorithm.js";
|
|
13
13
|
import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
|
|
14
14
|
import { CurrencyControl as P } from "./currency.js";
|
|
15
|
-
import { CURRENCY_CONTROL_ID as
|
|
15
|
+
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
17
|
-
import { FILTERS_CONTROL_ID as
|
|
17
|
+
import { FILTERS_CONTROL_ID as ht } from "./filters.js";
|
|
18
18
|
import { LayoutOrientationControl as O } from "./layoutOrientation.js";
|
|
19
19
|
import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
|
|
20
20
|
import { LocaleControl as L } from "./locale.js";
|
|
@@ -29,38 +29,38 @@ import { ShuffleControl as F } from "./shuffle.js";
|
|
|
29
29
|
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
30
|
import { StrategyControl as w } from "./strategy.js";
|
|
31
31
|
import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
|
|
32
|
-
import { setCurrencyAttributes as A, getBlockElement as
|
|
33
|
-
import { adjustProductsToSize as kt, formatProductPrice as Dt, getCardComposition as Ft, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as
|
|
32
|
+
import { setCurrencyAttributes as A, getBlockElement as B, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as kt, formatProductPrice as Dt, getCardComposition as Ft, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as Bt, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
|
|
34
34
|
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
35
|
const $ = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
37
37
|
constructor() {
|
|
38
38
|
super(...arguments);
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
r(this, "store", R());
|
|
40
|
+
r(this, "storeUnsubscription", () => {
|
|
41
41
|
});
|
|
42
42
|
// blockId -> fingerprint of the node config as it looked at the last sync.
|
|
43
|
-
|
|
43
|
+
r(this, "syncedConfigs", /* @__PURE__ */ new Map());
|
|
44
44
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
45
45
|
// re-render's single apply() — one user action must cost one undo press.
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
r(this, "pendingNodeConfigWrite", null);
|
|
47
|
+
r(this, "pendingConfigFlushTimer", null);
|
|
48
48
|
// Sub-control instances for lifecycle management
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
r(this, "algorithmControl", null);
|
|
50
|
+
r(this, "localeControl", null);
|
|
51
|
+
r(this, "currencyControl", null);
|
|
52
|
+
r(this, "productCountControl", null);
|
|
53
|
+
r(this, "productLayoutControl", null);
|
|
54
|
+
r(this, "filtersControl", null);
|
|
55
|
+
r(this, "shuffleControl", null);
|
|
56
|
+
r(this, "pricePlacementControl", null);
|
|
57
|
+
r(this, "layoutOrientationControl", null);
|
|
58
|
+
r(this, "strategyControl", null);
|
|
59
|
+
r(this, "rrsEnabled", !1);
|
|
60
60
|
/**
|
|
61
61
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
r(this, "_debouncedFetchProducts", f(async () => {
|
|
64
64
|
try {
|
|
65
65
|
await this.store.fetchRecommendationProducts();
|
|
66
66
|
} finally {
|
|
@@ -78,16 +78,16 @@ class at extends N {
|
|
|
78
78
|
* count. The store pads products to the configured size, so in-place only
|
|
79
79
|
* fails when the size actually changed.
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
r(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
82
82
|
const t = this.store.recommendationProducts;
|
|
83
83
|
if (!this.currentNode || !this.api)
|
|
84
84
|
return;
|
|
85
85
|
const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
86
|
-
if (
|
|
86
|
+
if (v(this.currentNode)) {
|
|
87
87
|
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
x({
|
|
91
91
|
currentNode: this.currentNode,
|
|
92
92
|
documentModifier: e,
|
|
93
93
|
products: t
|
|
@@ -142,8 +142,8 @@ class at extends N {
|
|
|
142
142
|
const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
|
|
143
143
|
if (!e)
|
|
144
144
|
return;
|
|
145
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t),
|
|
146
|
-
e.classList.toggle("strategy-block",
|
|
145
|
+
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !n;
|
|
146
|
+
e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
|
|
147
147
|
}
|
|
148
148
|
async onRender() {
|
|
149
149
|
var o;
|
|
@@ -161,9 +161,9 @@ class at extends N {
|
|
|
161
161
|
const e = this._getRecommendationIdFromNode(t);
|
|
162
162
|
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigIfChanged(e), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
|
|
163
163
|
this._initializeSubControls();
|
|
164
|
-
}), this._subControls.forEach((
|
|
165
|
-
var
|
|
166
|
-
|
|
164
|
+
}), this._subControls.forEach((n) => {
|
|
165
|
+
var s;
|
|
166
|
+
n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
onDestroy() {
|
|
@@ -210,11 +210,11 @@ class at extends N {
|
|
|
210
210
|
const t = this.store.currentRecommendationId;
|
|
211
211
|
if (!this.currentNode || !this.api || t === null)
|
|
212
212
|
return;
|
|
213
|
-
const { filters: e, strategyId: o, size:
|
|
213
|
+
const { filters: e, strategyId: o, size: n, nodeConfigVersion: s } = this.store.recommendationConfigs;
|
|
214
214
|
this.pendingNodeConfigWrite = {
|
|
215
215
|
blockId: t,
|
|
216
216
|
node: this.currentNode,
|
|
217
|
-
updates: { filters: e, strategyId: o, size:
|
|
217
|
+
updates: { filters: e, strategyId: o, size: n, configVersion: s }
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
@@ -257,11 +257,12 @@ class at extends N {
|
|
|
257
257
|
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
258
258
|
}
|
|
259
259
|
_syncNodeConfigToStore() {
|
|
260
|
-
var
|
|
261
|
-
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((
|
|
260
|
+
var n;
|
|
261
|
+
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
|
|
262
262
|
this.store.patchCurrentBlockConfig({
|
|
263
263
|
strategy: t.strategy,
|
|
264
264
|
strategyId: t.strategyId,
|
|
265
|
+
nodeConfigVersion: t.configVersion,
|
|
265
266
|
language: t.language,
|
|
266
267
|
size: t.size,
|
|
267
268
|
productIds: t.productIds,
|
|
@@ -300,8 +301,8 @@ class at extends N {
|
|
|
300
301
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
301
302
|
this.store.fetchRecommendationCreateData(),
|
|
302
303
|
this.store.fetchRecommendationFilters()
|
|
303
|
-
])).forEach((o,
|
|
304
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
304
|
+
])).forEach((o, n) => {
|
|
305
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
|
|
305
306
|
}), this._applySmartDefaults();
|
|
306
307
|
try {
|
|
307
308
|
await this.store.fetchRecommendationProducts();
|
|
@@ -323,30 +324,30 @@ class at extends N {
|
|
|
323
324
|
if (!this.currentNode || !this.api)
|
|
324
325
|
return;
|
|
325
326
|
const t = c.getConfig(this.currentNode), e = {};
|
|
326
|
-
let o = null,
|
|
327
|
+
let o = null, n = null, s = null;
|
|
327
328
|
if (t.currency.code === a.currency.code) {
|
|
328
|
-
const { currencyList:
|
|
329
|
-
|
|
329
|
+
const { currencyList: i } = this.store;
|
|
330
|
+
i.length > 0 && (i.some(
|
|
330
331
|
(d) => d.value === `price.${a.currency.code}`
|
|
331
|
-
) || (o =
|
|
332
|
+
) || (o = i[0].value.replace("price.", ""), e.currency = {
|
|
332
333
|
...a.currency,
|
|
333
334
|
code: o,
|
|
334
335
|
symbol: o
|
|
335
336
|
}));
|
|
336
337
|
}
|
|
337
338
|
if (t.strategy === a.strategy) {
|
|
338
|
-
const
|
|
339
|
-
|
|
339
|
+
const i = this.store.getActivePredictiveAlgorithms;
|
|
340
|
+
i.length > 0 && (i.some(
|
|
340
341
|
(d) => d.value === a.strategy
|
|
341
|
-
) || (
|
|
342
|
+
) || (n = i[0].value, e.strategy = n));
|
|
342
343
|
}
|
|
343
344
|
if (t.language === a.language) {
|
|
344
|
-
const
|
|
345
|
-
|
|
345
|
+
const i = this.store.getLanguages;
|
|
346
|
+
i.length > 0 && (i.some(
|
|
346
347
|
(d) => d.value === a.language
|
|
347
|
-
) || (
|
|
348
|
+
) || (s = i[0].value, e.language = s));
|
|
348
349
|
}
|
|
349
|
-
!o && !
|
|
350
|
+
!o && !n && !s || (c.updateConfig(
|
|
350
351
|
this.api,
|
|
351
352
|
this.currentNode,
|
|
352
353
|
e,
|
|
@@ -367,22 +368,22 @@ class at extends N {
|
|
|
367
368
|
thousandSeparator: a.currency.thousandSeparator
|
|
368
369
|
}
|
|
369
370
|
} : {},
|
|
370
|
-
...
|
|
371
|
-
...
|
|
371
|
+
...n ? { strategy: n } : {},
|
|
372
|
+
...s ? { language: s } : {}
|
|
372
373
|
}, { triggerRefetch: !1 }));
|
|
373
374
|
}
|
|
374
375
|
/**
|
|
375
376
|
* Reads the recommendation-id attribute from the block element within the node
|
|
376
377
|
*/
|
|
377
378
|
_getRecommendationIdFromNode(t) {
|
|
378
|
-
const e =
|
|
379
|
+
const e = B(t);
|
|
379
380
|
if (!e || !("getAttribute" in e))
|
|
380
381
|
return null;
|
|
381
382
|
const o = e.getAttribute(I);
|
|
382
383
|
if (!o)
|
|
383
384
|
return null;
|
|
384
|
-
const
|
|
385
|
-
return Number.isNaN(
|
|
385
|
+
const n = parseInt(o);
|
|
386
|
+
return Number.isNaN(n) ? null : n;
|
|
386
387
|
}
|
|
387
388
|
/**
|
|
388
389
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -399,17 +400,17 @@ class at extends N {
|
|
|
399
400
|
*/
|
|
400
401
|
_listenStateUpdates() {
|
|
401
402
|
const { store: t } = this;
|
|
402
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
403
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
|
|
403
404
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
404
|
-
const
|
|
405
|
-
if (
|
|
406
|
-
|
|
405
|
+
const s = t.currentRecommendationId;
|
|
406
|
+
if (s !== n) {
|
|
407
|
+
n = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
407
408
|
return;
|
|
408
409
|
}
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
const u = t.recommendationProducts, d = u !== e,
|
|
412
|
-
d &&
|
|
410
|
+
const i = t.$state.configVersion;
|
|
411
|
+
i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
|
|
412
|
+
const u = t.recommendationProducts, d = u !== e, h = Array.isArray(u) && u.length > 0;
|
|
413
|
+
d && h && (e = u, this._debouncedRegenerateWithProducts());
|
|
413
414
|
});
|
|
414
415
|
}
|
|
415
416
|
}
|
|
@@ -417,9 +418,9 @@ export {
|
|
|
417
418
|
ut as ALGORITHM_CONTROL_ID,
|
|
418
419
|
T as AlgorithmControl,
|
|
419
420
|
$ as CONTROL_BLOCK_ID,
|
|
420
|
-
|
|
421
|
+
gt as CURRENCY_CONTROL_ID,
|
|
421
422
|
P as CurrencyControl,
|
|
422
|
-
|
|
423
|
+
ht as FILTERS_CONTROL_ID,
|
|
423
424
|
S as FiltersControl,
|
|
424
425
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
425
426
|
yt as LOCALE_CONTROL_ID,
|
|
@@ -438,15 +439,15 @@ export {
|
|
|
438
439
|
w as StrategyControl,
|
|
439
440
|
kt as adjustProductsToSize,
|
|
440
441
|
Dt as formatProductPrice,
|
|
441
|
-
|
|
442
|
+
B as getBlockElement,
|
|
442
443
|
Ft as getCardComposition,
|
|
443
444
|
wt as getCurrentLayout,
|
|
444
445
|
At as getMainContainerTbody,
|
|
445
|
-
|
|
446
|
-
|
|
446
|
+
v as isPartnerManagedBlock,
|
|
447
|
+
Bt as regenerateMobileProductRows,
|
|
447
448
|
U as regenerateProductRowsWithStyles,
|
|
448
449
|
A as setCurrencyAttributes,
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
450
|
+
vt as updatePricesInPlace,
|
|
451
|
+
x as updateProductContentInPlace,
|
|
452
|
+
xt as updateSingleProductContent
|
|
452
453
|
};
|