@useinsider/guido 2.1.0-beta.2ad77c6 → 2.1.0-beta.2d0ecb3

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.
Files changed (73) hide show
  1. package/dist/components/organisms/base/Toaster.vue.js +4 -4
  2. package/dist/components/organisms/base/Toaster.vue2.js +12 -9
  3. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
  4. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  5. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  6. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  7. package/dist/composables/useRecommendation.js +9 -9
  8. package/dist/composables/useStripo.js +25 -23
  9. package/dist/composables/useVersionHistoryApi.js +1 -1
  10. package/dist/config/compiler/utils/recommendationCompilerUtils.js +1 -1
  11. package/dist/config/i18n/en/index.js +11 -0
  12. package/dist/config/i18n/en/labels.json.js +7 -0
  13. package/dist/config/i18n/en/toasters.json.js +56 -0
  14. package/dist/config/i18n/en/tooltips.json.js +82 -0
  15. package/dist/config/i18n/index.js +7 -0
  16. package/dist/config/migrator/itemsBlockMigrator.js +65 -64
  17. package/dist/config/migrator/recommendationMigrator.js +1 -1
  18. package/dist/extensions/Blocks/Recommendation/block.js +1 -1
  19. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +36 -33
  20. package/dist/extensions/Blocks/Recommendation/constants/layout.js +16 -14
  21. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -13
  22. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +9 -9
  23. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +1 -1
  24. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +41 -29
  25. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +16 -16
  26. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +30 -32
  27. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +173 -102
  28. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +9 -9
  29. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +46 -38
  30. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +16 -16
  31. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +291 -217
  32. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +14 -14
  33. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +10 -10
  34. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
  35. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +14 -14
  36. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +9 -9
  37. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +3 -3
  38. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +1 -1
  39. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +9 -9
  40. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +3 -3
  41. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +3 -3
  42. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +3 -3
  43. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +223 -99
  44. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +94 -53
  45. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +1 -1
  46. package/dist/extensions/Blocks/Recommendation/templates/utils.js +32 -32
  47. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  48. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  49. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  50. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  51. package/dist/guido.css +1 -1
  52. package/dist/src/config/i18n/en/index.d.ts +1 -0
  53. package/dist/src/config/i18n/index.d.ts +16 -0
  54. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +6 -0
  55. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -3
  56. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -2
  57. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +8 -1
  58. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +33 -10
  59. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +27 -14
  60. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +50 -17
  61. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
  62. package/dist/src/extensions/Blocks/Recommendation/templates/grid/migration.d.ts +1 -1
  63. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +4 -2
  64. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +1 -1
  65. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -1
  66. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +8 -0
  67. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  68. package/dist/static/styles/components/notification.css.js +18 -0
  69. package/dist/static/styles/components/tools.css.js +6 -2
  70. package/dist/static/styles/customEditorStyle.css.js +50 -23
  71. package/dist/static/styles/variables.css.js +2 -0
  72. package/dist/stores/unsubscribe.js +37 -34
  73. package/package.json +1 -1
