@useinsider/guido 2.0.0-beta.3f24769 → 2.0.0-beta.4178f89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/config/schemas.js +53 -39
- package/dist/components/organisms/email-preview/amp/AmpToggle.vue.js +2 -2
- package/dist/components/organisms/header/RightSlot.vue2.js +10 -10
- package/dist/composables/useConfig.js +29 -27
- package/dist/composables/useSave.js +13 -11
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +7 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +21 -41
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +48 -53
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +78 -50
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +16 -15
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +31 -39
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +17 -14
- package/dist/extensions/Blocks/Recommendation/templates/index.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/vertical/template.js +17 -16
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +27 -16
- package/dist/extensions/Blocks/Unsubscribe/extension.js +9 -9
- package/dist/extensions/Blocks/common-control.js +6 -7
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/index.d.ts +2 -2
- package/dist/src/@types/config/schemas.d.ts +26 -0
- package/dist/src/@types/config/types.d.ts +7 -1
- package/dist/src/composables/useConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +17 -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 +6 -17
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +0 -5
- package/dist/src/extensions/Blocks/common-control.d.ts +1 -1
- package/dist/src/stores/config.d.ts +147 -1
- package/dist/static/styles/components/button.css.js +1 -1
- package/dist/stores/config.js +7 -0
- package/package.json +1 -1
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (a,
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var f = (a, s, t) => s in a ? C(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
|
|
3
|
+
var c = (a, s, t) => f(a, typeof s != "symbol" ? s + "" : s, t);
|
|
4
4
|
import { ModificationDescription as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { ATTR_PRODUCT_IMAGE as
|
|
7
|
-
import { useRecommendationExtensionStore as
|
|
8
|
-
|
|
5
|
+
import { CommonControl as O } from "../../../common-control.js";
|
|
6
|
+
import { ATTR_PRODUCT_IMAGE as g, ATTR_PRODUCT_NAME as R, ATTR_PRODUCT_PRICE as A, ATTR_PRODUCT_OLD_PRICE as N, ATTR_PRODUCT_OMNIBUS_PRICE as D, ATTR_PRODUCT_OMNIBUS_DISCOUNT as E, ATTR_PRODUCT_BUTTON as I } from "../../constants/selectors.js";
|
|
7
|
+
import { useRecommendationExtensionStore as V } from "../../store/recommendation.js";
|
|
8
|
+
import { getCurrentLayout as P } from "../main/utils.js";
|
|
9
|
+
const S = "ui-elements-recommendation-card-composition", k = {
|
|
9
10
|
ORDERABLE: "cardComposition"
|
|
10
|
-
}, b = ".recommendation-attribute-row",
|
|
11
|
-
{ key:
|
|
12
|
-
{ key:
|
|
13
|
-
{ key:
|
|
11
|
+
}, b = ".recommendation-attribute-row", v = ".product-card-wrapper > tbody", T = "data-card-composition", p = "data-attribute-type", y = "data-visibility", n = [
|
|
12
|
+
{ key: g, label: "Product Image", visible: !0 },
|
|
13
|
+
{ key: R, label: "Product Name", visible: !0 },
|
|
14
|
+
{ key: A, label: "Product Price", visible: !0 },
|
|
14
15
|
{ key: N, label: "Product Original Price", visible: !0 },
|
|
15
|
-
{ key:
|
|
16
|
-
{ key:
|
|
17
|
-
{ key:
|
|
16
|
+
{ key: D, label: "Omnibus Price", visible: !1 },
|
|
17
|
+
{ key: E, label: "Omnibus Discount", visible: !1 },
|
|
18
|
+
{ key: I, label: "Product Button", visible: !0 }
|
|
18
19
|
];
|
|
19
|
-
class
|
|
20
|
+
class q extends O {
|
|
20
21
|
constructor() {
|
|
21
22
|
super(...arguments);
|
|
22
|
-
c(this, "store",
|
|
23
|
+
c(this, "store", V());
|
|
23
24
|
c(this, "unsubscribeOrientation", null);
|
|
24
25
|
}
|
|
25
26
|
getId() {
|
|
26
|
-
return
|
|
27
|
+
return S;
|
|
27
28
|
}
|
|
28
29
|
getTemplate() {
|
|
29
|
-
const t =
|
|
30
|
+
const t = n.map((e) => ({
|
|
30
31
|
key: e.key,
|
|
31
32
|
label: e.label,
|
|
32
33
|
content: this._createItemContent(e.label, e.key)
|
|
@@ -34,7 +35,7 @@ class x extends g {
|
|
|
34
35
|
return `
|
|
35
36
|
<div class="container" data-card-composition-control>
|
|
36
37
|
${this._GuLabel({ text: "Card Element Order & Visibility" })}
|
|
37
|
-
${this._GuOrderable(
|
|
38
|
+
${this._GuOrderable(k.ORDERABLE, t)}
|
|
38
39
|
</div>
|
|
39
40
|
`;
|
|
40
41
|
}
|
|
@@ -62,7 +63,7 @@ class x extends g {
|
|
|
62
63
|
_registerValueChangeListeners() {
|
|
63
64
|
this.api.onValueChanged("cardComposition", (t) => {
|
|
64
65
|
this._applyCompositionToBlock(t);
|
|
65
|
-
}),
|
|
66
|
+
}), n.forEach((t) => {
|
|
66
67
|
this.api.onValueChanged(`visibility_${t.key}`, (e) => {
|
|
67
68
|
this._applyVisibilityToBlock(t.key, e);
|
|
68
69
|
});
|
|
@@ -84,15 +85,15 @@ class x extends g {
|
|
|
84
85
|
*/
|
|
85
86
|
_readCompositionFromNode() {
|
|
86
87
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
87
|
-
return
|
|
88
|
-
const t = this.currentNode.getAttribute(
|
|
89
|
-
return t ? t.split(",").filter(Boolean) :
|
|
88
|
+
return n.map((e) => e.key);
|
|
89
|
+
const t = this.currentNode.getAttribute(T);
|
|
90
|
+
return t ? t.split(",").filter(Boolean) : n.map((e) => e.key);
|
|
90
91
|
}
|
|
91
92
|
/**
|
|
92
93
|
* Builds visibility values object from the visibility map
|
|
93
94
|
*/
|
|
94
95
|
_buildVisibilityValues(t) {
|
|
95
|
-
return
|
|
96
|
+
return n.reduce((e, i) => (e[`visibility_${i.key}`] = t[i.key] ?? !0, e), {});
|
|
96
97
|
}
|
|
97
98
|
/**
|
|
98
99
|
* Read visibility state from individual row elements' data-visibility attributes
|
|
@@ -108,7 +109,7 @@ class x extends g {
|
|
|
108
109
|
* Returns default visibility values for all items
|
|
109
110
|
*/
|
|
110
111
|
_getDefaultVisibilities() {
|
|
111
|
-
return
|
|
112
|
+
return n.reduce((t, e) => (t[e.key] = e.visible, t), {});
|
|
112
113
|
}
|
|
113
114
|
/**
|
|
114
115
|
* Extracts visibility values from DOM nodes
|
|
@@ -118,8 +119,8 @@ class x extends g {
|
|
|
118
119
|
return t.forEach((i) => {
|
|
119
120
|
if (!("getAttribute" in i))
|
|
120
121
|
return;
|
|
121
|
-
const
|
|
122
|
-
|
|
122
|
+
const r = i.getAttribute(p), o = i.getAttribute(y);
|
|
123
|
+
r && o !== null && (e[r] = this._parseVisibilityValue(o));
|
|
123
124
|
}), e;
|
|
124
125
|
}
|
|
125
126
|
/**
|
|
@@ -133,7 +134,7 @@ class x extends g {
|
|
|
133
134
|
* Merges extracted visibilities with default values for missing keys
|
|
134
135
|
*/
|
|
135
136
|
_mergeWithDefaults(t) {
|
|
136
|
-
return
|
|
137
|
+
return n.forEach((e) => {
|
|
137
138
|
e.key in t || (t[e.key] = e.visible);
|
|
138
139
|
}), t;
|
|
139
140
|
}
|
|
@@ -146,7 +147,7 @@ class x extends g {
|
|
|
146
147
|
if (!this.currentNode)
|
|
147
148
|
return;
|
|
148
149
|
const e = this._getCurrentLayout();
|
|
149
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(
|
|
150
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(T, t.join(",")).apply(new d("Update card composition")), e === "vertical" && this._reorderProductAttributes(t);
|
|
150
151
|
}
|
|
151
152
|
/**
|
|
152
153
|
* Reorders attribute rows within each product card based on composition order
|
|
@@ -155,22 +156,22 @@ class x extends g {
|
|
|
155
156
|
_reorderProductAttributes(t) {
|
|
156
157
|
if (!this.currentNode)
|
|
157
158
|
return;
|
|
158
|
-
const e = this.currentNode.querySelectorAll(
|
|
159
|
+
const e = this.currentNode.querySelectorAll(v);
|
|
159
160
|
if (!(e != null && e.length))
|
|
160
161
|
return;
|
|
161
162
|
const i = this.api.getDocumentModifier();
|
|
162
|
-
e.forEach((
|
|
163
|
-
const
|
|
164
|
-
i.modifyHtml(
|
|
163
|
+
e.forEach((r) => {
|
|
164
|
+
const o = this._buildCompositionHtml(r, t);
|
|
165
|
+
i.modifyHtml(r).setInnerHtml(o);
|
|
165
166
|
}), i.apply(new d("Reorder product attributes"));
|
|
166
167
|
}
|
|
167
168
|
/**
|
|
168
169
|
* Builds HTML string with attributes ordered according to composition
|
|
169
170
|
*/
|
|
170
171
|
_buildCompositionHtml(t, e) {
|
|
171
|
-
return e.reduce((i,
|
|
172
|
-
const
|
|
173
|
-
return
|
|
172
|
+
return e.reduce((i, r) => {
|
|
173
|
+
const o = t.querySelector(`${b}[${p}="${r}"]`);
|
|
174
|
+
return o && "getOuterHTML" in o ? i + o.getOuterHTML() : i;
|
|
174
175
|
}, "");
|
|
175
176
|
}
|
|
176
177
|
/**
|
|
@@ -185,7 +186,7 @@ class x extends g {
|
|
|
185
186
|
const i = this.currentNode.querySelectorAll(`${b}[${p}="${t}"]`);
|
|
186
187
|
if (!(i != null && i.length))
|
|
187
188
|
return;
|
|
188
|
-
const
|
|
189
|
+
const r = e ? "1" : "0", o = `Set ${t} visibility to ${e ? "visible" : "hidden"}`, m = this.api.getDocumentModifier();
|
|
189
190
|
i.forEach((l) => {
|
|
190
191
|
let u = "TR";
|
|
191
192
|
if ("tagName" in l && l.tagName)
|
|
@@ -194,21 +195,15 @@ class x extends g {
|
|
|
194
195
|
const _ = l;
|
|
195
196
|
typeof _.getTagName == "function" && (u = _.getTagName().toUpperCase());
|
|
196
197
|
}
|
|
197
|
-
const
|
|
198
|
-
m.modifyHtml(l).setStyle("display",
|
|
199
|
-
}), m.apply(new d(
|
|
198
|
+
const h = e ? u === "TD" || u === "BLOCK_IMAGE" || u === "BLOCK_BUTTON" ? "table-cell" : "table-row" : "none";
|
|
199
|
+
m.modifyHtml(l).setStyle("display", h).setAttribute(y, r);
|
|
200
|
+
}), m.apply(new d(o));
|
|
200
201
|
}
|
|
201
202
|
/**
|
|
202
203
|
* Gets the current layout orientation from store or DOM
|
|
203
204
|
*/
|
|
204
205
|
_getCurrentLayout() {
|
|
205
|
-
|
|
206
|
-
if (t)
|
|
207
|
-
return t;
|
|
208
|
-
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
209
|
-
return "vertical";
|
|
210
|
-
const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
|
|
211
|
-
return !e || !("getAttribute" in e) ? "vertical" : e.getAttribute("data-layout") === "horizontal" ? "horizontal" : "vertical";
|
|
206
|
+
return this.store.recommendationConfigs.orientation || P(this.currentNode);
|
|
212
207
|
}
|
|
213
208
|
/**
|
|
214
209
|
* Updates orderable state based on layout orientation
|
|
@@ -218,11 +213,11 @@ class x extends g {
|
|
|
218
213
|
const e = this._getCurrentLayout() === "horizontal", i = this.getContainer();
|
|
219
214
|
if (!i)
|
|
220
215
|
return;
|
|
221
|
-
const
|
|
222
|
-
if (!
|
|
216
|
+
const r = i.querySelector("[data-card-composition-control]");
|
|
217
|
+
if (!r)
|
|
223
218
|
return;
|
|
224
|
-
const
|
|
225
|
-
|
|
219
|
+
const o = r.querySelector("ue-orderable");
|
|
220
|
+
o && o.classList.toggle("orderable-disabled", e);
|
|
226
221
|
}
|
|
227
222
|
/**
|
|
228
223
|
* Subscribe to store orientation changes
|
|
@@ -238,6 +233,6 @@ class x extends g {
|
|
|
238
233
|
}
|
|
239
234
|
}
|
|
240
235
|
export {
|
|
241
|
-
|
|
242
|
-
|
|
236
|
+
S as COMPOSITION_CONTROL_BLOCK_ID,
|
|
237
|
+
q as RecommendationCardCompositionControl
|
|
243
238
|
};
|
|
@@ -1,40 +1,54 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var c = (n, r, o) => r in n ? a(n, r, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[r] = o;
|
|
3
|
+
var e = (n, r, o) => c(n, typeof r != "symbol" ? r + "" : r, o);
|
|
4
4
|
import { CommonControl as m } from "../../../common-control.js";
|
|
5
|
-
import { useRecommendationExtensionStore as
|
|
6
|
-
import { AlgorithmControl as
|
|
7
|
-
import { ALGORITHM_CONTROL_ID as
|
|
8
|
-
import { CurrencyControl as
|
|
9
|
-
import { CURRENCY_CONTROL_ID as
|
|
10
|
-
import { FiltersControl as
|
|
11
|
-
import { FILTERS_CONTROL_ID as
|
|
12
|
-
import { LocaleControl as
|
|
13
|
-
import { LOCALE_CONTROL_ID as
|
|
14
|
-
import { ProductLayoutControl as
|
|
15
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
16
|
-
import { ShuffleControl as
|
|
5
|
+
import { useRecommendationExtensionStore as h } from "../../store/recommendation.js";
|
|
6
|
+
import { AlgorithmControl as u } from "./algorithm.js";
|
|
7
|
+
import { ALGORITHM_CONTROL_ID as x } from "./algorithm.js";
|
|
8
|
+
import { CurrencyControl as C } from "./currency.js";
|
|
9
|
+
import { CURRENCY_CONTROL_ID as k } from "./currency.js";
|
|
10
|
+
import { FiltersControl as f } from "./filters.js";
|
|
11
|
+
import { FILTERS_CONTROL_ID as A } from "./filters.js";
|
|
12
|
+
import { LocaleControl as d } from "./locale.js";
|
|
13
|
+
import { LOCALE_CONTROL_ID as z } from "./locale.js";
|
|
14
|
+
import { ProductLayoutControl as p } from "./productLayout.js";
|
|
15
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Y } from "./productLayout.js";
|
|
16
|
+
import { ShuffleControl as R } from "./shuffle.js";
|
|
17
17
|
import { SHUFFLE_CONTROL_ID as B } from "./shuffle.js";
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
import { useDebounceFn as _ } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
19
|
+
const y = /* @__PURE__ */ new Set([
|
|
20
|
+
"size",
|
|
21
|
+
"strategy",
|
|
22
|
+
"filters",
|
|
23
|
+
"productIds",
|
|
24
|
+
"language",
|
|
25
|
+
"shuffleProducts"
|
|
26
|
+
]), L = "ui-elements-recommendation-block";
|
|
27
|
+
class P extends m {
|
|
20
28
|
constructor() {
|
|
21
29
|
super(...arguments);
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
e(this, "store", h());
|
|
31
|
+
e(this, "storeUnsubscription", () => {
|
|
24
32
|
});
|
|
25
33
|
// Sub-control instances for lifecycle management
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
e(this, "algorithmControl", null);
|
|
35
|
+
e(this, "localeControl", null);
|
|
36
|
+
e(this, "currencyControl", null);
|
|
37
|
+
e(this, "productLayoutControl", null);
|
|
38
|
+
e(this, "filtersControl", null);
|
|
39
|
+
e(this, "shuffleControl", null);
|
|
40
|
+
/**
|
|
41
|
+
* Debounced product fetch to prevent rapid API calls during config changes
|
|
42
|
+
*/
|
|
43
|
+
e(this, "_debouncedFetchProducts", _(() => {
|
|
44
|
+
this.store.fetchRecommendationProducts();
|
|
45
|
+
}, 500));
|
|
32
46
|
}
|
|
33
47
|
getId() {
|
|
34
|
-
return
|
|
48
|
+
return L;
|
|
35
49
|
}
|
|
36
50
|
getTemplate() {
|
|
37
|
-
return this.algorithmControl = new
|
|
51
|
+
return this.algorithmControl = new u(), this.localeControl = new d(), this.currencyControl = new C(), this.productLayoutControl = new p(), this.filtersControl = new f(), this.shuffleControl = new R(), `
|
|
38
52
|
<div class="recommendation-controls-container">
|
|
39
53
|
${this.algorithmControl.getTemplate()}
|
|
40
54
|
${this.localeControl.getTemplate()}
|
|
@@ -50,17 +64,26 @@ class I extends m {
|
|
|
50
64
|
this.store.fetchRecommendationFilters(),
|
|
51
65
|
this.store.fetchRecommendationCreateData(),
|
|
52
66
|
this.store.fetchRecommendationProducts()
|
|
53
|
-
])).forEach((
|
|
54
|
-
|
|
67
|
+
])).forEach((t, s) => {
|
|
68
|
+
t.status === "rejected" && console.warn(`Recommendation block: ${[
|
|
55
69
|
"fetchRecommendationFilters",
|
|
56
70
|
"fetchRecommendationCreateData",
|
|
57
71
|
"fetchRecommendationProducts"
|
|
58
|
-
][
|
|
72
|
+
][s]} failed`, t.reason);
|
|
59
73
|
}), this._initializeSubControls(), this._listenStateUpdates();
|
|
60
74
|
}
|
|
61
75
|
onDestroy() {
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
this.storeUnsubscription(), [
|
|
77
|
+
this.algorithmControl,
|
|
78
|
+
this.localeControl,
|
|
79
|
+
this.currencyControl,
|
|
80
|
+
this.productLayoutControl,
|
|
81
|
+
this.filtersControl,
|
|
82
|
+
this.shuffleControl
|
|
83
|
+
].forEach((t) => {
|
|
84
|
+
var s;
|
|
85
|
+
return (s = t == null ? void 0 : t.onDestroy) == null ? void 0 : s.call(t);
|
|
86
|
+
});
|
|
64
87
|
}
|
|
65
88
|
/**
|
|
66
89
|
* Initialize all sub-controls with the shared API context
|
|
@@ -74,33 +97,38 @@ class I extends m {
|
|
|
74
97
|
this.productLayoutControl,
|
|
75
98
|
this.filtersControl,
|
|
76
99
|
this.shuffleControl
|
|
77
|
-
].forEach((
|
|
78
|
-
var
|
|
79
|
-
|
|
100
|
+
].forEach((t) => {
|
|
101
|
+
var s;
|
|
102
|
+
t && (t.api = this.api, t.currentNode = this.currentNode, (s = t.onRender) == null || s.call(t));
|
|
80
103
|
});
|
|
81
104
|
}
|
|
82
105
|
/**
|
|
83
106
|
* Listen to store changes that require product refresh
|
|
107
|
+
* Only triggers for meaningful config changes (size, strategy, filters, etc.)
|
|
108
|
+
* Uses debounce to prevent rapid API calls
|
|
84
109
|
*/
|
|
85
110
|
_listenStateUpdates() {
|
|
86
|
-
this.storeUnsubscription = this.store.$subscribe((
|
|
87
|
-
"payload" in
|
|
111
|
+
this.storeUnsubscription = this.store.$subscribe((o) => {
|
|
112
|
+
if ("payload" in o) {
|
|
113
|
+
const t = o.payload.recommendationConfigs;
|
|
114
|
+
t && Object.keys(t).some((l) => y.has(l)) && this._debouncedFetchProducts();
|
|
115
|
+
}
|
|
88
116
|
});
|
|
89
117
|
}
|
|
90
118
|
}
|
|
91
119
|
export {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
120
|
+
x as ALGORITHM_CONTROL_ID,
|
|
121
|
+
u as AlgorithmControl,
|
|
122
|
+
L as CONTROL_BLOCK_ID,
|
|
123
|
+
k as CURRENCY_CONTROL_ID,
|
|
124
|
+
C as CurrencyControl,
|
|
125
|
+
A as FILTERS_CONTROL_ID,
|
|
126
|
+
f as FiltersControl,
|
|
127
|
+
z as LOCALE_CONTROL_ID,
|
|
128
|
+
d as LocaleControl,
|
|
129
|
+
Y as PRODUCT_LAYOUT_CONTROL_ID,
|
|
130
|
+
p as ProductLayoutControl,
|
|
131
|
+
P as RecommendationBlockControl,
|
|
104
132
|
B as SHUFFLE_CONTROL_ID,
|
|
105
|
-
|
|
133
|
+
R as ShuffleControl
|
|
106
134
|
};
|
|
@@ -3,35 +3,36 @@ var d = (i, o, t) => o in i ? u(i, o, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var s = (i, o, t) => d(i, typeof o != "symbol" ? o + "" : o, t);
|
|
4
4
|
import { UEAttr as a } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as c } from "../../../common-control.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
6
|
+
import { MAX_PRODUCT_COUNT as _, MAX_PRODUCTS_PER_ROW as R } from "../../constants/layout.js";
|
|
7
|
+
import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
|
|
8
|
+
import { getCurrentLayout as C, regenerateProductRows as h, reapplySpacing as l } from "./utils.js";
|
|
9
|
+
import { useDebounceFn as p } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
10
|
+
const O = "recommendation-product-layout-control", e = {
|
|
10
11
|
PRODUCT_COUNT: "size",
|
|
11
12
|
PRODUCT_IN_ROW: "cardsInRow",
|
|
12
13
|
PRODUCT_IN_ROW_LABEL: "cardsInRowLabel"
|
|
13
14
|
};
|
|
14
|
-
class
|
|
15
|
+
class D extends c {
|
|
15
16
|
constructor() {
|
|
16
17
|
super(...arguments);
|
|
17
|
-
s(this, "store",
|
|
18
|
+
s(this, "store", m());
|
|
18
19
|
s(this, "storeUnsubscription", () => {
|
|
19
20
|
});
|
|
20
|
-
s(this, "_debouncedRegenerateProductRows",
|
|
21
|
+
s(this, "_debouncedRegenerateProductRows", p(() => {
|
|
21
22
|
this._regenerateProductRows();
|
|
22
23
|
}, 500));
|
|
23
24
|
}
|
|
24
25
|
getId() {
|
|
25
|
-
return
|
|
26
|
+
return O;
|
|
26
27
|
}
|
|
27
28
|
getTemplate() {
|
|
28
29
|
return `
|
|
29
30
|
<div class="product-layout-control-container">
|
|
30
31
|
${this._GuTwoColumns([
|
|
31
32
|
this._GuLabel({ text: "Number of Products" }),
|
|
32
|
-
this._GuCounter({ name: e.PRODUCT_COUNT, maxValue:
|
|
33
|
+
this._GuCounter({ name: e.PRODUCT_COUNT, maxValue: _ }),
|
|
33
34
|
this._GuLabel({ text: "Products in One Row", name: e.PRODUCT_IN_ROW_LABEL }),
|
|
34
|
-
this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue:
|
|
35
|
+
this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: R })
|
|
35
36
|
])}
|
|
36
37
|
</div>
|
|
37
38
|
`;
|
|
@@ -70,7 +71,7 @@ class I extends c {
|
|
|
70
71
|
* Reads from store first (reliable during state transitions), falls back to DOM
|
|
71
72
|
*/
|
|
72
73
|
_updateProductsInRowVisibility() {
|
|
73
|
-
const r = (this.store.recommendationConfigs.orientation ||
|
|
74
|
+
const r = (this.store.recommendationConfigs.orientation || C(this.currentNode)) === "vertical";
|
|
74
75
|
this.api.setVisibility(e.PRODUCT_IN_ROW, r), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, r);
|
|
75
76
|
}
|
|
76
77
|
_onProductCountChange(t) {
|
|
@@ -88,11 +89,11 @@ class I extends c {
|
|
|
88
89
|
}), this._debouncedRegenerateProductRows();
|
|
89
90
|
}
|
|
90
91
|
_regenerateProductRows() {
|
|
91
|
-
|
|
92
|
+
h({
|
|
92
93
|
currentNode: this.currentNode,
|
|
93
94
|
documentModifier: this.api.getDocumentModifier(),
|
|
94
95
|
afterRegenerate: () => {
|
|
95
|
-
|
|
96
|
+
l({
|
|
96
97
|
currentNode: this.currentNode,
|
|
97
98
|
documentModifier: this.api.getDocumentModifier()
|
|
98
99
|
});
|
|
@@ -118,6 +119,6 @@ class I extends c {
|
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
export {
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
O as PRODUCT_LAYOUT_CONTROL_ID,
|
|
123
|
+
D as ProductLayoutControl
|
|
123
124
|
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (n, i, t) =>
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var O = (n, i, t) => i in n ? P(n, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[i] = t;
|
|
3
|
+
var p = (n, i, t) => O(n, typeof i != "symbol" ? i + "" : i, t);
|
|
4
4
|
import { ModificationDescription as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as b } from "../../../common-control.js";
|
|
6
|
-
import { useRecommendationExtensionStore as
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
|
|
7
|
+
import { getCurrentLayout as S } from "../main/utils.js";
|
|
8
|
+
import { useDebounceFn as _ } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
9
|
+
const y = "recommendation-spacing-control", a = {
|
|
9
10
|
COLUMN_SPACING: "columnSpacing",
|
|
10
11
|
COLUMN_SPACING_LABEL: "columnSpacingLabel",
|
|
11
12
|
ROW_SPACING: "rowSpacing"
|
|
12
|
-
},
|
|
13
|
+
}, f = {
|
|
13
14
|
COLUMN_SPACING: "data-column-spacing",
|
|
14
15
|
ROW_SPACING: "data-row-spacing"
|
|
15
16
|
}, s = {
|
|
@@ -21,40 +22,40 @@ const O = "recommendation-spacing-control", a = {
|
|
|
21
22
|
MAX_SPACING: 50,
|
|
22
23
|
STEP: 5
|
|
23
24
|
};
|
|
24
|
-
function
|
|
25
|
+
function C(n, i) {
|
|
25
26
|
return !n || !("getStyle" in n) ? null : n.getStyle(i);
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function G(n) {
|
|
28
29
|
return !n || !("parent" in n) || typeof n.parent != "function" ? null : n.parent();
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
+
function m(n, i) {
|
|
31
32
|
if (!n)
|
|
32
33
|
return i;
|
|
33
34
|
const t = parseFloat(n);
|
|
34
35
|
return Number.isNaN(t) ? i : t;
|
|
35
36
|
}
|
|
36
|
-
class
|
|
37
|
+
class E extends b {
|
|
37
38
|
constructor() {
|
|
38
39
|
super(...arguments);
|
|
39
|
-
p(this, "store",
|
|
40
|
+
p(this, "store", I());
|
|
40
41
|
p(this, "unsubscribeOrientation", null);
|
|
41
42
|
/**
|
|
42
43
|
* Debounced version of _onColumnSpacingChange
|
|
43
44
|
* Prevents excessive DOM updates when user rapidly adjusts the counter
|
|
44
45
|
*/
|
|
45
|
-
p(this, "_debouncedOnColumnSpacingChange",
|
|
46
|
+
p(this, "_debouncedOnColumnSpacingChange", _((t) => {
|
|
46
47
|
this._onColumnSpacingChange(t);
|
|
47
48
|
}, 300));
|
|
48
49
|
/**
|
|
49
50
|
* Debounced version of _onRowSpacingChange
|
|
50
51
|
* Prevents excessive DOM updates when user rapidly adjusts the counter
|
|
51
52
|
*/
|
|
52
|
-
p(this, "_debouncedOnRowSpacingChange",
|
|
53
|
+
p(this, "_debouncedOnRowSpacingChange", _((t) => {
|
|
53
54
|
this._onRowSpacingChange(t);
|
|
54
55
|
}, 300));
|
|
55
56
|
}
|
|
56
57
|
getId() {
|
|
57
|
-
return
|
|
58
|
+
return y;
|
|
58
59
|
}
|
|
59
60
|
getTemplate() {
|
|
60
61
|
return `
|
|
@@ -84,22 +85,13 @@ class w extends b {
|
|
|
84
85
|
onTemplateNodeUpdated(t) {
|
|
85
86
|
super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateColumnSpacingVisibility();
|
|
86
87
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Gets the current layout orientation from the block's data attribute
|
|
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";
|
|
95
|
-
}
|
|
96
88
|
/**
|
|
97
89
|
* Updates column spacing visibility based on layout orientation
|
|
98
90
|
* Column spacing is hidden for horizontal layout (products are stacked vertically)
|
|
99
91
|
* Reads from store first for reliability, falls back to DOM
|
|
100
92
|
*/
|
|
101
93
|
_updateColumnSpacingVisibility() {
|
|
102
|
-
const r = (this.store.recommendationConfigs.orientation || this.
|
|
94
|
+
const r = (this.store.recommendationConfigs.orientation || S(this.currentNode)) === "vertical";
|
|
103
95
|
this.api.setVisibility(a.COLUMN_SPACING, r), this.api.setVisibility(a.COLUMN_SPACING_LABEL, r);
|
|
104
96
|
}
|
|
105
97
|
/**
|
|
@@ -121,18 +113,18 @@ class w extends b {
|
|
|
121
113
|
_getStoredColumnSpacing() {
|
|
122
114
|
if (!this.currentNode)
|
|
123
115
|
return s.COLUMN_SPACING;
|
|
124
|
-
if (this.
|
|
125
|
-
const o = this.currentNode.querySelector(".recommendation-attribute-row"),
|
|
126
|
-
if (!
|
|
116
|
+
if (S(this.currentNode) === "vertical") {
|
|
117
|
+
const o = this.currentNode.querySelector(".recommendation-attribute-row"), A = o == null ? void 0 : o.querySelector("td"), h = C(A, "padding");
|
|
118
|
+
if (!h)
|
|
127
119
|
return s.COLUMN_SPACING;
|
|
128
|
-
const
|
|
129
|
-
return
|
|
120
|
+
const g = h.trim().split(/\s+/);
|
|
121
|
+
return g.length < 2 ? s.COLUMN_SPACING : m(g[1], s.COLUMN_SPACING / 2) * 2;
|
|
130
122
|
}
|
|
131
|
-
const e = this.currentNode.querySelector(".product-card-wrapper"), r =
|
|
123
|
+
const e = this.currentNode.querySelector(".product-card-wrapper"), r = G(e), l = C(r, "padding");
|
|
132
124
|
if (!l)
|
|
133
125
|
return s.COLUMN_SPACING;
|
|
134
126
|
const c = l.trim().split(/\s+/);
|
|
135
|
-
return c.length < 2 ? s.COLUMN_SPACING :
|
|
127
|
+
return c.length < 2 ? s.COLUMN_SPACING : m(c[1], s.COLUMN_SPACING / 2) * 2;
|
|
136
128
|
}
|
|
137
129
|
/**
|
|
138
130
|
* Gets stored row spacing from the first spacer element's height style
|
|
@@ -140,8 +132,8 @@ class w extends b {
|
|
|
140
132
|
_getStoredRowSpacing() {
|
|
141
133
|
if (!this.currentNode)
|
|
142
134
|
return s.ROW_SPACING;
|
|
143
|
-
const t = this.currentNode.querySelector(".spacer"), e =
|
|
144
|
-
return
|
|
135
|
+
const t = this.currentNode.querySelector(".spacer"), e = C(t, "height");
|
|
136
|
+
return m(e, s.ROW_SPACING);
|
|
145
137
|
}
|
|
146
138
|
/**
|
|
147
139
|
* Handles column spacing changes.
|
|
@@ -152,7 +144,7 @@ class w extends b {
|
|
|
152
144
|
if (!this.currentNode)
|
|
153
145
|
return;
|
|
154
146
|
this._storeColumnSpacing(t);
|
|
155
|
-
const e = this.
|
|
147
|
+
const e = S(this.currentNode), r = this.api.getDocumentModifier(), c = `0 ${t / 2}px`;
|
|
156
148
|
e === "vertical" ? Array.from(
|
|
157
149
|
this.currentNode.querySelectorAll(".attribute-cell")
|
|
158
150
|
).forEach((o) => {
|
|
@@ -188,7 +180,7 @@ class w extends b {
|
|
|
188
180
|
if (!this.currentNode)
|
|
189
181
|
return;
|
|
190
182
|
const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
|
|
191
|
-
e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(
|
|
183
|
+
e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(f.COLUMN_SPACING, t.toString()).apply(new d("Store column spacing"));
|
|
192
184
|
}
|
|
193
185
|
/**
|
|
194
186
|
* Stores row spacing value in block data attribute
|
|
@@ -197,7 +189,7 @@ class w extends b {
|
|
|
197
189
|
if (!this.currentNode)
|
|
198
190
|
return;
|
|
199
191
|
const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
|
|
200
|
-
e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(
|
|
192
|
+
e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(f.ROW_SPACING, t.toString()).apply(new d("Store row spacing"));
|
|
201
193
|
}
|
|
202
194
|
_listenToFormUpdates() {
|
|
203
195
|
this.api.onValueChanged(a.COLUMN_SPACING, (t) => {
|
|
@@ -219,6 +211,6 @@ class w extends b {
|
|
|
219
211
|
}
|
|
220
212
|
}
|
|
221
213
|
export {
|
|
222
|
-
|
|
223
|
-
|
|
214
|
+
y as SPACING_CONTROL_ID,
|
|
215
|
+
E as SpacingControl
|
|
224
216
|
};
|