@useinsider/guido 3.7.2-beta.13c9a35 → 3.7.2-beta.3cec1a4

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 (39) 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 +45 -61
  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 +84 -96
  10. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +80 -82
  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/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +0 -59
@@ -1,34 +1,34 @@
1
- var B = Object.defineProperty;
2
- var D = (a, c, t) => c in a ? B(a, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[c] = t;
3
- var h = (a, c, t) => D(a, typeof c != "symbol" ? c + "" : c, t);
1
+ var k = Object.defineProperty;
2
+ var B = (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) => B(a, typeof r != "symbol" ? r + "" : r, t);
4
4
  import { BlockId as R } from "../../../enums/block.js";
5
5
  import { getMigrationBannerHtml as y } 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";
6
+ import { Block as D, 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
12
  import { useRecommendationBlockWarning as M } from "./useRecommendationBlockWarning.js";
13
- const _ = R.Recommendation, m = "recommendation-block-v2", u = "recommendation-id", I = "hide-price";
14
- let k = !1;
15
- class P extends b {
13
+ const I = R.Recommendation, m = "recommendation-block-v2", u = "recommendation-id";
14
+ let _ = !1;
15
+ class H extends D {
16
16
  constructor() {
17
17
  super();
18
18
  /**
19
19
  * Stores the ID generated in getTemplate() so onCreated() can reuse it.
20
20
  * This avoids generating a new (different) ID in onCreated().
21
21
  */
22
- h(this, "_pendingBlockId", null);
22
+ d(this, "_pendingBlockId", null);
23
23
  }
24
24
  getId() {
25
- return _;
25
+ return I;
26
26
  }
27
27
  getIcon() {
28
28
  return "recommendation-icon";
29
29
  }
30
30
  getBlockCompositionType() {
31
- return A.CONTAINER;
31
+ return C.CONTAINER;
32
32
  }
33
33
  getName() {
34
34
  return this.api.translate("Recommendation Block");
@@ -40,7 +40,7 @@ class P extends b {
40
40
  }
41
41
  getSettingsPanelTitleHtml() {
42
42
  return y(
43
- _,
43
+ I,
44
44
  this.api.translate("Recommendation Block"),
45
45
  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.")
46
46
  );
@@ -48,8 +48,11 @@ class P extends b {
48
48
  allowInnerBlocksDND() {
49
49
  return !1;
50
50
  }
51
+ // A saved module carries its config in the esd-config blob, restored on
52
+ // re-drop by migrateFromDataAttributes; per-element styles ride the
53
+ // preserved inner HTML. (onCreated early-returns for re-drops, never clobbers.)
51
54
  canBeSavedAsModule() {
52
- return !1;
55
+ return !0;
53
56
  }
54
57
  /**
55
58
  * Returns the template HTML for a new recommendation block.
@@ -60,7 +63,7 @@ class P extends b {
60
63
  */
61
64
  getTemplate() {
62
65
  const t = this._generateNextId();
63
- return this._pendingBlockId = t, S(t);
66
+ return this._pendingBlockId = t, E(t);
64
67
  }
65
68
  /**
66
69
  * Called when a new block is dropped into the template
@@ -83,20 +86,20 @@ class P extends b {
83
86
  }
84
87
  const i = this._pendingBlockId ?? this._generateNextId();
85
88
  this._pendingBlockId = null, this._assignRecommendationId(t, i);
86
- const { config: n, wasFreshDrop: o } = s.initializeConfig(
89
+ const { config: n, wasFreshDrop: o } = c.initializeConfig(
87
90
  this.api,
88
91
  t,
89
92
  { recommendationId: i }
90
- ), r = d();
91
- if (r.setCurrentBlock(i), this._stampHidePrice(t, n.priceHideIfSameAsDiscounted), o) {
93
+ ), s = g();
94
+ if (s.setCurrentBlock(i), o) {
92
95
  p(this.api);
93
96
  const l = this._getBlockElement(t);
94
- l && (f(this.api, l, !0), C({
97
+ l && (f(this.api, l, !0), b({
95
98
  currentNode: t,
96
99
  documentModifier: this.api.getDocumentModifier()
97
100
  }));
98
101
  }
99
- r.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 }), this._warnIfMultipleBlocks();
102
+ s.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 }), this._warnIfMultipleBlocks();
100
103
  }
101
104
  /**
102
105
  * Called when the document changes or template is loaded
@@ -109,20 +112,20 @@ class P extends b {
109
112
  if (!(!t || !("getNodeConfig" in t))) {
110
113
  if (!this._getRecommendationId(t)) {
111
114
  const e = this._generateNextId();
112
- this._assignRecommendationId(t, e), s.hasConfig(t) && s.updateConfig(
115
+ this._assignRecommendationId(t, e), c.hasConfig(t) && c.updateConfig(
113
116
  this.api,
114
117
  t,
115
118
  { recommendationId: e },
116
119
  "Assign recommendation ID to legacy block"
117
120
  );
118
121
  }
119
- this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
122
+ this._healLingeringDuplicate(t), c.needsMigration(t) && this._migrateFromLegacy(t);
120
123
  try {
121
- k || (p(this.api), k = !0);
122
- const e = s.getConfig(t), i = this._getBlockElement(t);
124
+ _ || (p(this.api), _ = !0);
125
+ const e = c.getConfig(t), i = this._getBlockElement(t);
123
126
  if (i) {
124
127
  const n = !e.mobileLayoutEnabled;
125
- E(i) !== n && f(this.api, i, n);
128
+ A(i) !== n && f(this.api, i, n);
126
129
  }
127
130
  } catch {
128
131
  }
@@ -136,7 +139,7 @@ class P extends b {
136
139
  */
137
140
  onDelete(t) {
138
141
  const e = this._getRecommendationId(t);
139
- e && d().removeBlockState(e);
142
+ e && g().removeBlockState(e);
140
143
  }
141
144
  /**
142
145
  * Warns (dark advisory toaster) when the design holds more than one live
@@ -166,8 +169,8 @@ class P extends b {
166
169
  const e = this.api.getDocumentRoot();
167
170
  e && "querySelectorAll" in e && e.querySelectorAll(`.${m}`).forEach((n) => {
168
171
  if ("getAttribute" in n) {
169
- const o = n.getAttribute(u), r = o ? parseInt(o) : 0;
170
- r > t && (t = r);
172
+ const o = n.getAttribute(u), s = o ? parseInt(o) : 0;
173
+ s > t && (t = s);
171
174
  }
172
175
  });
173
176
  } catch {
@@ -201,13 +204,13 @@ class P extends b {
201
204
  const o = this._getBlockElement(t);
202
205
  if (!o)
203
206
  return;
204
- let r = -1;
207
+ let s = -1;
205
208
  for (let l = 0; l < n.length; l++)
206
209
  if (n[l] === o) {
207
- r = l;
210
+ s = l;
208
211
  break;
209
212
  }
210
- if (r <= 0)
213
+ if (s <= 0)
211
214
  return;
212
215
  this._reassignDuplicateId(t, e);
213
216
  } catch {
@@ -227,7 +230,7 @@ class P extends b {
227
230
  }
228
231
  /** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
229
232
  _handleDuplicate(t, e) {
230
- const i = this._reassignDuplicateId(t, e), n = d();
233
+ const i = this._reassignDuplicateId(t, e), n = g();
231
234
  n.cloneBlockState(e, i), n.setCurrentBlock(i), this._warnIfMultipleBlocks();
232
235
  }
233
236
  /**
@@ -243,7 +246,7 @@ class P extends b {
243
246
  */
244
247
  _reassignDuplicateId(t, e) {
245
248
  const i = this._generateNextId(), n = this._getBlockElement(t);
246
- return this._assignRecommendationId(t, i), n && this._reassignInstanceClass(n, e, i), s.hasConfig(t) && s.updateConfig(
249
+ return this._assignRecommendationId(t, i), n && this._reassignInstanceClass(n, e, i), c.hasConfig(t) && c.updateConfig(
247
250
  this.api,
248
251
  t,
249
252
  { recommendationId: i },
@@ -260,8 +263,8 @@ class P extends b {
260
263
  _reassignInstanceClass(t, e, i) {
261
264
  if (!("getAttribute" in t))
262
265
  return;
263
- const n = `ins-recommendation-v3-block-${e}`, o = `ins-recommendation-v3-block-${i}`, r = this.api.getDocumentModifier();
264
- r.modifyHtml(t).removeClass(n).setClass(o), r.apply(new g(
266
+ const n = `ins-recommendation-v3-block-${e}`, o = `ins-recommendation-v3-block-${i}`, s = this.api.getDocumentModifier();
267
+ s.modifyHtml(t).removeClass(n).setClass(o), s.apply(new h(
265
268
  `Reassign recommendation instance class ${n} -> ${o}`
266
269
  ));
267
270
  }
@@ -276,26 +279,7 @@ class P extends b {
276
279
  if (!i)
277
280
  return;
278
281
  const n = this.api.getDocumentModifier();
279
- n.modifyHtml(i).setAttribute(u, e.toString()), n.apply(new g(`Assign recommendation ID ${e}`));
280
- }
281
- /**
282
- * Stamps the `hide-price` attribute (read by email-service at send time) on
283
- * the block element from the config flag.
284
- */
285
- _stampHidePrice(t, e) {
286
- const i = this._getBlockElement(t);
287
- i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(I, String(e)).apply(new g("Stamp hide-price"));
288
- }
289
- /**
290
- * Stamps `hide-price` from config only when the block lacks the attribute —
291
- * heals templates saved before this feature without dirtying current ones.
292
- */
293
- _healHidePriceAttr(t) {
294
- const e = this._getBlockElement(t);
295
- if (!e || !("getAttribute" in e) || e.getAttribute(I) !== null)
296
- return;
297
- const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
298
- this._stampHidePrice(t, i);
282
+ n.modifyHtml(i).setAttribute(u, e.toString()), n.apply(new h(`Assign recommendation ID ${e}`));
299
283
  }
300
284
  /**
301
285
  * Gets the recommendation-id from a block node
@@ -325,10 +309,10 @@ class P extends b {
325
309
  * Migrate configuration from legacy format
326
310
  */
327
311
  _migrateFromLegacy(t) {
328
- s.migrateFromDataAttributes(this.api, t);
312
+ c.migrateFromDataAttributes(this.api, t);
329
313
  }
330
314
  }
331
315
  export {
332
- _ as BLOCK_ID,
333
- P as RecommendationBlock
316
+ I as BLOCK_ID,
317
+ H as RecommendationBlock
334
318
  };
@@ -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
  };