@useinsider/guido 2.1.0-beta.9b06e1d → 2.1.0-beta.9b797dd
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 +9 -12
- 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/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
- package/dist/config/migrator/itemsBlockMigrator.js +65 -64
- 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/extensions/Blocks/Unsubscribe/block.js +29 -29
- package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
- package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
- package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
- 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/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
- package/dist/stores/unsubscribe.js +37 -34
- package/package.json +1 -1
|
@@ -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
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var u = (n, i, e) =>
|
|
2
|
+
var h = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
|
|
3
|
+
var u = (n, i, e) => h(n, typeof i != "symbol" ? i + "" : i, e);
|
|
4
4
|
import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
|
|
5
5
|
import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
|
|
6
|
-
import { Block as
|
|
6
|
+
import { Block as _, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
7
|
import { getDefaultTemplate as L } from "./template.js";
|
|
8
8
|
import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
|
|
9
9
|
import { parsePageList as p } from "./utils/utils.js";
|
|
10
|
-
const
|
|
10
|
+
const v = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", T = "{{ins-unsubscribe-link}}", B = {
|
|
11
11
|
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
12
12
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
13
13
|
};
|
|
14
|
-
class R extends
|
|
14
|
+
class R extends _ {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
u(this, "selectEventListener", null);
|
|
@@ -19,7 +19,7 @@ class R extends h {
|
|
|
19
19
|
u(this, "currentNode");
|
|
20
20
|
}
|
|
21
21
|
getId() {
|
|
22
|
-
return
|
|
22
|
+
return v;
|
|
23
23
|
}
|
|
24
24
|
getIcon() {
|
|
25
25
|
return "unsubscribe-icon";
|
|
@@ -47,8 +47,8 @@ class R extends h {
|
|
|
47
47
|
}
|
|
48
48
|
_setupSelectEventListener() {
|
|
49
49
|
this._removeSelectEventListener(), this.selectEventListener = (e) => {
|
|
50
|
-
const
|
|
51
|
-
this._updateBlock(
|
|
50
|
+
const r = e, { collectionType: s, selectedPages: t } = r.detail;
|
|
51
|
+
this._updateBlock(s, t.join(","));
|
|
52
52
|
}, document.addEventListener(a.SELECT, this.selectEventListener);
|
|
53
53
|
}
|
|
54
54
|
_removeSelectEventListener() {
|
|
@@ -74,17 +74,17 @@ class R extends h {
|
|
|
74
74
|
_removeEventListeners() {
|
|
75
75
|
this._removeSelectEventListener(), this._removeCancelEventListener();
|
|
76
76
|
}
|
|
77
|
-
_updateBlock(e,
|
|
77
|
+
_updateBlock(e, r) {
|
|
78
78
|
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
79
79
|
return;
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
80
|
+
const s = this.currentNode.querySelector(g);
|
|
81
|
+
if (!s)
|
|
82
82
|
return;
|
|
83
|
-
const
|
|
84
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
83
|
+
const t = this._getMergeTag(e);
|
|
84
|
+
this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", t).apply(new b(`Updated unsubscribe link to ${t}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
|
|
85
85
|
}
|
|
86
86
|
_getMergeTag(e) {
|
|
87
|
-
return
|
|
87
|
+
return B[e] ?? T;
|
|
88
88
|
}
|
|
89
89
|
_openDrawer() {
|
|
90
90
|
if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
|
|
@@ -97,24 +97,24 @@ class R extends h {
|
|
|
97
97
|
}
|
|
98
98
|
_checkExistingBlocks() {
|
|
99
99
|
const e = c();
|
|
100
|
-
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((
|
|
101
|
-
if ("getAttribute" in
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
const l = Number(
|
|
100
|
+
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((s) => {
|
|
101
|
+
if ("getAttribute" in s) {
|
|
102
|
+
const t = s.getAttribute(o.PAGE_TYPE);
|
|
103
|
+
if (t) {
|
|
104
|
+
const l = Number(t);
|
|
105
105
|
l === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : l === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
_loadBlockState(e) {
|
|
110
|
+
async _loadBlockState(e) {
|
|
111
111
|
if (!("getAttribute" in e))
|
|
112
112
|
return;
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
113
|
+
const r = e.getAttribute(o.PAGE_TYPE), s = e.getAttribute(o.PAGE_LIST);
|
|
114
|
+
if (!r || !s)
|
|
115
115
|
return;
|
|
116
|
-
const
|
|
117
|
-
|
|
116
|
+
const t = c(), l = Number(r), m = p(s);
|
|
117
|
+
await t.fetchTemplates(), t.setCollectionWithoutAutoSelection(l), t.loadSelectedTemplates(m);
|
|
118
118
|
}
|
|
119
119
|
_resetStoreState() {
|
|
120
120
|
c().$reset();
|
|
@@ -122,14 +122,14 @@ class R extends h {
|
|
|
122
122
|
_removeBlockTemplatesFromStore(e) {
|
|
123
123
|
if (!("getAttribute" in e))
|
|
124
124
|
return;
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
125
|
+
const r = e.getAttribute(o.PAGE_LIST);
|
|
126
|
+
if (!r)
|
|
127
127
|
return;
|
|
128
|
-
const
|
|
129
|
-
|
|
128
|
+
const s = c(), t = p(r);
|
|
129
|
+
s.removeUnsubscribePages(t);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
export {
|
|
133
|
-
|
|
133
|
+
v as UNSUBSCRIBE_BLOCK_ID,
|
|
134
134
|
R as UnsubscribeBlock
|
|
135
135
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (a, s, e) =>
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var h = (a, s, e) => s in a ? d(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
|
|
3
|
+
var u = (a, s, e) => h(a, typeof s != "symbol" ? s + "" : s, e);
|
|
4
4
|
import { useUnsubscribeStore as l } from "../../../stores/unsubscribe.js";
|
|
5
5
|
import { Control as T, UEAttr as i, UIElementType as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { DATA_ATTRIBUTES as p } from "./utils/constants.js";
|
|
7
7
|
import { parsePageList as _ } from "./utils/utils.js";
|
|
8
|
-
const
|
|
8
|
+
const v = "ui-elements-unsubscribe", r = {
|
|
9
9
|
SELECT_BUTTON: "selectTemplateButton",
|
|
10
10
|
PREV_BUTTON: "prevButton",
|
|
11
11
|
NEXT_BUTTON: "nextButton",
|
|
12
12
|
COUNTER_TEXT: "counterText",
|
|
13
13
|
PREVIEW_IMAGE: "previewImage"
|
|
14
14
|
};
|
|
15
|
-
class
|
|
15
|
+
class B extends T {
|
|
16
16
|
constructor() {
|
|
17
17
|
super(...arguments);
|
|
18
18
|
u(this, "currentPreviewIndex", 0);
|
|
@@ -22,7 +22,7 @@ class N extends T {
|
|
|
22
22
|
u(this, "lastParsedAttribute");
|
|
23
23
|
}
|
|
24
24
|
getId() {
|
|
25
|
-
return
|
|
25
|
+
return v;
|
|
26
26
|
}
|
|
27
27
|
getTemplate() {
|
|
28
28
|
return `
|
|
@@ -35,7 +35,7 @@ class N extends T {
|
|
|
35
35
|
onTemplateNodeUpdated(e) {
|
|
36
36
|
if (this.currentNode = e, "getAttribute" in this.currentNode) {
|
|
37
37
|
const t = this.currentNode.getAttribute(p.PAGE_LIST);
|
|
38
|
-
t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this.
|
|
38
|
+
t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updateCounter(), this._loadAndUpdatePreview());
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
onRender() {
|
|
@@ -73,6 +73,9 @@ class N extends T {
|
|
|
73
73
|
_onNextClick() {
|
|
74
74
|
this.currentPreviewIndex < this.totalTemplates - 1 && (this.currentPreviewIndex++, this._updatePreview(), this._updateCounter());
|
|
75
75
|
}
|
|
76
|
+
async _loadAndUpdatePreview() {
|
|
77
|
+
await l().fetchTemplates(), this._updatePreview(), this._updateCounter();
|
|
78
|
+
}
|
|
76
79
|
_updatePreview() {
|
|
77
80
|
var e;
|
|
78
81
|
if ((e = this.currentPages) != null && e.length)
|
|
@@ -162,6 +165,6 @@ class N extends T {
|
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
167
|
export {
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
v as UNSUBSCRIBE_CONTROL_ID,
|
|
169
|
+
B as UnsubscribeControl
|
|
167
170
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UIElement as
|
|
5
|
-
const E = "unsubscribe-preview",
|
|
6
|
-
class
|
|
1
|
+
var n = Object.defineProperty;
|
|
2
|
+
var m = (s, i, e) => i in s ? n(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
|
|
3
|
+
var r = (s, i, e) => m(s, typeof i != "symbol" ? i + "" : i, e);
|
|
4
|
+
import { UIElement as l } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
const E = "unsubscribe-preview", c = "img", a = "Unsubscribe page preview", g = "is-loaded";
|
|
6
|
+
class d extends l {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
9
|
-
|
|
9
|
+
r(this, "imgElement");
|
|
10
10
|
}
|
|
11
11
|
getId() {
|
|
12
12
|
return E;
|
|
@@ -14,19 +14,21 @@ class o extends m {
|
|
|
14
14
|
getTemplate() {
|
|
15
15
|
return `
|
|
16
16
|
<div class="unsubscribe-preview-image-container">
|
|
17
|
+
<div class="unsubscribe-preview-loader"></div>
|
|
17
18
|
<img
|
|
18
19
|
src=""
|
|
19
|
-
alt="${
|
|
20
|
+
alt="${a}"
|
|
20
21
|
class="unsubscribe-preview-image"
|
|
21
22
|
/>
|
|
22
23
|
</div>
|
|
23
24
|
`;
|
|
24
25
|
}
|
|
25
26
|
onRender(e) {
|
|
26
|
-
this.imgElement = e.querySelector(
|
|
27
|
+
this.imgElement = e.querySelector(c);
|
|
27
28
|
}
|
|
28
29
|
setValue(e) {
|
|
29
|
-
|
|
30
|
+
var t;
|
|
31
|
+
this.imgElement && (this.imgElement.src = e, (t = this.imgElement.parentElement) == null || t.classList.add(g));
|
|
30
32
|
}
|
|
31
33
|
getValue() {
|
|
32
34
|
var e;
|
|
@@ -38,5 +40,5 @@ class o extends m {
|
|
|
38
40
|
}
|
|
39
41
|
export {
|
|
40
42
|
E as PREVIEW_UI_ELEMENT_ID,
|
|
41
|
-
|
|
43
|
+
d as PreviewUIElement
|
|
42
44
|
};
|
|
@@ -29,12 +29,42 @@ const n = `/* Unsubscribe Extension Styles */
|
|
|
29
29
|
display: flex;
|
|
30
30
|
align-items: center;
|
|
31
31
|
justify-content: center;
|
|
32
|
+
position: relative;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
.unsubscribe-preview-image {
|
|
35
|
+
.unsubscribe-preview-image-container .unsubscribe-preview-image {
|
|
35
36
|
object-fit: cover;
|
|
36
37
|
width: 100%;
|
|
37
38
|
height: auto;
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.unsubscribe-preview-image-container.is-loaded .unsubscribe-preview-image {
|
|
43
|
+
display: block;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.unsubscribe-preview-image-container.is-loaded .unsubscribe-preview-loader {
|
|
47
|
+
display: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Loading shimmer */
|
|
51
|
+
.unsubscribe-preview-loader {
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 200px;
|
|
54
|
+
border-radius: 4px;
|
|
55
|
+
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
|
|
56
|
+
background-size: 200% 100%;
|
|
57
|
+
animation: unsubscribe-shimmer 1.5s infinite;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@keyframes unsubscribe-shimmer {
|
|
61
|
+
0% {
|
|
62
|
+
background-position: 200% 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
100% {
|
|
66
|
+
background-position: -200% 0;
|
|
67
|
+
}
|
|
38
68
|
}
|
|
39
69
|
`;
|
|
40
70
|
export {
|