@useinsider/guido 2.1.0-beta.e2153c2 → 2.1.0-beta.e4c3fa1
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/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/composables/useRecommendation.js +9 -9
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +36 -33
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +16 -14
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +13 -12
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +37 -27
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +16 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +30 -32
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +173 -102
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +46 -38
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +16 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +269 -215
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +10 -10
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +14 -14
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +225 -102
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +94 -53
- package/dist/guido.css +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -2
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +6 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +33 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +24 -14
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +49 -17
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,14 +1,16 @@
|
|
|
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 {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { RecommendationFeedSourceMaps as S, PriceAttributes as R } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as k } from "../../../../services/recommendationApi.js";
|
|
3
|
+
import { useConfigStore as y } from "../../../../stores/config.js";
|
|
4
|
+
import { defineStore as C } from "pinia";
|
|
5
|
+
import { DEFAULT_CARDS_IN_ROW as G } from "../constants/layout.js";
|
|
6
|
+
import { EXCLUDED_ALGORITHM_IDS as P } from "../constants/defaultConfig.js";
|
|
7
|
+
import { getDefaultProducts as p } from "../templates/utils.js";
|
|
8
|
+
import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
|
|
9
|
+
const h = k();
|
|
10
|
+
let a = null, l = null, u = null;
|
|
11
|
+
function I() {
|
|
10
12
|
return {
|
|
11
|
-
cardsInRow:
|
|
13
|
+
cardsInRow: G,
|
|
12
14
|
currencySettings: {
|
|
13
15
|
name: "USD",
|
|
14
16
|
value: "USD",
|
|
@@ -32,9 +34,9 @@ function h() {
|
|
|
32
34
|
size: "6"
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
|
-
function
|
|
37
|
+
function v() {
|
|
36
38
|
return {
|
|
37
|
-
recommendationConfigs:
|
|
39
|
+
recommendationConfigs: I(),
|
|
38
40
|
recommendationProducts: [],
|
|
39
41
|
filterStatus: !1,
|
|
40
42
|
filterSelectionDrawerStatus: !1,
|
|
@@ -42,7 +44,7 @@ function C() {
|
|
|
42
44
|
isInitialized: !1
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
|
-
const
|
|
47
|
+
const D = () => ({
|
|
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
|
+
}), _ = C("guidoRecommendationExtension", {
|
|
57
|
+
state: () => D(),
|
|
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 : I();
|
|
66
68
|
},
|
|
67
69
|
/**
|
|
68
70
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -100,8 +102,8 @@ const y = () => ({
|
|
|
100
102
|
},
|
|
101
103
|
getActivePredictiveAlgorithms: (t) => {
|
|
102
104
|
const r = [];
|
|
103
|
-
return t.activePredictiveAlgorithms.forEach((e) => {
|
|
104
|
-
r.push(...
|
|
105
|
+
return t.activePredictiveAlgorithms.filter((e) => !P.includes(e)).forEach((e) => {
|
|
106
|
+
r.push(...S.filter((n) => n.id === e));
|
|
105
107
|
}), r.map((e) => ({
|
|
106
108
|
text: e.name,
|
|
107
109
|
value: e.key
|
|
@@ -117,7 +119,7 @@ const y = () => ({
|
|
|
117
119
|
})),
|
|
118
120
|
getFilterList() {
|
|
119
121
|
return Object.values(this.filterList).map((t) => {
|
|
120
|
-
const r = t.type === "defaultAttribute", e =
|
|
122
|
+
const r = t.type === "defaultAttribute", e = R.includes(t.attributeName);
|
|
121
123
|
let n = r ? t.attributeName : `product_attributes.${t.attributeName}`;
|
|
122
124
|
return n = e ? `${n}.${this.recommendationConfigs.currencySettings.value}` : n, {
|
|
123
125
|
text: t.displayName,
|
|
@@ -141,7 +143,7 @@ const y = () => ({
|
|
|
141
143
|
setCurrentBlock(t) {
|
|
142
144
|
this.blockStates[t] || (this.blockStates = {
|
|
143
145
|
...this.blockStates,
|
|
144
|
-
[t]:
|
|
146
|
+
[t]: v()
|
|
145
147
|
}), this.currentRecommendationId = t;
|
|
146
148
|
},
|
|
147
149
|
/**
|
|
@@ -213,22 +215,46 @@ const y = () => ({
|
|
|
213
215
|
// Shared Data Fetching (fetched once, used by all blocks)
|
|
214
216
|
// ====================================================================
|
|
215
217
|
async fetchRecommendationCreateData() {
|
|
216
|
-
if (this.activePredictiveAlgorithms.length)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
218
|
+
if (!this.activePredictiveAlgorithms.length) {
|
|
219
|
+
if (a) {
|
|
220
|
+
await a;
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
a = (async () => {
|
|
224
|
+
const {
|
|
225
|
+
activePredictiveAlgorithms: t,
|
|
226
|
+
languages: r,
|
|
227
|
+
currencies: e
|
|
228
|
+
} = await h.fetchRecommendationCreateData();
|
|
229
|
+
if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
230
|
+
const n = this.blockStates[this.currentRecommendationId];
|
|
231
|
+
n.filterStatus = !!n.recommendationConfigs.filters.length;
|
|
232
|
+
}
|
|
233
|
+
this.currencyList = e;
|
|
234
|
+
})();
|
|
235
|
+
try {
|
|
236
|
+
await a;
|
|
237
|
+
} finally {
|
|
238
|
+
a = null;
|
|
239
|
+
}
|
|
226
240
|
}
|
|
227
|
-
this.currencyList = e;
|
|
228
241
|
},
|
|
229
242
|
async fetchRecommendationFilters() {
|
|
230
|
-
|
|
231
|
-
|
|
243
|
+
if (!Object.keys(this.filterList).length) {
|
|
244
|
+
if (l) {
|
|
245
|
+
await l;
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
l = (async () => {
|
|
249
|
+
const t = await h.fetchRecommendationFilters();
|
|
250
|
+
this.filterList = t;
|
|
251
|
+
})();
|
|
252
|
+
try {
|
|
253
|
+
await l;
|
|
254
|
+
} finally {
|
|
255
|
+
l = null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
232
258
|
},
|
|
233
259
|
// ====================================================================
|
|
234
260
|
// Per-Block Filter Actions
|
|
@@ -268,47 +294,62 @@ const y = () => ({
|
|
|
268
294
|
addFilter(t) {
|
|
269
295
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
270
296
|
return;
|
|
271
|
-
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters],
|
|
272
|
-
(
|
|
273
|
-
).length + 1,
|
|
274
|
-
|
|
297
|
+
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], s = e.filter(
|
|
298
|
+
(o) => o.filterGroup === t.filterGroup
|
|
299
|
+
).length + 1, m = e.findLastIndex((o) => o.filterGroup === t.filterGroup);
|
|
300
|
+
m !== -1 ? e.splice(m + 1, 0, {
|
|
275
301
|
...t,
|
|
276
|
-
filterNumber:
|
|
302
|
+
filterNumber: s
|
|
277
303
|
}) : e.push({
|
|
278
304
|
...t,
|
|
279
|
-
filterNumber:
|
|
305
|
+
filterNumber: s
|
|
280
306
|
}), r.recommendationConfigs.filters = e;
|
|
281
307
|
},
|
|
282
308
|
generateFilterQuery() {
|
|
283
|
-
return
|
|
309
|
+
return b(this.recommendationConfigs.filters);
|
|
284
310
|
},
|
|
285
311
|
// ====================================================================
|
|
286
312
|
// Per-Block Product Fetching
|
|
287
313
|
// ====================================================================
|
|
288
314
|
async fetchRecommendationProducts() {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
315
|
+
if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
|
|
316
|
+
if (u) {
|
|
317
|
+
await u;
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
u = this._doFetchProducts();
|
|
321
|
+
try {
|
|
322
|
+
await u;
|
|
323
|
+
} finally {
|
|
324
|
+
u = null;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
async _doFetchProducts() {
|
|
329
|
+
var g;
|
|
330
|
+
const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((i) => i.isValid), s = b(n), m = ((g = S.find((i) => i.key === e.strategy)) == null ? void 0 : g.path) || "", o = y(), c = {
|
|
293
331
|
locale: e.language,
|
|
294
332
|
currency: e.currencySettings.value,
|
|
295
|
-
partnerName:
|
|
333
|
+
partnerName: o.partnerName,
|
|
296
334
|
size: e.size,
|
|
297
335
|
details: !0,
|
|
298
|
-
campaignId:
|
|
336
|
+
campaignId: o.variationId
|
|
299
337
|
};
|
|
300
|
-
e.strategy === "manualMerchandising" ? c.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (c.productId = "{itemId}"),
|
|
301
|
-
const
|
|
302
|
-
let
|
|
338
|
+
e.strategy === "manualMerchandising" ? c.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (c.productId = "{itemId}"), e.strategy === "userBased" && (c.userId = "{user_id}"), s && (c.filter = s), e.shuffleProducts && (c.shuffle = !0);
|
|
339
|
+
const f = parseInt(e.size) || 6;
|
|
340
|
+
let d;
|
|
303
341
|
try {
|
|
304
|
-
|
|
342
|
+
d = await h.fetchRecommendationProducts(m, c);
|
|
305
343
|
} catch {
|
|
306
|
-
|
|
344
|
+
d = [];
|
|
345
|
+
}
|
|
346
|
+
if (this.blockStates[t]) {
|
|
347
|
+
const i = d.length > 0 ? d : p(f);
|
|
348
|
+
this.blockStates[t].recommendationProducts = i.length < f ? [...i, ...p(f - i.length)] : i;
|
|
307
349
|
}
|
|
308
|
-
this.blockStates[t] && (this.blockStates[t].recommendationProducts = a.length > 0 ? a : k(g));
|
|
309
350
|
}
|
|
310
351
|
}
|
|
311
352
|
});
|
|
312
353
|
export {
|
|
313
|
-
|
|
354
|
+
_ as useRecommendationExtensionStore
|
|
314
355
|
};
|
package/dist/guido.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gap-16[data-v-6562e38c],.gap-16[data-v-1ccb6d4a]{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-
|
|
1
|
+
.gap-16[data-v-6562e38c],.gap-16[data-v-1ccb6d4a]{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-17dd4d8b]{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}
|
|
@@ -41,6 +41,12 @@ export declare const DEFAULT_VISIBILITY: Record<string, boolean>;
|
|
|
41
41
|
* All other code should import and use this constant.
|
|
42
42
|
*/
|
|
43
43
|
export declare const DEFAULT_NODE_CONFIG: RecommendationNodeConfig;
|
|
44
|
+
/**
|
|
45
|
+
* Algorithm IDs to exclude from the recommendation algorithm dropdown.
|
|
46
|
+
* These algorithms will not be shown as options regardless of API response.
|
|
47
|
+
* View Together and Purchase Together algorithms are disabled because these require product id.
|
|
48
|
+
*/
|
|
49
|
+
export declare const EXCLUDED_ALGORITHM_IDS: number[];
|
|
44
50
|
/**
|
|
45
51
|
* Current configuration version
|
|
46
52
|
* Increment this when making breaking changes to the schema
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { RecommendationBlockId } from './blockIds';
|
|
10
10
|
export { RecommendationControlId } from './controlIds';
|
|
11
|
-
export { CONTAINER_SELECTOR, DESKTOP_CONTAINER_SELECTOR, MOBILE_CONTAINER_SELECTOR, CURRENCY_ATTR, ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON, } from './selectors';
|
|
12
|
-
export { LAYOUT_VALUES, LAYOUT_OPTIONS, DEFAULT_PRODUCTS_PER_ROW, DEFAULT_CARDS_IN_ROW, DEFAULT_MOBILE_CARDS_IN_ROW, MAX_PRODUCT_COUNT, MIN_PRODUCT_COUNT, MAX_PRODUCTS_PER_ROW, MIN_PRODUCTS_PER_ROW, MAX_MOBILE_PRODUCTS_PER_ROW, MIN_MOBILE_PRODUCTS_PER_ROW, DEFAULT_COLUMN_SPACING, DEFAULT_ROW_SPACING, MIN_SPACING, MAX_SPACING, SPACING_STEP, } from './layout';
|
|
13
|
-
export { DEFAULT_NODE_CONFIG, DEFAULT_CURRENCY, DEFAULT_COMPOSITION, DEFAULT_VISIBILITY, CURRENT_CONFIG_VERSION, } from './defaultConfig';
|
|
11
|
+
export { BLOCK_ROOT_SELECTOR, CONTAINER_SELECTOR, DESKTOP_CONTAINER_SELECTOR, MOBILE_CONTAINER_SELECTOR, CURRENCY_ATTR, ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON, } from './selectors';
|
|
12
|
+
export { LAYOUT_VALUES, LAYOUT_OPTIONS, DEFAULT_PRODUCTS_PER_ROW, DEFAULT_CARDS_IN_ROW, DEFAULT_MOBILE_CARDS_IN_ROW, MAX_PRODUCT_COUNT, MIN_PRODUCT_COUNT, MAX_PRODUCTS_PER_ROW, MIN_PRODUCTS_PER_ROW, MAX_MOBILE_PRODUCTS_PER_ROW, MIN_MOBILE_PRODUCTS_PER_ROW, DEFAULT_COLUMN_SPACING, DEFAULT_ROW_SPACING, DEFAULT_MOBILE_COLUMN_SPACING, DEFAULT_MOBILE_ROW_SPACING, MIN_SPACING, MAX_SPACING, SPACING_STEP, } from './layout';
|
|
13
|
+
export { DEFAULT_NODE_CONFIG, DEFAULT_CURRENCY, DEFAULT_COMPOSITION, DEFAULT_VISIBILITY, CURRENT_CONFIG_VERSION, EXCLUDED_ALGORITHM_IDS, } from './defaultConfig';
|
|
@@ -31,8 +31,12 @@ export declare const MAX_MOBILE_PRODUCTS_PER_ROW = 2;
|
|
|
31
31
|
export declare const MIN_MOBILE_PRODUCTS_PER_ROW = 1;
|
|
32
32
|
/** Default column spacing between product cards (5px on each side = 10px total) */
|
|
33
33
|
export declare const DEFAULT_COLUMN_SPACING = 10;
|
|
34
|
-
/** Default row spacing between product rows */
|
|
35
|
-
export declare const DEFAULT_ROW_SPACING =
|
|
34
|
+
/** Default row spacing between product rows (matches spacer height in template) */
|
|
35
|
+
export declare const DEFAULT_ROW_SPACING = 10;
|
|
36
|
+
/** Default mobile column spacing between product cards */
|
|
37
|
+
export declare const DEFAULT_MOBILE_COLUMN_SPACING = 10;
|
|
38
|
+
/** Default mobile row spacing between product rows (matches spacer height in template) */
|
|
39
|
+
export declare const DEFAULT_MOBILE_ROW_SPACING = 10;
|
|
36
40
|
/** Minimum spacing value */
|
|
37
41
|
export declare const MIN_SPACING = 0;
|
|
38
42
|
/** Maximum spacing value */
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CSS selectors and data attributes used across the Recommendation extension
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Block root selector — common ancestor of both desktop and mobile containers.
|
|
6
|
+
* Used across attribute controls so edits apply to BOTH containers simultaneously.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BLOCK_ROOT_SELECTOR = ".ins-recommendation-v3-block-v2";
|
|
4
9
|
/**
|
|
5
10
|
* Container selector for the product container element
|
|
6
|
-
* Used
|
|
11
|
+
* Used in product regeneration logic where container-specific scoping is needed
|
|
7
12
|
*/
|
|
8
13
|
export declare const CONTAINER_SELECTOR = ".ins-recommendation-product-container";
|
|
9
14
|
/** Desktop product container selector */
|
|
@@ -25,18 +25,13 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
25
25
|
getId(): string;
|
|
26
26
|
getTemplate(): string;
|
|
27
27
|
onRender(): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Immediately regenerate products with styles (no debounce)
|
|
30
|
-
* Used for initial load after fetch completes
|
|
31
|
-
*/
|
|
32
|
-
private _regenerateWithProducts;
|
|
33
28
|
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
34
29
|
onDestroy(): void;
|
|
35
30
|
/**
|
|
36
31
|
* Initialize all sub-controls with the shared API context
|
|
37
32
|
* Each sub-control manages its own form values and event listeners
|
|
38
33
|
*/
|
|
39
|
-
_initializeSubControls
|
|
34
|
+
private _initializeSubControls;
|
|
40
35
|
/**
|
|
41
36
|
* Syncs persisted node config into the Pinia store's block state.
|
|
42
37
|
*
|
|
@@ -50,11 +45,26 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
50
45
|
*/
|
|
51
46
|
private _syncNodeConfigToStore;
|
|
52
47
|
/**
|
|
53
|
-
* Fetches initial data for a block
|
|
48
|
+
* Fetches initial data for a block in three phases:
|
|
49
|
+
* 1. Shared reference data (algorithms, currencies, filters) — parallel
|
|
50
|
+
* 2. Smart defaults for new blocks (currency, algorithm) — sequential
|
|
51
|
+
* 3. Product data with correct defaults — sequential
|
|
52
|
+
*
|
|
54
53
|
* Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
|
|
55
54
|
* Marks the block as initialized to prevent redundant fetches on re-selection.
|
|
56
55
|
*/
|
|
57
56
|
private _fetchBlockData;
|
|
57
|
+
/**
|
|
58
|
+
* Applies smart defaults for newly dropped blocks.
|
|
59
|
+
*
|
|
60
|
+
* For new blocks (config still matches hardcoded defaults), validates that
|
|
61
|
+
* the default currency and algorithm are available from the API response.
|
|
62
|
+
* If not, falls back to the first available option.
|
|
63
|
+
*
|
|
64
|
+
* Saved templates with user-customized config are left unchanged because
|
|
65
|
+
* their values won't match the hardcoded defaults.
|
|
66
|
+
*/
|
|
67
|
+
private _applySmartDefaults;
|
|
58
68
|
/**
|
|
59
69
|
* Reads the recommendation-id attribute from the block element within the node
|
|
60
70
|
*/
|
|
@@ -64,8 +74,15 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
64
74
|
*/
|
|
65
75
|
private _debouncedFetchProducts;
|
|
66
76
|
/**
|
|
67
|
-
* Debounced
|
|
68
|
-
*
|
|
77
|
+
* Debounced content update when products arrive from API.
|
|
78
|
+
*
|
|
79
|
+
* Tries in-place update first (preserves user-applied styles) — this succeeds
|
|
80
|
+
* when the product count matches the DOM (algorithm/locale/currency changes).
|
|
81
|
+
*
|
|
82
|
+
* Falls back to full regeneration when product count differs from DOM — this
|
|
83
|
+
* happens after "Number of Products" changes where the DOM still has the old
|
|
84
|
+
* count. The store pads products to the configured size, so in-place only
|
|
85
|
+
* fails when the size actually changed.
|
|
69
86
|
*/
|
|
70
87
|
private _debouncedRegenerateWithProducts;
|
|
71
88
|
/**
|
|
@@ -74,6 +91,12 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
74
91
|
* Uses configVersion counter (incremented only by patchCurrentBlockConfig)
|
|
75
92
|
* to distinguish user-initiated config changes from internal mutations
|
|
76
93
|
* (e.g., fetchRecommendationCreateData setting preferred currency).
|
|
94
|
+
*
|
|
95
|
+
* Tracks currentRecommendationId to detect block switches. When the user
|
|
96
|
+
* selects a different recommendation block, the proxy getters (e.g.,
|
|
97
|
+
* recommendationProducts) return the new block's data — a different array
|
|
98
|
+
* reference that would be falsely detected as "new products arrived".
|
|
99
|
+
* We skip that tick and update tracking references instead.
|
|
77
100
|
*/
|
|
78
|
-
_listenStateUpdates
|
|
101
|
+
private _listenStateUpdates;
|
|
79
102
|
}
|
|
@@ -75,8 +75,12 @@ export interface ReapplySpacingOptions {
|
|
|
75
75
|
documentModifier: DocumentModifier;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* Reapplies spacing values
|
|
79
|
-
*
|
|
78
|
+
* Reapplies spacing values after product regeneration.
|
|
79
|
+
* Desktop spacing applies only to the desktop container;
|
|
80
|
+
* mobile spacing applies only to the mobile container.
|
|
81
|
+
*
|
|
82
|
+
* Reads values from node config (primary) with data-attribute fallback
|
|
83
|
+
* for backward compatibility with pre-nodeConfig templates.
|
|
80
84
|
* @param options - Configuration options
|
|
81
85
|
*/
|
|
82
86
|
export declare function reapplySpacing(options: ReapplySpacingOptions): void;
|
|
@@ -112,6 +116,17 @@ export interface RegenerateWithStylesOptions extends Omit<RegenerateProductRowsO
|
|
|
112
116
|
* @param options - Configuration options for regeneration
|
|
113
117
|
*/
|
|
114
118
|
export declare function regenerateProductRowsWithStyles(options: RegenerateWithStylesOptions): void;
|
|
119
|
+
/**
|
|
120
|
+
* Adjusts a products array to a target size.
|
|
121
|
+
* Used by ProductLayoutControl to synchronously match products to the new size
|
|
122
|
+
* before regeneration, avoiding the race condition where the store still holds
|
|
123
|
+
* products from the previous (stale) fetch.
|
|
124
|
+
*
|
|
125
|
+
* - More products than target → truncate
|
|
126
|
+
* - Fewer products than target → pad with dummy products
|
|
127
|
+
* - Exact match → return as-is
|
|
128
|
+
*/
|
|
129
|
+
export declare function adjustProductsToSize(products: RecommendationProduct[], targetSize: number): RecommendationProduct[];
|
|
115
130
|
type PriceKey = 'price' | 'original_price' | 'discount';
|
|
116
131
|
/**
|
|
117
132
|
* Formats a product price using current currency settings
|
|
@@ -149,16 +164,11 @@ export interface UpdateProductContentInPlaceOptions {
|
|
|
149
164
|
* Updates product content in-place without regenerating HTML structure.
|
|
150
165
|
* Preserves all user-applied styles by only touching dynamic content.
|
|
151
166
|
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
167
|
+
* Scopes element queries to the desktop container to avoid double-counting
|
|
168
|
+
* mobile container elements (both containers share identical block IDs).
|
|
169
|
+
* After updating desktop, also updates mobile container to keep them in sync.
|
|
155
170
|
*
|
|
156
|
-
*
|
|
157
|
-
* Stripo's internal node references and avoid cursor/selection tracking issues.
|
|
158
|
-
*
|
|
159
|
-
* Falls back to false when:
|
|
160
|
-
* - Product count changed (need to add/remove elements)
|
|
161
|
-
* - Cannot find required elements
|
|
171
|
+
* Falls back to false when product count changed (need to add/remove elements).
|
|
162
172
|
* @param options - Configuration options
|
|
163
173
|
* @returns true if in-place update was successful, false to fall back to full regeneration
|
|
164
174
|
*/
|
|
@@ -171,13 +181,13 @@ export interface UpdatePricesInPlaceOptions {
|
|
|
171
181
|
* Updates only price displays in-place (for currency changes).
|
|
172
182
|
* This is a lightweight update when only formatting changes, not product data.
|
|
173
183
|
*
|
|
184
|
+
* Scopes element queries to the desktop container to avoid double-counting
|
|
185
|
+
* mobile container elements. After updating desktop, also updates mobile.
|
|
186
|
+
*
|
|
174
187
|
* Perfect for:
|
|
175
188
|
* - Currency symbol change
|
|
176
189
|
* - Currency alignment change
|
|
177
190
|
* - Decimal/thousand separator changes
|
|
178
|
-
*
|
|
179
|
-
* Uses setText() on text nodes instead of setInnerHtml() to preserve
|
|
180
|
-
* Stripo's internal node references and avoid cursor/selection tracking issues.
|
|
181
191
|
* @param options - Configuration options
|
|
182
192
|
* @returns true if update was successful, false otherwise
|
|
183
193
|
*/
|
|
@@ -5,16 +5,20 @@
|
|
|
5
5
|
* - Column spacing: horizontal gap between cards in the same row
|
|
6
6
|
* - Row spacing: vertical gap between different rows
|
|
7
7
|
*
|
|
8
|
+
* Desktop and mobile have independent spacing controls that toggle
|
|
9
|
+
* visibility based on Stripo's editor preview mode (desktop/mobile).
|
|
10
|
+
*
|
|
8
11
|
* Configuration is stored via node config (persists with template).
|
|
9
12
|
* Actual spacing is applied to DOM elements via inline styles.
|
|
10
13
|
*/
|
|
11
|
-
import { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
14
|
+
import { type ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
12
15
|
import { CommonControl } from '../../../common-control';
|
|
13
16
|
export declare const SPACING_CONTROL_ID = "recommendation-spacing-control";
|
|
14
17
|
/**
|
|
15
18
|
* Control for managing spacing between product cards
|
|
16
19
|
* - Column spacing: horizontal gap between cards in the same row
|
|
17
20
|
* - Row spacing: vertical gap between different rows
|
|
21
|
+
* - Separate controls for desktop and mobile with device-mode toggling
|
|
18
22
|
*/
|
|
19
23
|
export declare class SpacingControl extends CommonControl {
|
|
20
24
|
private store;
|
|
@@ -25,17 +29,27 @@ export declare class SpacingControl extends CommonControl {
|
|
|
25
29
|
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
26
30
|
onDestroy(): void;
|
|
27
31
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
32
|
+
* Checks if the editor is currently in mobile preview mode
|
|
33
|
+
* using Stripo's EditorStatePropertyType API.
|
|
34
|
+
*/
|
|
35
|
+
_isMobileMode(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Updates spacing control visibility based on layout orientation, editor mode,
|
|
38
|
+
* and products-per-row count.
|
|
39
|
+
* - List layout: hide column spacing (products are full-width)
|
|
40
|
+
* - Desktop mode: show desktop spacing, hide mobile spacing
|
|
41
|
+
* - Mobile mode: show mobile spacing, hide desktop spacing
|
|
42
|
+
* - 1 product per row: hide column spacing (no gap between single column)
|
|
31
43
|
*/
|
|
32
|
-
|
|
44
|
+
_updateSpacingVisibility(): void;
|
|
33
45
|
/**
|
|
34
|
-
* Reads spacing values from node config first, falls back to DOM styles
|
|
46
|
+
* Reads spacing values from node config first, falls back to DOM styles.
|
|
47
|
+
* DOM fallback is only used for legacy templates that lack node config.
|
|
35
48
|
*/
|
|
36
49
|
_setFormValues(): void;
|
|
37
50
|
/**
|
|
38
51
|
* Gets stored column spacing from the first attribute row cell's padding.
|
|
52
|
+
* Scoped to the desktop container for accurate readings.
|
|
39
53
|
* For grid layout: cells inside .recommendation-attribute-row have padding applied.
|
|
40
54
|
* For list layout: the parent of .product-card-wrapper has the padding.
|
|
41
55
|
* The padding is applied as "0 {halfSpacing}px", so we extract and multiply by 2.
|
|
@@ -43,27 +57,33 @@ export declare class SpacingControl extends CommonControl {
|
|
|
43
57
|
_getStoredColumnSpacing(): number;
|
|
44
58
|
/**
|
|
45
59
|
* Gets stored row spacing from the first spacer element's height style
|
|
60
|
+
* Scoped to the desktop container for accurate readings.
|
|
46
61
|
*/
|
|
47
62
|
_getStoredRowSpacing(): number;
|
|
48
63
|
/**
|
|
49
|
-
* Handles column spacing changes.
|
|
50
|
-
*
|
|
51
|
-
* For list layout: applies padding to parent of product card wrappers.
|
|
64
|
+
* Handles column spacing changes for desktop.
|
|
65
|
+
* Applies horizontal padding only to the desktop container elements.
|
|
52
66
|
*/
|
|
53
67
|
_onColumnSpacingChange(spacing: number): void;
|
|
54
68
|
/**
|
|
55
|
-
* Handles row spacing changes
|
|
56
|
-
* Applies height to
|
|
69
|
+
* Handles row spacing changes for desktop.
|
|
70
|
+
* Applies height only to spacer elements in the desktop container.
|
|
57
71
|
*/
|
|
58
72
|
_onRowSpacingChange(spacing: number): void;
|
|
59
73
|
/**
|
|
60
|
-
*
|
|
74
|
+
* Handles column spacing changes for mobile.
|
|
75
|
+
* Applies horizontal padding only to the mobile container elements.
|
|
61
76
|
*/
|
|
62
|
-
|
|
77
|
+
_onMobileColumnSpacingChange(spacing: number): void;
|
|
63
78
|
/**
|
|
64
|
-
*
|
|
79
|
+
* Handles row spacing changes for mobile.
|
|
80
|
+
* Applies height only to spacer elements in the mobile container.
|
|
65
81
|
*/
|
|
66
|
-
|
|
82
|
+
_onMobileRowSpacingChange(spacing: number): void;
|
|
83
|
+
/**
|
|
84
|
+
* Stores a spacing value as a data attribute on the block root element
|
|
85
|
+
*/
|
|
86
|
+
_storeDataAttribute(attr: string, spacing: number): void;
|
|
67
87
|
_listenToFormUpdates(): void;
|
|
68
88
|
/**
|
|
69
89
|
* Debounced version of _onColumnSpacingChange
|
|
@@ -72,12 +92,24 @@ export declare class SpacingControl extends CommonControl {
|
|
|
72
92
|
_debouncedOnColumnSpacingChange: import("@vueuse/shared").PromisifyFn<(spacing: number) => void>;
|
|
73
93
|
/**
|
|
74
94
|
* Debounced version of _onRowSpacingChange
|
|
75
|
-
* Prevents excessive DOM updates when user rapidly adjusts the counter
|
|
76
95
|
*/
|
|
77
96
|
_debouncedOnRowSpacingChange: import("@vueuse/shared").PromisifyFn<(spacing: number) => void>;
|
|
97
|
+
/**
|
|
98
|
+
* Debounced version of _onMobileColumnSpacingChange
|
|
99
|
+
*/
|
|
100
|
+
_debouncedOnMobileColumnSpacingChange: import("@vueuse/shared").PromisifyFn<(spacing: number) => void>;
|
|
101
|
+
/**
|
|
102
|
+
* Debounced version of _onMobileRowSpacingChange
|
|
103
|
+
*/
|
|
104
|
+
_debouncedOnMobileRowSpacingChange: import("@vueuse/shared").PromisifyFn<(spacing: number) => void>;
|
|
78
105
|
/**
|
|
79
106
|
* Subscribe to store orientation changes
|
|
80
|
-
* Updates
|
|
107
|
+
* Updates spacing visibility when layout changes via the layout control
|
|
81
108
|
*/
|
|
82
109
|
_subscribeToOrientationChanges(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Subscribes to editor preview mode changes via Stripo API.
|
|
112
|
+
* Toggles which spacing controls (desktop/mobile) are visible.
|
|
113
|
+
*/
|
|
114
|
+
_subscribeToEditorModeChanges(): void;
|
|
83
115
|
}
|
|
@@ -221,5 +221,6 @@ export declare const useRecommendationExtensionStore: import("pinia").StoreDefin
|
|
|
221
221
|
addFilter(filter: Filter): void;
|
|
222
222
|
generateFilterQuery(): string;
|
|
223
223
|
fetchRecommendationProducts(): Promise<void>;
|
|
224
|
+
_doFetchProducts(): Promise<void>;
|
|
224
225
|
}>;
|
|
225
226
|
export {};
|
|
@@ -106,6 +106,14 @@ export interface RecommendationNodeConfig {
|
|
|
106
106
|
* Vertical spacing between product rows in pixels
|
|
107
107
|
*/
|
|
108
108
|
rowSpacing: number;
|
|
109
|
+
/**
|
|
110
|
+
* Horizontal spacing between product cards on mobile in pixels (grid layout only)
|
|
111
|
+
*/
|
|
112
|
+
mobileColumnSpacing: number;
|
|
113
|
+
/**
|
|
114
|
+
* Vertical spacing between product rows on mobile in pixels
|
|
115
|
+
*/
|
|
116
|
+
mobileRowSpacing: number;
|
|
109
117
|
/**
|
|
110
118
|
* Order of card elements from top to bottom
|
|
111
119
|
* Array of ATTR_PRODUCT_* constants
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.e4c3fa1",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|