@useinsider/guido 3.7.0-beta.24bdfa3 → 3.7.0-beta.340a6d3

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 (40) hide show
  1. package/dist/@types/config/schemas.js +66 -70
  2. package/dist/composables/usePreviewMode.js +14 -15
  3. package/dist/config/compiler/utils/recommendationCompilerUtils.js +82 -90
  4. package/dist/config/migrator/recommendation/htmlBuilder.js +58 -59
  5. package/dist/config/migrator/recommendation/settingsMapper.js +33 -38
  6. package/dist/extensions/Blocks/Recommendation/block.js +43 -59
  7. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +32 -41
  8. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +313 -377
  9. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +72 -84
  10. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +66 -68
  11. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +7 -21
  12. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -64
  13. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +5 -7
  14. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +72 -101
  15. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -31
  16. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -9
  17. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +59 -74
  18. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
  19. package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -88
  20. package/dist/src/@types/config/schemas.d.ts +0 -16
  21. package/dist/src/composables/useConfig.d.ts +0 -4
  22. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
  23. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -10
  24. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -29
  25. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
  26. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -3
  27. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -2
  28. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -16
  29. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  30. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -13
  31. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +2 -3
  32. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -33
  33. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -15
  34. package/dist/src/stores/config.d.ts +0 -36
  35. package/package.json +1 -1
  36. package/dist/composables/useRecommendationPreview.js +0 -100
  37. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +0 -133
  38. package/dist/src/composables/useRecommendationPreview.d.ts +0 -10
  39. package/dist/src/composables/useRecommendationPreview.test.d.ts +0 -1
  40. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +0 -59
