@useinsider/guido 3.18.2-beta.3eec9b0 → 3.18.2-beta.4d2b065

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 (57) hide show
  1. package/README.md +21 -23
  2. package/dist/@types/config/schemas.js +59 -51
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +55 -53
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -7
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +53 -49
  7. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
  8. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
  9. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +24 -22
  10. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -24
  11. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
  12. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
  13. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
  14. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +46 -0
  15. package/dist/composables/useCustomInterfaceAppearance.js +46 -42
  16. package/dist/composables/useGuidoStateBridge.js +24 -29
  17. package/dist/composables/useLegacyStrategyConversion.js +61 -0
  18. package/dist/composables/useStripo.js +7 -7
  19. package/dist/enums/extensions/recommendationBlock.js +40 -31
  20. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +77 -76
  21. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -28
  22. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +45 -44
  23. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +110 -46
  24. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
  25. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +7 -7
  26. package/dist/guido.css +1 -1
  27. package/dist/library.js +13 -15
  28. package/dist/services/recommendationApi.js +46 -37
  29. package/dist/src/@types/config/schemas.d.ts +16 -0
  30. package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
  31. package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
  32. package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
  33. package/dist/src/composables/useConfig.d.ts +4 -0
  34. package/dist/src/composables/useGuidoStateBridge.d.ts +7 -11
  35. package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
  36. package/dist/src/enums/extensions/recommendationBlock.d.ts +5 -1
  37. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +2 -0
  38. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -0
  39. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +70 -1
  40. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
  41. package/dist/src/library.d.ts +0 -2
  42. package/dist/src/public/trackingIds.d.ts +2 -6
  43. package/dist/src/services/recommendationApi.d.ts +2 -1
  44. package/dist/src/stores/config.d.ts +322 -0
  45. package/dist/src/stores/editor.d.ts +0 -25
  46. package/dist/src/stores/guido-email-editor.d.ts +27 -27
  47. package/dist/src/stores/onboarding.d.ts +808 -10
  48. package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
  49. package/dist/static/assets/icons/line-info.svg.js +5 -0
  50. package/dist/static/styles/components/recommendation-strategy.css.js +70 -5
  51. package/dist/stores/config.js +74 -60
  52. package/dist/stores/editor.js +0 -4
  53. package/dist/stores/guido-email-editor.js +4 -0
  54. package/dist/stores/onboarding.js +46 -36
  55. package/package.json +1 -5
  56. package/dist/public/editorState.js +0 -4
  57. package/dist/src/public/editorState.d.ts +0 -14
