@useinsider/guido 3.7.2-beta.13c9a35 → 3.7.2-beta.1489585

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 (60) 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 +78 -92
  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 +41 -60
  7. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +32 -41
  8. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +11 -10
  9. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +288 -369
  10. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +82 -96
  11. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +30 -39
  12. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +28 -34
  13. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +288 -338
  14. package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
  15. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +7 -21
  16. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -64
  17. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
  18. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +5 -7
  19. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +155 -215
  20. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +56 -31
  21. package/dist/extensions/Blocks/Recommendation/templates/index.js +29 -10
  22. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +145 -133
  23. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +43 -22
  24. package/dist/extensions/Blocks/Recommendation/templates/utils.js +109 -92
  25. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +216 -0
  26. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +24 -19
  27. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +30 -22
  28. package/dist/extensions/Blocks/controlFactories.js +159 -133
  29. package/dist/src/@types/config/schemas.d.ts +0 -16
  30. package/dist/src/composables/useConfig.d.ts +0 -4
  31. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
  32. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
  33. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -10
  34. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  35. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +2 -0
  36. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
  37. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -29
  38. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
  39. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -3
  40. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +2 -1
  41. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +20 -47
  42. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -2
  43. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -16
  44. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  45. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  46. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -13
  47. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  48. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +163 -41
  49. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -15
  50. package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +78 -0
  51. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +15 -0
  52. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +29 -9
  53. package/dist/src/extensions/Blocks/controlFactories.d.ts +11 -1
  54. package/dist/src/stores/config.d.ts +0 -36
  55. package/package.json +1 -1
  56. package/dist/composables/useRecommendationPreview.js +0 -100
  57. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +0 -133
  58. package/dist/src/composables/useRecommendationPreview.d.ts +0 -10
  59. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +0 -59
  60. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