@@ -1,24 +1,24 @@
1
- var D = Object.defineProperty;
2
- var y = (a, c, t) => c in a ? D(a, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[c] = t;
3
- var h = (a, c, t) => y(a, typeof c != "symbol" ? c + "" : c, t);
1
+ var k = Object.defineProperty;
2
+ var y = (a, r, t) => r in a ? k(a, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[r] = t;
3
+ var d = (a, r, t) => y(a, typeof r != "symbol" ? r + "" : r, t);
4
4
  import { BlockId as B } from "../../../enums/block.js";
5
- import { getMigrationBannerHtml as R } from "../../../utils/migrationBannerHtml.js";
6
- import { Block as b, BlockCompositionType as A, ModificationDescription as g } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
- import { regenerateMobileProductRows as C } from "./controls/main/utils.js";
8
- import { ensureMobileCssRulesExist as p, setMobileLayoutOptOut as f, hasMobileLayoutOptOut as E } from "./controls/mobileLayout/cssRules.js";
9
- import { RecommendationConfigService as s } from "./services/configService.js";
10
- import { useRecommendationExtensionStore as d } from "./store/recommendation.js";
11
- import { getDefaultTemplate as S } from "./templates/grid/template.js";
12
- const _ = B.Recommendation, m = "recommendation-block-v2", u = "recommendation-id", I = "hide-price";
13
- let k = !1;
14
- class q extends b {
5
+ import { getMigrationBannerHtml as D } from "../../../utils/migrationBannerHtml.js";
6
+ import { Block as R, BlockCompositionType as C, ModificationDescription as h } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
+ import { regenerateMobileProductRows as b } from "./controls/main/utils.js";
8
+ import { ensureMobileCssRulesExist as p, setMobileLayoutOptOut as f, hasMobileLayoutOptOut as A } from "./controls/mobileLayout/cssRules.js";
9
+ import { RecommendationConfigService as c } from "./services/configService.js";
10
+ import { useRecommendationExtensionStore as g } from "./store/recommendation.js";
11
+ import { getDefaultTemplate as E } from "./templates/grid/template.js";
12
+ const _ = B.Recommendation, m = "recommendation-block-v2", u = "recommendation-id";
13
+ let I = !1;
14
+ class q extends R {
15
15
  constructor() {
16
16
  super();
17
17
  /**
18
18
  * Stores the ID generated in getTemplate() so onCreated() can reuse it.
19
19
  * This avoids generating a new (different) ID in onCreated().
20
20
  */
21
- h(this, "_pendingBlockId", null);
21
+ d(this, "_pendingBlockId", null);
22
22
  }
23
23
  getId() {
24
24
  return _;
@@ -27,7 +27,7 @@ class q extends b {
27
27
  return "recommendation-icon";
28
28
  }
29
29
  getBlockCompositionType() {
30
- return A.CONTAINER;
30
+ return C.CONTAINER;
31
31
  }
32
32
  getName() {
33
33
  return this.api.translate("Recommendation Block");
@@ -38,7 +38,7 @@ class q extends b {
38
38
  );
39
39
  }
40
40
  getSettingsPanelTitleHtml() {
41
- return R(
41
+ return D(
42
42
  _,
43
43
  this.api.translate("Recommendation Block"),
44
44
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
@@ -47,8 +47,11 @@ class q extends b {
47
47
  allowInnerBlocksDND() {
48
48
  return !1;
49
49
  }
50
+ // A saved module carries its config in the esd-config blob, restored on
51
+ // re-drop by migrateFromDataAttributes; per-element styles ride the
52
+ // preserved inner HTML. (onCreated early-returns for re-drops, never clobbers.)
50
53
  canBeSavedAsModule() {
51
- return !1;
54
+ return !0;
52
55
  }
53
56
  /**
54
57
  * Returns the template HTML for a new recommendation block.
@@ -59,7 +62,7 @@ class q extends b {
59
62
  */
60
63
  getTemplate() {
61
64
  const t = this._generateNextId();
62
- return this._pendingBlockId = t, S(t);
65
+ return this._pendingBlockId = t, E(t);
63
66
  }
64
67
  /**
65
68
  * Called when a new block is dropped into the template
@@ -82,20 +85,20 @@ class q extends b {
82
85
  }
83
86
  const i = this._pendingBlockId ?? this._generateNextId();
84
87
  this._pendingBlockId = null, this._assignRecommendationId(t, i);
85
- const { config: n, wasFreshDrop: o } = s.initializeConfig(
88
+ const { config: n, wasFreshDrop: o } = c.initializeConfig(
86
89
  this.api,
87
90
  t,
88
91
  { recommendationId: i }
89
- ), r = d();
90
- if (r.setCurrentBlock(i), this._stampHidePrice(t, n.priceHideIfSameAsDiscounted), o) {
92
+ ), s = g();
93
+ if (s.setCurrentBlock(i), o) {
91
94
  p(this.api);
92
95
  const l = this._getBlockElement(t);
93
- l && (f(this.api, l, !0), C({
96
+ l && (f(this.api, l, !0), b({
94
97
  currentNode: t,
95
98
  documentModifier: this.api.getDocumentModifier()
96
99
  }));
97
100
  }
98
- r.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
101
+ s.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
99
102
  }
100
103
  /**
101
104
  * Called when the document changes or template is loaded
@@ -108,20 +111,20 @@ class q extends b {
108
111
  if (!(!t || !("getNodeConfig" in t))) {
109
112
  if (!this._getRecommendationId(t)) {
110
113
  const e = this._generateNextId();
111
- this._assignRecommendationId(t, e), s.hasConfig(t) && s.updateConfig(
114
+ this._assignRecommendationId(t, e), c.hasConfig(t) && c.updateConfig(
112
115
  this.api,
113
116
  t,
114
117
  { recommendationId: e },
115
118
  "Assign recommendation ID to legacy block"
116
119
  );
117
120
  }
118
- this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
121
+ this._healLingeringDuplicate(t), c.needsMigration(t) && this._migrateFromLegacy(t);
119
122
  try {
120
- k || (p(this.api), k = !0);
121
- const e = s.getConfig(t), i = this._getBlockElement(t);
123
+ I || (p(this.api), I = !0);
124
+ const e = c.getConfig(t), i = this._getBlockElement(t);
122
125
  if (i) {
123
126
  const n = !e.mobileLayoutEnabled;
124
- E(i) !== n && f(this.api, i, n);
127
+ A(i) !== n && f(this.api, i, n);
125
128
  }
126
129
  } catch {
127
130
  }
@@ -135,7 +138,7 @@ class q extends b {
135
138
  */
136
139
  onDelete(t) {
137
140
  const e = this._getRecommendationId(t);
138
- e && d().removeBlockState(e);
141
+ e && g().removeBlockState(e);
139
142
  }
140
143
  /**
141
144
  * Generates the next unique recommendation ID by scanning all existing blocks
@@ -147,8 +150,8 @@ class q extends b {
147
150
  const e = this.api.getDocumentRoot();
148
151
  e && "querySelectorAll" in e && e.querySelectorAll(`.${m}`).forEach((n) => {
149
152
  if ("getAttribute" in n) {
150
- const o = n.getAttribute(u), r = o ? parseInt(o) : 0;
151
- r > t && (t = r);
153
+ const o = n.getAttribute(u), s = o ? parseInt(o) : 0;
154
+ s > t && (t = s);
152
155
  }
153
156
  });
154
157
  } catch {
@@ -182,13 +185,13 @@ class q extends b {
182
185
  const o = this._getBlockElement(t);
183
186
  if (!o)
184
187
  return;
185
- let r = -1;
188
+ let s = -1;
186
189
  for (let l = 0; l < n.length; l++)
187
190
  if (n[l] === o) {
188
- r = l;
191
+ s = l;
189
192
  break;
190
193
  }
191
- if (r <= 0)
194
+ if (s <= 0)
192
195
  return;
193
196
  this._reassignDuplicateId(t, e);
194
197
  } catch {
@@ -208,7 +211,7 @@ class q extends b {
208
211
  }
209
212
  /** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
210
213
  _handleDuplicate(t, e) {
211
- const i = this._reassignDuplicateId(t, e), n = d();
214
+ const i = this._reassignDuplicateId(t, e), n = g();
212
215
  n.cloneBlockState(e, i), n.setCurrentBlock(i);
213
216
  }
214
217
  /**
@@ -224,7 +227,7 @@ class q extends b {
224
227
  */
225
228
  _reassignDuplicateId(t, e) {
226
229
  const i = this._generateNextId(), n = this._getBlockElement(t);
227
- return this._assignRecommendationId(t, i), n && this._reassignInstanceClass(n, e, i), s.hasConfig(t) && s.updateConfig(
230
+ return this._assignRecommendationId(t, i), n && this._reassignInstanceClass(n, e, i), c.hasConfig(t) && c.updateConfig(
228
231
  this.api,
229
232
  t,
230
233
  { recommendationId: i },
@@ -241,8 +244,8 @@ class q extends b {
241
244
  _reassignInstanceClass(t, e, i) {
242
245
  if (!("getAttribute" in t))
243
246
  return;
244
- const n = `ins-recommendation-v3-block-${e}`, o = `ins-recommendation-v3-block-${i}`, r = this.api.getDocumentModifier();
245
- r.modifyHtml(t).removeClass(n).setClass(o), r.apply(new g(
247
+ const n = `ins-recommendation-v3-block-${e}`, o = `ins-recommendation-v3-block-${i}`, s = this.api.getDocumentModifier();
248
+ s.modifyHtml(t).removeClass(n).setClass(o), s.apply(new h(
246
249
  `Reassign recommendation instance class ${n} -> ${o}`
247
250
  ));
248
251
  }
@@ -257,26 +260,7 @@ class q extends b {
257
260
  if (!i)
258
261
  return;
259
262
  const n = this.api.getDocumentModifier();
260
- n.modifyHtml(i).setAttribute(u, e.toString()), n.apply(new g(`Assign recommendation ID ${e}`));
261
- }
262
- /**
263
- * Stamps the `hide-price` attribute (read by email-service at send time) on
264
- * the block element from the config flag.
265
- */
266
- _stampHidePrice(t, e) {
267
- const i = this._getBlockElement(t);
268
- i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(I, String(e)).apply(new g("Stamp hide-price"));
269
- }
270
- /**
271
- * Stamps `hide-price` from config only when the block lacks the attribute —
272
- * heals templates saved before this feature without dirtying current ones.
273
- */
274
- _healHidePriceAttr(t) {
275
- const e = this._getBlockElement(t);
276
- if (!e || !("getAttribute" in e) || e.getAttribute(I) !== null)
277
- return;
278
- const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
279
- this._stampHidePrice(t, i);
263
+ n.modifyHtml(i).setAttribute(u, e.toString()), n.apply(new h(`Assign recommendation ID ${e}`));
280
264
  }
281
265
  /**
282
266
  * Gets the recommendation-id from a block node
@@ -306,7 +290,7 @@ class q extends b {
306
290
  * Migrate configuration from legacy format
307
291
  */
308
292
  _migrateFromLegacy(t) {
309
- s.migrateFromDataAttributes(this.api, t);
293
+ c.migrateFromDataAttributes(this.api, t);
310
294
  }
311
295
  }
312
296
  export {
@@ -1,34 +1,34 @@
1
- import { DEFAULT_COLUMN_SPACING as n, DEFAULT_ROW_SPACING as s, DEFAULT_MOBILE_ROW_SPACING as R, DEFAULT_MOBILE_COLUMN_SPACING as U, DEFAULT_MOBILE_CARDS_IN_ROW as e, DEFAULT_CARDS_IN_ROW as C } from "./layout.js";
2
- import { ATTR_PRODUCT_IMAGE as o, ATTR_PRODUCT_NAME as t, ATTR_PRODUCT_OLD_PRICE as _, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OMNIBUS_PRICE as r, ATTR_PRODUCT_OMNIBUS_DISCOUNT as i, ATTR_PRODUCT_BUTTON as I } from "./selectors.js";
3
- const D = {
1
+ import { DEFAULT_COLUMN_SPACING as R, DEFAULT_ROW_SPACING as U, DEFAULT_MOBILE_ROW_SPACING as i, DEFAULT_MOBILE_COLUMN_SPACING as s, DEFAULT_MOBILE_CARDS_IN_ROW as o, DEFAULT_CARDS_IN_ROW as C } from "./layout.js";
2
+ import { ATTR_PRODUCT_IMAGE as _, ATTR_PRODUCT_NAME as e, ATTR_PRODUCT_OLD_PRICE as t, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OMNIBUS_PRICE as r, ATTR_PRODUCT_OMNIBUS_DISCOUNT as I, ATTR_PRODUCT_BUTTON as n } from "./selectors.js";
3
+ const O = {
4
4
  code: "USD",
5
5
  symbol: "USD",
6
6
  alignment: "after",
7
7
  decimalCount: 2,
8
8
  decimalSeparator: ".",
9
9
  thousandSeparator: ","
10
- }, O = {
10
+ }, D = {
11
11
  textBefore: "",
12
12
  textAfter: ""
13
- }, a = {
13
+ }, A = {
14
14
  textBefore: "",
15
15
  textAfter: ""
16
- }, A = [
17
- o,
18
- t,
16
+ }, a = [
19
17
  _,
18
+ e,
19
+ t,
20
20
  T,
21
21
  r,
22
- i,
23
- I
24
- ], c = {
25
- [o]: !0,
26
- [t]: !0,
27
- [T]: !0,
22
+ I,
23
+ n
24
+ ], E = {
28
25
  [_]: !0,
26
+ [e]: !0,
27
+ [T]: !0,
28
+ [t]: !0,
29
29
  [r]: !1,
30
- [i]: !1,
31
- [I]: !0
30
+ [I]: !1,
31
+ [n]: !0
32
32
  }, l = {
33
33
  // Settings
34
34
  strategy: "mostPopular",
@@ -36,45 +36,36 @@ const D = {
36
36
  size: "6",
37
37
  shuffleProducts: !1,
38
38
  language: "en_US",
39
- currency: D,
39
+ currency: O,
40
40
  filters: [],
41
41
  // Layout
42
42
  layout: "grid",
43
43
  cardsInRow: C,
44
- mobileCardsInRow: e,
44
+ mobileCardsInRow: o,
45
45
  mobileLayoutEnabled: !1,
46
- previousMobileCardsInRow: e,
47
- columnSpacing: n,
48
- rowSpacing: s,
49
- mobileColumnSpacing: U,
50
- mobileRowSpacing: R,
46
+ previousMobileCardsInRow: o,
47
+ columnSpacing: R,
48
+ rowSpacing: U,
49
+ mobileColumnSpacing: s,
50
+ mobileRowSpacing: i,
51
51
  // Composition
52
- composition: A,
53
- visibility: c,
52
+ composition: a,
53
+ visibility: E,
54
54
  // Element settings
55
- omnibusPrice: O,
56
- omnibusDiscount: a,
55
+ omnibusPrice: D,
56
+ omnibusDiscount: A,
57
57
  textTrimming: !1,
58
- // Price placement (block-level, affects all cards)
59
- // Default ON = current stacked look, so existing templates are unaffected.
60
- priceMovedToNextLine: !0,
61
- // Default OFF: the original price always shows; the user opts in to hide it
62
- // when it equals the sale price. Mirrors email-service's `hide-price` default
63
- // of "false" (the actual hiding happens server-side at send).
64
- priceHideIfSameAsDiscounted: !1,
65
58
  // Meta
66
- // Version NOT bumped: mergeWithDefaults() backfills the two new fields from
67
- // defaults, so no data transform (and no needsMigration trigger) is required.
68
59
  configVersion: 1,
69
60
  recommendationId: 0
70
61
  }, N = [11, 12], m = 1;
71
62
  export {
72
63
  m as CURRENT_CONFIG_VERSION,
73
- A as DEFAULT_COMPOSITION,
74
- D as DEFAULT_CURRENCY,
64
+ a as DEFAULT_COMPOSITION,
65
+ O as DEFAULT_CURRENCY,
75
66
  l as DEFAULT_NODE_CONFIG,
76
- a as DEFAULT_OMNIBUS_DISCOUNT,
77
- O as DEFAULT_OMNIBUS_PRICE,
78
- c as DEFAULT_VISIBILITY,
67
+ A as DEFAULT_OMNIBUS_DISCOUNT,
68
+ D as DEFAULT_OMNIBUS_PRICE,
69
+ E as DEFAULT_VISIBILITY,
79
70
  N as EXCLUDED_ALGORITHM_IDS
80
71
  };