@useinsider/guido 2.0.0-beta.e73ba15 → 2.0.0-beta.edc1f0a
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/extensions/Blocks/Recommendation/constants/layout.js +9 -4
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +21 -41
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +37 -48
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +80 -39
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +22 -35
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +72 -70
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +71 -84
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +8 -4
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +16 -14
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +27 -16
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
- package/dist/extensions/Blocks/common-control.js +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +1 -5
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
- package/package.json +1 -1
|
@@ -1,112 +1,114 @@
|
|
|
1
1
|
import { ModificationDescription as s } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
import { CONTAINER_SELECTOR as
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
4
|
-
import { prepareProductRows as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { CONTAINER_SELECTOR as S } from "../../constants/selectors.js";
|
|
3
|
+
import { useRecommendationExtensionStore as A } from "../../store/recommendation.js";
|
|
4
|
+
import { prepareProductRows as b } from "../../templates/index.js";
|
|
5
|
+
import { hasGetStyle as d, isTdNode as C } from "../../utils/tagName.js";
|
|
6
|
+
import { DEFAULT_CARD_COMPOSITION as f, getDefaultProducts as h } from "../../templates/utils.js";
|
|
7
|
+
const m = "ins-recommendation-v3-block-v2";
|
|
8
|
+
function p(r) {
|
|
9
|
+
if (!r)
|
|
9
10
|
return null;
|
|
10
|
-
if ("getAttribute" in
|
|
11
|
-
const t =
|
|
12
|
-
if (t && t.includes(
|
|
13
|
-
return
|
|
11
|
+
if ("getAttribute" in r) {
|
|
12
|
+
const t = r.getAttribute("class");
|
|
13
|
+
if (t && t.includes(m))
|
|
14
|
+
return r;
|
|
14
15
|
}
|
|
15
|
-
return "querySelector" in
|
|
16
|
+
return "querySelector" in r ? r.querySelector(`.${m}`) : null;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
const t = p(
|
|
18
|
+
function g(r) {
|
|
19
|
+
const t = p(r);
|
|
19
20
|
return !t || !("getAttribute" in t) ? "vertical" : t.getAttribute("data-layout") === "horizontal" ? "horizontal" : "vertical";
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
const t = p(
|
|
22
|
+
function w(r) {
|
|
23
|
+
const t = p(r);
|
|
23
24
|
if (!t || !("getAttribute" in t))
|
|
24
|
-
return
|
|
25
|
-
const
|
|
26
|
-
return
|
|
25
|
+
return f;
|
|
26
|
+
const e = t.getAttribute("data-card-composition");
|
|
27
|
+
return e ? e.split(",").filter(Boolean) : f;
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
-
const { currentNode: t, documentModifier:
|
|
29
|
+
function I(r) {
|
|
30
|
+
const { currentNode: t, documentModifier: e, afterRegenerate: o } = r;
|
|
30
31
|
if (!t || !("querySelector" in t))
|
|
31
32
|
return;
|
|
32
|
-
const a = t.querySelector(
|
|
33
|
+
const a = t.querySelector(S);
|
|
33
34
|
if (!a)
|
|
34
35
|
return;
|
|
35
|
-
const
|
|
36
|
+
const n = A(), c = n.recommendationProducts.length > 0 ? n.recommendationProducts : h(), { cardsInRow: l } = n.recommendationConfigs, i = w(t), u = g(t), y = b(c, u, {
|
|
36
37
|
productsPerRow: l,
|
|
37
|
-
composition:
|
|
38
|
+
composition: i
|
|
38
39
|
});
|
|
39
|
-
|
|
40
|
+
e.modifyHtml(a).setInnerHtml(y).apply(new s("Updated product")), o == null || o();
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
let
|
|
42
|
+
function E(r, t, e, o) {
|
|
43
|
+
const n = `0 ${Math.floor(e / 2)}px`;
|
|
44
|
+
let c = !1;
|
|
44
45
|
return o === "vertical" ? Array.from(
|
|
45
|
-
|
|
46
|
-
).forEach((
|
|
47
|
-
t.modifyHtml(
|
|
46
|
+
r.querySelectorAll(".attribute-cell")
|
|
47
|
+
).forEach((i) => {
|
|
48
|
+
t.modifyHtml(i).setStyle("padding", n), c = !0;
|
|
48
49
|
}) : Array.from(
|
|
49
|
-
|
|
50
|
-
).forEach((
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
function E(e, t, r) {
|
|
55
|
-
const o = `${r}px`, a = Array.from(e.querySelectorAll(".spacer"));
|
|
56
|
-
let c = !1;
|
|
57
|
-
return a.forEach((i) => {
|
|
58
|
-
t.modifyHtml(i).setStyle("height", o), c = !0;
|
|
50
|
+
r.querySelectorAll(".product-card-wrapper")
|
|
51
|
+
).forEach((i) => {
|
|
52
|
+
const u = "parentNode" in i ? i.parentNode : null;
|
|
53
|
+
u && C(u) && (t.modifyHtml(u).setStyle("padding", n), c = !0);
|
|
59
54
|
}), c;
|
|
60
55
|
}
|
|
61
|
-
function
|
|
62
|
-
const
|
|
56
|
+
function k(r, t, e) {
|
|
57
|
+
const o = `${e}px`, a = Array.from(r.querySelectorAll(".spacer"));
|
|
58
|
+
let n = !1;
|
|
59
|
+
return a.forEach((c) => {
|
|
60
|
+
t.modifyHtml(c).setStyle("height", o), n = !0;
|
|
61
|
+
}), n;
|
|
62
|
+
}
|
|
63
|
+
function v(r) {
|
|
64
|
+
const { currentNode: t, documentModifier: e } = r;
|
|
63
65
|
if (!t)
|
|
64
66
|
return;
|
|
65
67
|
const o = p(t);
|
|
66
68
|
if (!o || !("getAttribute" in o))
|
|
67
69
|
return;
|
|
68
|
-
const a = o.getAttribute("data-column-spacing"),
|
|
70
|
+
const a = o.getAttribute("data-column-spacing"), n = o.getAttribute("data-row-spacing"), c = g(t);
|
|
69
71
|
let l = !1;
|
|
70
72
|
if (a) {
|
|
71
|
-
const
|
|
72
|
-
Number.isNaN(
|
|
73
|
+
const i = parseInt(a);
|
|
74
|
+
Number.isNaN(i) || (l = E(
|
|
73
75
|
t,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
e,
|
|
77
|
+
i,
|
|
78
|
+
c
|
|
77
79
|
));
|
|
78
80
|
}
|
|
79
|
-
if (
|
|
80
|
-
const
|
|
81
|
-
if (!Number.isNaN(
|
|
82
|
-
const u =
|
|
81
|
+
if (n) {
|
|
82
|
+
const i = parseInt(n);
|
|
83
|
+
if (!Number.isNaN(i)) {
|
|
84
|
+
const u = k(t, e, i);
|
|
83
85
|
l = l || u;
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
|
-
l &&
|
|
88
|
+
l && e.apply(new s("Reapply spacing after regeneration"));
|
|
87
89
|
}
|
|
88
|
-
function
|
|
89
|
-
if (!
|
|
90
|
+
function x(r) {
|
|
91
|
+
if (!r)
|
|
90
92
|
return null;
|
|
91
|
-
const t =
|
|
93
|
+
const t = r.querySelector(".product-card-segment"), e = r.querySelector(".product-card-wrapper");
|
|
92
94
|
let o = null;
|
|
93
|
-
return t &&
|
|
95
|
+
return t && d(t) && (o = t.getStyle("background-color") ?? null), (!o || o === "transparent") && e && d(e) && (o = e.getStyle("background-color") ?? null), o;
|
|
94
96
|
}
|
|
95
|
-
function
|
|
96
|
-
const { currentNode: t, documentModifier:
|
|
97
|
+
function O(r) {
|
|
98
|
+
const { currentNode: t, documentModifier: e, bgColor: o, layout: a } = r;
|
|
97
99
|
if (!o || o === "transparent" || !t)
|
|
98
100
|
return;
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}),
|
|
101
|
+
const n = a === "vertical" ? ".product-card-segment" : ".product-card-wrapper", c = Array.from(t.querySelectorAll(n));
|
|
102
|
+
c.length !== 0 && (c.forEach((l) => {
|
|
103
|
+
e.modifyHtml(l).setStyle("background-color", o);
|
|
104
|
+
}), e.apply(new s("Apply card background color")));
|
|
103
105
|
}
|
|
104
106
|
export {
|
|
105
|
-
|
|
107
|
+
O as applyCardBackgroundColor,
|
|
106
108
|
p as getBlockElement,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
w as getCardComposition,
|
|
110
|
+
x as getCurrentCardBackgroundColor,
|
|
111
|
+
g as getCurrentLayout,
|
|
112
|
+
v as reapplySpacing,
|
|
113
|
+
I as regenerateProductRows
|
|
112
114
|
};
|
|
@@ -5,7 +5,7 @@ import { RecommendationControlId as d } from "../../constants/controlIds.js";
|
|
|
5
5
|
import { CONTAINER_SELECTOR as T } from "../../constants/selectors.js";
|
|
6
6
|
import { preserveTextStyles as f } from "../../utils/preserveTextStyles.js";
|
|
7
7
|
const i = "data-text-before", u = "", p = ".omnibus-text-before";
|
|
8
|
-
class
|
|
8
|
+
class g extends l {
|
|
9
9
|
getId() {
|
|
10
10
|
return d.OMNIBUS_DISCOUNT_TEXT_BEFORE;
|
|
11
11
|
}
|
|
@@ -64,10 +64,10 @@ class B extends l {
|
|
|
64
64
|
}
|
|
65
65
|
_listenToFormUpdates() {
|
|
66
66
|
this.api.onValueChanged("omnibusDiscountTextBefore", (e) => {
|
|
67
|
-
this._onTextChange(e);
|
|
67
|
+
typeof e == "string" && this._onTextChange(e);
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
export {
|
|
72
|
-
|
|
72
|
+
g as OmnibusDiscountTextBeforeControl
|
|
73
73
|
};
|
|
@@ -1,78 +1,67 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { ModificationDescription as
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var G = (o, i, t) => i in o ? P(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
|
|
3
|
+
var l = (o, i, t) => G(o, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
+
import { ModificationDescription as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as I } from "../../../common-control.js";
|
|
6
|
+
import { SPACING_STEP as N, MAX_SPACING as _, MIN_SPACING as f, DEFAULT_COLUMN_SPACING as c, DEFAULT_ROW_SPACING as b } from "../../constants/layout.js";
|
|
7
|
+
import { useRecommendationExtensionStore as L } from "../../store/recommendation.js";
|
|
8
|
+
import { safeGetStyle as d, safeGetParent as V } from "../../utils/tagName.js";
|
|
9
|
+
import { getCurrentLayout as m } from "../main/utils.js";
|
|
10
|
+
import { useDebounceFn as y } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
11
|
+
const w = "recommendation-spacing-control", s = {
|
|
9
12
|
COLUMN_SPACING: "columnSpacing",
|
|
10
13
|
COLUMN_SPACING_LABEL: "columnSpacingLabel",
|
|
11
14
|
ROW_SPACING: "rowSpacing"
|
|
12
|
-
},
|
|
15
|
+
}, A = {
|
|
13
16
|
COLUMN_SPACING: "data-column-spacing",
|
|
14
17
|
ROW_SPACING: "data-row-spacing"
|
|
15
|
-
}, s = {
|
|
16
|
-
COLUMN_SPACING: 10,
|
|
17
|
-
// 5px on each side = 10px total
|
|
18
|
-
ROW_SPACING: 20
|
|
19
|
-
}, u = {
|
|
20
|
-
MIN_SPACING: 0,
|
|
21
|
-
MAX_SPACING: 50,
|
|
22
|
-
STEP: 5
|
|
23
18
|
};
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
function I(n) {
|
|
28
|
-
return !n || !("parent" in n) || typeof n.parent != "function" ? null : n.parent();
|
|
29
|
-
}
|
|
30
|
-
function C(n, i) {
|
|
31
|
-
if (!n)
|
|
19
|
+
function h(o, i) {
|
|
20
|
+
if (!o)
|
|
32
21
|
return i;
|
|
33
|
-
const t = parseFloat(
|
|
22
|
+
const t = parseFloat(o);
|
|
34
23
|
return Number.isNaN(t) ? i : t;
|
|
35
24
|
}
|
|
36
|
-
class
|
|
25
|
+
class q extends I {
|
|
37
26
|
constructor() {
|
|
38
27
|
super(...arguments);
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
l(this, "store", L());
|
|
29
|
+
l(this, "unsubscribeOrientation", null);
|
|
41
30
|
/**
|
|
42
31
|
* Debounced version of _onColumnSpacingChange
|
|
43
32
|
* Prevents excessive DOM updates when user rapidly adjusts the counter
|
|
44
33
|
*/
|
|
45
|
-
|
|
34
|
+
l(this, "_debouncedOnColumnSpacingChange", y((t) => {
|
|
46
35
|
this._onColumnSpacingChange(t);
|
|
47
36
|
}, 300));
|
|
48
37
|
/**
|
|
49
38
|
* Debounced version of _onRowSpacingChange
|
|
50
39
|
* Prevents excessive DOM updates when user rapidly adjusts the counter
|
|
51
40
|
*/
|
|
52
|
-
|
|
41
|
+
l(this, "_debouncedOnRowSpacingChange", y((t) => {
|
|
53
42
|
this._onRowSpacingChange(t);
|
|
54
43
|
}, 300));
|
|
55
44
|
}
|
|
56
45
|
getId() {
|
|
57
|
-
return
|
|
46
|
+
return w;
|
|
58
47
|
}
|
|
59
48
|
getTemplate() {
|
|
60
49
|
return `
|
|
61
50
|
<div class="spacing-control-container">
|
|
62
51
|
${this._GuTwoColumns([
|
|
63
|
-
this._GuLabel({ text: "Column Spacing (px)", name:
|
|
52
|
+
this._GuLabel({ text: "Column Spacing (px)", name: s.COLUMN_SPACING_LABEL }),
|
|
64
53
|
this._GuCounter({
|
|
65
|
-
name:
|
|
66
|
-
minValue:
|
|
67
|
-
maxValue:
|
|
68
|
-
step:
|
|
54
|
+
name: s.COLUMN_SPACING,
|
|
55
|
+
minValue: f,
|
|
56
|
+
maxValue: _,
|
|
57
|
+
step: N
|
|
69
58
|
}),
|
|
70
59
|
this._GuLabel({ text: "Row Spacing (px)" }),
|
|
71
60
|
this._GuCounter({
|
|
72
|
-
name:
|
|
73
|
-
minValue:
|
|
74
|
-
maxValue:
|
|
75
|
-
step:
|
|
61
|
+
name: s.ROW_SPACING,
|
|
62
|
+
minValue: f,
|
|
63
|
+
maxValue: _,
|
|
64
|
+
step: N
|
|
76
65
|
})
|
|
77
66
|
])}
|
|
78
67
|
</div>
|
|
@@ -84,14 +73,8 @@ class w extends b {
|
|
|
84
73
|
onTemplateNodeUpdated(t) {
|
|
85
74
|
super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateColumnSpacingVisibility();
|
|
86
75
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
*/
|
|
90
|
-
_getCurrentLayout() {
|
|
91
|
-
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
92
|
-
return "vertical";
|
|
93
|
-
const t = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
|
|
94
|
-
return !t || !("getAttribute" in t) ? "vertical" : t.getAttribute("data-layout") === "horizontal" ? "horizontal" : "vertical";
|
|
76
|
+
onDestroy() {
|
|
77
|
+
this.unsubscribeOrientation && (this.unsubscribeOrientation(), this.unsubscribeOrientation = null);
|
|
95
78
|
}
|
|
96
79
|
/**
|
|
97
80
|
* Updates column spacing visibility based on layout orientation
|
|
@@ -99,17 +82,21 @@ class w extends b {
|
|
|
99
82
|
* Reads from store first for reliability, falls back to DOM
|
|
100
83
|
*/
|
|
101
84
|
_updateColumnSpacingVisibility() {
|
|
102
|
-
|
|
103
|
-
|
|
85
|
+
if (!this.api)
|
|
86
|
+
return;
|
|
87
|
+
const n = (this.store.recommendationConfigs.orientation || m(this.currentNode)) === "vertical";
|
|
88
|
+
this.api.setVisibility(s.COLUMN_SPACING, n), this.api.setVisibility(s.COLUMN_SPACING_LABEL, n);
|
|
104
89
|
}
|
|
105
90
|
/**
|
|
106
91
|
* Reads spacing values from data attributes or returns defaults
|
|
107
92
|
*/
|
|
108
93
|
_setFormValues() {
|
|
94
|
+
if (!this.api)
|
|
95
|
+
return;
|
|
109
96
|
const t = this._getStoredColumnSpacing(), e = this._getStoredRowSpacing();
|
|
110
97
|
this.api.updateValues({
|
|
111
|
-
[
|
|
112
|
-
[
|
|
98
|
+
[s.COLUMN_SPACING]: t,
|
|
99
|
+
[s.ROW_SPACING]: e
|
|
113
100
|
});
|
|
114
101
|
}
|
|
115
102
|
/**
|
|
@@ -120,28 +107,28 @@ class w extends b {
|
|
|
120
107
|
*/
|
|
121
108
|
_getStoredColumnSpacing() {
|
|
122
109
|
if (!this.currentNode)
|
|
123
|
-
return
|
|
124
|
-
if (this.
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
127
|
-
return
|
|
128
|
-
const
|
|
129
|
-
return
|
|
110
|
+
return c;
|
|
111
|
+
if (m(this.currentNode) === "vertical") {
|
|
112
|
+
const r = this.currentNode.querySelector(".recommendation-attribute-row"), O = r == null ? void 0 : r.querySelector("td"), S = d(O, "padding");
|
|
113
|
+
if (!S)
|
|
114
|
+
return c;
|
|
115
|
+
const C = S.trim().split(/\s+/);
|
|
116
|
+
return C.length < 2 ? c : h(C[1], c / 2) * 2;
|
|
130
117
|
}
|
|
131
|
-
const e = this.currentNode.querySelector(".product-card-wrapper"),
|
|
132
|
-
if (!
|
|
133
|
-
return
|
|
134
|
-
const
|
|
135
|
-
return
|
|
118
|
+
const e = this.currentNode.querySelector(".product-card-wrapper"), n = V(e), u = d(n, "padding");
|
|
119
|
+
if (!u)
|
|
120
|
+
return c;
|
|
121
|
+
const a = u.trim().split(/\s+/);
|
|
122
|
+
return a.length < 2 ? c : h(a[1], c / 2) * 2;
|
|
136
123
|
}
|
|
137
124
|
/**
|
|
138
125
|
* Gets stored row spacing from the first spacer element's height style
|
|
139
126
|
*/
|
|
140
127
|
_getStoredRowSpacing() {
|
|
141
128
|
if (!this.currentNode)
|
|
142
|
-
return
|
|
143
|
-
const t = this.currentNode.querySelector(".spacer"), e =
|
|
144
|
-
return
|
|
129
|
+
return b;
|
|
130
|
+
const t = this.currentNode.querySelector(".spacer"), e = d(t, "height");
|
|
131
|
+
return h(e, b);
|
|
145
132
|
}
|
|
146
133
|
/**
|
|
147
134
|
* Handles column spacing changes.
|
|
@@ -152,16 +139,16 @@ class w extends b {
|
|
|
152
139
|
if (!this.currentNode)
|
|
153
140
|
return;
|
|
154
141
|
this._storeColumnSpacing(t);
|
|
155
|
-
const e = this.
|
|
142
|
+
const e = m(this.currentNode), n = this.api.getDocumentModifier(), a = `0 ${t / 2}px`;
|
|
156
143
|
e === "vertical" ? Array.from(
|
|
157
144
|
this.currentNode.querySelectorAll(".attribute-cell")
|
|
158
|
-
).forEach((
|
|
159
|
-
|
|
145
|
+
).forEach((r) => {
|
|
146
|
+
n.modifyHtml(r).setStyle("padding", a);
|
|
160
147
|
}) : Array.from(
|
|
161
148
|
this.currentNode.querySelectorAll(".product-card-wrapper")
|
|
162
|
-
).forEach((
|
|
163
|
-
"parent" in
|
|
164
|
-
}),
|
|
149
|
+
).forEach((r) => {
|
|
150
|
+
"parent" in r && r.parent() && n.modifyHtml(r.parent()).setStyle("padding", a);
|
|
151
|
+
}), n.apply(new p(`Update column spacing to ${t}px`));
|
|
165
152
|
}
|
|
166
153
|
/**
|
|
167
154
|
* Handles row spacing changes
|
|
@@ -176,10 +163,10 @@ class w extends b {
|
|
|
176
163
|
);
|
|
177
164
|
if (!e.length)
|
|
178
165
|
return;
|
|
179
|
-
const
|
|
180
|
-
e.forEach((
|
|
181
|
-
|
|
182
|
-
}),
|
|
166
|
+
const n = this.api.getDocumentModifier(), u = `${t}px`;
|
|
167
|
+
e.forEach((a) => {
|
|
168
|
+
n.modifyHtml(a).setStyle("height", u);
|
|
169
|
+
}), n.apply(new p(`Update row spacing to ${t}px`));
|
|
183
170
|
}
|
|
184
171
|
/**
|
|
185
172
|
* Stores column spacing value in block data attribute
|
|
@@ -188,7 +175,7 @@ class w extends b {
|
|
|
188
175
|
if (!this.currentNode)
|
|
189
176
|
return;
|
|
190
177
|
const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
|
|
191
|
-
e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(
|
|
178
|
+
e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(A.COLUMN_SPACING, t.toString()).apply(new p("Store column spacing"));
|
|
192
179
|
}
|
|
193
180
|
/**
|
|
194
181
|
* Stores row spacing value in block data attribute
|
|
@@ -197,13 +184,13 @@ class w extends b {
|
|
|
197
184
|
if (!this.currentNode)
|
|
198
185
|
return;
|
|
199
186
|
const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
|
|
200
|
-
e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(
|
|
187
|
+
e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(A.ROW_SPACING, t.toString()).apply(new p("Store row spacing"));
|
|
201
188
|
}
|
|
202
189
|
_listenToFormUpdates() {
|
|
203
|
-
this.api.onValueChanged(
|
|
190
|
+
this.api.onValueChanged(s.COLUMN_SPACING, (t) => {
|
|
204
191
|
const e = parseInt(t);
|
|
205
192
|
Number.isNaN(e) || this._debouncedOnColumnSpacingChange(e);
|
|
206
|
-
}), this.api.onValueChanged(
|
|
193
|
+
}), this.api.onValueChanged(s.ROW_SPACING, (t) => {
|
|
207
194
|
const e = parseInt(t);
|
|
208
195
|
Number.isNaN(e) || this._debouncedOnRowSpacingChange(e);
|
|
209
196
|
});
|
|
@@ -219,6 +206,6 @@ class w extends b {
|
|
|
219
206
|
}
|
|
220
207
|
}
|
|
221
208
|
export {
|
|
222
|
-
|
|
223
|
-
|
|
209
|
+
w as SPACING_CONTROL_ID,
|
|
210
|
+
q as SpacingControl
|
|
224
211
|
};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
const n = `/* Utils */
|
|
2
2
|
.es-180w { width: 180px; }
|
|
3
3
|
|
|
4
|
-
/* Recommendation Controls */
|
|
5
|
-
.recommendation-controls-container >
|
|
6
|
-
|
|
4
|
+
/* Recommendation Controls - Main settings panel separators */
|
|
5
|
+
.recommendation-controls-container > div {
|
|
6
|
+
border-bottom: 1px solid #e0e0e0;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.recommendation-controls-container >
|
|
9
|
+
.recommendation-controls-container > div:first-child {
|
|
10
10
|
padding-top: 0;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.recommendation-controls-container > div:last-child {
|
|
14
|
+
border-bottom: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
.container:has(.recommendation-controls-container) {
|
|
14
18
|
padding: 0
|
|
15
19
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { RecommendationFeedSourceMaps as u, PriceAttributes as c } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
2
|
import { useRecommendationApi as p } from "../../../../services/recommendationApi.js";
|
|
3
3
|
import { useConfigStore as m } from "../../../../stores/config.js";
|
|
4
|
-
import { defineStore as
|
|
5
|
-
import { DEFAULT_CARDS_IN_ROW as
|
|
4
|
+
import { defineStore as f } from "pinia";
|
|
5
|
+
import { DEFAULT_CARDS_IN_ROW as d } from "../constants/layout.js";
|
|
6
6
|
import { generateCompleteFilterQuery as l } from "../utils/filterUtil.js";
|
|
7
|
-
const
|
|
7
|
+
const s = p(), g = () => ({
|
|
8
8
|
recommendationCampaignUrls: {},
|
|
9
9
|
recommendationProducts: [],
|
|
10
10
|
recommendationConfigs: {
|
|
11
|
-
cardsInRow:
|
|
11
|
+
cardsInRow: d,
|
|
12
12
|
currencySettings: {
|
|
13
13
|
name: "USD",
|
|
14
14
|
value: "USD",
|
|
@@ -135,7 +135,7 @@ const n = p(), g = () => ({
|
|
|
135
135
|
filterSelectionDrawerStatus: !1,
|
|
136
136
|
filterList: {},
|
|
137
137
|
filterGroup: 1
|
|
138
|
-
}), S =
|
|
138
|
+
}), S = f("guidoRecommendationExtension", {
|
|
139
139
|
state: () => g(),
|
|
140
140
|
getters: {
|
|
141
141
|
hasFilters: (e) => !!e.recommendationConfigs.filters.length,
|
|
@@ -179,13 +179,13 @@ const n = p(), g = () => ({
|
|
|
179
179
|
activePredictiveAlgorithms: e,
|
|
180
180
|
languages: t,
|
|
181
181
|
currencies: r
|
|
182
|
-
} = await
|
|
182
|
+
} = await s.fetchRecommendationCreateData();
|
|
183
183
|
this.activePredictiveAlgorithms = e, this.languages = t;
|
|
184
184
|
const [i] = r;
|
|
185
185
|
this.recommendationConfigs.currencySettings.name = i.text, this.recommendationConfigs.currencySettings.value = i.value, this.currencyList = r, this.filterStatus = !!this.recommendationConfigs.filters.length;
|
|
186
186
|
},
|
|
187
187
|
async fetchRecommendationFilters() {
|
|
188
|
-
const e = await
|
|
188
|
+
const e = await s.fetchRecommendationFilters();
|
|
189
189
|
this.filterList = e;
|
|
190
190
|
},
|
|
191
191
|
addFilterGroup(e) {
|
|
@@ -225,13 +225,15 @@ const n = p(), g = () => ({
|
|
|
225
225
|
}
|
|
226
226
|
},
|
|
227
227
|
addFilter(e) {
|
|
228
|
-
const t = [...this.recommendationConfigs.filters],
|
|
229
|
-
|
|
228
|
+
const t = [...this.recommendationConfigs.filters], i = t.filter(
|
|
229
|
+
(a) => a.filterGroup === e.filterGroup
|
|
230
|
+
).length + 1, o = t.findLastIndex((a) => a.filterGroup === e.filterGroup);
|
|
231
|
+
o !== -1 ? t.splice(o + 1, 0, {
|
|
230
232
|
...e,
|
|
231
|
-
filterNumber:
|
|
233
|
+
filterNumber: i
|
|
232
234
|
}) : t.push({
|
|
233
235
|
...e,
|
|
234
|
-
filterNumber:
|
|
236
|
+
filterNumber: i
|
|
235
237
|
}), this.$patch({
|
|
236
238
|
recommendationConfigs: {
|
|
237
239
|
filters: t
|
|
@@ -242,11 +244,11 @@ const n = p(), g = () => ({
|
|
|
242
244
|
return l(this.recommendationConfigs.filters);
|
|
243
245
|
},
|
|
244
246
|
async fetchRecommendationProducts() {
|
|
245
|
-
var
|
|
246
|
-
const e = this.recommendationConfigs.filters.filter((
|
|
247
|
+
var a;
|
|
248
|
+
const e = this.recommendationConfigs.filters.filter((n) => n.isValid), t = l(e), r = ((a = u.find((n) => n.key === this.recommendationConfigs.strategy)) == null ? void 0 : a.path) || "", i = m(), o = await s.fetchRecommendationProducts(
|
|
247
249
|
r,
|
|
248
250
|
{
|
|
249
|
-
//
|
|
251
|
+
// Note: {itemId} and {campaignId} are template placeholders replaced at runtime
|
|
250
252
|
locale: this.recommendationConfigs.language,
|
|
251
253
|
currency: this.recommendationConfigs.currencySettings.value,
|
|
252
254
|
partnerName: i.partnerName,
|
|
@@ -1,25 +1,36 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
1
|
+
function p(t) {
|
|
2
|
+
const r = {
|
|
3
|
+
"&": "&",
|
|
4
|
+
"<": "<",
|
|
5
|
+
">": ">",
|
|
6
|
+
'"': """,
|
|
7
|
+
"'": "'"
|
|
8
|
+
};
|
|
9
|
+
return t.replace(/[&<>"']/g, (n) => r[n]);
|
|
3
10
|
}
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
function m(t) {
|
|
12
|
+
return "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML() : "innerHTML" in t ? t.innerHTML : "";
|
|
13
|
+
}
|
|
14
|
+
function T(t, r) {
|
|
15
|
+
const n = p(r);
|
|
16
|
+
if (!t)
|
|
17
|
+
return n;
|
|
18
|
+
const e = m(t);
|
|
19
|
+
if (!e || e.trim() === "" || !/<(strong|em|u|s|b|i)\b/i.test(e))
|
|
20
|
+
return n;
|
|
21
|
+
const i = [], o = [];
|
|
22
|
+
let c = e.trim();
|
|
12
23
|
for (; ; ) {
|
|
13
|
-
const u =
|
|
24
|
+
const u = c.match(/^<(strong|em|u|s|b|i)(\s[^>]*)?>(.*)$/is);
|
|
14
25
|
if (!u)
|
|
15
26
|
break;
|
|
16
|
-
const [,
|
|
17
|
-
if (!
|
|
27
|
+
const [, s, f = "", g] = u, a = new RegExp(`</${s}>$`, "i");
|
|
28
|
+
if (!a.test(g))
|
|
18
29
|
break;
|
|
19
|
-
i.push(`<${
|
|
30
|
+
i.push(`<${s}${f}>`), o.unshift(`</${s}>`), c = g.replace(a, "").trim();
|
|
20
31
|
}
|
|
21
|
-
return i.length > 0 ? i.join("") +
|
|
32
|
+
return i.length > 0 ? i.join("") + n + o.join("") : n;
|
|
22
33
|
}
|
|
23
34
|
export {
|
|
24
|
-
|
|
35
|
+
T as preserveTextStyles
|
|
25
36
|
};
|