@useinsider/guido 3.6.0-beta.4f2bf14 → 3.6.0-beta.596b70e
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 +34 -33
- package/dist/composables/useStripoEventHandler.js +11 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +50 -48
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +24 -32
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +34 -40
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +310 -338
- package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +13 -9
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +117 -146
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +49 -30
- package/dist/extensions/Blocks/Recommendation/templates/index.js +9 -8
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +110 -83
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +31 -21
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +90 -54
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +139 -0
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +21 -0
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +24 -19
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +20 -16
- package/dist/extensions/Blocks/controlFactories.js +159 -133
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +20 -47
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +127 -11
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +44 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerCustomizations.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +20 -9
- package/dist/src/extensions/Blocks/controlFactories.d.ts +11 -1
- package/package.json +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
- /package/dist/src/{composables/useStripoEventHandler.test.d.ts → extensions/Blocks/Recommendation/templates/grid/elementRenderer.test.d.ts} +0 -0
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { getRecommendationFeedSourceMaps as I, URLS as
|
|
2
|
-
import { MinDeviceViewport as
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
1
|
+
import { getRecommendationFeedSourceMaps as I, URLS as R } from "../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { MinDeviceViewport as C, DefaultPadding as b } from "../enums/recommendation.js";
|
|
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
|
+
import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
|
|
5
6
|
import { useConfigStore as x } from "../stores/config.js";
|
|
6
|
-
const
|
|
7
|
+
const k = () => ({
|
|
7
8
|
calculateCardWidth: ({
|
|
8
|
-
mobileLeftPadding:
|
|
9
|
+
mobileLeftPadding: a,
|
|
9
10
|
mobileRightPadding: s,
|
|
10
|
-
cardsInRow:
|
|
11
|
-
unresponsive:
|
|
11
|
+
cardsInRow: c,
|
|
12
|
+
unresponsive: o
|
|
12
13
|
}) => {
|
|
13
|
-
const r =
|
|
14
|
-
return (
|
|
14
|
+
const r = o ? c : 1, e = a + s + (r - 1) * b;
|
|
15
|
+
return (C - e) / r;
|
|
15
16
|
},
|
|
16
|
-
getRecommendationCampaignData: (
|
|
17
|
-
const s =
|
|
18
|
-
if (!
|
|
17
|
+
getRecommendationCampaignData: (a) => {
|
|
18
|
+
const s = l(), c = Number(a), o = s.blockStates[c];
|
|
19
|
+
if (!o)
|
|
19
20
|
return {
|
|
20
21
|
textTrimming: !1,
|
|
21
22
|
orientation: "vertical",
|
|
@@ -28,7 +29,7 @@ const w = () => ({
|
|
|
28
29
|
discountBeforeTextValue: "",
|
|
29
30
|
discountAfterTextValue: ""
|
|
30
31
|
};
|
|
31
|
-
const { recommendationConfigs: r } =
|
|
32
|
+
const { recommendationConfigs: r } = o, e = r.orientation === "grid" ? "vertical" : "horizontal";
|
|
32
33
|
return {
|
|
33
34
|
textTrimming: r.textTrimming,
|
|
34
35
|
orientation: e,
|
|
@@ -42,35 +43,35 @@ const w = () => ({
|
|
|
42
43
|
discountAfterTextValue: ""
|
|
43
44
|
};
|
|
44
45
|
},
|
|
45
|
-
buildCampaignUrl: (
|
|
46
|
-
var
|
|
47
|
-
const
|
|
46
|
+
buildCampaignUrl: (a, s) => {
|
|
47
|
+
var m;
|
|
48
|
+
const c = l(), o = x(), r = Number(a);
|
|
48
49
|
let e;
|
|
49
50
|
if (s)
|
|
50
51
|
e = s;
|
|
51
52
|
else {
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
53
|
+
const i = c.blockStates[r];
|
|
54
|
+
if (!i)
|
|
54
55
|
return "";
|
|
55
|
-
const { recommendationConfigs:
|
|
56
|
+
const { recommendationConfigs: n } = i;
|
|
56
57
|
e = {
|
|
57
|
-
strategy:
|
|
58
|
-
language:
|
|
59
|
-
currencyCode:
|
|
60
|
-
size:
|
|
61
|
-
productIds:
|
|
62
|
-
filters:
|
|
63
|
-
shuffleProducts:
|
|
58
|
+
strategy: n.strategy,
|
|
59
|
+
language: n.language,
|
|
60
|
+
currencyCode: n.currencySettings.value,
|
|
61
|
+
size: n.size,
|
|
62
|
+
productIds: n.productIds,
|
|
63
|
+
filters: n.filters,
|
|
64
|
+
shuffleProducts: n.shuffleProducts
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
|
-
const f = ((
|
|
67
|
-
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName",
|
|
68
|
-
const g = e.filters.filter((
|
|
69
|
-
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true");
|
|
70
|
-
const p = decodeURIComponent(t.toString()), u = `${
|
|
71
|
-
return
|
|
67
|
+
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", o.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", o.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
69
|
+
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(o.partnerName, e.strategy)).forEach(([i, n]) => t.set(i, n));
|
|
71
|
+
const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
|
|
72
|
+
return c.recommendationCampaignUrls[a] = u, u;
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
75
|
export {
|
|
75
|
-
|
|
76
|
+
k as useRecommendation
|
|
76
77
|
};
|
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
import { useStripoApi as
|
|
1
|
+
import { useStripoApi as i } from "../services/stripoApi.js";
|
|
2
2
|
import { useEditorStore as u } from "../stores/editor.js";
|
|
3
3
|
import { useOnboardingStore as l } from "../stores/onboarding.js";
|
|
4
4
|
import { useUnsubscribeStore as b } from "../stores/unsubscribe.js";
|
|
5
5
|
const v = () => {
|
|
6
|
-
const { updateSyncModule:
|
|
6
|
+
const { updateSyncModule: d, getSyncModule: r } = i(), n = u(), s = b(), a = {
|
|
7
7
|
block_dropped: ({ blockName: e }) => {
|
|
8
8
|
if (e === "BLOCK_TEXT") {
|
|
9
|
-
const o = l(),
|
|
10
|
-
if (
|
|
9
|
+
const o = l(), t = !o.shouldShowOnboarding("textBlockOnboarding"), c = o.isActive("textBlockOnboarding");
|
|
10
|
+
if (t || c)
|
|
11
11
|
return;
|
|
12
12
|
o.start("textBlockOnboarding");
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
module_saved: async (e) => {
|
|
16
|
-
|
|
16
|
+
n.syncModulesEnabled && (console.debug("[module_saved] Saved module data:", e), await d(e));
|
|
17
17
|
},
|
|
18
18
|
module_dropped: async (e) => {
|
|
19
|
-
if (!
|
|
19
|
+
if (!n.syncModulesEnabled)
|
|
20
20
|
return;
|
|
21
|
-
const { moduleId: o } = e,
|
|
22
|
-
console.debug("[module_dropped] Sync module data:",
|
|
23
|
-
n.unsubscriptionPreferencePages.map((d) => d.id)
|
|
24
|
-
));
|
|
21
|
+
const { moduleId: o } = e, t = await r(o);
|
|
22
|
+
console.debug("[module_dropped] Sync module data:", t), t.unsubscriptionPreferencePages.length && await s.fetchTemplates();
|
|
25
23
|
},
|
|
26
24
|
module_updated: async (e) => {
|
|
27
|
-
|
|
25
|
+
n.syncModulesEnabled && (console.debug("[module_updated] Updated module data:", e), await d(e));
|
|
28
26
|
}
|
|
29
27
|
};
|
|
30
28
|
return { handleEvent: async (e, o) => {
|
|
31
|
-
const
|
|
32
|
-
console.debug("Stripo Event: ", e, o),
|
|
29
|
+
const t = a[e];
|
|
30
|
+
console.debug("Stripo Event: ", e, o), t && await t(o);
|
|
33
31
|
} };
|
|
34
32
|
};
|
|
35
33
|
export {
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var p = (d, l, t) => l in d ?
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var p = (d, l, t) => l in d ? C(d, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[l] = t;
|
|
3
3
|
var s = (d, l, t) => p(d, typeof l != "symbol" ? l + "" : l, t);
|
|
4
4
|
import { CommonControl as g } from "../../../common-control.js";
|
|
5
5
|
import { DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
6
6
|
import { RecommendationConfigService as h } from "../../services/configService.js";
|
|
7
7
|
import { useRecommendationExtensionStore as y } from "../../store/recommendation.js";
|
|
8
|
-
import { AlgorithmControl as
|
|
9
|
-
import { ALGORITHM_CONTROL_ID as
|
|
10
|
-
import { CurrencyControl as
|
|
11
|
-
import { CURRENCY_CONTROL_ID as
|
|
8
|
+
import { AlgorithmControl as N } from "./algorithm.js";
|
|
9
|
+
import { ALGORITHM_CONTROL_ID as Q } from "./algorithm.js";
|
|
10
|
+
import { CurrencyControl as R } from "./currency.js";
|
|
11
|
+
import { CURRENCY_CONTROL_ID as Z } from "./currency.js";
|
|
12
12
|
import { FiltersControl as _ } from "./filters.js";
|
|
13
|
-
import { FILTERS_CONTROL_ID as
|
|
13
|
+
import { FILTERS_CONTROL_ID as et } from "./filters.js";
|
|
14
14
|
import { LayoutOrientationControl as b } from "./layoutOrientation.js";
|
|
15
|
-
import { LAYOUT_ORIENTATION_CONTROL_ID as
|
|
15
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as rt } from "./layoutOrientation.js";
|
|
16
16
|
import { LocaleControl as O } from "./locale.js";
|
|
17
|
-
import { LOCALE_CONTROL_ID as
|
|
17
|
+
import { LOCALE_CONTROL_ID as it } from "./locale.js";
|
|
18
18
|
import { ProductCountControl as I } from "./productCount.js";
|
|
19
|
-
import { PRODUCT_COUNT_CONTROL_ID as
|
|
19
|
+
import { PRODUCT_COUNT_CONTROL_ID as at } from "./productCount.js";
|
|
20
20
|
import { ProductLayoutControl as T } from "./productLayout.js";
|
|
21
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
21
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as ct } from "./productLayout.js";
|
|
22
22
|
import { ShuffleControl as S } from "./shuffle.js";
|
|
23
|
-
import { SHUFFLE_CONTROL_ID as
|
|
24
|
-
import {
|
|
25
|
-
import { adjustProductsToSize as
|
|
23
|
+
import { SHUFFLE_CONTROL_ID as dt } from "./shuffle.js";
|
|
24
|
+
import { setCurrencyAttributes as L, getBlockElement as P, updateProductContentInPlace as D, regenerateProductRowsWithStyles as k } from "./utils.js";
|
|
25
|
+
import { adjustProductsToSize as mt, formatProductPrice as ft, getCardComposition as Ct, getCurrentLayout as pt, regenerateMobileProductRows as gt, updatePricesInPlace as yt, updateSingleProductContent as Nt } from "./utils.js";
|
|
26
26
|
import { useDebounceFn as m } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
27
|
-
const
|
|
28
|
-
class
|
|
27
|
+
const E = "recommendation-id", v = "ui-elements-recommendation-block";
|
|
28
|
+
class K extends g {
|
|
29
29
|
constructor() {
|
|
30
30
|
super(...arguments);
|
|
31
31
|
s(this, "store", y());
|
|
@@ -62,11 +62,11 @@ class H extends g {
|
|
|
62
62
|
if (!this.currentNode || !this.api)
|
|
63
63
|
return;
|
|
64
64
|
const e = this.api.getDocumentModifier();
|
|
65
|
-
|
|
65
|
+
D({
|
|
66
66
|
currentNode: this.currentNode,
|
|
67
67
|
documentModifier: e,
|
|
68
68
|
products: t
|
|
69
|
-
}) ||
|
|
69
|
+
}) || k({
|
|
70
70
|
currentNode: this.currentNode,
|
|
71
71
|
documentModifier: e,
|
|
72
72
|
products: t
|
|
@@ -74,10 +74,10 @@ class H extends g {
|
|
|
74
74
|
}, 100));
|
|
75
75
|
}
|
|
76
76
|
getId() {
|
|
77
|
-
return
|
|
77
|
+
return v;
|
|
78
78
|
}
|
|
79
79
|
getTemplate() {
|
|
80
|
-
return this.algorithmControl = new
|
|
80
|
+
return this.algorithmControl = new N(), this.localeControl = new O(), this.currencyControl = new R(), this.productCountControl = new I(), this.productLayoutControl = new T(), this.filtersControl = new _(), this.shuffleControl = new S(), this.layoutOrientationControl = new b(), [
|
|
81
81
|
this.algorithmControl,
|
|
82
82
|
this.localeControl,
|
|
83
83
|
this.currencyControl,
|
|
@@ -263,7 +263,11 @@ class H extends g {
|
|
|
263
263
|
this.currentNode,
|
|
264
264
|
e,
|
|
265
265
|
"Applied smart defaults"
|
|
266
|
-
),
|
|
266
|
+
), o && e.currency && L({
|
|
267
|
+
currentNode: this.currentNode,
|
|
268
|
+
documentModifier: this.api.getDocumentModifier(),
|
|
269
|
+
currency: e.currency
|
|
270
|
+
}), this.store.patchCurrentBlockConfig({
|
|
267
271
|
...o ? {
|
|
268
272
|
currencySettings: {
|
|
269
273
|
name: o,
|
|
@@ -283,10 +287,10 @@ class H extends g {
|
|
|
283
287
|
* Reads the recommendation-id attribute from the block element within the node
|
|
284
288
|
*/
|
|
285
289
|
_getRecommendationIdFromNode(t) {
|
|
286
|
-
const e =
|
|
290
|
+
const e = P(t);
|
|
287
291
|
if (!e || !("getAttribute" in e))
|
|
288
292
|
return null;
|
|
289
|
-
const o = e.getAttribute(
|
|
293
|
+
const o = e.getAttribute(E);
|
|
290
294
|
if (!o)
|
|
291
295
|
return null;
|
|
292
296
|
const r = parseInt(o);
|
|
@@ -316,8 +320,8 @@ class H extends g {
|
|
|
316
320
|
}
|
|
317
321
|
const i = t.$state.configVersion;
|
|
318
322
|
i !== o && (o = i, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
|
|
319
|
-
const c = t.recommendationProducts, u = c !== e,
|
|
320
|
-
u &&
|
|
323
|
+
const c = t.recommendationProducts, u = c !== e, f = Array.isArray(c) && c.length > 0;
|
|
324
|
+
u && f && (e = c, this._debouncedRegenerateWithProducts());
|
|
321
325
|
});
|
|
322
326
|
}
|
|
323
327
|
/**
|
|
@@ -337,35 +341,33 @@ class H extends g {
|
|
|
337
341
|
}
|
|
338
342
|
}
|
|
339
343
|
export {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
Q as ALGORITHM_CONTROL_ID,
|
|
345
|
+
N as AlgorithmControl,
|
|
346
|
+
v as CONTROL_BLOCK_ID,
|
|
347
|
+
Z as CURRENCY_CONTROL_ID,
|
|
348
|
+
R as CurrencyControl,
|
|
349
|
+
et as FILTERS_CONTROL_ID,
|
|
346
350
|
_ as FiltersControl,
|
|
347
|
-
|
|
348
|
-
|
|
351
|
+
rt as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
352
|
+
it as LOCALE_CONTROL_ID,
|
|
349
353
|
b as LayoutOrientationControl,
|
|
350
354
|
O as LocaleControl,
|
|
351
|
-
|
|
352
|
-
|
|
355
|
+
at as PRODUCT_COUNT_CONTROL_ID,
|
|
356
|
+
ct as PRODUCT_LAYOUT_CONTROL_ID,
|
|
353
357
|
I as ProductCountControl,
|
|
354
358
|
T as ProductLayoutControl,
|
|
355
|
-
|
|
356
|
-
|
|
359
|
+
K as RecommendationBlockControl,
|
|
360
|
+
dt as SHUFFLE_CONTROL_ID,
|
|
357
361
|
S as ShuffleControl,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
362
|
+
mt as adjustProductsToSize,
|
|
363
|
+
ft as formatProductPrice,
|
|
364
|
+
P as getBlockElement,
|
|
361
365
|
Ct as getCardComposition,
|
|
362
|
-
|
|
363
|
-
pt as reapplySpacing,
|
|
366
|
+
pt as getCurrentLayout,
|
|
364
367
|
gt as regenerateMobileProductRows,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
_t as updateSingleProductContent
|
|
368
|
+
k as regenerateProductRowsWithStyles,
|
|
369
|
+
L as setCurrencyAttributes,
|
|
370
|
+
yt as updatePricesInPlace,
|
|
371
|
+
D as updateProductContentInPlace,
|
|
372
|
+
Nt as updateSingleProductContent
|
|
371
373
|
};
|
|
@@ -1,61 +1,53 @@
|
|
|
1
|
-
var
|
|
2
|
-
var p = (
|
|
3
|
-
var r = (
|
|
4
|
-
import { ModificationDescription as
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { ATTR_DATA_CUSTOM_ATTRIBUTES as
|
|
7
|
-
import { LAYOUT_OPTIONS as
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var p = (e, o, t) => o in e ? A(e, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[o] = t;
|
|
3
|
+
var r = (e, o, t) => p(e, typeof o != "symbol" ? o + "" : o, t);
|
|
4
|
+
import { ModificationDescription as O } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as L } from "../../../common-control.js";
|
|
6
|
+
import { ATTR_DATA_CUSTOM_ATTRIBUTES as T } from "../../constants/selectors.js";
|
|
7
|
+
import { LAYOUT_OPTIONS as h, DEFAULT_MOBILE_ROW_SPACING as m, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as l, DEFAULT_COLUMN_SPACING as C } from "../../constants/layout.js";
|
|
8
8
|
import { DEFAULT_COMPOSITION as _ } from "../../constants/defaultConfig.js";
|
|
9
9
|
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
import { getCurrentLayout as
|
|
12
|
-
const
|
|
10
|
+
import { useRecommendationExtensionStore as N } from "../../store/recommendation.js";
|
|
11
|
+
import { getCurrentLayout as g, getBlockElement as f, regenerateProductRowsWithStyles as S } from "./utils.js";
|
|
12
|
+
const I = "recommendation-layout-orientation-control", a = {
|
|
13
13
|
LAYOUT: "layout"
|
|
14
|
-
},
|
|
14
|
+
}, U = "data-card-composition", n = {
|
|
15
15
|
LAYOUT: "data-layout",
|
|
16
16
|
COLUMN_SPACING: "data-column-spacing",
|
|
17
17
|
ROW_SPACING: "data-row-spacing",
|
|
18
18
|
MOBILE_COLUMN_SPACING: "data-mobile-column-spacing",
|
|
19
19
|
MOBILE_ROW_SPACING: "data-mobile-row-spacing"
|
|
20
20
|
};
|
|
21
|
-
class
|
|
21
|
+
class w extends L {
|
|
22
22
|
constructor() {
|
|
23
23
|
super(...arguments);
|
|
24
|
-
r(this, "store",
|
|
24
|
+
r(this, "store", N());
|
|
25
25
|
r(this, "isChangingLayout", !1);
|
|
26
26
|
}
|
|
27
27
|
getId() {
|
|
28
|
-
return
|
|
28
|
+
return I;
|
|
29
29
|
}
|
|
30
30
|
getTemplate() {
|
|
31
31
|
return `
|
|
32
32
|
<div class="layout-control-container">
|
|
33
|
-
${this._GuOnPageMessage({ name: A })}
|
|
34
|
-
|
|
35
33
|
${this._GuTwoColumns([
|
|
36
34
|
this._GuLabel({ text: this.api.translate("Layout Orientation") }),
|
|
37
35
|
this._GuRadioButton({
|
|
38
36
|
name: a.LAYOUT,
|
|
39
|
-
buttons:
|
|
37
|
+
buttons: h
|
|
40
38
|
})
|
|
41
39
|
])}
|
|
42
40
|
</div>
|
|
43
41
|
`;
|
|
44
42
|
}
|
|
45
43
|
onRender() {
|
|
46
|
-
this.
|
|
47
|
-
A,
|
|
48
|
-
this.api.translate(
|
|
49
|
-
`Note that updating the Layout Orientation, Number of Products and
|
|
50
|
-
Products in One Row settings resets the style of your Recommendation block.`
|
|
51
|
-
)
|
|
52
|
-
), this._setFormValues(), this._listenToFormUpdates();
|
|
44
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
53
45
|
}
|
|
54
46
|
onTemplateNodeUpdated(t) {
|
|
55
47
|
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
56
48
|
}
|
|
57
49
|
_setFormValues() {
|
|
58
|
-
const u = s.getConfig(this.currentNode).layout ||
|
|
50
|
+
const u = s.getConfig(this.currentNode).layout || g(this.currentNode);
|
|
59
51
|
this.api.updateValues({
|
|
60
52
|
[a.LAYOUT]: u
|
|
61
53
|
});
|
|
@@ -65,9 +57,9 @@ class Y extends N {
|
|
|
65
57
|
* Updates node config, data attribute and regenerates product rows
|
|
66
58
|
*/
|
|
67
59
|
_onLayoutChange(t) {
|
|
68
|
-
if (this.isChangingLayout || !this.currentNode || (s.getConfig(this.currentNode).layout ||
|
|
60
|
+
if (this.isChangingLayout || !this.currentNode || (s.getConfig(this.currentNode).layout || g(this.currentNode)) === t)
|
|
69
61
|
return;
|
|
70
|
-
const c =
|
|
62
|
+
const c = f(this.currentNode);
|
|
71
63
|
if (c) {
|
|
72
64
|
this.isChangingLayout = !0;
|
|
73
65
|
try {
|
|
@@ -76,15 +68,15 @@ class Y extends N {
|
|
|
76
68
|
this.currentNode,
|
|
77
69
|
{
|
|
78
70
|
layout: t,
|
|
79
|
-
columnSpacing:
|
|
71
|
+
columnSpacing: C,
|
|
80
72
|
rowSpacing: l,
|
|
81
73
|
mobileColumnSpacing: d,
|
|
82
74
|
mobileRowSpacing: m
|
|
83
75
|
},
|
|
84
76
|
`Changed layout to ${t}`
|
|
85
77
|
), this.store.patchCurrentBlockConfig({ orientation: t });
|
|
86
|
-
const
|
|
87
|
-
t === "list" ? (
|
|
78
|
+
const i = this.api.getDocumentModifier().modifyHtml(c).setAttribute(n.LAYOUT, t).setAttribute(n.COLUMN_SPACING, C.toString()).setAttribute(n.ROW_SPACING, l.toString()).setAttribute(n.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(n.MOBILE_ROW_SPACING, m.toString());
|
|
79
|
+
t === "list" ? (i.setClass("es-m-p0"), i.setClass("ins-recommendation-list-layout")) : (i.removeClass("es-m-p0"), i.removeClass("ins-recommendation-list-layout")), i.setAttribute(U, _.join(",")).setAttribute(T, "[]"), i.apply(new O(`Update layout to ${t}`)), this._regenerateProductRows(t);
|
|
88
80
|
} finally {
|
|
89
81
|
this.isChangingLayout = !1;
|
|
90
82
|
}
|
|
@@ -110,6 +102,6 @@ class Y extends N {
|
|
|
110
102
|
}
|
|
111
103
|
}
|
|
112
104
|
export {
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
I as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
106
|
+
w as LayoutOrientationControl
|
|
115
107
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var I = Object.defineProperty;
|
|
2
2
|
var E = (a, n, t) => n in a ? I(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
|
|
3
3
|
var u = (a, n, t) => E(a, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
-
import { EditorStatePropertyType as
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { MAX_PRODUCTS_PER_ROW as
|
|
4
|
+
import { EditorStatePropertyType as p, PreviewDeviceMode as f, UEAttr as T } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as N } from "../../../common-control.js";
|
|
6
|
+
import { MAX_PRODUCTS_PER_ROW as O, MAX_MOBILE_PRODUCTS_PER_ROW as M, DEFAULT_MOBILE_CARDS_IN_ROW as m } from "../../constants/layout.js";
|
|
7
7
|
import { RecommendationConfigService as i } from "../../services/configService.js";
|
|
8
|
-
import { useRecommendationExtensionStore as
|
|
9
|
-
import { setMobileLayoutOptOut as
|
|
10
|
-
import { getCurrentLayout as
|
|
11
|
-
import { useDebounceFn as
|
|
12
|
-
const
|
|
8
|
+
import { useRecommendationExtensionStore as P } from "../../store/recommendation.js";
|
|
9
|
+
import { setMobileLayoutOptOut as L, ensureMobileCssRulesExist as C } from "../mobileLayout/cssRules.js";
|
|
10
|
+
import { getCurrentLayout as y, getBlockElement as D, regenerateProductRowsWithStyles as b, regenerateMobileProductRows as g, adjustProductsToSize as w } from "./utils.js";
|
|
11
|
+
import { useDebounceFn as U } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
12
|
+
const B = "recommendation-product-layout-control", e = {
|
|
13
13
|
// "Products in One Row" — shown when toggle is OFF
|
|
14
14
|
PRODUCT_IN_ROW: "cardsInRow",
|
|
15
15
|
PRODUCT_IN_ROW_LABEL: "cardsInRowLabel",
|
|
@@ -23,19 +23,19 @@ const S = "recommendation-product-layout-control", e = {
|
|
|
23
23
|
MOBILE_LAYOUT_TOGGLE: "mobileLayoutEnabled",
|
|
24
24
|
MOBILE_LAYOUT_LABEL: "mobileLayoutLabel"
|
|
25
25
|
};
|
|
26
|
-
class
|
|
26
|
+
class Y extends N {
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments);
|
|
29
29
|
// Store is used for backward compatibility with product fetching and regeneration
|
|
30
|
-
u(this, "store",
|
|
30
|
+
u(this, "store", P());
|
|
31
31
|
u(this, "storeUnsubscription", () => {
|
|
32
32
|
});
|
|
33
|
-
u(this, "_debouncedRegenerateProductRows",
|
|
33
|
+
u(this, "_debouncedRegenerateProductRows", U(() => {
|
|
34
34
|
this._regenerateProductRows();
|
|
35
35
|
}, 500));
|
|
36
36
|
}
|
|
37
37
|
getId() {
|
|
38
|
-
return
|
|
38
|
+
return B;
|
|
39
39
|
}
|
|
40
40
|
getTemplate() {
|
|
41
41
|
return `
|
|
@@ -45,12 +45,12 @@ class v extends T {
|
|
|
45
45
|
text: this.api.translate("Products in One Row"),
|
|
46
46
|
name: e.PRODUCT_IN_ROW_LABEL
|
|
47
47
|
}),
|
|
48
|
-
this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue:
|
|
48
|
+
this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: O }),
|
|
49
49
|
this._GuLabel({
|
|
50
50
|
text: this.api.translate("Products in One Row on Desktop"),
|
|
51
51
|
name: e.PRODUCT_IN_ROW_DESKTOP_LABEL
|
|
52
52
|
}),
|
|
53
|
-
this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue:
|
|
53
|
+
this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue: O }),
|
|
54
54
|
this._GuLabel({
|
|
55
55
|
text: this.api.translate("Products in One Row on Mobile"),
|
|
56
56
|
name: e.MOBILE_CARDS_IN_ROW_LABEL
|
|
@@ -95,7 +95,7 @@ class v extends T {
|
|
|
95
95
|
* Returns true when the editor preview is in mobile mode.
|
|
96
96
|
*/
|
|
97
97
|
_isMobilePreview() {
|
|
98
|
-
return this.api.getEditorState()[
|
|
98
|
+
return this.api.getEditorState()[p.previewDeviceMode] === f.MOBILE;
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* Updates counter visibility based on layout, mobileLayoutEnabled, and editor preview mode.
|
|
@@ -110,10 +110,10 @@ class v extends T {
|
|
|
110
110
|
*/
|
|
111
111
|
_updateProductsInRowVisibility() {
|
|
112
112
|
var R;
|
|
113
|
-
const t = i.getConfig(this.currentNode), o = (t.layout ||
|
|
113
|
+
const t = i.getConfig(this.currentNode), o = (t.layout || y(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, d = this._isMobilePreview();
|
|
114
114
|
this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE, o), this.api.setVisibility(e.MOBILE_LAYOUT_LABEL, o);
|
|
115
|
-
const c = o && !r,
|
|
116
|
-
this.api.setVisibility(e.PRODUCT_IN_ROW, c), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, c), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP,
|
|
115
|
+
const c = o && !r, l = o && r && !d, _ = o && r && d;
|
|
116
|
+
this.api.setVisibility(e.PRODUCT_IN_ROW, c), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, c), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP, l), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP_LABEL, l), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, _), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, _);
|
|
117
117
|
const h = (R = this.getContainer()) == null ? void 0 : R.querySelector("[data-product-layout-control]");
|
|
118
118
|
h && (h.style.display = o ? "" : "none");
|
|
119
119
|
}
|
|
@@ -125,7 +125,7 @@ class v extends T {
|
|
|
125
125
|
const t = i.getConfig(this.currentNode);
|
|
126
126
|
this.api.setUIEAttribute(
|
|
127
127
|
e.MOBILE_LAYOUT_TOGGLE,
|
|
128
|
-
|
|
128
|
+
T.SELECTPICKER.items,
|
|
129
129
|
t.mobileLayoutEnabled
|
|
130
130
|
);
|
|
131
131
|
}
|
|
@@ -140,9 +140,9 @@ class v extends T {
|
|
|
140
140
|
const s = i.getConfig(this.currentNode);
|
|
141
141
|
if (s.mobileLayoutEnabled === t)
|
|
142
142
|
return;
|
|
143
|
-
const o =
|
|
143
|
+
const o = D(this.currentNode);
|
|
144
144
|
if (t) {
|
|
145
|
-
const r = s.previousMobileCardsInRow ||
|
|
145
|
+
const r = s.previousMobileCardsInRow || m;
|
|
146
146
|
i.updateConfig(
|
|
147
147
|
this.api,
|
|
148
148
|
this.currentNode,
|
|
@@ -154,7 +154,7 @@ class v extends T {
|
|
|
154
154
|
), this.store.patchCurrentBlockConfig(
|
|
155
155
|
{ mobileLayoutEnabled: !0 },
|
|
156
156
|
{ triggerRefetch: !1 }
|
|
157
|
-
), o &&
|
|
157
|
+
), o && L(this.api, o, !1), C(this.api), b({
|
|
158
158
|
currentNode: this.currentNode,
|
|
159
159
|
documentModifier: this.api.getDocumentModifier()
|
|
160
160
|
});
|
|
@@ -166,13 +166,13 @@ class v extends T {
|
|
|
166
166
|
{
|
|
167
167
|
mobileLayoutEnabled: !1,
|
|
168
168
|
previousMobileCardsInRow: r,
|
|
169
|
-
mobileCardsInRow:
|
|
169
|
+
mobileCardsInRow: m
|
|
170
170
|
},
|
|
171
171
|
"Disabled mobile layout optimization"
|
|
172
172
|
), this.store.patchCurrentBlockConfig(
|
|
173
173
|
{ mobileLayoutEnabled: !1 },
|
|
174
174
|
{ triggerRefetch: !1 }
|
|
175
|
-
), o &&
|
|
175
|
+
), o && L(this.api, o, !0), g({
|
|
176
176
|
currentNode: this.currentNode,
|
|
177
177
|
documentModifier: this.api.getDocumentModifier()
|
|
178
178
|
});
|
|
@@ -180,32 +180,26 @@ class v extends T {
|
|
|
180
180
|
this._setFormValues(), this._updateProductsInRowVisibility();
|
|
181
181
|
}
|
|
182
182
|
_onProductsInRowChange(t) {
|
|
183
|
-
|
|
184
|
-
return;
|
|
185
|
-
const o = t === 1 ? 0 : P;
|
|
186
|
-
i.updateConfig(
|
|
183
|
+
!this.currentNode || i.getConfig(this.currentNode).cardsInRow === t || (i.updateConfig(
|
|
187
184
|
this.api,
|
|
188
185
|
this.currentNode,
|
|
189
|
-
{ cardsInRow: t
|
|
186
|
+
{ cardsInRow: t },
|
|
190
187
|
`Changed products per row to ${t}`
|
|
191
|
-
), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows();
|
|
188
|
+
), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows());
|
|
192
189
|
}
|
|
193
190
|
_onMobileCardsInRowChange(t) {
|
|
194
|
-
|
|
195
|
-
return;
|
|
196
|
-
const o = t === 1 ? 0 : y;
|
|
197
|
-
i.updateConfig(
|
|
191
|
+
!this.currentNode || i.getConfig(this.currentNode).mobileCardsInRow === t || (i.updateConfig(
|
|
198
192
|
this.api,
|
|
199
193
|
this.currentNode,
|
|
200
|
-
{ mobileCardsInRow: t
|
|
194
|
+
{ mobileCardsInRow: t },
|
|
201
195
|
`Changed mobile products per row to ${t}`
|
|
202
196
|
), C(this.api), g({
|
|
203
197
|
currentNode: this.currentNode,
|
|
204
198
|
documentModifier: this.api.getDocumentModifier()
|
|
205
|
-
});
|
|
199
|
+
}));
|
|
206
200
|
}
|
|
207
201
|
_regenerateProductRows() {
|
|
208
|
-
const t = i.getConfig(this.currentNode), s = parseInt(t.size) || 6, o =
|
|
202
|
+
const t = i.getConfig(this.currentNode), s = parseInt(t.size) || 6, o = w(this.store.recommendationProducts, s);
|
|
209
203
|
b({
|
|
210
204
|
currentNode: this.currentNode,
|
|
211
205
|
documentModifier: this.api.getDocumentModifier(),
|
|
@@ -241,7 +235,7 @@ class v extends T {
|
|
|
241
235
|
*/
|
|
242
236
|
_listenEditorModeChanges() {
|
|
243
237
|
this.api.onEditorStatePropUpdated(
|
|
244
|
-
|
|
238
|
+
p.previewDeviceMode,
|
|
245
239
|
() => {
|
|
246
240
|
i.getConfig(this.currentNode).mobileLayoutEnabled && this._updateProductsInRowVisibility();
|
|
247
241
|
}
|
|
@@ -249,6 +243,6 @@ class v extends T {
|
|
|
249
243
|
}
|
|
250
244
|
}
|
|
251
245
|
export {
|
|
252
|
-
|
|
253
|
-
|
|
246
|
+
B as PRODUCT_LAYOUT_CONTROL_ID,
|
|
247
|
+
Y as ProductLayoutControl
|
|
254
248
|
};
|