@useinsider/guido 3.15.0-beta.0b5dc39 → 3.15.0-beta.0cbd17f
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/composables/useRecommendation.js +20 -19
- package/dist/composables/useStripo.js +29 -30
- package/dist/extensions/Blocks/Items/block.js +44 -42
- package/dist/extensions/Blocks/Items/template.js +86 -86
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +37 -26
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +21 -21
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +13 -12
- package/dist/extensions/Blocks/Recommendation/utils/productIds.js +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +6 -0
- package/dist/utils/pairProductVariables.js +105 -99
- package/package.json +1 -1
|
@@ -3,20 +3,21 @@ import { MinDeviceViewport as C, DefaultPadding as b } from "../enums/recommenda
|
|
|
3
3
|
import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
4
|
import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
5
5
|
import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { sanitizeProductIds as x } from "../extensions/Blocks/Recommendation/utils/productIds.js";
|
|
7
|
+
import { useConfigStore as P } from "../stores/config.js";
|
|
8
|
+
const B = () => ({
|
|
8
9
|
calculateCardWidth: ({
|
|
9
10
|
mobileLeftPadding: a,
|
|
10
11
|
mobileRightPadding: s,
|
|
11
12
|
cardsInRow: c,
|
|
12
|
-
unresponsive:
|
|
13
|
+
unresponsive: n
|
|
13
14
|
}) => {
|
|
14
|
-
const r =
|
|
15
|
+
const r = n ? c : 1, e = a + s + (r - 1) * b;
|
|
15
16
|
return (C - e) / r;
|
|
16
17
|
},
|
|
17
18
|
getRecommendationCampaignData: (a) => {
|
|
18
|
-
const s = l(), c = Number(a),
|
|
19
|
-
if (!
|
|
19
|
+
const s = l(), c = Number(a), n = s.blockStates[c];
|
|
20
|
+
if (!n)
|
|
20
21
|
return {
|
|
21
22
|
textTrimming: !1,
|
|
22
23
|
orientation: "vertical",
|
|
@@ -29,7 +30,7 @@ const k = () => ({
|
|
|
29
30
|
discountBeforeTextValue: "",
|
|
30
31
|
discountAfterTextValue: ""
|
|
31
32
|
};
|
|
32
|
-
const { recommendationConfigs: r } =
|
|
33
|
+
const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
|
|
33
34
|
return {
|
|
34
35
|
textTrimming: r.textTrimming,
|
|
35
36
|
orientation: e,
|
|
@@ -45,7 +46,7 @@ const k = () => ({
|
|
|
45
46
|
},
|
|
46
47
|
buildCampaignUrl: (a, s) => {
|
|
47
48
|
var m;
|
|
48
|
-
const c = l(),
|
|
49
|
+
const c = l(), n = P(), r = Number(a);
|
|
49
50
|
let e;
|
|
50
51
|
if (s)
|
|
51
52
|
e = s;
|
|
@@ -53,25 +54,25 @@ const k = () => ({
|
|
|
53
54
|
const i = c.blockStates[r];
|
|
54
55
|
if (!i)
|
|
55
56
|
return "";
|
|
56
|
-
const { recommendationConfigs:
|
|
57
|
+
const { recommendationConfigs: o } = i;
|
|
57
58
|
e = {
|
|
58
|
-
strategy:
|
|
59
|
-
language:
|
|
60
|
-
currencyCode:
|
|
61
|
-
size:
|
|
62
|
-
productIds:
|
|
63
|
-
filters:
|
|
64
|
-
shuffleProducts:
|
|
59
|
+
strategy: o.strategy,
|
|
60
|
+
language: o.language,
|
|
61
|
+
currencyCode: o.currencySettings.value,
|
|
62
|
+
size: o.size,
|
|
63
|
+
productIds: o.productIds,
|
|
64
|
+
filters: o.filters,
|
|
65
|
+
shuffleProducts: o.shuffleProducts
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
const f = ((m = I().find((i) => i.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
|
|
68
|
-
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName",
|
|
69
|
+
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising" ? t.set("productId", x(e.productIds)) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
69
70
|
const g = e.filters.filter((i) => i.isValid), d = h(g);
|
|
70
|
-
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(
|
|
71
|
+
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(n.partnerName, e.strategy)).forEach(([i, o]) => t.set(i, o));
|
|
71
72
|
const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
|
|
72
73
|
return c.recommendationCampaignUrls[a] = u, u;
|
|
73
74
|
}
|
|
74
75
|
});
|
|
75
76
|
export {
|
|
76
|
-
|
|
77
|
+
B as useRecommendation
|
|
77
78
|
};
|
|
@@ -16,22 +16,22 @@ import { useEditorStore as b } from "../stores/editor.js";
|
|
|
16
16
|
import { buildMergeTagEntries as W, flattenDynamicContentList as Y } from "../utils/genericUtil.js";
|
|
17
17
|
import Z from "../package.json.js";
|
|
18
18
|
let n = null;
|
|
19
|
-
const
|
|
20
|
-
const { features: c, template: u, isFeatureEnabled: m } = q(), { handleError: p, showToaster: k } = G(), { getToken:
|
|
19
|
+
const Ct = () => {
|
|
20
|
+
const { features: c, template: u, isFeatureEnabled: m } = q(), { handleError: p, showToaster: k } = G(), { getToken: T, getCustomFonts: v, getSyncModulesStatus: B } = K(), { handleEvent: F } = z(), { handleModuleAdd: M } = j(), { getStripoBlocksConfig: A } = O(), { getStripoNotifications: V } = $(), f = () => n || (n = new Promise((i, s) => {
|
|
21
21
|
var l;
|
|
22
22
|
if (document.getElementById("UiEditorScript")) {
|
|
23
23
|
i();
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const o = Z.guido, r = `https://email-static.useinsider.com/guido/${(l = o == null ? void 0 : o.stripo) == null ? void 0 : l.version}/UIEditor.js`,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}, document.body.appendChild(
|
|
26
|
+
const o = Z.guido, r = `https://email-static.useinsider.com/guido/${(l = o == null ? void 0 : o.stripo) == null ? void 0 : l.version}/UIEditor.js`, t = document.createElement("script");
|
|
27
|
+
t.id = "UiEditorScript", t.type = "module", t.src = r, t.onload = () => i(), t.onerror = () => {
|
|
28
|
+
t.remove(), s(new Error(`Failed to load Stripo UIEditor script from S3: ${r}`));
|
|
29
|
+
}, document.body.appendChild(t);
|
|
30
30
|
}), n.catch(() => {
|
|
31
31
|
n = null;
|
|
32
32
|
}), n), _ = async (i, s, o, a = [], r = !1) => {
|
|
33
33
|
var y, E, h, C;
|
|
34
|
-
const
|
|
34
|
+
const t = b(), { html: l, css: D } = i, { baseBlocks: g, extensions: R } = await A(), S = ((y = c.value) == null ? void 0 : y.displayConditions) ?? !0, P = ((E = c.value) == null ? void 0 : E.modulesDisabled) ?? !1, U = ((h = u.value) == null ? void 0 : h.forceRecreate) ?? !1;
|
|
35
35
|
await window.UIEditor.initEditor(
|
|
36
36
|
document.querySelector("#guido-editor"),
|
|
37
37
|
{
|
|
@@ -57,7 +57,6 @@ const Ce = () => {
|
|
|
57
57
|
messageSettingsEnabled: !0,
|
|
58
58
|
displayGmailAnnotations: !0,
|
|
59
59
|
displayHiddenPreheader: !1,
|
|
60
|
-
keepModuleStylesEnabled: !0,
|
|
61
60
|
displayTitle: !1,
|
|
62
61
|
displayUTM: !1,
|
|
63
62
|
selectElementAfterDrop: !0,
|
|
@@ -78,38 +77,38 @@ const Ce = () => {
|
|
|
78
77
|
)
|
|
79
78
|
}
|
|
80
79
|
],
|
|
81
|
-
async onTokenRefreshRequest(
|
|
80
|
+
async onTokenRefreshRequest(e) {
|
|
82
81
|
try {
|
|
83
|
-
const d = await
|
|
84
|
-
|
|
82
|
+
const d = await T();
|
|
83
|
+
e(d);
|
|
85
84
|
} catch (d) {
|
|
86
85
|
p(d, "Failed to refresh token");
|
|
87
86
|
}
|
|
88
87
|
},
|
|
89
88
|
onTemplateLoaded() {
|
|
90
89
|
try {
|
|
91
|
-
const { importCss:
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
const { importCss: e } = H(), { activateCustomViewStyles: d, updateTimerInClonedTemplate: I } = L(), { injectFullStory: x } = N();
|
|
91
|
+
e(), d(), x(), I(), o.onReady(), t.isStripoInitialized = !0, t.loadingStatus = !1, setTimeout(() => {
|
|
92
|
+
t.hasChanges = !1;
|
|
94
93
|
}, 1e3);
|
|
95
|
-
} catch (
|
|
96
|
-
p(
|
|
94
|
+
} catch (e) {
|
|
95
|
+
p(e, "Failed to load custom interface appearance");
|
|
97
96
|
}
|
|
98
97
|
},
|
|
99
|
-
onCodeEditorVisibilityChanged(
|
|
100
|
-
|
|
98
|
+
onCodeEditorVisibilityChanged(e) {
|
|
99
|
+
t.isCodeEditorOpen = e;
|
|
101
100
|
},
|
|
102
|
-
onEditorVisualModeChanged(
|
|
103
|
-
|
|
101
|
+
onEditorVisualModeChanged(e) {
|
|
102
|
+
t.editorVisualMode = e.toLowerCase();
|
|
104
103
|
},
|
|
105
|
-
onVersionHistoryVisibilityChanged(
|
|
106
|
-
|
|
104
|
+
onVersionHistoryVisibilityChanged(e) {
|
|
105
|
+
t.isVersionHistoryOpen = e;
|
|
107
106
|
},
|
|
108
107
|
onDataChanged() {
|
|
109
|
-
|
|
108
|
+
t.hasChanges = !0;
|
|
110
109
|
},
|
|
111
|
-
onEvent:
|
|
112
|
-
onModuleAdd:
|
|
110
|
+
onEvent: F,
|
|
111
|
+
onModuleAdd: M,
|
|
113
112
|
notifications: V(),
|
|
114
113
|
ignoreClickOutsideSelectors: [
|
|
115
114
|
"#guido-dynamic-content-modal",
|
|
@@ -125,11 +124,11 @@ const Ce = () => {
|
|
|
125
124
|
const a = b();
|
|
126
125
|
try {
|
|
127
126
|
await f();
|
|
128
|
-
const [r,
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
const [r, t] = await Promise.all([
|
|
128
|
+
v(),
|
|
129
|
+
B()
|
|
131
130
|
]);
|
|
132
|
-
a.syncModulesEnabled =
|
|
131
|
+
a.syncModulesEnabled = t, await _(i, s, o, r, t);
|
|
133
132
|
} catch {
|
|
134
133
|
a.loadingStatus = !1, k({
|
|
135
134
|
type: X.Error,
|
|
@@ -146,5 +145,5 @@ const Ce = () => {
|
|
|
146
145
|
} };
|
|
147
146
|
};
|
|
148
147
|
export {
|
|
149
|
-
|
|
148
|
+
Ct as useStripo
|
|
150
149
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { BlockId as
|
|
2
|
-
import { useOnboardingStore as
|
|
3
|
-
import { getMigrationBannerHtml as
|
|
4
|
-
import { Block as
|
|
5
|
-
import { SETTINGS_ENUMS as
|
|
6
|
-
import { getDefaultTemplate as
|
|
7
|
-
import { getItemsBlockContainer as
|
|
8
|
-
const p =
|
|
9
|
-
class
|
|
1
|
+
import { BlockId as g } from "../../../enums/block.js";
|
|
2
|
+
import { useOnboardingStore as y } from "../../../stores/onboarding.js";
|
|
3
|
+
import { getMigrationBannerHtml as I } from "../../../utils/migrationBannerHtml.js";
|
|
4
|
+
import { Block as C, BlockCompositionType as b, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { SETTINGS_ENUMS as l, DefaultConfigValues as d } from "./enums/settingsEnums.js";
|
|
6
|
+
import { getDefaultTemplate as h } from "./template.js";
|
|
7
|
+
import { getItemsBlockContainer as u, getItemsBlockConfig as f, deriveItemNumber as D, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
|
|
8
|
+
const p = g.Items;
|
|
9
|
+
class E extends C {
|
|
10
10
|
getId() {
|
|
11
11
|
return p;
|
|
12
12
|
}
|
|
@@ -14,7 +14,7 @@ class O extends I {
|
|
|
14
14
|
return "items-icon";
|
|
15
15
|
}
|
|
16
16
|
getBlockCompositionType() {
|
|
17
|
-
return
|
|
17
|
+
return b.CONTAINER;
|
|
18
18
|
}
|
|
19
19
|
getName() {
|
|
20
20
|
return this.api.translate("Items");
|
|
@@ -23,20 +23,20 @@ class O extends I {
|
|
|
23
23
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
24
24
|
}
|
|
25
25
|
getSettingsPanelTitleHtml() {
|
|
26
|
-
return
|
|
26
|
+
return I(
|
|
27
27
|
p,
|
|
28
28
|
this.api.translate("Items"),
|
|
29
29
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
getTemplate() {
|
|
33
|
-
return
|
|
34
|
-
orientation:
|
|
35
|
-
itemsType:
|
|
33
|
+
return h({
|
|
34
|
+
orientation: l.ORIENTATION.VERTICAL,
|
|
35
|
+
itemsType: l.ITEMS_TYPE.CART_ITEMS,
|
|
36
36
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
37
|
-
currencySymbol:
|
|
38
|
-
currencyLocation:
|
|
39
|
-
formattedPrice:
|
|
37
|
+
currencySymbol: d.productPriceCurrencySymbolControlValue,
|
|
38
|
+
currencyLocation: d.productPriceCurrencyLocationControlValue,
|
|
39
|
+
formattedPrice: d.productPriceFormattedControlValue === "1"
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
allowInnerBlocksDND() {
|
|
@@ -45,23 +45,23 @@ class O extends I {
|
|
|
45
45
|
canBeSavedAsModule() {
|
|
46
46
|
return !0;
|
|
47
47
|
}
|
|
48
|
-
onCreated(
|
|
49
|
-
const t = this.api.getDocumentModifier(),
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
48
|
+
onCreated(n) {
|
|
49
|
+
const t = this.api.getDocumentModifier(), a = this.api.getDocumentRootCssNode();
|
|
50
|
+
a.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(a).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
51
|
+
const e = u(n);
|
|
52
|
+
if (!e)
|
|
53
53
|
return;
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
if (
|
|
57
|
-
|
|
54
|
+
const o = e.getNodeConfig(), r = o && Object.keys(o).length > 0, i = f(n);
|
|
55
|
+
if (i != null && i.initialized)
|
|
56
|
+
if (r)
|
|
57
|
+
i.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...i, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
|
|
58
58
|
else {
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
const s = this.api.getDocumentModifier();
|
|
60
|
+
s.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, s), s.apply(new c("Migrate legacy config to nodeConfig"));
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
const
|
|
64
|
-
|
|
63
|
+
const s = N(), m = this.api.getDocumentModifier();
|
|
64
|
+
m.modifyHtml(e).setNodeConfig(s), this._stampProductTdDomAttributes(e, s, m, !0), m.apply(new c("Initialize Items block with default configuration")), y().startOnboarding("itemsOnboarding");
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
@@ -70,18 +70,18 @@ class O extends I {
|
|
|
70
70
|
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
71
71
|
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
72
72
|
*/
|
|
73
|
-
onDocumentChanged(
|
|
74
|
-
const t =
|
|
73
|
+
onDocumentChanged(n) {
|
|
74
|
+
const t = u(n);
|
|
75
75
|
if (!t)
|
|
76
76
|
return;
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
77
|
+
const a = t.getNodeConfig();
|
|
78
|
+
if (a && Object.keys(a).length > 0)
|
|
79
79
|
return;
|
|
80
|
-
const
|
|
81
|
-
if (!(
|
|
80
|
+
const o = f(n);
|
|
81
|
+
if (!(o != null && o.initialized))
|
|
82
82
|
return;
|
|
83
|
-
const
|
|
84
|
-
|
|
83
|
+
const r = this.api.getDocumentModifier();
|
|
84
|
+
r.modifyHtml(t).setNodeConfig(o), this._stampProductTdDomAttributes(t, o, r), r.apply(new c("Recover Items block config from saved module"));
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
|
|
@@ -91,12 +91,14 @@ class O extends I {
|
|
|
91
91
|
* restored before export. The name `<a>` carries no data-type/data-number of its own and
|
|
92
92
|
* relies on this td-level fallback in pairProductVariables.
|
|
93
93
|
*/
|
|
94
|
-
_stampProductTdDomAttributes(
|
|
95
|
-
const
|
|
96
|
-
|
|
94
|
+
_stampProductTdDomAttributes(n, t, a, e = !1) {
|
|
95
|
+
const o = D(t.itemsSelectValue, t.type), r = (i, s) => {
|
|
96
|
+
e && n.getAttribute(i) || a.modifyHtml(n).setAttribute(i, s);
|
|
97
|
+
};
|
|
98
|
+
r("data-type", t.type), r("data-number", o), r("data-nodup", String(t.priceHideDiscount));
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
export {
|
|
100
102
|
p as BLOCK_ID,
|
|
101
|
-
|
|
103
|
+
E as ItemsBlock
|
|
102
104
|
};
|