@useinsider/guido 3.8.0-beta.84f6c0a → 3.8.0-beta.910d4af
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/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +8 -8
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue2.js +15 -12
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue2.js +16 -15
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +5 -5
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +42 -37
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +3 -3
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +40 -37
- package/dist/composables/usePreviewInteractionGuard.js +17 -0
- package/dist/composables/useSave.js +14 -14
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +26 -17
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +25 -19
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +10 -11
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +26 -24
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +39 -30
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +34 -28
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +333 -285
- package/dist/extensions/Blocks/Recommendation/extension.js +5 -6
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +2 -3
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +173 -142
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -56
- package/dist/extensions/Blocks/Recommendation/templates/index.js +8 -29
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +105 -132
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +23 -44
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +64 -112
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +19 -24
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +22 -30
- package/dist/extensions/Blocks/Unsubscribe/block.js +40 -37
- package/dist/extensions/Blocks/Unsubscribe/control.js +19 -16
- package/dist/extensions/Blocks/controlFactories.js +133 -159
- package/dist/guido.css +1 -1
- package/dist/src/composables/usePreviewInteractionGuard.d.ts +3 -0
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +1 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +47 -20
- 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/template.d.ts +2 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +11 -165
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -15
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +9 -29
- package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -11
- package/dist/src/stores/unsubscribe.d.ts +11 -1
- package/dist/stores/unsubscribe.js +8 -7
- package/package.json +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +0 -219
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +0 -78
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
1
|
+
import { useConfig as g } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
|
|
3
3
|
import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
4
|
import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
-
function
|
|
5
|
+
function y(r, n, e, o, i = "") {
|
|
6
6
|
const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
|
|
7
7
|
return o === "before" ? `${t} ${c}` : `${c} ${t}`;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function A(r) {
|
|
10
10
|
let n = r;
|
|
11
11
|
for (; n.children.length === 1; )
|
|
12
12
|
[n] = n.children;
|
|
13
13
|
return n;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function f(r, n, e, o, i, c) {
|
|
16
16
|
switch (n) {
|
|
17
17
|
case "productImage": {
|
|
18
18
|
const t = r.querySelector("img");
|
|
@@ -23,12 +23,15 @@ function A(r, n, e, o, i, c) {
|
|
|
23
23
|
}
|
|
24
24
|
case "productName": {
|
|
25
25
|
const t = r.querySelector("p");
|
|
26
|
-
|
|
26
|
+
if (t) {
|
|
27
|
+
const s = t.querySelector("strong") || t;
|
|
28
|
+
s.textContent = `{{${c}${e}_${o}_name}}`;
|
|
29
|
+
}
|
|
27
30
|
break;
|
|
28
31
|
}
|
|
29
32
|
case "productPrice": {
|
|
30
33
|
const t = r.querySelector("p");
|
|
31
|
-
t && (
|
|
34
|
+
t && (A(t).textContent = y(
|
|
32
35
|
e,
|
|
33
36
|
o,
|
|
34
37
|
"price",
|
|
@@ -39,7 +42,7 @@ function A(r, n, e, o, i, c) {
|
|
|
39
42
|
}
|
|
40
43
|
case "productOldPrice": {
|
|
41
44
|
const t = r.querySelector("p");
|
|
42
|
-
t && (
|
|
45
|
+
t && (A(t).textContent = y(
|
|
43
46
|
e,
|
|
44
47
|
o,
|
|
45
48
|
"original_price",
|
|
@@ -75,7 +78,10 @@ function A(r, n, e, o, i, c) {
|
|
|
75
78
|
const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
|
|
76
79
|
if (t) {
|
|
77
80
|
const s = t.getAttribute("product-attr"), a = t.querySelector("p");
|
|
78
|
-
|
|
81
|
+
if (a) {
|
|
82
|
+
const u = a.querySelector("strong") || a;
|
|
83
|
+
u.textContent = `{{${c}${e}_${o}_${s}}}`;
|
|
84
|
+
}
|
|
79
85
|
}
|
|
80
86
|
break;
|
|
81
87
|
}
|
|
@@ -86,8 +92,8 @@ function w(r, n, e, o) {
|
|
|
86
92
|
c.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
87
93
|
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
88
94
|
p.length > 0 ? p.forEach((l) => {
|
|
89
|
-
|
|
90
|
-
}) :
|
|
95
|
+
f(l, u, n, t, e, o);
|
|
96
|
+
}) : f(a, u, n, t, e, o);
|
|
91
97
|
});
|
|
92
98
|
});
|
|
93
99
|
}
|
|
@@ -99,9 +105,9 @@ function E(r, n, e, o) {
|
|
|
99
105
|
i.forEach((a, u) => {
|
|
100
106
|
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
101
107
|
const d = l.getAttribute("data-attribute-type") || "";
|
|
102
|
-
l.querySelectorAll(".attribute-cell").forEach((
|
|
108
|
+
l.querySelectorAll(".attribute-cell").forEach((h, $) => {
|
|
103
109
|
const S = u * s + $;
|
|
104
|
-
|
|
110
|
+
f(h, d, n, S, e, o);
|
|
105
111
|
});
|
|
106
112
|
});
|
|
107
113
|
});
|
|
@@ -115,7 +121,7 @@ function P(r, n, e) {
|
|
|
115
121
|
const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
|
|
116
122
|
o === "list" ? w(r, n, i, e) : R(r, n, i, e);
|
|
117
123
|
}
|
|
118
|
-
function
|
|
124
|
+
function b(r, n, e) {
|
|
119
125
|
const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
|
|
120
126
|
return i ? parseInt(i[1]) : e;
|
|
121
127
|
}
|
|
@@ -132,14 +138,14 @@ function T(r, n) {
|
|
|
132
138
|
return null;
|
|
133
139
|
}
|
|
134
140
|
function v(r) {
|
|
135
|
-
const n = r.getAttribute("style") || "", e =
|
|
141
|
+
const n = r.getAttribute("style") || "", e = b(n, "width", 600), o = b(n, "padding", 0) * 2, i = Math.max(0, e - o);
|
|
136
142
|
i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
|
|
137
143
|
if (c.hasAttribute("width"))
|
|
138
144
|
return;
|
|
139
145
|
const t = T(c, r);
|
|
140
146
|
if (!t)
|
|
141
147
|
return;
|
|
142
|
-
const s = t.getAttribute("width"), a = parseFloat(s), u =
|
|
148
|
+
const s = t.getAttribute("width"), a = parseFloat(s), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
|
|
143
149
|
c.setAttribute("width", String(l));
|
|
144
150
|
const d = c.getAttribute("style") || "";
|
|
145
151
|
if (!/\bwidth\s*:\s*\d/i.test(d)) {
|
|
@@ -157,9 +163,9 @@ function N(r) {
|
|
|
157
163
|
const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
158
164
|
if (!o.length)
|
|
159
165
|
return r;
|
|
160
|
-
const { buildCampaignUrl: i } =
|
|
166
|
+
const { buildCampaignUrl: i } = _(), c = C();
|
|
161
167
|
c.recommendationCampaignUrls = {};
|
|
162
|
-
const { isFeatureEnabled: t } =
|
|
168
|
+
const { isFeatureEnabled: t } = g(), s = t("liquidSyntax") ? "reco_" : "";
|
|
163
169
|
return o.forEach((u) => {
|
|
164
170
|
var l, d;
|
|
165
171
|
const p = u.getAttribute("recommendation-id");
|
|
@@ -167,6 +173,6 @@ function N(r) {
|
|
|
167
173
|
}), O(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
168
174
|
}
|
|
169
175
|
export {
|
|
170
|
-
|
|
176
|
+
y as formatPriceVariable,
|
|
171
177
|
N as prepareRecommendationBlocks
|
|
172
178
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const T = ".recommendation-block-v2", c = ".ins-recommendation-product-container",
|
|
1
|
+
const T = ".recommendation-block-v2", c = ".ins-recommendation-product-container", o = ".ins-recommendation-desktop-container", n = ".ins-recommendation-mobile-container", t = ".ins-recommendation-mobile-row", r = "reco-v3-button", _ = {
|
|
2
2
|
CURRENCY: "currency",
|
|
3
3
|
SYMBOL: "currency-symbol",
|
|
4
4
|
ALIGNMENT: "currency-alignment",
|
|
5
5
|
THOUSAND_SEPARATOR: "currency-thousand-separator",
|
|
6
6
|
DECIMAL_SEPARATOR: "currency-decimal-separator",
|
|
7
7
|
DECIMAL_COUNT: "currency-decimal-count"
|
|
8
|
-
}, R = "productImage", e = "productName", O = "productPrice", s = "productOldPrice",
|
|
8
|
+
}, R = "productImage", e = "productName", O = "productPrice", s = "productOldPrice", i = "productOmnibusPrice", C = "productOmnibusDiscount", E = "productButton", A = "customAttr:", u = "data-custom-attributes", m = "product-attr", a = /* @__PURE__ */ new Set([
|
|
9
9
|
"name",
|
|
10
10
|
// productName
|
|
11
11
|
"price",
|
|
@@ -24,21 +24,20 @@ const T = ".recommendation-block-v2", c = ".ins-recommendation-product-container
|
|
|
24
24
|
export {
|
|
25
25
|
A as ATTR_CUSTOM_PREFIX,
|
|
26
26
|
u as ATTR_DATA_CUSTOM_ATTRIBUTES,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
m as ATTR_PRODUCT_ATTR,
|
|
28
|
+
E as ATTR_PRODUCT_BUTTON,
|
|
29
29
|
R as ATTR_PRODUCT_IMAGE,
|
|
30
30
|
e as ATTR_PRODUCT_NAME,
|
|
31
31
|
s as ATTR_PRODUCT_OLD_PRICE,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
C as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
|
|
33
|
+
i as ATTR_PRODUCT_OMNIBUS_PRICE,
|
|
34
34
|
O as ATTR_PRODUCT_PRICE,
|
|
35
35
|
T as BLOCK_ROOT_SELECTOR,
|
|
36
|
-
|
|
36
|
+
a as BUILT_IN_DEFAULT_ATTRIBUTES,
|
|
37
37
|
c as CONTAINER_SELECTOR,
|
|
38
38
|
r as CSS_CLASS_RECO_BUTTON,
|
|
39
39
|
_ as CURRENCY_ATTR,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
m as PRODUCT_ATTRIBUTE_PREFIX
|
|
40
|
+
o as DESKTOP_CONTAINER_SELECTOR,
|
|
41
|
+
n as MOBILE_CONTAINER_SELECTOR,
|
|
42
|
+
t as MOBILE_ROW_SELECTOR
|
|
44
43
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var C = Object.defineProperty;
|
|
2
|
-
var p = (d,
|
|
3
|
-
var s = (d,
|
|
2
|
+
var p = (d, c, t) => c in d ? C(d, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[c] = t;
|
|
3
|
+
var s = (d, c, t) => p(d, typeof c != "symbol" ? c + "" : c, t);
|
|
4
4
|
import { CommonControl as g } from "../../../common-control.js";
|
|
5
|
-
import { DEFAULT_NODE_CONFIG as
|
|
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
8
|
import { AlgorithmControl as R } from "./algorithm.js";
|
|
@@ -16,13 +16,13 @@ import { LAYOUT_ORIENTATION_CONTROL_ID as rt } from "./layoutOrientation.js";
|
|
|
16
16
|
import { LocaleControl as _ } from "./locale.js";
|
|
17
17
|
import { LOCALE_CONTROL_ID as it } from "./locale.js";
|
|
18
18
|
import { ProductCountControl as O } 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 lt } from "./productLayout.js";
|
|
22
22
|
import { ShuffleControl as S } from "./shuffle.js";
|
|
23
23
|
import { SHUFFLE_CONTROL_ID as dt } from "./shuffle.js";
|
|
24
24
|
import { setCurrencyAttributes as L, getBlockElement as P, updateProductContentInPlace as k, regenerateProductRowsWithStyles as D } from "./utils.js";
|
|
25
|
-
import { adjustProductsToSize as mt, formatProductPrice as ft, getCardComposition as Ct, getCurrentLayout as pt,
|
|
25
|
+
import { adjustProductsToSize as mt, formatProductPrice as ft, getCardComposition as Ct, getCurrentLayout as pt, reapplySpacing as gt, regenerateMobileProductRows as yt, regenerateProductRows as Rt, updatePricesInPlace as bt, updateSingleProductContent as Nt } from "./utils.js";
|
|
26
26
|
import { useDebounceFn as m } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
27
27
|
const E = "recommendation-id", w = "ui-elements-recommendation-block";
|
|
28
28
|
class K extends g {
|
|
@@ -241,26 +241,26 @@ class K extends g {
|
|
|
241
241
|
return;
|
|
242
242
|
const t = h.getConfig(this.currentNode), e = {};
|
|
243
243
|
let o = null, r = null, n = null;
|
|
244
|
-
if (t.currency.code ===
|
|
244
|
+
if (t.currency.code === a.currency.code) {
|
|
245
245
|
const { currencyList: i } = this.store;
|
|
246
246
|
i.length > 0 && (i.some(
|
|
247
|
-
(u) => u.value === `price.${
|
|
247
|
+
(u) => u.value === `price.${a.currency.code}`
|
|
248
248
|
) || (o = i[0].value.replace("price.", ""), e.currency = {
|
|
249
|
-
...
|
|
249
|
+
...a.currency,
|
|
250
250
|
code: o,
|
|
251
251
|
symbol: o
|
|
252
252
|
}));
|
|
253
253
|
}
|
|
254
|
-
if (t.strategy ===
|
|
254
|
+
if (t.strategy === a.strategy) {
|
|
255
255
|
const i = this.store.getActivePredictiveAlgorithms;
|
|
256
256
|
i.length > 0 && (i.some(
|
|
257
|
-
(u) => u.value ===
|
|
257
|
+
(u) => u.value === a.strategy
|
|
258
258
|
) || (r = i[0].value, e.strategy = r));
|
|
259
259
|
}
|
|
260
|
-
if (t.language ===
|
|
260
|
+
if (t.language === a.language) {
|
|
261
261
|
const i = this.store.getLanguages;
|
|
262
262
|
i.length > 0 && (i.some(
|
|
263
|
-
(u) => u.value ===
|
|
263
|
+
(u) => u.value === a.language
|
|
264
264
|
) || (n = i[0].value, e.language = n));
|
|
265
265
|
}
|
|
266
266
|
!o && !r && !n || (h.updateConfig(
|
|
@@ -278,10 +278,10 @@ class K extends g {
|
|
|
278
278
|
name: o,
|
|
279
279
|
value: o,
|
|
280
280
|
symbol: o,
|
|
281
|
-
alignment:
|
|
282
|
-
decimalCount:
|
|
283
|
-
decimalSeparator:
|
|
284
|
-
thousandSeparator:
|
|
281
|
+
alignment: a.currency.alignment === "before" ? "0" : "1",
|
|
282
|
+
decimalCount: a.currency.decimalCount.toString(),
|
|
283
|
+
decimalSeparator: a.currency.decimalSeparator,
|
|
284
|
+
thousandSeparator: a.currency.thousandSeparator
|
|
285
285
|
}
|
|
286
286
|
} : {},
|
|
287
287
|
...r ? { strategy: r } : {},
|
|
@@ -325,8 +325,8 @@ class K extends g {
|
|
|
325
325
|
}
|
|
326
326
|
const i = t.$state.configVersion;
|
|
327
327
|
i !== o && (o = i, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
|
|
328
|
-
const
|
|
329
|
-
u && f && (e =
|
|
328
|
+
const l = t.recommendationProducts, u = l !== e, f = Array.isArray(l) && l.length > 0;
|
|
329
|
+
u && f && (e = l, this._debouncedRegenerateWithProducts());
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
/**
|
|
@@ -357,8 +357,8 @@ export {
|
|
|
357
357
|
it as LOCALE_CONTROL_ID,
|
|
358
358
|
I as LayoutOrientationControl,
|
|
359
359
|
_ as LocaleControl,
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
at as PRODUCT_COUNT_CONTROL_ID,
|
|
361
|
+
lt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
362
362
|
O as ProductCountControl,
|
|
363
363
|
T as ProductLayoutControl,
|
|
364
364
|
K as RecommendationBlockControl,
|
|
@@ -369,10 +369,12 @@ export {
|
|
|
369
369
|
P as getBlockElement,
|
|
370
370
|
Ct as getCardComposition,
|
|
371
371
|
pt as getCurrentLayout,
|
|
372
|
-
gt as
|
|
372
|
+
gt as reapplySpacing,
|
|
373
|
+
yt as regenerateMobileProductRows,
|
|
374
|
+
Rt as regenerateProductRows,
|
|
373
375
|
D as regenerateProductRowsWithStyles,
|
|
374
376
|
L as setCurrencyAttributes,
|
|
375
|
-
|
|
377
|
+
bt as updatePricesInPlace,
|
|
376
378
|
k as updateProductContentInPlace,
|
|
377
|
-
|
|
379
|
+
Nt as updateSingleProductContent
|
|
378
380
|
};
|
|
@@ -1,53 +1,64 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var A = (o, e, t) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var r = (o, e, t) => A(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as N } from "../../../common-control.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
6
|
+
import { ATTR_DATA_CUSTOM_ATTRIBUTES as L } from "../../constants/selectors.js";
|
|
7
|
+
import { LAYOUT_OPTIONS as T, DEFAULT_MOBILE_ROW_SPACING as m, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as l, DEFAULT_COLUMN_SPACING as g } from "../../constants/layout.js";
|
|
8
|
+
import { DEFAULT_COMPOSITION as _ } from "../../constants/defaultConfig.js";
|
|
9
|
+
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as f } from "../../store/recommendation.js";
|
|
11
|
+
import { getCurrentLayout as C, getBlockElement as I, regenerateProductRowsWithStyles as S } from "./utils.js";
|
|
12
|
+
const U = "recommendation-layout-orientation-control", O = "recommendationInfoBannerTest", a = {
|
|
11
13
|
LAYOUT: "layout"
|
|
12
|
-
}, n = {
|
|
14
|
+
}, y = "data-card-composition", n = {
|
|
13
15
|
LAYOUT: "data-layout",
|
|
14
16
|
COLUMN_SPACING: "data-column-spacing",
|
|
15
17
|
ROW_SPACING: "data-row-spacing",
|
|
16
18
|
MOBILE_COLUMN_SPACING: "data-mobile-column-spacing",
|
|
17
19
|
MOBILE_ROW_SPACING: "data-mobile-row-spacing"
|
|
18
20
|
};
|
|
19
|
-
class
|
|
21
|
+
class Y extends N {
|
|
20
22
|
constructor() {
|
|
21
23
|
super(...arguments);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
r(this, "store", f());
|
|
25
|
+
r(this, "isChangingLayout", !1);
|
|
24
26
|
}
|
|
25
27
|
getId() {
|
|
26
|
-
return
|
|
28
|
+
return U;
|
|
27
29
|
}
|
|
28
30
|
getTemplate() {
|
|
29
31
|
return `
|
|
30
32
|
<div class="layout-control-container">
|
|
33
|
+
${this._GuOnPageMessage({ name: O })}
|
|
34
|
+
|
|
31
35
|
${this._GuTwoColumns([
|
|
32
36
|
this._GuLabel({ text: this.api.translate("Layout Orientation") }),
|
|
33
37
|
this._GuRadioButton({
|
|
34
|
-
name:
|
|
35
|
-
buttons:
|
|
38
|
+
name: a.LAYOUT,
|
|
39
|
+
buttons: T
|
|
36
40
|
})
|
|
37
41
|
])}
|
|
38
42
|
</div>
|
|
39
43
|
`;
|
|
40
44
|
}
|
|
41
45
|
onRender() {
|
|
42
|
-
this.
|
|
46
|
+
this._setInfoMessageValue(
|
|
47
|
+
O,
|
|
48
|
+
this.api.translate(
|
|
49
|
+
`Note that updating the Layout Orientation, Number of Products,
|
|
50
|
+
Products in One Row and Mobile Layout Optimization settings
|
|
51
|
+
resets the style of your Recommendation block.`
|
|
52
|
+
)
|
|
53
|
+
), this._setFormValues(), this._listenToFormUpdates();
|
|
43
54
|
}
|
|
44
55
|
onTemplateNodeUpdated(t) {
|
|
45
56
|
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
46
57
|
}
|
|
47
58
|
_setFormValues() {
|
|
48
|
-
const
|
|
59
|
+
const u = s.getConfig(this.currentNode).layout || C(this.currentNode);
|
|
49
60
|
this.api.updateValues({
|
|
50
|
-
[
|
|
61
|
+
[a.LAYOUT]: u
|
|
51
62
|
});
|
|
52
63
|
}
|
|
53
64
|
/**
|
|
@@ -55,14 +66,13 @@ class w extends N {
|
|
|
55
66
|
* Updates node config, data attribute and regenerates product rows
|
|
56
67
|
*/
|
|
57
68
|
_onLayoutChange(t) {
|
|
58
|
-
if (this.isChangingLayout || !this.currentNode || (
|
|
69
|
+
if (this.isChangingLayout || !this.currentNode || (s.getConfig(this.currentNode).layout || C(this.currentNode)) === t)
|
|
59
70
|
return;
|
|
60
|
-
const c =
|
|
71
|
+
const c = I(this.currentNode);
|
|
61
72
|
if (c) {
|
|
62
73
|
this.isChangingLayout = !0;
|
|
63
74
|
try {
|
|
64
|
-
|
|
65
|
-
a.updateConfig(
|
|
75
|
+
s.updateConfig(
|
|
66
76
|
this.api,
|
|
67
77
|
this.currentNode,
|
|
68
78
|
{
|
|
@@ -75,7 +85,7 @@ class w extends N {
|
|
|
75
85
|
`Changed layout to ${t}`
|
|
76
86
|
), this.store.patchCurrentBlockConfig({ orientation: t });
|
|
77
87
|
const i = this.api.getDocumentModifier().modifyHtml(c).setAttribute(n.LAYOUT, t).setAttribute(n.COLUMN_SPACING, g.toString()).setAttribute(n.ROW_SPACING, l.toString()).setAttribute(n.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(n.MOBILE_ROW_SPACING, m.toString());
|
|
78
|
-
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.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t
|
|
88
|
+
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(y, _.join(",")).setAttribute(L, "[]"), i.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t);
|
|
79
89
|
} finally {
|
|
80
90
|
this.isChangingLayout = !1;
|
|
81
91
|
}
|
|
@@ -85,23 +95,22 @@ class w extends N {
|
|
|
85
95
|
* Regenerates product rows based on the selected layout
|
|
86
96
|
* Uses unified style-preserving regeneration to maintain user customizations
|
|
87
97
|
* @param layout - The layout to use for regeneration (passed explicitly to avoid stale DOM reads)
|
|
88
|
-
* @param composition - The preserved card composition, incl. customAttr:* entries
|
|
89
98
|
*/
|
|
90
|
-
_regenerateProductRows(t
|
|
91
|
-
this.currentNode &&
|
|
99
|
+
_regenerateProductRows(t) {
|
|
100
|
+
this.currentNode && S({
|
|
92
101
|
currentNode: this.currentNode,
|
|
93
102
|
documentModifier: this.api.getDocumentModifier(),
|
|
94
103
|
layout: t,
|
|
95
|
-
composition:
|
|
104
|
+
composition: _
|
|
96
105
|
});
|
|
97
106
|
}
|
|
98
107
|
_listenToFormUpdates() {
|
|
99
|
-
this.api.onValueChanged(
|
|
108
|
+
this.api.onValueChanged(a.LAYOUT, (t) => {
|
|
100
109
|
this._onLayoutChange(t);
|
|
101
110
|
});
|
|
102
111
|
}
|
|
103
112
|
}
|
|
104
113
|
export {
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
U as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
115
|
+
Y as LayoutOrientationControl
|
|
107
116
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var E = Object.defineProperty;
|
|
2
2
|
var f = (a, n, t) => n in a ? E(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
|
|
3
3
|
var c = (a, n, t) => f(a, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
-
import { EditorStatePropertyType as O, PreviewDeviceMode as
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { MAX_PRODUCTS_PER_ROW as m, MAX_MOBILE_PRODUCTS_PER_ROW as
|
|
4
|
+
import { EditorStatePropertyType as O, PreviewDeviceMode as N, UEAttr as T } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as M } from "../../../common-control.js";
|
|
6
|
+
import { MAX_PRODUCTS_PER_ROW as m, MAX_MOBILE_PRODUCTS_PER_ROW as P, DEFAULT_MOBILE_CARDS_IN_ROW as l, DEFAULT_COLUMN_SPACING as w, DEFAULT_MOBILE_COLUMN_SPACING as y } from "../../constants/layout.js";
|
|
7
7
|
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
8
|
-
import { useRecommendationExtensionStore as
|
|
9
|
-
import { setMobileLayoutOptOut as C, ensureMobileCssRulesExist as
|
|
10
|
-
import { getCurrentLayout as
|
|
11
|
-
import { useDebounceFn as
|
|
12
|
-
const
|
|
8
|
+
import { useRecommendationExtensionStore as D } from "../../store/recommendation.js";
|
|
9
|
+
import { setMobileLayoutOptOut as C, ensureMobileCssRulesExist as L } from "../mobileLayout/cssRules.js";
|
|
10
|
+
import { getCurrentLayout as U, getBlockElement as A, adjustProductsToSize as b, regenerateProductRowsWithStyles as g, regenerateMobileProductRows as I } from "./utils.js";
|
|
11
|
+
import { useDebounceFn as B } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
12
|
+
const S = "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 B = "recommendation-product-layout-control", e = {
|
|
|
23
23
|
MOBILE_LAYOUT_TOGGLE: "mobileLayoutEnabled",
|
|
24
24
|
MOBILE_LAYOUT_LABEL: "mobileLayoutLabel"
|
|
25
25
|
};
|
|
26
|
-
class v extends
|
|
26
|
+
class v extends M {
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments);
|
|
29
29
|
// Store is used for backward compatibility with product fetching and regeneration
|
|
30
|
-
c(this, "store",
|
|
30
|
+
c(this, "store", D());
|
|
31
31
|
c(this, "storeUnsubscription", () => {
|
|
32
32
|
});
|
|
33
|
-
c(this, "_debouncedRegenerateProductRows",
|
|
33
|
+
c(this, "_debouncedRegenerateProductRows", B(() => {
|
|
34
34
|
this._regenerateProductRows();
|
|
35
35
|
}, 500));
|
|
36
36
|
}
|
|
37
37
|
getId() {
|
|
38
|
-
return
|
|
38
|
+
return S;
|
|
39
39
|
}
|
|
40
40
|
getTemplate() {
|
|
41
41
|
return `
|
|
@@ -57,7 +57,7 @@ class v extends P {
|
|
|
57
57
|
}),
|
|
58
58
|
this._GuCounter({
|
|
59
59
|
name: e.MOBILE_CARDS_IN_ROW,
|
|
60
|
-
maxValue:
|
|
60
|
+
maxValue: P
|
|
61
61
|
}),
|
|
62
62
|
this._GuLabel({
|
|
63
63
|
text: this.api.translate("Mobile Layout Optimization"),
|
|
@@ -95,7 +95,7 @@ class v extends P {
|
|
|
95
95
|
* Returns true when the editor preview is in mobile mode.
|
|
96
96
|
*/
|
|
97
97
|
_isMobilePreview() {
|
|
98
|
-
return this.api.getEditorState()[O.previewDeviceMode] ===
|
|
98
|
+
return this.api.getEditorState()[O.previewDeviceMode] === N.MOBILE;
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* Updates counter visibility based on layout, mobileLayoutEnabled, and editor preview mode.
|
|
@@ -110,7 +110,7 @@ class v extends P {
|
|
|
110
110
|
*/
|
|
111
111
|
_updateProductsInRowVisibility() {
|
|
112
112
|
var p;
|
|
113
|
-
const t = s.getConfig(this.currentNode), o = (t.layout ||
|
|
113
|
+
const t = s.getConfig(this.currentNode), o = (t.layout || U(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, u = this._isMobilePreview();
|
|
114
114
|
this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE, o), this.api.setVisibility(e.MOBILE_LAYOUT_LABEL, o);
|
|
115
115
|
const d = o && !r, _ = o && r && !u, h = o && r && u;
|
|
116
116
|
this.api.setVisibility(e.PRODUCT_IN_ROW, d), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, d), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP, _), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP_LABEL, _), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, h), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, h);
|
|
@@ -125,7 +125,7 @@ class v extends P {
|
|
|
125
125
|
const t = s.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,7 +140,7 @@ class v extends P {
|
|
|
140
140
|
const i = s.getConfig(this.currentNode);
|
|
141
141
|
if (i.mobileLayoutEnabled === t)
|
|
142
142
|
return;
|
|
143
|
-
const o =
|
|
143
|
+
const o = A(this.currentNode);
|
|
144
144
|
if (t) {
|
|
145
145
|
const r = i.previousMobileCardsInRow || l;
|
|
146
146
|
s.updateConfig(
|
|
@@ -157,8 +157,8 @@ class v extends P {
|
|
|
157
157
|
mobileCardsInRow: r
|
|
158
158
|
},
|
|
159
159
|
{ triggerRefetch: !1 }
|
|
160
|
-
), o && C(this.api, o, !1),
|
|
161
|
-
const u = parseInt(i.size) || 6, d =
|
|
160
|
+
), o && C(this.api, o, !1), L(this.api);
|
|
161
|
+
const u = parseInt(i.size) || 6, d = b(this.store.recommendationProducts, u);
|
|
162
162
|
g({
|
|
163
163
|
currentNode: this.currentNode,
|
|
164
164
|
documentModifier: this.api.getDocumentModifier(),
|
|
@@ -189,29 +189,35 @@ class v extends P {
|
|
|
189
189
|
this._setFormValues(), this._updateProductsInRowVisibility();
|
|
190
190
|
}
|
|
191
191
|
_onProductsInRowChange(t) {
|
|
192
|
-
!this.currentNode || s.getConfig(this.currentNode).cardsInRow === t
|
|
192
|
+
if (!this.currentNode || s.getConfig(this.currentNode).cardsInRow === t)
|
|
193
|
+
return;
|
|
194
|
+
const o = t === 1 ? 0 : w;
|
|
195
|
+
s.updateConfig(
|
|
193
196
|
this.api,
|
|
194
197
|
this.currentNode,
|
|
195
|
-
{ cardsInRow: t },
|
|
198
|
+
{ cardsInRow: t, columnSpacing: o },
|
|
196
199
|
`Changed products per row to ${t}`
|
|
197
|
-
), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows()
|
|
200
|
+
), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows();
|
|
198
201
|
}
|
|
199
202
|
_onMobileCardsInRowChange(t) {
|
|
200
|
-
!this.currentNode || s.getConfig(this.currentNode).mobileCardsInRow === t
|
|
203
|
+
if (!this.currentNode || s.getConfig(this.currentNode).mobileCardsInRow === t)
|
|
204
|
+
return;
|
|
205
|
+
const o = t === 1 ? 0 : y;
|
|
206
|
+
s.updateConfig(
|
|
201
207
|
this.api,
|
|
202
208
|
this.currentNode,
|
|
203
|
-
{ mobileCardsInRow: t },
|
|
209
|
+
{ mobileCardsInRow: t, mobileColumnSpacing: o },
|
|
204
210
|
`Changed mobile products per row to ${t}`
|
|
205
|
-
),
|
|
211
|
+
), L(this.api), this.store.patchCurrentBlockConfig(
|
|
206
212
|
{ mobileCardsInRow: t },
|
|
207
213
|
{ triggerRefetch: !1 }
|
|
208
214
|
), I({
|
|
209
215
|
currentNode: this.currentNode,
|
|
210
216
|
documentModifier: this.api.getDocumentModifier()
|
|
211
|
-
})
|
|
217
|
+
});
|
|
212
218
|
}
|
|
213
219
|
_regenerateProductRows() {
|
|
214
|
-
const t = s.getConfig(this.currentNode), i = parseInt(t.size) || 6, o =
|
|
220
|
+
const t = s.getConfig(this.currentNode), i = parseInt(t.size) || 6, o = b(this.store.recommendationProducts, i);
|
|
215
221
|
g({
|
|
216
222
|
currentNode: this.currentNode,
|
|
217
223
|
documentModifier: this.api.getDocumentModifier(),
|
|
@@ -255,6 +261,6 @@ class v extends P {
|
|
|
255
261
|
}
|
|
256
262
|
}
|
|
257
263
|
export {
|
|
258
|
-
|
|
264
|
+
S as PRODUCT_LAYOUT_CONTROL_ID,
|
|
259
265
|
v as ProductLayoutControl
|
|
260
266
|
};
|