@useinsider/guido 3.0.0-beta.34a1600 → 3.0.0-beta.39155d9

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 (91) hide show
  1. package/dist/@types/config/schemas.js +10 -8
  2. package/dist/components/Guido.vue.js +3 -3
  3. package/dist/components/Guido.vue2.js +61 -60
  4. package/dist/components/organisms/header/EditorActions.vue.js +1 -1
  5. package/dist/components/organisms/header/EditorActions.vue2.js +6 -6
  6. package/dist/composables/useCustomFieldAttributes.js +16 -0
  7. package/dist/composables/useHtmlValidator.js +40 -38
  8. package/dist/config/compiler/unsubscribeCompilerRules.js +14 -14
  9. package/dist/config/compiler/utils/recommendationCompilerUtils.js +29 -18
  10. package/dist/extensions/Blocks/Recommendation/block.js +40 -55
  11. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
  12. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  13. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +34 -36
  14. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -12
  15. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +4 -4
  16. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +693 -144
  17. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +78 -0
  18. package/dist/extensions/Blocks/Recommendation/controls/{main/layoutOrientation.js → layout/index.js} +27 -32
  19. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +15 -15
  20. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +24 -24
  21. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +2 -2
  22. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +78 -107
  23. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +2 -2
  24. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +64 -150
  25. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +2 -2
  26. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +191 -177
  27. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +8 -25
  28. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -6
  29. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
  30. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +21 -21
  31. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +13 -13
  32. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +17 -17
  33. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +100 -94
  34. package/dist/extensions/Blocks/Recommendation/extension.js +27 -25
  35. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +125 -36
  36. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +111 -99
  37. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +2 -2
  38. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +63 -34
  39. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -33
  40. package/dist/extensions/Blocks/Recommendation/templates/index.js +8 -8
  41. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +28 -13
  42. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +25 -44
  43. package/dist/extensions/Blocks/Recommendation/templates/utils.js +62 -38
  44. package/dist/extensions/Blocks/common-control.js +41 -90
  45. package/dist/guido.css +1 -1
  46. package/dist/services/customFieldAttributesApi.js +21 -0
  47. package/dist/src/@types/config/schemas.d.ts +4 -0
  48. package/dist/src/components/Guido.vue.d.ts +1 -1
  49. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  50. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  51. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  52. package/dist/src/composables/useConfig.d.ts +2 -0
  53. package/dist/src/composables/useCustomFieldAttributes.d.ts +5 -0
  54. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
  55. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +2 -1
  56. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +7 -1
  57. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  58. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +10 -0
  59. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.d.ts +25 -0
  60. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +134 -44
  61. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +105 -0
  62. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +3 -2
  63. package/dist/src/extensions/Blocks/Recommendation/controls/{main/layoutOrientation.d.ts → layout/index.d.ts} +3 -3
  64. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -5
  65. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +20 -38
  66. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -4
  67. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +1 -23
  68. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.d.ts +15 -0
  69. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.d.ts +15 -0
  70. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.d.ts +15 -0
  71. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.d.ts +15 -0
  72. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +18 -8
  73. package/dist/src/extensions/Blocks/Recommendation/controls/spacingControl.d.ts +60 -0
  74. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -1
  75. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +1 -1
  76. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +1 -1
  77. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +10 -4
  78. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +37 -2
  79. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -13
  80. package/dist/src/extensions/Blocks/common-control.d.ts +2 -24
  81. package/dist/src/mock/api/custom-field-attributes.d.ts +2 -0
  82. package/dist/src/services/customFieldAttributesApi.d.ts +3 -0
  83. package/dist/src/stores/config.d.ts +18 -0
  84. package/dist/static/styles/components/wide-panel.css.js +0 -1
  85. package/dist/static/styles/customEditorStyle.css.js +0 -9
  86. package/dist/static/styles/variables.css.js +3 -0
  87. package/package.json +1 -1
  88. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +0 -58
  89. package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +0 -65
  90. package/dist/src/extensions/Blocks/Recommendation/controls/main/productCount.d.ts +0 -28
  91. package/dist/src/extensions/Blocks/Recommendation/controls/syncInfoMessage.d.ts +0 -34