@@ -1,14 +1,16 @@
1
- import { RecommendationFeedSourceMaps as d, PriceAttributes as S } from "../../../../enums/extensions/recommendationBlock.js";
2
- import { useRecommendationApi as p } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as b } from "../../../../stores/config.js";
4
- import { defineStore as I } from "pinia";
5
- import { DEFAULT_CARDS_IN_ROW as R } from "../constants/layout.js";
6
- import { getDefaultProducts as k } from "../templates/utils.js";
7
- import { generateCompleteFilterQuery as f } from "../utils/filterUtil.js";
8
- const m = p();
9
- function h() {
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: R,
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 C() {
37
+ function v() {
36
38
  return {
37
- recommendationConfigs: h(),
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 y = () => ({
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
- }), A = I("guidoRecommendationExtension", {
55
- state: () => y(),
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 : h();
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(...d.filter((n) => n.id === e));
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 = S.includes(t.attributeName);
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]: C()
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
- return;
218
- const {
219
- activePredictiveAlgorithms: t,
220
- languages: r,
221
- currencies: e
222
- } = await m.fetchRecommendationCreateData();
223
- if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
224
- const n = this.blockStates[this.currentRecommendationId];
225
- n.filterStatus = !!n.recommendationConfigs.filters.length;
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
- const t = await m.fetchRecommendationFilters();
231
- this.filterList = t;
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], o = e.filter(
272
- (i) => i.filterGroup === t.filterGroup
273
- ).length + 1, s = e.findLastIndex((i) => i.filterGroup === t.filterGroup);
274
- s !== -1 ? e.splice(s + 1, 0, {
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: o
302
+ filterNumber: s
277
303
  }) : e.push({
278
304
  ...t,
279
- filterNumber: o
305
+ filterNumber: s
280
306
  }), r.recommendationConfigs.filters = e;
281
307
  },
282
308
  generateFilterQuery() {
283
- return f(this.recommendationConfigs.filters);
309
+ return b(this.recommendationConfigs.filters);
284
310
  },
285
311
  // ====================================================================
286
312
  // Per-Block Product Fetching
287
313
  // ====================================================================
288
314
  async fetchRecommendationProducts() {
289
- var u;
290
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
291
- return;
292
- const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((l) => l.isValid), o = f(n), s = ((u = d.find((l) => l.key === e.strategy)) == null ? void 0 : u.path) || "", i = b(), c = {
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: i.partnerName,
333
+ partnerName: o.partnerName,
296
334
  size: e.size,
297
335
  details: !0,
298
- campaignId: i.variationId
336
+ campaignId: o.variationId
299
337
  };
300
- e.strategy === "manualMerchandising" ? c.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (c.productId = "{itemId}"), o && (c.filter = o), e.shuffleProducts && (c.shuffle = !0);
301
- const g = parseInt(e.size) || 6;
302
- let a;
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
- a = await m.fetchRecommendationProducts(s, c);
342
+ d = await h.fetchRecommendationProducts(m, c);
305
343
  } catch {
306
- a = [];
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
- A as useRecommendationExtensionStore
354
+ _ as useRecommendationExtensionStore
314
355
  };
@@ -5,7 +5,7 @@ const u = `
5
5
  align="left"
6
6
  esd-extension-block-id="recommendation-block"
7
7
  esd-handler-name="esd-extension-RecommendationBlock"
8
- class="ins-recommendation-v3-block-v2 esd-block-recommendation-v3-block esd-extension-block es-p20"
8
+ class="recommendation-block-v2 esd-block-recommendation-v3-block esd-extension-block es-p20"
9
9
  >
10
10
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
11
11
  <tr>
@@ -1,28 +1,28 @@
1
- import { ATTR_PRODUCT_IMAGE as n, ATTR_PRODUCT_NAME as o, ATTR_PRODUCT_OLD_PRICE as a, ATTR_PRODUCT_PRICE as c, ATTR_PRODUCT_OMNIBUS_PRICE as l, ATTR_PRODUCT_OMNIBUS_DISCOUNT as i, ATTR_PRODUCT_BUTTON as s } from "../constants/selectors.js";
2
- const g = {
1
+ import { ATTR_PRODUCT_IMAGE as o, ATTR_PRODUCT_NAME as s, ATTR_PRODUCT_OLD_PRICE as r, ATTR_PRODUCT_PRICE as l, ATTR_PRODUCT_OMNIBUS_PRICE as i, ATTR_PRODUCT_OMNIBUS_DISCOUNT as a, ATTR_PRODUCT_BUTTON as c } from "../constants/selectors.js";
2
+ const C = {
3
3
  TITLE: "You May Also Like!"
4
- }, u = [
5
- n,
4
+ }, D = [
6
5
  o,
7
- a,
8
- c,
6
+ s,
7
+ r,
9
8
  l,
10
9
  i,
11
- s
12
- ], b = {
13
- [n]: !0,
10
+ a,
11
+ c
12
+ ], O = {
14
13
  [o]: !0,
15
- [c]: !0,
16
- [a]: !0,
17
- [l]: !1,
14
+ [s]: !0,
15
+ [l]: !0,
16
+ [r]: !0,
18
17
  [i]: !1,
19
- [s]: !0
20
- }, p = `
18
+ [a]: !1,
19
+ [c]: !0
20
+ }, m = `
21
21
  <tr>
22
22
  <td class="spacer" style="height: 10px;"></td>
23
23
  </tr>
24
24
  `, d = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
25
- function R(t) {
25
+ function U(t) {
26
26
  return !t || typeof t != "string" || t.trim() === "" ? d : t.startsWith("http://") ? t.replace("http://", "https://") : t;
27
27
  }
28
28
  function T(t) {
@@ -40,19 +40,19 @@ function T(t) {
40
40
  category: []
41
41
  };
42
42
  }
43
- function D(t = 6) {
43
+ function A(t = 6) {
44
44
  return Array.from(
45
45
  { length: t },
46
- (e, r) => T(String(r + 1))
46
+ (e, n) => T(String(n + 1))
47
47
  );
48
48
  }
49
- function O(t = "grid", e) {
50
- const r = t === "list" ? `
51
- data-layout="list"` : "";
49
+ function I(t = "grid", e) {
50
+ const n = t === "list" ? `
51
+ data-layout="list"` : "", p = e ? ` ${e}` : "";
52
52
  return `
53
53
  <td
54
54
  align="left"
55
- class="ins-recommendation-v3-block-v2 esd-block-recommendation-v3-block es-p20${e ? ` ${e}` : ""}"${r}>
55
+ class="${`recommendation-block-v2 esd-block-recommendation-v3-block es-p20${t === "list" ? " es-m-p0 ins-recommendation-list-layout" : ""}${p}`}"${n}>
56
56
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
57
57
  <tr>
58
58
  <td align="center">
@@ -84,7 +84,7 @@ function O(t = "grid", e) {
84
84
  </table>
85
85
  </td>
86
86
  </tr>
87
- ${p}
87
+ ${m}
88
88
  <tr>
89
89
  <td>
90
90
  <table
@@ -99,7 +99,7 @@ function O(t = "grid", e) {
99
99
  </table>
100
100
  </td>
101
101
  </tr>
102
- <tr>
102
+ <tr class="ins-recommendation-mobile-row"${t === "list" ? ' style="display: none;"' : ""}>
103
103
  <td>
104
104
  <table
105
105
  class="ins-recommendation-product-container
@@ -109,8 +109,8 @@ function O(t = "grid", e) {
109
109
  cellspacing="0"
110
110
  border="0"
111
111
  style="display: none;"
112
- >
113
- {-{-MOBILE_PRODUCT_ROWS-}-}
112
+ >${t === "list" ? "" : `
113
+ {-{-MOBILE_PRODUCT_ROWS-}-}`}
114
114
  </table>
115
115
  </td>
116
116
  </tr>
@@ -123,12 +123,12 @@ function O(t = "grid", e) {
123
123
  `;
124
124
  }
125
125
  export {
126
- g as DEFAULTS,
127
- u as DEFAULT_CARD_COMPOSITION,
128
- b as DEFAULT_CARD_VISIBILITY,
126
+ C as DEFAULTS,
127
+ D as DEFAULT_CARD_COMPOSITION,
128
+ O as DEFAULT_CARD_VISIBILITY,
129
129
  d as PLACEHOLDER_IMAGE,
130
- O as createBlockTemplate,
131
- D as getDefaultProducts,
132
- R as sanitizeImageUrl,
133
- p as spacer
130
+ I as createBlockTemplate,
131
+ A as getDefaultProducts,
132
+ U as sanitizeImageUrl,
133
+ m as spacer
134
134
  };
@@ -1,17 +1,17 @@
1
1
  var d = Object.defineProperty;
2
- var _ = (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) => _(n, typeof i != "symbol" ? i + "" : 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 h, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
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 g = "unsubscribe-block", v = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", T = {
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 h {
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 g;
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 s = e, { collectionType: t, selectedPages: r } = s.detail;
51
- this._updateBlock(t, r.join(","));
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, s) {
77
+ _updateBlock(e, r) {
78
78
  if (!this.currentNode || !("querySelector" in this.currentNode))
79
79
  return;
80
- const t = this.currentNode.querySelector(v);
81
- if (!t)
80
+ const s = this.currentNode.querySelector(g);
81
+ if (!s)
82
82
  return;
83
- const r = this._getMergeTag(e);
84
- this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", r).apply(new b(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, s).apply(new b("Updated unsubscribe block metadata"));
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 T[e] ?? B;
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((t) => {
101
- if ("getAttribute" in t) {
102
- const r = t.getAttribute(o.PAGE_TYPE);
103
- if (r) {
104
- const l = Number(r);
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 s = e.getAttribute(o.PAGE_TYPE), t = e.getAttribute(o.PAGE_LIST);
114
- if (!s || !t)
113
+ const r = e.getAttribute(o.PAGE_TYPE), s = e.getAttribute(o.PAGE_LIST);
114
+ if (!r || !s)
115
115
  return;
116
- const r = c(), l = Number(s), m = p(t);
117
- r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(m);
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 s = e.getAttribute(o.PAGE_LIST);
126
- if (!s)
125
+ const r = e.getAttribute(o.PAGE_LIST);
126
+ if (!r)
127
127
  return;
128
- const t = c(), r = p(s);
129
- t.removeUnsubscribePages(r);
128
+ const s = c(), t = p(r);
129
+ s.removeUnsubscribePages(t);
130
130
  }
131
131
  }
132
132
  export {
133
- g as UNSUBSCRIBE_BLOCK_ID,
133
+ v as UNSUBSCRIBE_BLOCK_ID,
134
134
  R as UnsubscribeBlock
135
135
  };
@@ -1,18 +1,18 @@
1
- var h = Object.defineProperty;
2
- var d = (a, s, e) => s in a ? h(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
- var u = (a, s, e) => d(a, typeof s != "symbol" ? s + "" : 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 g = "ui-elements-unsubscribe", r = {
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 N extends T {
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 g;
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._updatePreview(), this._updateCounter());
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
- g as UNSUBSCRIBE_CONTROL_ID,
166
- N as UnsubscribeControl
168
+ v as UNSUBSCRIBE_CONTROL_ID,
169
+ B as UnsubscribeControl
167
170
  };
@@ -1,12 +1,12 @@
1
- var r = Object.defineProperty;
2
- var n = (i, t, e) => t in i ? r(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var s = (i, t, e) => n(i, typeof t != "symbol" ? t + "" : t, e);
4
- import { UIElement as m } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- const E = "unsubscribe-preview", l = "img", c = "Unsubscribe page preview";
6
- class o extends m {
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
- s(this, "imgElement");
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="${c}"
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(l);
27
+ this.imgElement = e.querySelector(c);
27
28
  }
28
29
  setValue(e) {
29
- this.imgElement && (this.imgElement.src = e);
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
- o as PreviewUIElement
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 {