@@ -1,26 +1,32 @@
1
- var d = Object.defineProperty;
2
- var y = (r, s, t) => s in r ? d(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
3
- var o = (r, s, t) => y(r, typeof s != "symbol" ? s + "" : s, t);
4
- import { ACADEMY_LINKS as m } from "../../../../../enums/academy.js";
5
- import { CommonControl as h } from "../../../common-control.js";
6
- import { useRecommendationExtensionStore as u } from "../../store/recommendation.js";
7
- const p = "recommendation-strategy-control";
8
- class f extends h {
1
+ var p = Object.defineProperty;
2
+ var v = (i, s, t) => s in i ? p(i, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[s] = t;
3
+ var r = (i, s, t) => v(i, typeof s != "symbol" ? s + "" : s, t);
4
+ import { useLegacyStrategyConversion as _ } from "../../../../../composables/useLegacyStrategyConversion.js";
5
+ import { ACADEMY_LINKS as b } from "../../../../../enums/academy.js";
6
+ import { useOnboardingStore as S } from "../../../../../stores/onboarding.js";
7
+ import { CommonControl as f } from "../../../common-control.js";
8
+ import { useRecommendationExtensionStore as $ } from "../../store/recommendation.js";
9
+ const C = "recommendation-strategy-control";
10
+ class N extends f {
9
11
  constructor() {
10
12
  super(...arguments);
11
- o(this, "store", u());
12
- o(this, "storeUnsubscription", () => {
13
+ r(this, "store", $());
14
+ r(this, "onboardingStore", S());
15
+ r(this, "legacyConversion", _());
16
+ r(this, "storeUnsubscription", () => {
13
17
  });
14
- o(this, "listeners", []);
15
- o(this, "lastPaintedState", null);
18
+ r(this, "listeners", []);
19
+ r(this, "lastPaintedState", null);
16
20
  }
17
21
  getId() {
18
- return p;
22
+ return C;
19
23
  }
20
24
  getTemplate() {
21
25
  const t = this.api.translate(
22
26
  "You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
23
- ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
27
+ ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy"), o = this.api.translate("Legacy Strategy"), n = this.api.translate(
28
+ "Note that this is an older version of the Recommendation Strategy. We recommend you update it to the new Recommendation Strategy for an improved experience."
29
+ );
24
30
  return `
25
31
  <div class="strategy-control-container">
26
32
  <div class="strategy-control-header">
@@ -31,7 +37,7 @@ class f extends h {
31
37
  ${t}
32
38
  ${e}
33
39
  <a
34
- href="${m.EMAIL_RECOMMENDATION_BLOCK}"
40
+ href="${b.EMAIL_RECOMMENDATION_BLOCK}"
35
41
  target="_blank"
36
42
  rel="noopener noreferrer">${a}</a>.
37
43
  </p>
@@ -53,6 +59,33 @@ class f extends h {
53
59
  })
54
60
  ], "strategy-control-cta-row")}
55
61
  </div>
62
+ <div data-strategy-legacy-state style="display: none;">
63
+ <div class="strategy-control-notice-row">
64
+ <div class="strategy-control-notice">
65
+ <p class="strategy-control-notice-text">${n}</p>
66
+ </div>
67
+ </div>
68
+ <div class="strategy-control-name-band">
69
+ <span class="strategy-control-name">${o}</span>
70
+ ${this._strategyAction({
71
+ id: "guido__btn-update-legacy-strategy",
72
+ label: this.api.translate("Update"),
73
+ modifier: "update"
74
+ })}
75
+ </div>
76
+ <div class="strategy-control-actions">
77
+ ${this._strategyAction({
78
+ id: "guido__btn-change-legacy-strategy",
79
+ label: this.api.translate("Change"),
80
+ modifier: "change"
81
+ })}
82
+ ${this._strategyAction({
83
+ id: "guido__btn-remove-legacy-strategy",
84
+ label: this.api.translate("Remove"),
85
+ modifier: "remove"
86
+ })}
87
+ </div>
88
+ </div>
56
89
  <div data-strategy-assigned-state style="display: none;">
57
90
  <div class="strategy-control-name-band">
58
91
  <span class="strategy-control-name" data-strategy-name></span>
@@ -88,6 +121,8 @@ class f extends h {
88
121
  this._renderState();
89
122
  }), this.store.recommendationConfigs.strategyId && !this.store.strategies.length && this.store.fetchStrategies().catch(() => {
90
123
  });
124
+ const t = this.store.currentRecommendationId, e = t !== null && !!this.store.blockStates[t], a = this.store.isLegacyStrategyBlock;
125
+ e && !this.store.recommendationConfigs.strategyId && !a && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding"), e && a && this.onboardingStore.startOnboarding("recommendationLegacyStrategyOnboarding");
91
126
  }
92
127
  onDestroy() {
93
128
  this._teardown();
@@ -100,25 +135,34 @@ class f extends h {
100
135
  const t = this.getContainer();
101
136
  if (!t)
102
137
  return;
103
- const e = (a, n) => {
104
- const i = t.querySelector(a);
105
- i && (i.addEventListener("click", n), this.listeners.push({ element: i, handler: n }));
138
+ const e = (a, o) => {
139
+ const n = t.querySelector(a);
140
+ n && (n.addEventListener("click", o), this.listeners.push({ element: n, handler: o }));
106
141
  };
107
- e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal());
142
+ e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-legacy-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-remove-legacy-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-update-legacy-strategy", () => {
143
+ this.legacyConversion.convertLegacyStrategy();
144
+ });
108
145
  }
109
146
  _renderState() {
110
- var l;
111
- const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((l = this.store.assignedStrategy) == null ? void 0 : l.name) ?? "" : "", a = `${t}\0${e}`;
112
- if (a === this.lastPaintedState)
147
+ var h;
148
+ const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((h = this.store.assignedStrategy) == null ? void 0 : h.name) ?? "" : "", a = this.store.legacyConversionLoading, o = this.store.isLegacyStrategyBlock, n = `${t}\0${e}\0${a}\0${o}`;
149
+ if (n === this.lastPaintedState)
150
+ return;
151
+ const c = this.getContainer();
152
+ if (!c)
113
153
  return;
114
- const n = this.getContainer();
115
- if (!n)
154
+ const d = c.querySelector("[data-strategy-empty-state]"), y = c.querySelector("[data-strategy-assigned-state]"), g = c.querySelector("[data-strategy-legacy-state]"), m = c.querySelector("[data-strategy-name]");
155
+ if (!d || !y || !g)
116
156
  return;
117
- const i = n.querySelector("[data-strategy-empty-state]"), c = n.querySelector("[data-strategy-assigned-state]"), g = n.querySelector("[data-strategy-name]");
118
- !i || !c || (i.style.display = t ? "none" : "", c.style.display = t ? "" : "none", g && t && (g.textContent = e || `#${t}`), this.lastPaintedState = a);
157
+ const u = t ? y : o ? g : d;
158
+ [d, y, g].forEach((l) => {
159
+ l.style.display = l === u ? "" : "none";
160
+ }), g.querySelectorAll("button").forEach((l) => {
161
+ l.disabled = a;
162
+ }), g.classList.toggle("is-converting", a), m && t && (m.textContent = e || `#${t}`), this.lastPaintedState = n;
119
163
  }
120
164
  }
121
165
  export {
122
- p as STRATEGY_CONTROL_ID,
123
- f as StrategyControl
166
+ C as STRATEGY_CONTROL_ID,
167
+ N as StrategyControl
124
168
  };
@@ -94,9 +94,9 @@ function j(e, t = {}) {
94
94
  const u = s ?? P(n), l = y.getConfig(n);
95
95
  if (u === "list" || !l.mobileLayoutEnabled)
96
96
  return te({ currentNode: n, documentModifier: o });
97
- const c = A(), a = $(r, c.recommendationProducts), f = i ?? U(n, c.filterList), p = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${k(a, u, {
97
+ const c = A(), f = $(r, c.recommendationProducts), a = i ?? U(n, c.filterList), p = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${k(f, u, {
98
98
  productsPerRow: l.mobileCardsInRow,
99
- composition: f,
99
+ composition: a,
100
100
  filterList: c.filterList,
101
101
  priceInline: !l.priceMovedToNextLine,
102
102
  // Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
@@ -122,9 +122,9 @@ function ie(e, t = {}) {
122
122
  const u = n.querySelector(L) ?? n.querySelector(W);
123
123
  if (!u)
124
124
  return !1;
125
- const l = A(), c = $(r, l.recommendationProducts), { cardsInRow: a } = y.getConfig(n), f = i ?? U(n, l.filterList), d = s ?? P(n), p = y.getConfig(n), E = k(c, d, {
126
- productsPerRow: a,
127
- composition: f,
125
+ const l = A(), c = $(r, l.recommendationProducts), { cardsInRow: f } = y.getConfig(n), a = i ?? U(n, l.filterList), d = s ?? P(n), p = y.getConfig(n), E = k(c, d, {
126
+ productsPerRow: f,
127
+ composition: a,
128
128
  filterList: l.filterList,
129
129
  priceInline: !p.priceMovedToNextLine,
130
130
  // Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
@@ -153,10 +153,10 @@ function ce(e, t, n) {
153
153
  return !1;
154
154
  const s = A(), i = r.split(",").filter(Boolean), u = D(i, o, s.filterList), l = [], c = u.join(",") !== i.join(",");
155
155
  c && l.push([R, u.join(",")]);
156
- const a = le(
156
+ const f = le(
157
157
  o.getAttribute(q)
158
- ), f = a && z(a, o, s.filterList);
159
- if (a && f && f.join(",") !== a.join(",") && l.push([q, JSON.stringify(f)]), l.length === 0)
158
+ ), a = f && z(f, o, s.filterList);
159
+ if (f && a && a.join(",") !== f.join(",") && l.push([q, JSON.stringify(a)]), l.length === 0)
160
160
  return !1;
161
161
  if (l.forEach(([d, p]) => {
162
162
  t.modifyHtml(o).setAttribute(d, p);
@@ -177,19 +177,20 @@ function Te(e) {
177
177
  products: r,
178
178
  layout: s,
179
179
  composition: i,
180
- skipStylePreservation: u
180
+ skipStylePreservation: u,
181
+ forceApply: l = !1
181
182
  } = e;
182
183
  if (!t)
183
184
  return;
184
- const l = u ? {} : x(t), c = {
185
+ const c = u ? {} : x(t), f = {
185
186
  currentNode: t,
186
187
  documentModifier: n,
187
188
  products: r,
188
189
  layout: s,
189
190
  composition: i
190
191
  };
191
- let a = ie(c, l);
192
- a = j(c, l) || a, a && (ce(t, n, i), n.apply(new S("Regenerate products with styles"))), o == null || o();
192
+ let a = ie(f, c);
193
+ a = j(f, c) || a, a && ce(t, n, i), (a || l) && n.apply(new S("Regenerate products with styles")), o == null || o();
193
194
  }
194
195
  function Re(e, t) {
195
196
  return e.length === t ? e : e.length > t ? e.slice(0, t) : [...e, ...H(t - e.length)];
@@ -250,16 +251,16 @@ function se(e) {
250
251
  omnibusDiscountEl: l,
251
252
  buttonEl: c
252
253
  } = e;
253
- let a = !1;
254
+ let f = !1;
254
255
  if (o && "querySelector" in o) {
255
- const f = o.querySelector("img");
256
- f && (t.modifyHtml(f).setAttribute("src", X(n.image_url)).setAttribute("alt", n.name), a = !0);
256
+ const a = o.querySelector("img");
257
+ a && (t.modifyHtml(a).setAttribute("src", X(n.image_url)).setAttribute("alt", n.name), f = !0);
257
258
  const d = o.querySelector("a");
258
- d && (t.modifyHtml(d).setAttribute("href", n.url), a = !0);
259
+ d && (t.modifyHtml(d).setAttribute("href", n.url), f = !0);
259
260
  }
260
261
  if (r && "querySelector" in r) {
261
- const f = r.querySelector("strong") ?? r.querySelector("p");
262
- b(t, f ?? null, n.name) && (a = !0);
262
+ const a = r.querySelector("strong") ?? r.querySelector("p");
263
+ b(t, a ?? null, n.name) && (f = !0);
263
264
  }
264
265
  if (K({
265
266
  documentModifier: t,
@@ -268,11 +269,11 @@ function se(e) {
268
269
  oldPriceEl: i,
269
270
  omnibusPriceEl: u,
270
271
  omnibusDiscountEl: l
271
- }) && (a = !0), c && "querySelector" in c) {
272
- const f = c.querySelector("a.es-button") || c.querySelector("a");
273
- f && (t.modifyHtml(f).setAttribute("href", n.url), a = !0);
272
+ }) && (f = !0), c && "querySelector" in c) {
273
+ const a = c.querySelector("a.es-button") || c.querySelector("a");
274
+ a && (t.modifyHtml(a).setAttribute("href", n.url), f = !0);
274
275
  }
275
- return a;
276
+ return f;
276
277
  }
277
278
  function V(e) {
278
279
  return "querySelector" in e ? e.querySelector(L) ?? e : e;
@@ -308,14 +309,14 @@ function fe(e, t, n) {
308
309
  let s = !1;
309
310
  return r.forEach((i, u) => {
310
311
  const l = Math.min(i.length, n.length);
311
- i.slice(0, l).forEach((c, a) => {
312
+ i.slice(0, l).forEach((c, f) => {
312
313
  if (!("querySelector" in c))
313
314
  return;
314
- const f = ae(u, n[a]);
315
- if (f === null)
315
+ const a = ae(u, n[f]);
316
+ if (a === null)
316
317
  return;
317
318
  const d = c.querySelector("p") ?? null;
318
- b(t, d, f) && (s = !0);
319
+ b(t, d, a) && (s = !0);
319
320
  });
320
321
  }), s;
321
322
  }
@@ -336,9 +337,9 @@ function O(e, t, n) {
336
337
  `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
337
338
  ), c = e.querySelectorAll(
338
339
  `[esd-extension-block-id="${m.BUTTON}"]`
339
- ), a = Math.min(o.length, n.length);
340
- let f = !1;
341
- for (let d = 0; d < a; d++) {
340
+ ), f = Math.min(o.length, n.length);
341
+ let a = !1;
342
+ for (let d = 0; d < f; d++) {
342
343
  const p = se({
343
344
  documentModifier: t,
344
345
  product: n[d],
@@ -350,33 +351,33 @@ function O(e, t, n) {
350
351
  omnibusDiscountEl: l[d] ?? null,
351
352
  buttonEl: c[d] ?? null
352
353
  });
353
- f = f || p;
354
+ a = a || p;
354
355
  }
355
- return fe(e, t, n) && (f = !0), f;
356
+ return fe(e, t, n) && (a = !0), a;
356
357
  }
357
358
  function qe(e) {
358
- const { currentNode: t, documentModifier: n, products: o } = e;
359
+ const { currentNode: t, documentModifier: n, products: o, forceApply: r = !1 } = e;
359
360
  if (!t || !("querySelectorAll" in t))
360
361
  return !1;
361
- const r = V(t);
362
- if (!("querySelectorAll" in r) || r.querySelectorAll(
362
+ const s = V(t);
363
+ if (!("querySelectorAll" in s) || s.querySelectorAll(
363
364
  `[esd-extension-block-id="${m.IMAGE}"]`
364
365
  ).length !== o.length)
365
366
  return !1;
366
- let i = O(r, n, o);
367
- const u = P(t), l = y.getConfig(t);
368
- if (u !== "list" && l.mobileLayoutEnabled && "querySelector" in t) {
369
- const c = t.querySelector(N);
370
- if (c) {
367
+ let u = O(s, n, o);
368
+ const l = P(t), c = y.getConfig(t);
369
+ if (l !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
370
+ const f = t.querySelector(N);
371
+ if (f) {
371
372
  const a = O(
372
- c,
373
+ f,
373
374
  n,
374
375
  o
375
376
  );
376
- i = i || a;
377
+ u = u || a;
377
378
  }
378
379
  }
379
- return i && n.apply(new S("Updated product content in-place")), !0;
380
+ return (u || r) && n.apply(new S("Updated product content in-place")), !0;
380
381
  }
381
382
  function _(e, t, n) {
382
383
  if (!("querySelectorAll" in e))
@@ -417,8 +418,8 @@ function Me(e) {
417
418
  if (u !== "list" && l.mobileLayoutEnabled && "querySelector" in t) {
418
419
  const c = t.querySelector(N);
419
420
  if (c) {
420
- const a = _(c, n, r);
421
- i = i || a;
421
+ const f = _(c, n, r);
422
+ i = i || f;
422
423
  }
423
424
  }
424
425
  return i && n.apply(new S("Updated price formatting in-place")), i;