@@ -1,49 +1,43 @@
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);
4
- import { CommonControl as g } from "../../../common-control.js";
1
+ var g = Object.defineProperty;
2
+ var C = (d, c, t) => c in d ? g(d, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[c] = t;
3
+ var i = (d, c, t) => C(d, typeof c != "symbol" ? c + "" : c, t);
4
+ import { CommonControl as p } from "../../../common-control.js";
5
5
  import { DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
6
- import { RecommendationConfigService as h } from "../../services/configService.js";
6
+ import { RecommendationConfigService as m } 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 J } from "./algorithm.js";
9
+ import { ALGORITHM_CONTROL_ID as H } from "./algorithm.js";
10
10
  import { CurrencyControl as N } from "./currency.js";
11
- import { CURRENCY_CONTROL_ID as X } from "./currency.js";
12
- import { FiltersControl as _ } from "./filters.js";
13
- import { FILTERS_CONTROL_ID as tt } from "./filters.js";
14
- import { LayoutOrientationControl as b } from "./layoutOrientation.js";
15
- import { LAYOUT_ORIENTATION_CONTROL_ID as ot } from "./layoutOrientation.js";
16
- import { LocaleControl as O } from "./locale.js";
17
- import { LOCALE_CONTROL_ID as nt } from "./locale.js";
18
- import { ProductCountControl as I } from "./productCount.js";
19
- import { PRODUCT_COUNT_CONTROL_ID as st } from "./productCount.js";
20
- import { ProductLayoutControl as T } from "./productLayout.js";
21
- import { PRODUCT_LAYOUT_CONTROL_ID as lt } from "./productLayout.js";
11
+ import { CURRENCY_CONTROL_ID as K } from "./currency.js";
12
+ import { FiltersControl as b } from "./filters.js";
13
+ import { FILTERS_CONTROL_ID as J } from "./filters.js";
14
+ import { LocaleControl as _ } from "./locale.js";
15
+ import { LOCALE_CONTROL_ID as X } from "./locale.js";
16
+ import { ProductLayoutControl as I } from "./productLayout.js";
17
+ import { PRODUCT_LAYOUT_CONTROL_ID as tt } from "./productLayout.js";
22
18
  import { ShuffleControl as S } from "./shuffle.js";
23
- import { SHUFFLE_CONTROL_ID as ut } from "./shuffle.js";
24
- import { getBlockElement as L, updateProductContentInPlace as P, regenerateProductRowsWithStyles as D } from "./utils.js";
25
- import { adjustProductsToSize as ht, formatProductPrice as mt, getCardComposition as Ct, getCurrentLayout as ft, reapplySpacing as pt, regenerateMobileProductRows as gt, regenerateProductRows as yt, setCurrencyAttributes as Rt, updatePricesInPlace as Nt, updateSingleProductContent as _t } from "./utils.js";
26
- import { useDebounceFn as m } from "../../../../../node_modules/@vueuse/shared/index.js";
27
- const k = "recommendation-id", E = "ui-elements-recommendation-block";
28
- class H extends g {
19
+ import { SHUFFLE_CONTROL_ID as ot } from "./shuffle.js";
20
+ import { getBlockElement as P, updateProductContentInPlace as T, regenerateProductRowsWithStyles as L } from "./utils.js";
21
+ import { adjustProductsToSize as nt, formatProductPrice as st, getCardComposition as it, getCurrentLayout as at, reapplySpacing as ct, regenerateMobileProductRows as lt, regenerateProductRows as ut, setCurrencyAttributes as dt, updatePricesInPlace as mt, updateSingleProductContent as ht } from "./utils.js";
22
+ import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
23
+ const k = "recommendation-id", D = "ui-elements-recommendation-block";
24
+ class W extends p {
29
25
  constructor() {
30
26
  super(...arguments);
31
- s(this, "store", y());
32
- s(this, "storeUnsubscription", () => {
27
+ i(this, "store", y());
28
+ i(this, "storeUnsubscription", () => {
33
29
  });
34
30
  // Sub-control instances for lifecycle management
35
- s(this, "algorithmControl", null);
36
- s(this, "localeControl", null);
37
- s(this, "currencyControl", null);
38
- s(this, "productCountControl", null);
39
- s(this, "productLayoutControl", null);
40
- s(this, "filtersControl", null);
41
- s(this, "shuffleControl", null);
42
- s(this, "layoutOrientationControl", null);
31
+ i(this, "algorithmControl", null);
32
+ i(this, "localeControl", null);
33
+ i(this, "currencyControl", null);
34
+ i(this, "productLayoutControl", null);
35
+ i(this, "filtersControl", null);
36
+ i(this, "shuffleControl", null);
43
37
  /**
44
38
  * Debounced product fetch to prevent rapid API calls during config changes
45
39
  */
46
- s(this, "_debouncedFetchProducts", m(() => {
40
+ i(this, "_debouncedFetchProducts", h(() => {
47
41
  this.store.fetchRecommendationProducts();
48
42
  }, 500));
49
43
  /**
@@ -57,16 +51,16 @@ class H extends g {
57
51
  * count. The store pads products to the configured size, so in-place only
58
52
  * fails when the size actually changed.
59
53
  */
60
- s(this, "_debouncedRegenerateWithProducts", m(() => {
54
+ i(this, "_debouncedRegenerateWithProducts", h(() => {
61
55
  const t = this.store.recommendationProducts;
62
56
  if (!this.currentNode || !this.api)
63
57
  return;
64
58
  const e = this.api.getDocumentModifier();
65
- P({
59
+ T({
66
60
  currentNode: this.currentNode,
67
61
  documentModifier: e,
68
62
  products: t
69
- }) || D({
63
+ }) || L({
70
64
  currentNode: this.currentNode,
71
65
  documentModifier: e,
72
66
  products: t
@@ -74,29 +68,16 @@ class H extends g {
74
68
  }, 100));
75
69
  }
76
70
  getId() {
77
- return E;
71
+ return D;
78
72
  }
79
73
  getTemplate() {
80
- return this.algorithmControl = new R(), this.localeControl = new O(), this.currencyControl = new N(), this.productCountControl = new I(), this.productLayoutControl = new T(), this.filtersControl = new _(), this.shuffleControl = new S(), this.layoutOrientationControl = new b(), [
81
- this.algorithmControl,
82
- this.localeControl,
83
- this.currencyControl,
84
- this.productCountControl,
85
- this.productLayoutControl,
86
- this.filtersControl,
87
- this.shuffleControl,
88
- this.layoutOrientationControl
89
- ].forEach((e) => {
90
- e.api = this.api;
91
- }), `
74
+ return this.algorithmControl = new R(), this.localeControl = new _(), this.currencyControl = new N(), this.productLayoutControl = new I(), this.filtersControl = new b(), this.shuffleControl = new S(), `
92
75
  <div class="recommendation-controls-container">
93
- ${this.layoutOrientationControl.getTemplate()}
94
- ${this.productCountControl.getTemplate()}
95
- ${this.productLayoutControl.getTemplate()}
96
76
  ${this.algorithmControl.getTemplate()}
97
77
  ${this.localeControl.getTemplate()}
98
78
  ${this.currencyControl.getTemplate()}
99
79
  ${this.filtersControl.getTemplate()}
80
+ ${this.productLayoutControl.getTemplate()}
100
81
  ${this.shuffleControl.getTemplate()}
101
82
  </div>
102
83
  `;
@@ -115,8 +96,6 @@ class H extends g {
115
96
  super.onTemplateNodeUpdated(t);
116
97
  const e = this._getRecommendationIdFromNode(t);
117
98
  e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((r = this.store.blockStates[e]) != null && r.isInitialized) && this._fetchBlockData(e), [
118
- this.layoutOrientationControl,
119
- this.productCountControl,
120
99
  this.algorithmControl,
121
100
  this.localeControl,
122
101
  this.currencyControl,
@@ -124,14 +103,12 @@ class H extends g {
124
103
  this.filtersControl,
125
104
  this.shuffleControl
126
105
  ].forEach((n) => {
127
- var i;
128
- n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
106
+ var s;
107
+ n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
129
108
  });
130
109
  }
131
110
  onDestroy() {
132
111
  this.storeUnsubscription(), [
133
- this.layoutOrientationControl,
134
- this.productCountControl,
135
112
  this.algorithmControl,
136
113
  this.localeControl,
137
114
  this.currencyControl,
@@ -149,8 +126,6 @@ class H extends g {
149
126
  */
150
127
  _initializeSubControls() {
151
128
  [
152
- this.layoutOrientationControl,
153
- this.productCountControl,
154
129
  this.algorithmControl,
155
130
  this.localeControl,
156
131
  this.currencyControl,
@@ -175,7 +150,7 @@ class H extends g {
175
150
  */
176
151
  _syncNodeConfigToStore() {
177
152
  var r;
178
- const t = h.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
153
+ const t = m.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
179
154
  this.store.patchCurrentBlockConfig({
180
155
  strategy: t.strategy,
181
156
  language: t.language,
@@ -232,31 +207,31 @@ class H extends g {
232
207
  _applySmartDefaults() {
233
208
  if (!this.currentNode || !this.api)
234
209
  return;
235
- const t = h.getConfig(this.currentNode), e = {};
210
+ const t = m.getConfig(this.currentNode), e = {};
236
211
  let o = null, r = null, n = null;
237
212
  if (t.currency.code === a.currency.code) {
238
- const { currencyList: i } = this.store;
239
- i.length > 0 && (i.some(
213
+ const { currencyList: s } = this.store;
214
+ s.length > 0 && (s.some(
240
215
  (u) => u.value === `price.${a.currency.code}`
241
- ) || (o = i[0].value.replace("price.", ""), e.currency = {
216
+ ) || (o = s[0].value.replace("price.", ""), e.currency = {
242
217
  ...a.currency,
243
218
  code: o,
244
219
  symbol: o
245
220
  }));
246
221
  }
247
222
  if (t.strategy === a.strategy) {
248
- const i = this.store.getActivePredictiveAlgorithms;
249
- i.length > 0 && (i.some(
223
+ const s = this.store.getActivePredictiveAlgorithms;
224
+ s.length > 0 && (s.some(
250
225
  (u) => u.value === a.strategy
251
- ) || (r = i[0].value, e.strategy = r));
226
+ ) || (r = s[0].value, e.strategy = r));
252
227
  }
253
228
  if (t.language === a.language) {
254
- const i = this.store.getLanguages;
255
- i.length > 0 && (i.some(
229
+ const s = this.store.getLanguages;
230
+ s.length > 0 && (s.some(
256
231
  (u) => u.value === a.language
257
- ) || (n = i[0].value, e.language = n));
232
+ ) || (n = s[0].value, e.language = n));
258
233
  }
259
- !o && !r && !n || (h.updateConfig(
234
+ !o && !r && !n || (m.updateConfig(
260
235
  this.api,
261
236
  this.currentNode,
262
237
  e,
@@ -281,7 +256,7 @@ class H extends g {
281
256
  * Reads the recommendation-id attribute from the block element within the node
282
257
  */
283
258
  _getRecommendationIdFromNode(t) {
284
- const e = L(t);
259
+ const e = P(t);
285
260
  if (!e || !("getAttribute" in e))
286
261
  return null;
287
262
  const o = e.getAttribute(k);
@@ -312,10 +287,10 @@ class H extends g {
312
287
  r = n, e = t.recommendationProducts, o = t.$state.configVersion;
313
288
  return;
314
289
  }
315
- const i = t.$state.configVersion;
316
- i !== o && (o = i, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
317
- const c = t.recommendationProducts, u = c !== e, C = Array.isArray(c) && c.length > 0;
318
- u && C && (e = c, this._debouncedRegenerateWithProducts());
290
+ const s = t.$state.configVersion;
291
+ s !== o && (o = s, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
292
+ const l = t.recommendationProducts, u = l !== e, f = Array.isArray(l) && l.length > 0;
293
+ u && f && (e = l, this._debouncedRegenerateWithProducts());
319
294
  });
320
295
  }
321
296
  /**
@@ -326,7 +301,7 @@ class H extends g {
326
301
  if (!this.currentNode || !this.api)
327
302
  return;
328
303
  const { filters: t } = this.store.recommendationConfigs;
329
- h.updateConfig(
304
+ m.updateConfig(
330
305
  this.api,
331
306
  this.currentNode,
332
307
  { filters: t },
@@ -335,35 +310,31 @@ class H extends g {
335
310
  }
336
311
  }
337
312
  export {
338
- J as ALGORITHM_CONTROL_ID,
313
+ H as ALGORITHM_CONTROL_ID,
339
314
  R as AlgorithmControl,
340
- E as CONTROL_BLOCK_ID,
341
- X as CURRENCY_CONTROL_ID,
315
+ D as CONTROL_BLOCK_ID,
316
+ K as CURRENCY_CONTROL_ID,
342
317
  N as CurrencyControl,
343
- tt as FILTERS_CONTROL_ID,
344
- _ as FiltersControl,
345
- ot as LAYOUT_ORIENTATION_CONTROL_ID,
346
- nt as LOCALE_CONTROL_ID,
347
- b as LayoutOrientationControl,
348
- O as LocaleControl,
349
- st as PRODUCT_COUNT_CONTROL_ID,
350
- lt as PRODUCT_LAYOUT_CONTROL_ID,
351
- I as ProductCountControl,
352
- T as ProductLayoutControl,
353
- H as RecommendationBlockControl,
354
- ut as SHUFFLE_CONTROL_ID,
318
+ J as FILTERS_CONTROL_ID,
319
+ b as FiltersControl,
320
+ X as LOCALE_CONTROL_ID,
321
+ _ as LocaleControl,
322
+ tt as PRODUCT_LAYOUT_CONTROL_ID,
323
+ I as ProductLayoutControl,
324
+ W as RecommendationBlockControl,
325
+ ot as SHUFFLE_CONTROL_ID,
355
326
  S as ShuffleControl,
356
- ht as adjustProductsToSize,
357
- mt as formatProductPrice,
358
- L as getBlockElement,
359
- Ct as getCardComposition,
360
- ft as getCurrentLayout,
361
- pt as reapplySpacing,
362
- gt as regenerateMobileProductRows,
363
- yt as regenerateProductRows,
364
- D as regenerateProductRowsWithStyles,
365
- Rt as setCurrencyAttributes,
366
- Nt as updatePricesInPlace,
367
- P as updateProductContentInPlace,
368
- _t as updateSingleProductContent
327
+ nt as adjustProductsToSize,
328
+ st as formatProductPrice,
329
+ P as getBlockElement,
330
+ it as getCardComposition,
331
+ at as getCurrentLayout,
332
+ ct as reapplySpacing,
333
+ lt as regenerateMobileProductRows,
334
+ ut as regenerateProductRows,
335
+ L as regenerateProductRowsWithStyles,
336
+ dt as setCurrencyAttributes,
337
+ mt as updatePricesInPlace,
338
+ T as updateProductContentInPlace,
339
+ ht as updateSingleProductContent
369
340
  };
@@ -21,10 +21,10 @@ class E extends c {
21
21
  return `
22
22
  <div class="locale-control-container">
23
23
  ${this._GuTwoColumns([
24
- this._GuLabel({ text: this.api.translate("Recommendation Locale") }),
24
+ this._GuLabel({ text: "Recommendation Locale" }),
25
25
  this._GuSelect({
26
26
  name: n.LOCALE,
27
- placeholder: this.api.translate("Select Recommendation Locale"),
27
+ placeholder: "Select Recommendation Locale",
28
28
  options: this.store.getLanguages
29
29
  })
30
30
  ])}
@@ -1,80 +1,60 @@
1
- var I = Object.defineProperty;
2
- var E = (a, n, t) => n in a ? I(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
- var u = (a, n, t) => E(a, typeof n != "symbol" ? n + "" : n, t);
4
- import { EditorStatePropertyType as O, PreviewDeviceMode as f, UEAttr as N } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as T } from "../../../common-control.js";
6
- import { MAX_PRODUCTS_PER_ROW as p, MAX_MOBILE_PRODUCTS_PER_ROW as M, DEFAULT_MOBILE_CARDS_IN_ROW as L, DEFAULT_COLUMN_SPACING as P, DEFAULT_MOBILE_COLUMN_SPACING as y } from "../../constants/layout.js";
1
+ var u = Object.defineProperty;
2
+ var _ = (n, r, t) => r in n ? u(n, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[r] = t;
3
+ var a = (n, r, t) => _(n, typeof r != "symbol" ? r + "" : r, t);
4
+ import { EditorStatePropertyType as c, PreviewDeviceMode as C } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as R } from "../../../common-control.js";
6
+ import { MAX_PRODUCT_COUNT as h, MAX_PRODUCTS_PER_ROW as p, MAX_MOBILE_PRODUCTS_PER_ROW as g, DEFAULT_COLUMN_SPACING as m, DEFAULT_MOBILE_COLUMN_SPACING as O } from "../../constants/layout.js";
7
7
  import { RecommendationConfigService as i } from "../../services/configService.js";
8
- import { useRecommendationExtensionStore as D } from "../../store/recommendation.js";
9
- import { setMobileLayoutOptOut as m, ensureMobileCssRulesExist as C } from "../mobileLayout/cssRules.js";
10
- import { getCurrentLayout as w, getBlockElement as U, regenerateProductRowsWithStyles as b, regenerateMobileProductRows as g, adjustProductsToSize as A } from "./utils.js";
11
- import { useDebounceFn as B } from "../../../../../node_modules/@vueuse/shared/index.js";
12
- const S = "recommendation-product-layout-control", e = {
13
- // "Products in One Row" — shown when toggle is OFF
8
+ import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
9
+ import { ensureMobileCssRulesExist as I } from "../mobileLayout/cssRules.js";
10
+ import { getCurrentLayout as N, regenerateMobileProductRows as f, adjustProductsToSize as b, regenerateProductRowsWithStyles as P } from "./utils.js";
11
+ import { useDebounceFn as L } from "../../../../../node_modules/@vueuse/shared/index.js";
12
+ const M = "recommendation-product-layout-control", e = {
13
+ PRODUCT_COUNT: "size",
14
14
  PRODUCT_IN_ROW: "cardsInRow",
15
15
  PRODUCT_IN_ROW_LABEL: "cardsInRowLabel",
16
- // "Products in One Row on Desktop" — shown when toggle is ON + desktop preview
17
- PRODUCT_IN_ROW_DESKTOP: "cardsInRowDesktop",
18
- PRODUCT_IN_ROW_DESKTOP_LABEL: "cardsInRowDesktopLabel",
19
- // "Products in One Row on Mobile" — shown when toggle is ON + mobile preview
20
16
  MOBILE_CARDS_IN_ROW: "mobileCardsInRow",
21
- MOBILE_CARDS_IN_ROW_LABEL: "mobileCardsInRowLabel",
22
- // Toggle
23
- MOBILE_LAYOUT_TOGGLE: "mobileLayoutEnabled",
24
- MOBILE_LAYOUT_LABEL: "mobileLayoutLabel"
17
+ MOBILE_CARDS_IN_ROW_LABEL: "mobileCardsInRowLabel"
25
18
  };
26
- class v extends T {
19
+ class V extends R {
27
20
  constructor() {
28
21
  super(...arguments);
29
22
  // Store is used for backward compatibility with product fetching and regeneration
30
- u(this, "store", D());
31
- u(this, "storeUnsubscription", () => {
23
+ a(this, "store", l());
24
+ a(this, "storeUnsubscription", () => {
32
25
  });
33
- u(this, "_debouncedRegenerateProductRows", B(() => {
26
+ a(this, "_debouncedRegenerateProductRows", L(() => {
34
27
  this._regenerateProductRows();
35
28
  }, 500));
36
29
  }
37
30
  getId() {
38
- return S;
31
+ return M;
39
32
  }
40
33
  getTemplate() {
41
34
  return `
42
- <div class="product-layout-control-container" data-product-layout-control>
35
+ <div class="product-layout-control-container">
43
36
  ${this._GuTwoColumns([
37
+ this._GuLabel({ text: "Number of Products" }),
38
+ this._GuCounter({ name: e.PRODUCT_COUNT, maxValue: h }),
44
39
  this._GuLabel({
45
- text: this.api.translate("Products in One Row"),
40
+ text: "Products in One Row on Desktop",
46
41
  name: e.PRODUCT_IN_ROW_LABEL
47
42
  }),
48
43
  this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: p }),
49
44
  this._GuLabel({
50
- text: this.api.translate("Products in One Row on Desktop"),
51
- name: e.PRODUCT_IN_ROW_DESKTOP_LABEL
52
- }),
53
- this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue: p }),
54
- this._GuLabel({
55
- text: this.api.translate("Products in One Row on Mobile"),
45
+ text: "Products in One Row on Mobile",
56
46
  name: e.MOBILE_CARDS_IN_ROW_LABEL
57
47
  }),
58
48
  this._GuCounter({
59
49
  name: e.MOBILE_CARDS_IN_ROW,
60
- maxValue: M
61
- }),
62
- this._GuLabel({
63
- text: this.api.translate("Mobile Layout Optimization"),
64
- name: e.MOBILE_LAYOUT_LABEL,
65
- hint: this.api.translate(
66
- `Mobile Layout Optimization lets you display up to 2 products in one row.
67
- Note that enabling Mobile Layout Optimization increases the size of
68
- your recommendation block.`
69
- )
70
- }),
71
- this._GuToggle(e.MOBILE_LAYOUT_TOGGLE)
50
+ maxValue: g
51
+ })
72
52
  ])}
73
53
  </div>
74
54
  `;
75
55
  }
76
56
  onRender() {
77
- this._initializeMobileLayoutToggle(), this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates(), this._listenEditorModeChanges();
57
+ this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates(), this._subscribeToEditorModeChanges();
78
58
  }
79
59
  onTemplateNodeUpdated(t) {
80
60
  super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
@@ -85,104 +65,53 @@ class v extends T {
85
65
  _setFormValues() {
86
66
  const t = i.getConfig(this.currentNode);
87
67
  this.api.updateValues({
68
+ [e.PRODUCT_COUNT]: t.size,
88
69
  [e.PRODUCT_IN_ROW]: t.cardsInRow,
89
- [e.PRODUCT_IN_ROW_DESKTOP]: t.cardsInRow,
90
- [e.MOBILE_LAYOUT_TOGGLE]: t.mobileLayoutEnabled,
91
70
  [e.MOBILE_CARDS_IN_ROW]: t.mobileCardsInRow
92
71
  });
93
72
  }
94
73
  /**
95
- * Returns true when the editor preview is in mobile mode.
74
+ * Checks if the editor is currently in mobile preview mode
75
+ * using Stripo's EditorStatePropertyType API.
96
76
  */
97
- _isMobilePreview() {
98
- return this.api.getEditorState()[O.previewDeviceMode] === f.MOBILE;
77
+ _isMobileMode() {
78
+ return this.api.getEditorState()[c.previewDeviceMode] === C.MOBILE;
99
79
  }
100
80
  /**
101
- * Updates counter visibility based on layout, mobileLayoutEnabled, and editor preview mode.
102
- *
103
- * Three mutually exclusive rows exist in the template:
104
- * 1. "Products in One Row" — generic, shown when toggle is OFF
105
- * 2. "Products in One Row on Desktop" — shown when toggle is ON + desktop preview
106
- * 3. "Products in One Row on Mobile" — shown when toggle is ON + mobile preview
107
- *
108
- * Only one row is visible at a time. This avoids setUIEAttribute on hidden
109
- * elements, which Stripo does not apply reliably.
81
+ * Updates counter visibility based on layout orientation and editor mode.
82
+ * - List layout: hide both counters (products always full-width)
83
+ * - Grid + desktop mode: show desktop counter, hide mobile counter
84
+ * - Grid + mobile mode: show mobile counter, hide desktop counter
110
85
  */
111
86
  _updateProductsInRowVisibility() {
112
- var R;
113
- const t = i.getConfig(this.currentNode), o = (t.layout || w(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, d = this._isMobilePreview();
114
- this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE, o), this.api.setVisibility(e.MOBILE_LAYOUT_LABEL, o);
115
- const c = o && !r, _ = o && r && !d, l = o && r && d;
116
- this.api.setVisibility(e.PRODUCT_IN_ROW, c), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, c), 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, l), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, l);
117
- const h = (R = this.getContainer()) == null ? void 0 : R.querySelector("[data-product-layout-control]");
118
- h && (h.style.display = o ? "" : "none");
87
+ const o = (i.getConfig(this.currentNode).layout || N(this.currentNode)) === "grid", d = this._isMobileMode();
88
+ this.api.setVisibility(e.PRODUCT_IN_ROW, o && !d), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, o && !d), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, o && d), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, o && d);
119
89
  }
120
90
  /**
121
- * Initializes the mobile layout toggle using the same pattern as shuffle.ts.
122
- * Sets the initial UI attribute value from the node config.
91
+ * Subscribes to editor preview mode changes via Stripo API.
92
+ * When the user switches between desktop/mobile preview, toggles
93
+ * which "Products in One Row" counter is visible.
123
94
  */
124
- _initializeMobileLayoutToggle() {
125
- const t = i.getConfig(this.currentNode);
126
- this.api.setUIEAttribute(
127
- e.MOBILE_LAYOUT_TOGGLE,
128
- N.SELECTPICKER.items,
129
- t.mobileLayoutEnabled
95
+ _subscribeToEditorModeChanges() {
96
+ this.api.onEditorStatePropUpdated(
97
+ c.previewDeviceMode,
98
+ () => {
99
+ this._updateProductsInRowVisibility();
100
+ }
130
101
  );
131
102
  }
132
- /**
133
- * Handles mobile layout toggle change.
134
- * When enabled: opts in to mobile layout, restores previous mobileCardsInRow.
135
- * When disabled: snapshots current mobileCardsInRow, resets to 1, opts out.
136
- */
137
- _onMobileLayoutToggleChange(t) {
138
- if (!this.currentNode)
139
- return;
140
- const s = i.getConfig(this.currentNode);
141
- if (s.mobileLayoutEnabled === t)
142
- return;
143
- const o = U(this.currentNode);
144
- if (t) {
145
- const r = s.previousMobileCardsInRow || L;
146
- i.updateConfig(
147
- this.api,
148
- this.currentNode,
149
- {
150
- mobileLayoutEnabled: !0,
151
- mobileCardsInRow: r
152
- },
153
- "Enabled mobile layout optimization"
154
- ), this.store.patchCurrentBlockConfig(
155
- { mobileLayoutEnabled: !0 },
156
- { triggerRefetch: !1 }
157
- ), o && m(this.api, o, !1), C(this.api), b({
158
- currentNode: this.currentNode,
159
- documentModifier: this.api.getDocumentModifier()
160
- });
161
- } else {
162
- const r = s.mobileCardsInRow;
163
- i.updateConfig(
164
- this.api,
165
- this.currentNode,
166
- {
167
- mobileLayoutEnabled: !1,
168
- previousMobileCardsInRow: r,
169
- mobileCardsInRow: L
170
- },
171
- "Disabled mobile layout optimization"
172
- ), this.store.patchCurrentBlockConfig(
173
- { mobileLayoutEnabled: !1 },
174
- { triggerRefetch: !1 }
175
- ), o && m(this.api, o, !0), g({
176
- currentNode: this.currentNode,
177
- documentModifier: this.api.getDocumentModifier()
178
- });
179
- }
180
- this._setFormValues(), this._updateProductsInRowVisibility();
103
+ _onProductCountChange(t) {
104
+ !this.currentNode || i.getConfig(this.currentNode).size === t || (i.updateConfig(
105
+ this.api,
106
+ this.currentNode,
107
+ { size: t },
108
+ `Changed product count to ${t}`
109
+ ), this.store.patchCurrentBlockConfig({ size: t }));
181
110
  }
182
111
  _onProductsInRowChange(t) {
183
112
  if (!this.currentNode || i.getConfig(this.currentNode).cardsInRow === t)
184
113
  return;
185
- const o = t === 1 ? 0 : P;
114
+ const o = t === 1 ? 0 : m;
186
115
  i.updateConfig(
187
116
  this.api,
188
117
  this.currentNode,
@@ -193,39 +122,37 @@ class v extends T {
193
122
  _onMobileCardsInRowChange(t) {
194
123
  if (!this.currentNode || i.getConfig(this.currentNode).mobileCardsInRow === t)
195
124
  return;
196
- const o = t === 1 ? 0 : y;
125
+ const o = t === 1 ? 0 : O;
197
126
  i.updateConfig(
198
127
  this.api,
199
128
  this.currentNode,
200
129
  { mobileCardsInRow: t, mobileColumnSpacing: o },
201
130
  `Changed mobile products per row to ${t}`
202
- ), C(this.api), g({
131
+ ), I(this.api), f({
203
132
  currentNode: this.currentNode,
204
133
  documentModifier: this.api.getDocumentModifier()
205
134
  });
206
135
  }
207
136
  _regenerateProductRows() {
208
- const t = i.getConfig(this.currentNode), s = parseInt(t.size) || 6, o = A(this.store.recommendationProducts, s);
209
- b({
137
+ const t = i.getConfig(this.currentNode), s = parseInt(t.size) || 6, o = b(this.store.recommendationProducts, s);
138
+ P({
210
139
  currentNode: this.currentNode,
211
140
  documentModifier: this.api.getDocumentModifier(),
212
141
  products: o
213
142
  });
214
143
  }
215
144
  _listenToFormUpdates() {
216
- this.api.onValueChanged(e.PRODUCT_IN_ROW, (t) => {
145
+ this.api.onValueChanged(e.PRODUCT_COUNT, (t) => {
146
+ this._onProductCountChange(t.toString());
147
+ }), this.api.onValueChanged(e.PRODUCT_IN_ROW, (t) => {
217
148
  this._onProductsInRowChange(Number(t));
218
- }), this.api.onValueChanged(e.PRODUCT_IN_ROW_DESKTOP, (t) => {
219
- this._onProductsInRowChange(Number(t));
220
- }), this.api.onValueChanged(e.MOBILE_LAYOUT_TOGGLE, (t) => {
221
- this._onMobileLayoutToggleChange(!!t);
222
149
  }), this.api.onValueChanged(e.MOBILE_CARDS_IN_ROW, (t) => {
223
150
  this._onMobileCardsInRowChange(Number(t));
224
151
  });
225
152
  }
226
153
  /**
227
154
  * Subscribe to store changes to update visibility when layout changes
228
- * This is still needed because layout changes come from LayoutOrientationControl
155
+ * This is still needed because layout changes come from LayoutControl
229
156
  */
230
157
  _listenStateUpdates() {
231
158
  let t = this.store.recommendationConfigs.orientation;
@@ -234,21 +161,8 @@ class v extends T {
234
161
  s !== t && (t = s, this._updateProductsInRowVisibility());
235
162
  });
236
163
  }
237
- /**
238
- * Subscribe to editor preview mode changes (desktop ↔ mobile).
239
- * When the user switches preview mode and mobile layout is enabled,
240
- * we swap which "Products in One Row" counter is visible.
241
- */
242
- _listenEditorModeChanges() {
243
- this.api.onEditorStatePropUpdated(
244
- O.previewDeviceMode,
245
- () => {
246
- i.getConfig(this.currentNode).mobileLayoutEnabled && this._updateProductsInRowVisibility();
247
- }
248
- );
249
- }
250
164
  }
251
165
  export {
252
- S as PRODUCT_LAYOUT_CONTROL_ID,
253
- v as ProductLayoutControl
166
+ M as PRODUCT_LAYOUT_CONTROL_ID,
167
+ V as ProductLayoutControl
254
168
  };
@@ -19,9 +19,9 @@ class S extends l {
19
19
  }
20
20
  getTemplate() {
21
21
  return `
22
- <div class="shuffle-control-container" style="border-bottom: 1px solid #e0e0e0;">
22
+ <div class="shuffle-control-container">
23
23
  ${this._GuTwoColumns([
24
- this._GuLabel({ text: this.api.translate("Shuffle Recommended Products") }),
24
+ this._GuLabel({ text: "Shuffle Recommended Products" }),
25
25
  this._GuToggle(i.SHUFFLE_PRODUCTS)
26
26
  ])}
27
27
  </div>