@@ -1,33 +1,31 @@
1
- var f = Object.defineProperty;
2
- var p = (d, l, t) => l in d ? f(d, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[l] = t;
3
- var s = (d, l, t) => p(d, typeof l != "symbol" ? l + "" : l, t);
1
+ var C = Object.defineProperty;
2
+ var p = (d, a, t) => a in d ? C(d, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[a] = t;
3
+ var s = (d, a, t) => p(d, typeof a != "symbol" ? a + "" : a, t);
4
4
  import { CommonControl as g } from "../../../common-control.js";
5
- import { DEFAULT_NODE_CONFIG as c } from "../../constants/defaultConfig.js";
6
- import { RecommendationConfigService as m } from "../../services/configService.js";
5
+ import { DEFAULT_NODE_CONFIG as l } from "../../constants/defaultConfig.js";
6
+ import { RecommendationConfigService as h } from "../../services/configService.js";
7
7
  import { useRecommendationExtensionStore as y } from "../../store/recommendation.js";
8
8
  import { AlgorithmControl as R } from "./algorithm.js";
9
- import { ALGORITHM_CONTROL_ID as Z } from "./algorithm.js";
10
- import { CurrencyControl as N } from "./currency.js";
11
- import { CURRENCY_CONTROL_ID as et } from "./currency.js";
12
- import { FiltersControl as I } from "./filters.js";
13
- import { FILTERS_CONTROL_ID as rt } from "./filters.js";
14
- import { LayoutOrientationControl as _ } from "./layoutOrientation.js";
15
- import { LAYOUT_ORIENTATION_CONTROL_ID as it } from "./layoutOrientation.js";
16
- import { LocaleControl as b } from "./locale.js";
17
- import { LOCALE_CONTROL_ID as ct } from "./locale.js";
18
- import { PricePlacementControl as T } from "./pricePlacement.js";
19
- import { PRICE_PLACEMENT_CONTROL_ID as at } from "./pricePlacement.js";
20
- import { ProductCountControl as P } from "./productCount.js";
21
- import { PRODUCT_COUNT_CONTROL_ID as dt } from "./productCount.js";
22
- import { ProductLayoutControl as O } from "./productLayout.js";
23
- import { PRODUCT_LAYOUT_CONTROL_ID as ht } from "./productLayout.js";
24
- import { ShuffleControl as L } from "./shuffle.js";
25
- import { SHUFFLE_CONTROL_ID as ft } from "./shuffle.js";
26
- import { setCurrencyAttributes as S, getBlockElement as k, updateProductContentInPlace as D, regenerateProductRowsWithStyles as E } from "./utils.js";
27
- import { adjustProductsToSize as gt, formatProductPrice as yt, getCardComposition as Rt, getCurrentLayout as Nt, reapplySpacing as It, regenerateMobileProductRows as _t, regenerateProductRows as bt, updatePricesInPlace as Tt, updateSingleProductContent as Pt } from "./utils.js";
28
- import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
29
- const w = "recommendation-id", A = "ui-elements-recommendation-block";
30
- class J extends g {
9
+ import { ALGORITHM_CONTROL_ID as Q } from "./algorithm.js";
10
+ import { CurrencyControl as b } from "./currency.js";
11
+ import { CURRENCY_CONTROL_ID as Z } from "./currency.js";
12
+ import { FiltersControl as N } from "./filters.js";
13
+ import { FILTERS_CONTROL_ID as et } from "./filters.js";
14
+ import { LayoutOrientationControl as I } from "./layoutOrientation.js";
15
+ import { LAYOUT_ORIENTATION_CONTROL_ID as rt } from "./layoutOrientation.js";
16
+ import { LocaleControl as _ } from "./locale.js";
17
+ import { LOCALE_CONTROL_ID as it } from "./locale.js";
18
+ import { ProductCountControl as O } from "./productCount.js";
19
+ import { PRODUCT_COUNT_CONTROL_ID as lt } from "./productCount.js";
20
+ import { ProductLayoutControl as T } from "./productLayout.js";
21
+ import { PRODUCT_LAYOUT_CONTROL_ID as ct } from "./productLayout.js";
22
+ import { ShuffleControl as S } from "./shuffle.js";
23
+ import { SHUFFLE_CONTROL_ID as dt } from "./shuffle.js";
24
+ import { setCurrencyAttributes as L, getBlockElement as P, updateProductContentInPlace as k, regenerateProductRowsWithStyles as D } from "./utils.js";
25
+ import { adjustProductsToSize as mt, formatProductPrice as ft, getCardComposition as Ct, getCurrentLayout as pt, regenerateMobileProductRows as gt, updatePricesInPlace as yt, updateSingleProductContent as Rt } from "./utils.js";
26
+ import { useDebounceFn as m } from "../../../../../node_modules/@vueuse/shared/index.js";
27
+ const E = "recommendation-id", w = "ui-elements-recommendation-block";
28
+ class K extends g {
31
29
  constructor() {
32
30
  super(...arguments);
33
31
  s(this, "store", y());
@@ -42,12 +40,11 @@ class J extends g {
42
40
  s(this, "productLayoutControl", null);
43
41
  s(this, "filtersControl", null);
44
42
  s(this, "shuffleControl", null);
45
- s(this, "pricePlacementControl", null);
46
43
  s(this, "layoutOrientationControl", null);
47
44
  /**
48
45
  * Debounced product fetch to prevent rapid API calls during config changes
49
46
  */
50
- s(this, "_debouncedFetchProducts", h(() => {
47
+ s(this, "_debouncedFetchProducts", m(() => {
51
48
  this.store.fetchRecommendationProducts();
52
49
  }, 500));
53
50
  /**
@@ -61,16 +58,16 @@ class J extends g {
61
58
  * count. The store pads products to the configured size, so in-place only
62
59
  * fails when the size actually changed.
63
60
  */
64
- s(this, "_debouncedRegenerateWithProducts", h(() => {
61
+ s(this, "_debouncedRegenerateWithProducts", m(() => {
65
62
  const t = this.store.recommendationProducts;
66
63
  if (!this.currentNode || !this.api)
67
64
  return;
68
65
  const e = this.api.getDocumentModifier();
69
- D({
66
+ k({
70
67
  currentNode: this.currentNode,
71
68
  documentModifier: e,
72
69
  products: t
73
- }) || E({
70
+ }) || D({
74
71
  currentNode: this.currentNode,
75
72
  documentModifier: e,
76
73
  products: t
@@ -78,10 +75,10 @@ class J extends g {
78
75
  }, 100));
79
76
  }
80
77
  getId() {
81
- return A;
78
+ return w;
82
79
  }
83
80
  getTemplate() {
84
- return this.algorithmControl = new R(), this.localeControl = new b(), this.currencyControl = new N(), this.productCountControl = new P(), this.productLayoutControl = new O(), this.filtersControl = new I(), this.shuffleControl = new L(), this.pricePlacementControl = new T(), this.layoutOrientationControl = new _(), [
81
+ return this.algorithmControl = new R(), this.localeControl = new _(), this.currencyControl = new b(), this.productCountControl = new O(), this.productLayoutControl = new T(), this.filtersControl = new N(), this.shuffleControl = new S(), this.layoutOrientationControl = new I(), [
85
82
  this.algorithmControl,
86
83
  this.localeControl,
87
84
  this.currencyControl,
@@ -89,7 +86,6 @@ class J extends g {
89
86
  this.productLayoutControl,
90
87
  this.filtersControl,
91
88
  this.shuffleControl,
92
- this.pricePlacementControl,
93
89
  this.layoutOrientationControl
94
90
  ].forEach((e) => {
95
91
  e.api = this.api;
@@ -100,7 +96,6 @@ class J extends g {
100
96
  ${this.productLayoutControl.getTemplate()}
101
97
  ${this.algorithmControl.getTemplate()}
102
98
  ${this.localeControl.getTemplate()}
103
- ${this.pricePlacementControl.getTemplate()}
104
99
  ${this.currencyControl.getTemplate()}
105
100
  ${this.filtersControl.getTemplate()}
106
101
  ${this.shuffleControl.getTemplate()}
@@ -130,8 +125,7 @@ class J extends g {
130
125
  this.currencyControl,
131
126
  this.productLayoutControl,
132
127
  this.filtersControl,
133
- this.shuffleControl,
134
- this.pricePlacementControl
128
+ this.shuffleControl
135
129
  ].forEach((n) => {
136
130
  var i;
137
131
  n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
@@ -146,8 +140,7 @@ class J extends g {
146
140
  this.currencyControl,
147
141
  this.productLayoutControl,
148
142
  this.filtersControl,
149
- this.shuffleControl,
150
- this.pricePlacementControl
143
+ this.shuffleControl
151
144
  ].forEach((e) => {
152
145
  var o;
153
146
  return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
@@ -166,8 +159,7 @@ class J extends g {
166
159
  this.currencyControl,
167
160
  this.productLayoutControl,
168
161
  this.filtersControl,
169
- this.shuffleControl,
170
- this.pricePlacementControl
162
+ this.shuffleControl
171
163
  ].forEach((e) => {
172
164
  var o;
173
165
  e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
@@ -186,7 +178,7 @@ class J extends g {
186
178
  */
187
179
  _syncNodeConfigToStore() {
188
180
  var r;
189
- const t = m.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
181
+ const t = h.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
190
182
  this.store.patchCurrentBlockConfig({
191
183
  strategy: t.strategy,
192
184
  language: t.language,
@@ -201,8 +193,6 @@ class J extends g {
201
193
  // for filters (edited via the filter drawer).
202
194
  ...o ? {} : { filters: t.filters },
203
195
  shuffleProducts: t.shuffleProducts,
204
- priceMovedToNextLine: t.priceMovedToNextLine,
205
- priceHideIfSameAsDiscounted: t.priceHideIfSameAsDiscounted,
206
196
  currencySettings: {
207
197
  name: t.currency.code,
208
198
  value: t.currency.code,
@@ -249,36 +239,36 @@ class J extends g {
249
239
  _applySmartDefaults() {
250
240
  if (!this.currentNode || !this.api)
251
241
  return;
252
- const t = m.getConfig(this.currentNode), e = {};
242
+ const t = h.getConfig(this.currentNode), e = {};
253
243
  let o = null, r = null, n = null;
254
- if (t.currency.code === c.currency.code) {
244
+ if (t.currency.code === l.currency.code) {
255
245
  const { currencyList: i } = this.store;
256
246
  i.length > 0 && (i.some(
257
- (u) => u.value === `price.${c.currency.code}`
247
+ (u) => u.value === `price.${l.currency.code}`
258
248
  ) || (o = i[0].value.replace("price.", ""), e.currency = {
259
- ...c.currency,
249
+ ...l.currency,
260
250
  code: o,
261
251
  symbol: o
262
252
  }));
263
253
  }
264
- if (t.strategy === c.strategy) {
254
+ if (t.strategy === l.strategy) {
265
255
  const i = this.store.getActivePredictiveAlgorithms;
266
256
  i.length > 0 && (i.some(
267
- (u) => u.value === c.strategy
257
+ (u) => u.value === l.strategy
268
258
  ) || (r = i[0].value, e.strategy = r));
269
259
  }
270
- if (t.language === c.language) {
260
+ if (t.language === l.language) {
271
261
  const i = this.store.getLanguages;
272
262
  i.length > 0 && (i.some(
273
- (u) => u.value === c.language
263
+ (u) => u.value === l.language
274
264
  ) || (n = i[0].value, e.language = n));
275
265
  }
276
- !o && !r && !n || (m.updateConfig(
266
+ !o && !r && !n || (h.updateConfig(
277
267
  this.api,
278
268
  this.currentNode,
279
269
  e,
280
270
  "Applied smart defaults"
281
- ), o && e.currency && S({
271
+ ), o && e.currency && L({
282
272
  currentNode: this.currentNode,
283
273
  documentModifier: this.api.getDocumentModifier(),
284
274
  currency: e.currency
@@ -288,10 +278,10 @@ class J extends g {
288
278
  name: o,
289
279
  value: o,
290
280
  symbol: o,
291
- alignment: c.currency.alignment === "before" ? "0" : "1",
292
- decimalCount: c.currency.decimalCount.toString(),
293
- decimalSeparator: c.currency.decimalSeparator,
294
- thousandSeparator: c.currency.thousandSeparator
281
+ alignment: l.currency.alignment === "before" ? "0" : "1",
282
+ decimalCount: l.currency.decimalCount.toString(),
283
+ decimalSeparator: l.currency.decimalSeparator,
284
+ thousandSeparator: l.currency.thousandSeparator
295
285
  }
296
286
  } : {},
297
287
  ...r ? { strategy: r } : {},
@@ -302,10 +292,10 @@ class J extends g {
302
292
  * Reads the recommendation-id attribute from the block element within the node
303
293
  */
304
294
  _getRecommendationIdFromNode(t) {
305
- const e = k(t);
295
+ const e = P(t);
306
296
  if (!e || !("getAttribute" in e))
307
297
  return null;
308
- const o = e.getAttribute(w);
298
+ const o = e.getAttribute(E);
309
299
  if (!o)
310
300
  return null;
311
301
  const r = parseInt(o);
@@ -335,8 +325,8 @@ class J extends g {
335
325
  }
336
326
  const i = t.$state.configVersion;
337
327
  i !== o && (o = i, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
338
- const a = t.recommendationProducts, u = a !== e, C = Array.isArray(a) && a.length > 0;
339
- u && C && (e = a, this._debouncedRegenerateWithProducts());
328
+ const c = t.recommendationProducts, u = c !== e, f = Array.isArray(c) && c.length > 0;
329
+ u && f && (e = c, this._debouncedRegenerateWithProducts());
340
330
  });
341
331
  }
342
332
  /**
@@ -347,7 +337,7 @@ class J extends g {
347
337
  if (!this.currentNode || !this.api)
348
338
  return;
349
339
  const { filters: t } = this.store.recommendationConfigs;
350
- m.updateConfig(
340
+ h.updateConfig(
351
341
  this.api,
352
342
  this.currentNode,
353
343
  { filters: t },
@@ -356,37 +346,33 @@ class J extends g {
356
346
  }
357
347
  }
358
348
  export {
359
- Z as ALGORITHM_CONTROL_ID,
349
+ Q as ALGORITHM_CONTROL_ID,
360
350
  R as AlgorithmControl,
361
- A as CONTROL_BLOCK_ID,
362
- et as CURRENCY_CONTROL_ID,
363
- N as CurrencyControl,
364
- rt as FILTERS_CONTROL_ID,
365
- I as FiltersControl,
366
- it as LAYOUT_ORIENTATION_CONTROL_ID,
367
- ct as LOCALE_CONTROL_ID,
368
- _ as LayoutOrientationControl,
369
- b as LocaleControl,
370
- at as PRICE_PLACEMENT_CONTROL_ID,
371
- dt as PRODUCT_COUNT_CONTROL_ID,
372
- ht as PRODUCT_LAYOUT_CONTROL_ID,
373
- T as PricePlacementControl,
374
- P as ProductCountControl,
375
- O as ProductLayoutControl,
376
- J as RecommendationBlockControl,
377
- ft as SHUFFLE_CONTROL_ID,
378
- L as ShuffleControl,
379
- gt as adjustProductsToSize,
380
- yt as formatProductPrice,
381
- k as getBlockElement,
382
- Rt as getCardComposition,
383
- Nt as getCurrentLayout,
384
- It as reapplySpacing,
385
- _t as regenerateMobileProductRows,
386
- bt as regenerateProductRows,
387
- E as regenerateProductRowsWithStyles,
388
- S as setCurrencyAttributes,
389
- Tt as updatePricesInPlace,
390
- D as updateProductContentInPlace,
391
- Pt as updateSingleProductContent
351
+ w as CONTROL_BLOCK_ID,
352
+ Z as CURRENCY_CONTROL_ID,
353
+ b as CurrencyControl,
354
+ et as FILTERS_CONTROL_ID,
355
+ N as FiltersControl,
356
+ rt as LAYOUT_ORIENTATION_CONTROL_ID,
357
+ it as LOCALE_CONTROL_ID,
358
+ I as LayoutOrientationControl,
359
+ _ as LocaleControl,
360
+ lt as PRODUCT_COUNT_CONTROL_ID,
361
+ ct as PRODUCT_LAYOUT_CONTROL_ID,
362
+ O as ProductCountControl,
363
+ T as ProductLayoutControl,
364
+ K as RecommendationBlockControl,
365
+ dt as SHUFFLE_CONTROL_ID,
366
+ S as ShuffleControl,
367
+ mt as adjustProductsToSize,
368
+ ft as formatProductPrice,
369
+ P as getBlockElement,
370
+ Ct as getCardComposition,
371
+ pt as getCurrentLayout,
372
+ gt as regenerateMobileProductRows,
373
+ D as regenerateProductRowsWithStyles,
374
+ L as setCurrencyAttributes,
375
+ yt as updatePricesInPlace,
376
+ k as updateProductContentInPlace,
377
+ Rt as updateSingleProductContent
392
378
  };
@@ -1,64 +1,53 @@
1
- var p = Object.defineProperty;
2
- var A = (o, e, t) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var r = (o, e, t) => A(o, typeof e != "symbol" ? e + "" : e, t);
1
+ var L = Object.defineProperty;
2
+ var _ = (o, e, t) => e in o ? L(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var s = (o, e, t) => _(o, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
5
  import { CommonControl as N } from "../../../common-control.js";
6
- import { ATTR_DATA_CUSTOM_ATTRIBUTES as L } from "../../constants/selectors.js";
7
- import { LAYOUT_OPTIONS as T, DEFAULT_MOBILE_ROW_SPACING as m, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as l, DEFAULT_COLUMN_SPACING as g } from "../../constants/layout.js";
8
- import { DEFAULT_COMPOSITION as _ } from "../../constants/defaultConfig.js";
9
- import { RecommendationConfigService as s } from "../../services/configService.js";
10
- import { useRecommendationExtensionStore as f } from "../../store/recommendation.js";
11
- import { getCurrentLayout as C, getBlockElement as I, regenerateProductRowsWithStyles as S } from "./utils.js";
12
- const U = "recommendation-layout-orientation-control", O = "recommendationInfoBannerTest", a = {
6
+ import { LAYOUT_OPTIONS as O, DEFAULT_MOBILE_ROW_SPACING as m, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as l, DEFAULT_COLUMN_SPACING as g } from "../../constants/layout.js";
7
+ import { RecommendationConfigService as a } from "../../services/configService.js";
8
+ import { useRecommendationExtensionStore as A } from "../../store/recommendation.js";
9
+ import { getCurrentLayout as C, getBlockElement as f, getCardComposition as S, regenerateProductRowsWithStyles as T } from "./utils.js";
10
+ const I = "recommendation-layout-orientation-control", u = {
13
11
  LAYOUT: "layout"
14
- }, y = "data-card-composition", n = {
12
+ }, n = {
15
13
  LAYOUT: "data-layout",
16
14
  COLUMN_SPACING: "data-column-spacing",
17
15
  ROW_SPACING: "data-row-spacing",
18
16
  MOBILE_COLUMN_SPACING: "data-mobile-column-spacing",
19
17
  MOBILE_ROW_SPACING: "data-mobile-row-spacing"
20
18
  };
21
- class Y extends N {
19
+ class w extends N {
22
20
  constructor() {
23
21
  super(...arguments);
24
- r(this, "store", f());
25
- r(this, "isChangingLayout", !1);
22
+ s(this, "store", A());
23
+ s(this, "isChangingLayout", !1);
26
24
  }
27
25
  getId() {
28
- return U;
26
+ return I;
29
27
  }
30
28
  getTemplate() {
31
29
  return `
32
30
  <div class="layout-control-container">
33
- ${this._GuOnPageMessage({ name: O })}
34
-
35
31
  ${this._GuTwoColumns([
36
32
  this._GuLabel({ text: this.api.translate("Layout Orientation") }),
37
33
  this._GuRadioButton({
38
- name: a.LAYOUT,
39
- buttons: T
34
+ name: u.LAYOUT,
35
+ buttons: O
40
36
  })
41
37
  ])}
42
38
  </div>
43
39
  `;
44
40
  }
45
41
  onRender() {
46
- this._setInfoMessageValue(
47
- O,
48
- this.api.translate(
49
- `Note that updating the Layout Orientation, Number of Products,
50
- Products in One Row and Mobile Layout Optimization settings
51
- resets the style of your Recommendation block.`
52
- )
53
- ), this._setFormValues(), this._listenToFormUpdates();
42
+ this._setFormValues(), this._listenToFormUpdates();
54
43
  }
55
44
  onTemplateNodeUpdated(t) {
56
45
  super.onTemplateNodeUpdated(t), this._setFormValues();
57
46
  }
58
47
  _setFormValues() {
59
- const u = s.getConfig(this.currentNode).layout || C(this.currentNode);
48
+ const r = a.getConfig(this.currentNode).layout || C(this.currentNode);
60
49
  this.api.updateValues({
61
- [a.LAYOUT]: u
50
+ [u.LAYOUT]: r
62
51
  });
63
52
  }
64
53
  /**
@@ -66,13 +55,14 @@ class Y extends N {
66
55
  * Updates node config, data attribute and regenerates product rows
67
56
  */
68
57
  _onLayoutChange(t) {
69
- if (this.isChangingLayout || !this.currentNode || (s.getConfig(this.currentNode).layout || C(this.currentNode)) === t)
58
+ if (this.isChangingLayout || !this.currentNode || (a.getConfig(this.currentNode).layout || C(this.currentNode)) === t)
70
59
  return;
71
- const c = I(this.currentNode);
60
+ const c = f(this.currentNode);
72
61
  if (c) {
73
62
  this.isChangingLayout = !0;
74
63
  try {
75
- s.updateConfig(
64
+ const p = S(this.currentNode);
65
+ a.updateConfig(
76
66
  this.api,
77
67
  this.currentNode,
78
68
  {
@@ -85,7 +75,7 @@ class Y extends N {
85
75
  `Changed layout to ${t}`
86
76
  ), this.store.patchCurrentBlockConfig({ orientation: t });
87
77
  const i = this.api.getDocumentModifier().modifyHtml(c).setAttribute(n.LAYOUT, t).setAttribute(n.COLUMN_SPACING, g.toString()).setAttribute(n.ROW_SPACING, l.toString()).setAttribute(n.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(n.MOBILE_ROW_SPACING, m.toString());
88
- t === "list" ? (i.setClass("es-m-p0"), i.setClass("ins-recommendation-list-layout")) : (i.removeClass("es-m-p0"), i.removeClass("ins-recommendation-list-layout")), i.setAttribute(y, _.join(",")).setAttribute(L, "[]"), i.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t);
78
+ t === "list" ? (i.setClass("es-m-p0"), i.setClass("ins-recommendation-list-layout")) : (i.removeClass("es-m-p0"), i.removeClass("ins-recommendation-list-layout")), i.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t, p);
89
79
  } finally {
90
80
  this.isChangingLayout = !1;
91
81
  }
@@ -95,22 +85,23 @@ class Y extends N {
95
85
  * Regenerates product rows based on the selected layout
96
86
  * Uses unified style-preserving regeneration to maintain user customizations
97
87
  * @param layout - The layout to use for regeneration (passed explicitly to avoid stale DOM reads)
88
+ * @param composition - The preserved card composition, incl. customAttr:* entries
98
89
  */
99
- _regenerateProductRows(t) {
100
- this.currentNode && S({
90
+ _regenerateProductRows(t, r) {
91
+ this.currentNode && T({
101
92
  currentNode: this.currentNode,
102
93
  documentModifier: this.api.getDocumentModifier(),
103
94
  layout: t,
104
- composition: _
95
+ composition: r
105
96
  });
106
97
  }
107
98
  _listenToFormUpdates() {
108
- this.api.onValueChanged(a.LAYOUT, (t) => {
99
+ this.api.onValueChanged(u.LAYOUT, (t) => {
109
100
  this._onLayoutChange(t);
110
101
  });
111
102
  }
112
103
  }
113
104
  export {
114
- U as LAYOUT_ORIENTATION_CONTROL_ID,
115
- Y as LayoutOrientationControl
105
+ I as LAYOUT_ORIENTATION_CONTROL_ID,
106
+ w as LayoutOrientationControl
116
107
  };
@@ -1,15 +1,15 @@
1
1
  var E = Object.defineProperty;
2
2
  var f = (a, n, t) => n in a ? E(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
3
  var c = (a, n, t) => f(a, typeof n != "symbol" ? n + "" : n, t);
4
- import { EditorStatePropertyType as O, PreviewDeviceMode as N, UEAttr as T } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as M } from "../../../common-control.js";
6
- import { MAX_PRODUCTS_PER_ROW as m, MAX_MOBILE_PRODUCTS_PER_ROW as P, DEFAULT_MOBILE_CARDS_IN_ROW as l, DEFAULT_COLUMN_SPACING as w, DEFAULT_MOBILE_COLUMN_SPACING as y } from "../../constants/layout.js";
4
+ import { EditorStatePropertyType as O, PreviewDeviceMode as T, UEAttr as N } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as P } from "../../../common-control.js";
6
+ import { MAX_PRODUCTS_PER_ROW as m, MAX_MOBILE_PRODUCTS_PER_ROW as M, DEFAULT_MOBILE_CARDS_IN_ROW as l } from "../../constants/layout.js";
7
7
  import { RecommendationConfigService as s } from "../../services/configService.js";
8
- import { useRecommendationExtensionStore as D } from "../../store/recommendation.js";
9
- import { setMobileLayoutOptOut as C, ensureMobileCssRulesExist as L } from "../mobileLayout/cssRules.js";
10
- import { getCurrentLayout as U, getBlockElement as A, adjustProductsToSize as b, regenerateProductRowsWithStyles as g, regenerateMobileProductRows as I } from "./utils.js";
11
- import { useDebounceFn as B } from "../../../../../node_modules/@vueuse/shared/index.js";
12
- const S = "recommendation-product-layout-control", e = {
8
+ import { useRecommendationExtensionStore as w } from "../../store/recommendation.js";
9
+ import { setMobileLayoutOptOut as C, ensureMobileCssRulesExist as b } from "../mobileLayout/cssRules.js";
10
+ import { getCurrentLayout as y, getBlockElement as D, adjustProductsToSize as L, regenerateProductRowsWithStyles as g, regenerateMobileProductRows as I } from "./utils.js";
11
+ import { useDebounceFn as U } from "../../../../../node_modules/@vueuse/shared/index.js";
12
+ const B = "recommendation-product-layout-control", e = {
13
13
  // "Products in One Row" — shown when toggle is OFF
14
14
  PRODUCT_IN_ROW: "cardsInRow",
15
15
  PRODUCT_IN_ROW_LABEL: "cardsInRowLabel",
@@ -23,19 +23,19 @@ const S = "recommendation-product-layout-control", e = {
23
23
  MOBILE_LAYOUT_TOGGLE: "mobileLayoutEnabled",
24
24
  MOBILE_LAYOUT_LABEL: "mobileLayoutLabel"
25
25
  };
26
- class v extends M {
26
+ class v extends P {
27
27
  constructor() {
28
28
  super(...arguments);
29
29
  // Store is used for backward compatibility with product fetching and regeneration
30
- c(this, "store", D());
30
+ c(this, "store", w());
31
31
  c(this, "storeUnsubscription", () => {
32
32
  });
33
- c(this, "_debouncedRegenerateProductRows", B(() => {
33
+ c(this, "_debouncedRegenerateProductRows", U(() => {
34
34
  this._regenerateProductRows();
35
35
  }, 500));
36
36
  }
37
37
  getId() {
38
- return S;
38
+ return B;
39
39
  }
40
40
  getTemplate() {
41
41
  return `
@@ -57,7 +57,7 @@ class v extends M {
57
57
  }),
58
58
  this._GuCounter({
59
59
  name: e.MOBILE_CARDS_IN_ROW,
60
- maxValue: P
60
+ maxValue: M
61
61
  }),
62
62
  this._GuLabel({
63
63
  text: this.api.translate("Mobile Layout Optimization"),
@@ -95,7 +95,7 @@ class v extends M {
95
95
  * Returns true when the editor preview is in mobile mode.
96
96
  */
97
97
  _isMobilePreview() {
98
- return this.api.getEditorState()[O.previewDeviceMode] === N.MOBILE;
98
+ return this.api.getEditorState()[O.previewDeviceMode] === T.MOBILE;
99
99
  }
100
100
  /**
101
101
  * Updates counter visibility based on layout, mobileLayoutEnabled, and editor preview mode.
@@ -110,7 +110,7 @@ class v extends M {
110
110
  */
111
111
  _updateProductsInRowVisibility() {
112
112
  var p;
113
- const t = s.getConfig(this.currentNode), o = (t.layout || U(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, u = this._isMobilePreview();
113
+ const t = s.getConfig(this.currentNode), o = (t.layout || y(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, u = this._isMobilePreview();
114
114
  this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE, o), this.api.setVisibility(e.MOBILE_LAYOUT_LABEL, o);
115
115
  const d = o && !r, _ = o && r && !u, h = o && r && u;
116
116
  this.api.setVisibility(e.PRODUCT_IN_ROW, d), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, d), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP, _), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP_LABEL, _), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, h), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, h);
@@ -125,7 +125,7 @@ class v extends M {
125
125
  const t = s.getConfig(this.currentNode);
126
126
  this.api.setUIEAttribute(
127
127
  e.MOBILE_LAYOUT_TOGGLE,
128
- T.SELECTPICKER.items,
128
+ N.SELECTPICKER.items,
129
129
  t.mobileLayoutEnabled
130
130
  );
131
131
  }
@@ -140,7 +140,7 @@ class v extends M {
140
140
  const i = s.getConfig(this.currentNode);
141
141
  if (i.mobileLayoutEnabled === t)
142
142
  return;
143
- const o = A(this.currentNode);
143
+ const o = D(this.currentNode);
144
144
  if (t) {
145
145
  const r = i.previousMobileCardsInRow || l;
146
146
  s.updateConfig(
@@ -157,8 +157,8 @@ class v extends M {
157
157
  mobileCardsInRow: r
158
158
  },
159
159
  { triggerRefetch: !1 }
160
- ), o && C(this.api, o, !1), L(this.api);
161
- const u = parseInt(i.size) || 6, d = b(this.store.recommendationProducts, u);
160
+ ), o && C(this.api, o, !1), b(this.api);
161
+ const u = parseInt(i.size) || 6, d = L(this.store.recommendationProducts, u);
162
162
  g({
163
163
  currentNode: this.currentNode,
164
164
  documentModifier: this.api.getDocumentModifier(),
@@ -189,35 +189,29 @@ class v extends M {
189
189
  this._setFormValues(), this._updateProductsInRowVisibility();
190
190
  }
191
191
  _onProductsInRowChange(t) {
192
- if (!this.currentNode || s.getConfig(this.currentNode).cardsInRow === t)
193
- return;
194
- const o = t === 1 ? 0 : w;
195
- s.updateConfig(
192
+ !this.currentNode || s.getConfig(this.currentNode).cardsInRow === t || (s.updateConfig(
196
193
  this.api,
197
194
  this.currentNode,
198
- { cardsInRow: t, columnSpacing: o },
195
+ { cardsInRow: t },
199
196
  `Changed products per row to ${t}`
200
- ), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows();
197
+ ), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows());
201
198
  }
202
199
  _onMobileCardsInRowChange(t) {
203
- if (!this.currentNode || s.getConfig(this.currentNode).mobileCardsInRow === t)
204
- return;
205
- const o = t === 1 ? 0 : y;
206
- s.updateConfig(
200
+ !this.currentNode || s.getConfig(this.currentNode).mobileCardsInRow === t || (s.updateConfig(
207
201
  this.api,
208
202
  this.currentNode,
209
- { mobileCardsInRow: t, mobileColumnSpacing: o },
203
+ { mobileCardsInRow: t },
210
204
  `Changed mobile products per row to ${t}`
211
- ), L(this.api), this.store.patchCurrentBlockConfig(
205
+ ), b(this.api), this.store.patchCurrentBlockConfig(
212
206
  { mobileCardsInRow: t },
213
207
  { triggerRefetch: !1 }
214
208
  ), I({
215
209
  currentNode: this.currentNode,
216
210
  documentModifier: this.api.getDocumentModifier()
217
- });
211
+ }));
218
212
  }
219
213
  _regenerateProductRows() {
220
- const t = s.getConfig(this.currentNode), i = parseInt(t.size) || 6, o = b(this.store.recommendationProducts, i);
214
+ const t = s.getConfig(this.currentNode), i = parseInt(t.size) || 6, o = L(this.store.recommendationProducts, i);
221
215
  g({
222
216
  currentNode: this.currentNode,
223
217
  documentModifier: this.api.getDocumentModifier(),
@@ -261,6 +255,6 @@ class v extends M {
261
255
  }
262
256
  }
263
257
  export {
264
- S as PRODUCT_LAYOUT_CONTROL_ID,
258
+ B as PRODUCT_LAYOUT_CONTROL_ID,
265
259
  v as ProductLayoutControl
266
260
  };