@useinsider/guido 2.1.0-beta.ab9a598 → 2.1.0-beta.abc38f2
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 +1 -1
- package/dist/components/organisms/base/Toaster.vue.js +4 -4
- package/dist/components/organisms/base/Toaster.vue2.js +12 -9
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +11 -13
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +54 -23
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +7 -5
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +34 -21
- package/dist/components/organisms/extensions/recommendation/Filters.vue.js +11 -11
- package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +48 -36
- package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue2.js +11 -9
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +58 -39
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +116 -70
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +8 -8
- package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +29 -0
- package/dist/guido.css +1 -1
- package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +1 -0
- package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +17 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +18 -2
- package/dist/src/extensions/Blocks/Recommendation/validation/filterSchema.d.ts +15 -0
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var n = (c, s, t) =>
|
|
4
|
-
import { CommonControl as
|
|
5
|
-
import { RecommendationConfigService as
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var h = (c, s, t) => s in c ? m(c, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[s] = t;
|
|
3
|
+
var n = (c, s, t) => h(c, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
+
import { CommonControl as f } from "../../../common-control.js";
|
|
5
|
+
import { RecommendationConfigService as l } from "../../services/configService.js";
|
|
6
6
|
import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
|
|
7
7
|
import { AlgorithmControl as p } from "./algorithm.js";
|
|
8
8
|
import { ALGORITHM_CONTROL_ID as W } from "./algorithm.js";
|
|
@@ -10,17 +10,17 @@ import { CurrencyControl as g } from "./currency.js";
|
|
|
10
10
|
import { CURRENCY_CONTROL_ID as H } from "./currency.js";
|
|
11
11
|
import { FiltersControl as R } from "./filters.js";
|
|
12
12
|
import { FILTERS_CONTROL_ID as j } from "./filters.js";
|
|
13
|
-
import { LocaleControl as
|
|
13
|
+
import { LocaleControl as N } from "./locale.js";
|
|
14
14
|
import { LOCALE_CONTROL_ID as K } from "./locale.js";
|
|
15
|
-
import { ProductLayoutControl as
|
|
15
|
+
import { ProductLayoutControl as y } from "./productLayout.js";
|
|
16
16
|
import { PRODUCT_LAYOUT_CONTROL_ID as J } from "./productLayout.js";
|
|
17
|
-
import { ShuffleControl as
|
|
17
|
+
import { ShuffleControl as _ } from "./shuffle.js";
|
|
18
18
|
import { SHUFFLE_CONTROL_ID as X } from "./shuffle.js";
|
|
19
|
-
import { regenerateProductRowsWithStyles as b, getBlockElement as
|
|
20
|
-
import { formatProductPrice as tt, getCardComposition as et, getCurrentLayout as ot, reapplySpacing as rt, regenerateMobileProductRows as
|
|
21
|
-
import { useDebounceFn as
|
|
19
|
+
import { regenerateProductRowsWithStyles as b, getBlockElement as I, updateProductContentInPlace as P } from "./utils.js";
|
|
20
|
+
import { formatProductPrice as tt, getCardComposition as et, getCurrentLayout as ot, reapplySpacing as rt, regenerateMobileProductRows as it, regenerateProductRows as nt, setCurrencyAttributes as st, updatePricesInPlace as ct, updateSingleProductContent as at } from "./utils.js";
|
|
21
|
+
import { useDebounceFn as u } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
22
22
|
const T = "recommendation-id", S = "ui-elements-recommendation-block";
|
|
23
|
-
class
|
|
23
|
+
class z extends f {
|
|
24
24
|
constructor() {
|
|
25
25
|
super(...arguments);
|
|
26
26
|
n(this, "store", C());
|
|
@@ -36,19 +36,19 @@ class $ extends h {
|
|
|
36
36
|
/**
|
|
37
37
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
38
38
|
*/
|
|
39
|
-
n(this, "_debouncedFetchProducts",
|
|
39
|
+
n(this, "_debouncedFetchProducts", u(() => {
|
|
40
40
|
this.store.fetchRecommendationProducts();
|
|
41
41
|
}, 500));
|
|
42
42
|
/**
|
|
43
43
|
* Debounced regeneration when products arrive from API
|
|
44
44
|
* Tries in-place update first to preserve styles, falls back to full regeneration
|
|
45
45
|
*/
|
|
46
|
-
n(this, "_debouncedRegenerateWithProducts",
|
|
46
|
+
n(this, "_debouncedRegenerateWithProducts", u(() => {
|
|
47
47
|
const t = this.store.recommendationProducts;
|
|
48
48
|
if (!this.currentNode || !this.api)
|
|
49
49
|
return;
|
|
50
50
|
const e = this.api.getDocumentModifier();
|
|
51
|
-
|
|
51
|
+
P({
|
|
52
52
|
currentNode: this.currentNode,
|
|
53
53
|
documentModifier: e,
|
|
54
54
|
products: t
|
|
@@ -59,7 +59,7 @@ class $ extends h {
|
|
|
59
59
|
return S;
|
|
60
60
|
}
|
|
61
61
|
getTemplate() {
|
|
62
|
-
return this.algorithmControl = new p(), this.localeControl = new
|
|
62
|
+
return this.algorithmControl = new p(), this.localeControl = new N(), this.currencyControl = new g(), this.productLayoutControl = new y(), this.filtersControl = new R(), this.shuffleControl = new _(), `
|
|
63
63
|
<div class="recommendation-controls-container">
|
|
64
64
|
${this.algorithmControl.getTemplate()}
|
|
65
65
|
${this.localeControl.getTemplate()}
|
|
@@ -95,19 +95,19 @@ class $ extends h {
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
onTemplateNodeUpdated(t) {
|
|
98
|
-
var
|
|
98
|
+
var r;
|
|
99
99
|
super.onTemplateNodeUpdated(t);
|
|
100
100
|
const e = this._getRecommendationIdFromNode(t);
|
|
101
|
-
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((
|
|
101
|
+
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((r = this.store.blockStates[e]) != null && r.isInitialized) && this._fetchBlockData(e), [
|
|
102
102
|
this.algorithmControl,
|
|
103
103
|
this.localeControl,
|
|
104
104
|
this.currencyControl,
|
|
105
105
|
this.productLayoutControl,
|
|
106
106
|
this.filtersControl,
|
|
107
107
|
this.shuffleControl
|
|
108
|
-
].forEach((
|
|
108
|
+
].forEach((i) => {
|
|
109
109
|
var a;
|
|
110
|
-
|
|
110
|
+
i != null && i.api && (i.currentNode = t, (a = i.onTemplateNodeUpdated) == null || a.call(i, t));
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
onDestroy() {
|
|
@@ -152,13 +152,17 @@ class $ extends h {
|
|
|
152
152
|
* values are being prepared for the upcoming initial fetch.
|
|
153
153
|
*/
|
|
154
154
|
_syncNodeConfigToStore() {
|
|
155
|
-
|
|
155
|
+
var r;
|
|
156
|
+
const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
|
|
156
157
|
this.store.patchCurrentBlockConfig({
|
|
157
158
|
strategy: t.strategy,
|
|
158
159
|
language: t.language,
|
|
159
160
|
size: t.size,
|
|
160
161
|
productIds: t.productIds,
|
|
161
|
-
filters
|
|
162
|
+
// Only sync filters from node config during initial load.
|
|
163
|
+
// After initialization, the Pinia store is the source of truth
|
|
164
|
+
// for filters (edited via the filter drawer).
|
|
165
|
+
...o ? {} : { filters: t.filters },
|
|
162
166
|
shuffleProducts: t.shuffleProducts,
|
|
163
167
|
currencySettings: {
|
|
164
168
|
name: t.currency.code,
|
|
@@ -181,26 +185,26 @@ class $ extends h {
|
|
|
181
185
|
this.store.fetchRecommendationFilters(),
|
|
182
186
|
this.store.fetchRecommendationCreateData(),
|
|
183
187
|
this.store.fetchRecommendationProducts()
|
|
184
|
-
])).forEach((o,
|
|
188
|
+
])).forEach((o, r) => {
|
|
185
189
|
o.status === "rejected" && console.warn(`Recommendation block: ${[
|
|
186
190
|
"fetchRecommendationFilters",
|
|
187
191
|
"fetchRecommendationCreateData",
|
|
188
192
|
"fetchRecommendationProducts"
|
|
189
|
-
][
|
|
193
|
+
][r]} failed`, o.reason);
|
|
190
194
|
});
|
|
191
195
|
}
|
|
192
196
|
/**
|
|
193
197
|
* Reads the recommendation-id attribute from the block element within the node
|
|
194
198
|
*/
|
|
195
199
|
_getRecommendationIdFromNode(t) {
|
|
196
|
-
const e =
|
|
200
|
+
const e = I(t);
|
|
197
201
|
if (!e || !("getAttribute" in e))
|
|
198
202
|
return null;
|
|
199
203
|
const o = e.getAttribute(T);
|
|
200
204
|
if (!o)
|
|
201
205
|
return null;
|
|
202
|
-
const
|
|
203
|
-
return Number.isNaN(
|
|
206
|
+
const r = parseInt(o);
|
|
207
|
+
return Number.isNaN(r) ? null : r;
|
|
204
208
|
}
|
|
205
209
|
/**
|
|
206
210
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -213,12 +217,27 @@ class $ extends h {
|
|
|
213
217
|
const { store: t } = this;
|
|
214
218
|
let e = t.recommendationProducts, o = t.$state.configVersion;
|
|
215
219
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
a &&
|
|
220
|
+
const r = t.$state.configVersion;
|
|
221
|
+
r !== o && (o = r, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
|
|
222
|
+
const i = t.recommendationProducts, a = i !== e, d = Array.isArray(i) && i.length > 0;
|
|
223
|
+
a && d && (e = i, this._debouncedRegenerateWithProducts());
|
|
220
224
|
});
|
|
221
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Persists the current filter state from Pinia store to the Stripo node config.
|
|
228
|
+
* This ensures filters survive template save/reload cycles.
|
|
229
|
+
*/
|
|
230
|
+
_persistFiltersToNodeConfig() {
|
|
231
|
+
if (!this.currentNode || !this.api)
|
|
232
|
+
return;
|
|
233
|
+
const { filters: t } = this.store.recommendationConfigs;
|
|
234
|
+
l.updateConfig(
|
|
235
|
+
this.api,
|
|
236
|
+
this.currentNode,
|
|
237
|
+
{ filters: t },
|
|
238
|
+
"Update recommendation filters"
|
|
239
|
+
);
|
|
240
|
+
}
|
|
222
241
|
}
|
|
223
242
|
export {
|
|
224
243
|
W as ALGORITHM_CONTROL_ID,
|
|
@@ -229,22 +248,22 @@ export {
|
|
|
229
248
|
j as FILTERS_CONTROL_ID,
|
|
230
249
|
R as FiltersControl,
|
|
231
250
|
K as LOCALE_CONTROL_ID,
|
|
232
|
-
|
|
251
|
+
N as LocaleControl,
|
|
233
252
|
J as PRODUCT_LAYOUT_CONTROL_ID,
|
|
234
|
-
|
|
235
|
-
|
|
253
|
+
y as ProductLayoutControl,
|
|
254
|
+
z as RecommendationBlockControl,
|
|
236
255
|
X as SHUFFLE_CONTROL_ID,
|
|
237
|
-
|
|
256
|
+
_ as ShuffleControl,
|
|
238
257
|
tt as formatProductPrice,
|
|
239
|
-
|
|
258
|
+
I as getBlockElement,
|
|
240
259
|
et as getCardComposition,
|
|
241
260
|
ot as getCurrentLayout,
|
|
242
261
|
rt as reapplySpacing,
|
|
243
|
-
|
|
244
|
-
|
|
262
|
+
it as regenerateMobileProductRows,
|
|
263
|
+
nt as regenerateProductRows,
|
|
245
264
|
b as regenerateProductRowsWithStyles,
|
|
246
265
|
st as setCurrencyAttributes,
|
|
247
266
|
ct as updatePricesInPlace,
|
|
248
|
-
|
|
267
|
+
P as updateProductContentInPlace,
|
|
249
268
|
at as updateSingleProductContent
|
|
250
269
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { RecommendationFeedSourceMaps as
|
|
2
|
-
import { useRecommendationApi as
|
|
3
|
-
import { useConfigStore as
|
|
4
|
-
import { defineStore as
|
|
5
|
-
import { DEFAULT_CARDS_IN_ROW as
|
|
6
|
-
import { getDefaultProducts as
|
|
7
|
-
import { generateCompleteFilterQuery as
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { RecommendationFeedSourceMaps as f, getOperatorOptions as g, PriceAttributes as S } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as b } from "../../../../services/recommendationApi.js";
|
|
3
|
+
import { useConfigStore as I } from "../../../../stores/config.js";
|
|
4
|
+
import { defineStore as R } from "pinia";
|
|
5
|
+
import { DEFAULT_CARDS_IN_ROW as k } from "../constants/layout.js";
|
|
6
|
+
import { getDefaultProducts as C } from "../templates/utils.js";
|
|
7
|
+
import { generateCompleteFilterQuery as h } from "../utils/filterUtil.js";
|
|
8
|
+
import { isFilterValid as G } from "../validation/filterSchema.js";
|
|
9
|
+
const u = b();
|
|
10
|
+
function p() {
|
|
10
11
|
return {
|
|
11
|
-
cardsInRow:
|
|
12
|
+
cardsInRow: k,
|
|
12
13
|
currencySettings: {
|
|
13
14
|
name: "USD",
|
|
14
15
|
value: "USD",
|
|
@@ -32,17 +33,18 @@ function h() {
|
|
|
32
33
|
size: "6"
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
+
function y() {
|
|
36
37
|
return {
|
|
37
|
-
recommendationConfigs:
|
|
38
|
+
recommendationConfigs: p(),
|
|
38
39
|
recommendationProducts: [],
|
|
39
40
|
filterStatus: !1,
|
|
40
41
|
filterSelectionDrawerStatus: !1,
|
|
41
42
|
filterGroup: 1,
|
|
42
|
-
isInitialized: !1
|
|
43
|
+
isInitialized: !1,
|
|
44
|
+
filterSnapshot: null
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
|
-
const
|
|
47
|
+
const F = () => ({
|
|
46
48
|
recommendationCampaignUrls: {},
|
|
47
49
|
activePredictiveAlgorithms: [],
|
|
48
50
|
languages: {},
|
|
@@ -51,8 +53,8 @@ const y = () => ({
|
|
|
51
53
|
blockStates: {},
|
|
52
54
|
currentRecommendationId: null,
|
|
53
55
|
configVersion: 0
|
|
54
|
-
}),
|
|
55
|
-
state: () =>
|
|
56
|
+
}), V = R("guidoRecommendationExtension", {
|
|
57
|
+
state: () => F(),
|
|
56
58
|
getters: {
|
|
57
59
|
// ====================================================================
|
|
58
60
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -62,7 +64,7 @@ const y = () => ({
|
|
|
62
64
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
63
65
|
*/
|
|
64
66
|
recommendationConfigs(t) {
|
|
65
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs :
|
|
67
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : p();
|
|
66
68
|
},
|
|
67
69
|
/**
|
|
68
70
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -94,14 +96,22 @@ const y = () => ({
|
|
|
94
96
|
hasFilters() {
|
|
95
97
|
return !!this.recommendationConfigs.filters.length;
|
|
96
98
|
},
|
|
99
|
+
hasValidFilters() {
|
|
100
|
+
const { filters: t } = this.recommendationConfigs;
|
|
101
|
+
return t.length ? t.every((r) => r.isValid) : !1;
|
|
102
|
+
},
|
|
97
103
|
getFilterGroupCount() {
|
|
98
104
|
const { filters: t } = this.recommendationConfigs;
|
|
99
|
-
return t.length
|
|
105
|
+
return t.length ? new Set(t.map((r) => r.filterGroup)).size : 0;
|
|
106
|
+
},
|
|
107
|
+
getUniqueFilterGroups() {
|
|
108
|
+
const { filters: t } = this.recommendationConfigs;
|
|
109
|
+
return [...new Set(t.map((r) => r.filterGroup))].sort((r, e) => r - e);
|
|
100
110
|
},
|
|
101
111
|
getActivePredictiveAlgorithms: (t) => {
|
|
102
112
|
const r = [];
|
|
103
113
|
return t.activePredictiveAlgorithms.forEach((e) => {
|
|
104
|
-
r.push(...
|
|
114
|
+
r.push(...f.filter((n) => n.id === e));
|
|
105
115
|
}), r.map((e) => ({
|
|
106
116
|
text: e.name,
|
|
107
117
|
value: e.key
|
|
@@ -141,7 +151,7 @@ const y = () => ({
|
|
|
141
151
|
setCurrentBlock(t) {
|
|
142
152
|
this.blockStates[t] || (this.blockStates = {
|
|
143
153
|
...this.blockStates,
|
|
144
|
-
[t]:
|
|
154
|
+
[t]: y()
|
|
145
155
|
}), this.currentRecommendationId = t;
|
|
146
156
|
},
|
|
147
157
|
/**
|
|
@@ -181,33 +191,56 @@ const y = () => ({
|
|
|
181
191
|
const { triggerRefetch: n = !0 } = r;
|
|
182
192
|
n && this.configVersion++;
|
|
183
193
|
},
|
|
194
|
+
/**
|
|
195
|
+
* Creates a filter with the first available attribute and operator pre-selected.
|
|
196
|
+
*/
|
|
197
|
+
createDefaultFilter(t, r) {
|
|
198
|
+
const [e] = this.getFilterList, [n] = g(e == null ? void 0 : e.type);
|
|
199
|
+
return {
|
|
200
|
+
type: "standardFilter",
|
|
201
|
+
attribute: (e == null ? void 0 : e.value) ?? "",
|
|
202
|
+
operator: (n == null ? void 0 : n.value) ?? "",
|
|
203
|
+
innerGroupOperator: "*",
|
|
204
|
+
outerGroupOperator: "*",
|
|
205
|
+
filterNumber: r,
|
|
206
|
+
filterGroup: t,
|
|
207
|
+
isValid: !1,
|
|
208
|
+
value: ""
|
|
209
|
+
};
|
|
210
|
+
},
|
|
184
211
|
/**
|
|
185
212
|
* Opens the filter selection drawer for the current block.
|
|
186
|
-
*
|
|
213
|
+
* Saves a snapshot of current filters for cancel/revert.
|
|
214
|
+
* If no filters exist, initializes with a default filter
|
|
187
215
|
* so the user has a starting point for input.
|
|
188
216
|
*/
|
|
189
217
|
openFilterDrawer() {
|
|
190
218
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
191
219
|
return;
|
|
192
220
|
const t = this.blockStates[this.currentRecommendationId];
|
|
193
|
-
t.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
operatorReplace: "",
|
|
197
|
-
operator: "",
|
|
198
|
-
innerGroupOperator: "*",
|
|
199
|
-
outerGroupOperator: "*",
|
|
200
|
-
filterNumber: 1,
|
|
201
|
-
filterGroup: 1,
|
|
202
|
-
isValid: !1,
|
|
203
|
-
value: ""
|
|
204
|
-
}]), t.filterSelectionDrawerStatus = !0;
|
|
221
|
+
t.filterSnapshot = JSON.parse(
|
|
222
|
+
JSON.stringify(t.recommendationConfigs.filters)
|
|
223
|
+
), t.recommendationConfigs.filters.length || (t.recommendationConfigs.filters = [this.createDefaultFilter(1, 1)]), t.filterSelectionDrawerStatus = !0;
|
|
205
224
|
},
|
|
206
225
|
/**
|
|
207
|
-
* Closes the filter selection drawer for the current block
|
|
226
|
+
* Closes the filter selection drawer for the current block.
|
|
227
|
+
* Called after successful apply — discards the snapshot.
|
|
208
228
|
*/
|
|
209
229
|
closeFilterDrawer() {
|
|
210
|
-
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId]
|
|
230
|
+
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
231
|
+
return;
|
|
232
|
+
const t = this.blockStates[this.currentRecommendationId];
|
|
233
|
+
t.filterSnapshot = null, t.filterSelectionDrawerStatus = !1;
|
|
234
|
+
},
|
|
235
|
+
/**
|
|
236
|
+
* Cancels the filter selection drawer and reverts filters
|
|
237
|
+
* to the snapshot taken when the drawer was opened.
|
|
238
|
+
*/
|
|
239
|
+
cancelFilterDrawer() {
|
|
240
|
+
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
241
|
+
return;
|
|
242
|
+
const t = this.blockStates[this.currentRecommendationId];
|
|
243
|
+
t.filterSnapshot !== null && (t.recommendationConfigs.filters = t.filterSnapshot, t.filterSnapshot = null), t.filterSelectionDrawerStatus = !1;
|
|
211
244
|
},
|
|
212
245
|
// ====================================================================
|
|
213
246
|
// Shared Data Fetching (fetched once, used by all blocks)
|
|
@@ -219,7 +252,7 @@ const y = () => ({
|
|
|
219
252
|
activePredictiveAlgorithms: t,
|
|
220
253
|
languages: r,
|
|
221
254
|
currencies: e
|
|
222
|
-
} = await
|
|
255
|
+
} = await u.fetchRecommendationCreateData();
|
|
223
256
|
if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
224
257
|
const n = this.blockStates[this.currentRecommendationId];
|
|
225
258
|
n.filterStatus = !!n.recommendationConfigs.filters.length;
|
|
@@ -227,25 +260,25 @@ const y = () => ({
|
|
|
227
260
|
this.currencyList = e;
|
|
228
261
|
},
|
|
229
262
|
async fetchRecommendationFilters() {
|
|
230
|
-
const t = await
|
|
263
|
+
const t = await u.fetchRecommendationFilters();
|
|
231
264
|
this.filterList = t;
|
|
232
265
|
},
|
|
233
266
|
// ====================================================================
|
|
234
267
|
// Per-Block Filter Actions
|
|
235
268
|
// ====================================================================
|
|
236
269
|
addFilterGroup(t) {
|
|
237
|
-
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || this.blockStates[this.currentRecommendationId].recommendationConfigs.filters.push(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
filterGroup:
|
|
248
|
-
});
|
|
270
|
+
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || this.blockStates[this.currentRecommendationId].recommendationConfigs.filters.push(
|
|
271
|
+
this.createDefaultFilter(t, 1)
|
|
272
|
+
);
|
|
273
|
+
},
|
|
274
|
+
deleteFilterGroup(t) {
|
|
275
|
+
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
276
|
+
return;
|
|
277
|
+
const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(e.map((i) => i.filterGroup))].sort((i, o) => i - o), c = new Map(n.map((i, o) => [i, o + 1]));
|
|
278
|
+
r.recommendationConfigs.filters = e.map((i) => ({
|
|
279
|
+
...i,
|
|
280
|
+
filterGroup: c.get(i.filterGroup) ?? i.filterGroup
|
|
281
|
+
}));
|
|
249
282
|
},
|
|
250
283
|
updateFilter(t) {
|
|
251
284
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
@@ -253,7 +286,10 @@ const y = () => ({
|
|
|
253
286
|
const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
254
287
|
if (e !== -1) {
|
|
255
288
|
const n = [...r.recommendationConfigs.filters];
|
|
256
|
-
n[e] =
|
|
289
|
+
n[e] = {
|
|
290
|
+
...t,
|
|
291
|
+
isValid: G(t)
|
|
292
|
+
}, r.recommendationConfigs.filters = n;
|
|
257
293
|
}
|
|
258
294
|
},
|
|
259
295
|
deleteFilter(t) {
|
|
@@ -261,54 +297,64 @@ const y = () => ({
|
|
|
261
297
|
return;
|
|
262
298
|
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
263
299
|
if (e !== -1) {
|
|
264
|
-
|
|
265
|
-
n.splice(e, 1),
|
|
300
|
+
let n = [...r.recommendationConfigs.filters];
|
|
301
|
+
if (n.splice(e, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
|
|
302
|
+
let i = 1;
|
|
303
|
+
n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
|
|
304
|
+
} else {
|
|
305
|
+
const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, a) => s - a), o = new Map(i.map((s, a) => [s, a + 1]));
|
|
306
|
+
n = n.map((s) => ({
|
|
307
|
+
...s,
|
|
308
|
+
filterGroup: o.get(s.filterGroup) ?? s.filterGroup
|
|
309
|
+
}));
|
|
310
|
+
}
|
|
311
|
+
r.recommendationConfigs.filters = n;
|
|
266
312
|
}
|
|
267
313
|
},
|
|
268
314
|
addFilter(t) {
|
|
269
315
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
270
316
|
return;
|
|
271
|
-
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters],
|
|
272
|
-
(
|
|
273
|
-
).length + 1,
|
|
274
|
-
|
|
317
|
+
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], c = e.filter(
|
|
318
|
+
(o) => o.filterGroup === t.filterGroup
|
|
319
|
+
).length + 1, i = e.findLastIndex((o) => o.filterGroup === t.filterGroup);
|
|
320
|
+
i !== -1 ? e.splice(i + 1, 0, {
|
|
275
321
|
...t,
|
|
276
|
-
filterNumber:
|
|
322
|
+
filterNumber: c
|
|
277
323
|
}) : e.push({
|
|
278
324
|
...t,
|
|
279
|
-
filterNumber:
|
|
325
|
+
filterNumber: c
|
|
280
326
|
}), r.recommendationConfigs.filters = e;
|
|
281
327
|
},
|
|
282
328
|
generateFilterQuery() {
|
|
283
|
-
return
|
|
329
|
+
return h(this.recommendationConfigs.filters);
|
|
284
330
|
},
|
|
285
331
|
// ====================================================================
|
|
286
332
|
// Per-Block Product Fetching
|
|
287
333
|
// ====================================================================
|
|
288
334
|
async fetchRecommendationProducts() {
|
|
289
|
-
var
|
|
335
|
+
var d;
|
|
290
336
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
291
337
|
return;
|
|
292
|
-
const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((
|
|
338
|
+
const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((m) => m.isValid), c = h(n), i = ((d = f.find((m) => m.key === e.strategy)) == null ? void 0 : d.path) || "", o = I(), s = {
|
|
293
339
|
locale: e.language,
|
|
294
340
|
currency: e.currencySettings.value,
|
|
295
|
-
partnerName:
|
|
341
|
+
partnerName: o.partnerName,
|
|
296
342
|
size: e.size,
|
|
297
343
|
details: !0,
|
|
298
|
-
campaignId:
|
|
344
|
+
campaignId: o.variationId
|
|
299
345
|
};
|
|
300
|
-
e.strategy === "manualMerchandising" ?
|
|
301
|
-
const
|
|
302
|
-
let
|
|
346
|
+
e.strategy === "manualMerchandising" ? s.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (s.productId = "{itemId}"), c && (s.filter = c), e.shuffleProducts && (s.shuffle = !0);
|
|
347
|
+
const a = parseInt(e.size) || 6;
|
|
348
|
+
let l;
|
|
303
349
|
try {
|
|
304
|
-
|
|
350
|
+
l = await u.fetchRecommendationProducts(i, s);
|
|
305
351
|
} catch {
|
|
306
|
-
|
|
352
|
+
l = [];
|
|
307
353
|
}
|
|
308
|
-
this.blockStates[t] && (this.blockStates[t].recommendationProducts =
|
|
354
|
+
this.blockStates[t] && (this.blockStates[t].recommendationProducts = l.length > 0 ? l : C(a));
|
|
309
355
|
}
|
|
310
356
|
}
|
|
311
357
|
});
|
|
312
358
|
export {
|
|
313
|
-
|
|
359
|
+
V as useRecommendationExtensionStore
|
|
314
360
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
function l(t) {
|
|
2
2
|
if (t.length === 0)
|
|
3
3
|
return "";
|
|
4
|
-
const o = t.sort((r, e) => r.filterNumber - e.filterNumber), n = o.map((r) => `[${r.attribute}][${r.
|
|
5
|
-
let u =
|
|
6
|
-
for (let r = 0; r <
|
|
7
|
-
const e = o[r
|
|
8
|
-
u += `${e}${
|
|
4
|
+
const o = t.sort((r, e) => r.filterNumber - e.filterNumber), n = o.map((r) => `[${r.attribute}][${r.operator}][${r.value}]`), [p, ...i] = n;
|
|
5
|
+
let u = p;
|
|
6
|
+
for (let r = 0; r < i.length; r++) {
|
|
7
|
+
const e = o[r].innerGroupOperator;
|
|
8
|
+
u += `${e}${i[r]}`;
|
|
9
9
|
}
|
|
10
10
|
return `(${u})`;
|
|
11
11
|
}
|
|
12
12
|
function f(t) {
|
|
13
13
|
if (!t || t.length === 0)
|
|
14
14
|
return "";
|
|
15
|
-
const o = t.reduce((r, e) => (r[e.filterGroup] || (r[e.filterGroup] = []), r[e.filterGroup].push(e), r), {}), n = Object.keys(o).map(Number).sort((r, e) => r - e),
|
|
15
|
+
const o = t.reduce((r, e) => (r[e.filterGroup] || (r[e.filterGroup] = []), r[e.filterGroup].push(e), r), {}), n = Object.keys(o).map(Number).sort((r, e) => r - e), p = n.map((r) => {
|
|
16
16
|
const e = o[r];
|
|
17
17
|
return l(e);
|
|
18
|
-
}), [
|
|
19
|
-
let s =
|
|
18
|
+
}), [i, ...u] = p;
|
|
19
|
+
let s = i;
|
|
20
20
|
for (let r = 0; r < u.length; r++) {
|
|
21
21
|
const e = n[r + 1], c = o[e][0].outerGroupOperator;
|
|
22
22
|
s += `${c}${u[r]}`;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { safeParse as o, object as p, boolean as l, number as i, pipe as c, minLength as f, string as m } from "../../../../node_modules/valibot/dist/index.js";
|
|
2
|
+
const e = c(m(), f(1)), s = p({
|
|
3
|
+
type: e,
|
|
4
|
+
attribute: e,
|
|
5
|
+
operator: e,
|
|
6
|
+
innerGroupOperator: e,
|
|
7
|
+
outerGroupOperator: e,
|
|
8
|
+
value: e,
|
|
9
|
+
filterGroup: i(),
|
|
10
|
+
filterNumber: i(),
|
|
11
|
+
isValid: l()
|
|
12
|
+
});
|
|
13
|
+
function g(t) {
|
|
14
|
+
return o(s, t).success;
|
|
15
|
+
}
|
|
16
|
+
function S(t) {
|
|
17
|
+
const r = o(s, t);
|
|
18
|
+
return r.success ? /* @__PURE__ */ new Set() : new Set(
|
|
19
|
+
r.issues.flatMap((u) => {
|
|
20
|
+
var n;
|
|
21
|
+
return ((n = u.path) == null ? void 0 : n.map((a) => String(a.key))) ?? [];
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
s as FilterSchema,
|
|
27
|
+
S as getInvalidFilterFields,
|
|
28
|
+
g as isFilterValid
|
|
29
|
+
};
|
package/dist/guido.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gap-16[data-v-
|
|
1
|
+
.gap-16[data-v-3b53a736],.gap-16[data-v-0e1b0c54]{gap:16px}[data-v-cd76c125] .in-button-v2__wrapper{line-height:0}[data-v-22226124] .in-segments-wrapper__button_selected,[data-v-22226124] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb;color:#0010ac;border-color:#0010ac}[data-v-079d2bf7] .in-progress-wrapper__progress p span:last-child{display:none!important}.view-options-wrapper[data-v-195ab6d4]{position:relative;display:inline-block}.new-tag[data-v-195ab6d4]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-195ab6d4] .guido__view-option-selection-desktop svg,[data-v-195ab6d4] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-195ab6d4] .in-segments-wrapper__button_selected,[data-v-195ab6d4] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-195ab6d4] .in-tooltip-wrapper__icon{cursor:pointer}.editor-toolbar[data-v-173c3a40]{gap:4px}.version-history-item[data-v-ee4b9c3f]{flex-basis:200px}.version-history[data-v-64c52560]{gap:8px}.version-history__toolbar[data-v-64c52560]{gap:4px}.view-options-wrapper[data-v-d405ca59]{position:relative;display:inline-block}.new-tag[data-v-d405ca59]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-d405ca59] .guido__verion-history-view-option-selection-desktop svg,[data-v-d405ca59] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-d405ca59] .in-segments-wrapper__button_selected,[data-v-d405ca59] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-d405ca59] .in-tooltip-wrapper__icon{cursor:pointer}.editor-actions[data-v-a289b9e9]{gap:4px}.header-wrapper[data-v-5c02dcc7]{min-width:1000px}.guido-loading__wrapper[data-v-07c4b2d8]{height:100%;top:75px!important;bottom:0!important}.guido-editor__wrapper[data-v-16abb398]{position:relative;width:100%;height:calc(100vh - 128px)}.guido-editor__container[data-v-16abb398]{width:100%;height:calc(100vh - 128px)}.guido-editor__no-header[data-v-16abb398]{height:calc(100vh - 75px)}[data-v-293f1c47] .in-breadcrumb-wrapper__links{cursor:pointer}.templates-wrapper[data-v-df672485]{gap:16px;grid-template-columns:repeat(3,1fr)}.templates-wrapper .template-wrapper[data-v-df672485]{cursor:pointer}.templates-wrapper .template-wrapper .template-container[data-v-df672485]{height:274px;padding:2px;transition:none}.templates-wrapper .template-wrapper .template-container.selected[data-v-df672485]{padding:1px}.templates-wrapper .template-wrapper .template-container .thumbnail[data-v-df672485]{object-fit:cover;transform:scale(1)}[data-v-43c617a7] .guido__verion-history-view-option-selection-desktop svg,[data-v-43c617a7] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-43c617a7] .in-segments-wrapper__button_selected,[data-v-43c617a7] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}.error-list[data-v-c3fd5d4b]{gap:16px}.desktop-browser-header[data-v-d86c5af5]{height:79px;min-height:79px}.desktop-browser-header__left[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:378px}.desktop-browser-header__center[data-v-d86c5af5]{height:79px;background-repeat:repeat-x;background-size:auto 100%;background-position:left top}.desktop-browser-header__right[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:112px}.desktop-preview[data-v-988f8da6]{min-width:602px;height:70vh;min-height:583px;border-radius:10px}.desktop-preview iframe[data-v-988f8da6]{min-height:504px}.iframe-wrapper[data-v-e0424e99]{width:258px}.iframe-scaled[data-v-e0424e99]{width:320px;height:124.0310077519%;transform:scale(.80625);transform-origin:top left}.cropped-text[data-v-eb3d05d7]{width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mobile-preview-wrapper__phone[data-v-3f472f96]{width:282px}.mobile-preview-wrapper__phone img[data-v-3f472f96]{object-fit:cover;border-radius:44px}.mobile-preview-wrapper__content[data-v-3f472f96]{width:258px;height:450px;left:12px}[data-v-d3c52b44] .vueperslides__bullets,[data-v-dd1a237a] .vueperslides__bullets{pointer-events:none!important}[data-v-dd1a237a] .vueperslides__parallax-wrapper{height:110px!important}[data-v-a408dcea] .vueperslides__bullets{pointer-events:none!important}[data-v-a408dcea] .vueperslides__parallax-wrapper{height:110px!important}
|
|
@@ -3,6 +3,7 @@ type __VLS_Props = {
|
|
|
3
3
|
filter: Filter;
|
|
4
4
|
index: number;
|
|
5
5
|
hasLogicAdapter?: boolean;
|
|
6
|
+
submitted: boolean;
|
|
6
7
|
};
|
|
7
8
|
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
|
|
8
9
|
"delete-filter": (filter: Filter) => void;
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
submitted: boolean;
|
|
3
|
+
};
|
|
4
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {
|
|
5
|
+
switchToGroup: (groupId: number) => void;
|
|
6
|
+
}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
|
|
7
|
+
"reset-validation": () => void;
|
|
8
|
+
}, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
|
|
2
9
|
export default _default;
|
|
10
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
11
|
+
type __VLS_TypePropsToOption<T> = {
|
|
12
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
13
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
14
|
+
} : {
|
|
15
|
+
type: import('vue').PropType<T[K]>;
|
|
16
|
+
required: true;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -76,4 +76,9 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
76
76
|
* (e.g., fetchRecommendationCreateData setting preferred currency).
|
|
77
77
|
*/
|
|
78
78
|
_listenStateUpdates(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Persists the current filter state from Pinia store to the Stripo node config.
|
|
81
|
+
* This ensures filters survive template save/reload cycles.
|
|
82
|
+
*/
|
|
83
|
+
private _persistFiltersToNodeConfig;
|
|
79
84
|
}
|