@useinsider/guido 3.20.1-beta.2c8da49 → 3.20.1-beta.2d09f29

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 (72) hide show
  1. package/dist/composables/useActionsApi.js +64 -80
  2. package/dist/composables/useFullStoryBridge.js +10 -9
  3. package/dist/composables/useGuidoStateBridge.js +3 -3
  4. package/dist/composables/useLegacyStrategyConversion.js +16 -16
  5. package/dist/composables/useStripo.js +10 -11
  6. package/dist/config/migrator/fullStoryScriptMigrator.js +5 -0
  7. package/dist/config/migrator/index.js +11 -10
  8. package/dist/extensions/Blocks/Items/block.js +42 -43
  9. package/dist/extensions/Blocks/Recommendation/block.js +29 -33
  10. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +83 -78
  11. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +2 -1
  12. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +12 -2
  13. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +86 -104
  14. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +263 -348
  15. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +50 -48
  16. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +21 -16
  17. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +40 -44
  18. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +19 -14
  19. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +102 -104
  20. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +23 -18
  21. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +286 -312
  22. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +20 -24
  23. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +7 -6
  24. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +8 -8
  25. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +151 -113
  26. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +205 -219
  27. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +1 -1
  28. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +40 -111
  29. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +35 -31
  30. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +192 -271
  31. package/dist/package.json.js +1 -1
  32. package/dist/src/composables/useActionsApi.d.ts +1 -5
  33. package/dist/src/config/migrator/fullStoryScriptMigrator.d.ts +1 -0
  34. package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +0 -1
  35. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +0 -8
  36. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +0 -40
  37. package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +0 -1
  38. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
  39. package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +0 -1
  40. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +0 -11
  41. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +6 -3
  42. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +0 -7
  43. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +0 -2
  44. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +5 -5
  45. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +12 -21
  46. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +3 -6
  47. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +5 -6
  48. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +3 -6
  49. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -21
  50. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +13 -19
  51. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +0 -7
  52. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +0 -7
  53. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +0 -7
  54. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +0 -7
  55. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +0 -7
  56. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +8 -10
  57. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +5 -9
  58. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +0 -7
  59. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -8
  60. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +11 -18
  61. package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +0 -1
  62. package/dist/src/extensions/Blocks/controlFactories.d.ts +0 -22
  63. package/dist/src/stores/editor.d.ts +1 -3
  64. package/dist/src/utils/fullStoryScripts.d.ts +6 -0
  65. package/dist/static/styles/components/button.css.js +0 -5
  66. package/dist/stores/editor.js +0 -5
  67. package/dist/utils/fullStoryScripts.js +8 -0
  68. package/package.json +3 -3
  69. package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +0 -28
  70. package/dist/extensions/Blocks/Recommendation/utils/currencySettings.js +0 -25
  71. package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +0 -17
  72. package/dist/src/extensions/Blocks/Recommendation/utils/currencySettings.d.ts +0 -6
@@ -1,14 +1,15 @@
1
1
  var f = Object.defineProperty;
2
- var T = (c, a, t) => a in c ? f(c, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[a] = t;
3
- var h = (c, a, t) => T(c, typeof a != "symbol" ? a + "" : a, t);
4
- import { UEAttr as _, EditorStatePropertyType as g, PreviewDeviceMode as y, ModificationDescription as O } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as N } from "../../../common-control.js";
2
+ var T = (a, n, t) => n in a ? f(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
+ var l = (a, n, t) => T(a, typeof n != "symbol" ? n + "" : n, t);
4
+ import { UEAttr as d, EditorStatePropertyType as b, PreviewDeviceMode as N } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as P } from "../../../common-control.js";
6
6
  import "../../constants/selectors.js";
7
- import { MAX_PRODUCTS_PER_ROW as b, MAX_MOBILE_PRODUCTS_PER_ROW as M, DEFAULT_MOBILE_CARDS_IN_ROW as R } from "../../constants/layout.js";
8
- import { RecommendationConfigService as r } from "../../services/configService.js";
9
- import { useRecommendationExtensionStore as P } from "../../store/recommendation.js";
10
- import { ensureMobileCssRulesExist as C, stageMobileLayoutOptOut as D } from "../mobileLayout/cssRules.js";
11
- import { isPartnerManagedBlock as w, getCurrentLayout as U, adjustProductsToSize as L, regenerateProductRowsWithStyles as I, regenerateMobileProductRows as E, getBlockElement as A } from "./utils.js";
7
+ import { MAX_PRODUCTS_PER_ROW as C, MAX_MOBILE_PRODUCTS_PER_ROW as D, DEFAULT_MOBILE_CARDS_IN_ROW as _ } from "../../constants/layout.js";
8
+ import { RecommendationConfigService as s } from "../../services/configService.js";
9
+ import { useRecommendationExtensionStore as M } from "../../store/recommendation.js";
10
+ import { setMobileLayoutOptOut as m, ensureMobileCssRulesExist as L } from "../mobileLayout/cssRules.js";
11
+ import { isPartnerManagedBlock as y, getCurrentLayout as w, getBlockElement as U, adjustProductsToSize as I, regenerateProductRowsWithStyles as g, regenerateMobileProductRows as E } from "./utils.js";
12
+ import { useDebounceFn as A } from "../../../../../node_modules/@vueuse/shared/index.js";
12
13
  const B = "recommendation-product-layout-control", e = {
13
14
  // "Products in One Row" — shown when toggle is OFF
14
15
  PRODUCT_IN_ROW: "cardsInRow",
@@ -23,13 +24,16 @@ const B = "recommendation-product-layout-control", e = {
23
24
  MOBILE_LAYOUT_TOGGLE: "mobileLayoutEnabled",
24
25
  MOBILE_LAYOUT_LABEL: "mobileLayoutLabel"
25
26
  };
26
- class K extends N {
27
+ class F extends P {
27
28
  constructor() {
28
29
  super(...arguments);
29
30
  // Store is used for backward compatibility with product fetching and regeneration
30
- h(this, "store", P());
31
- h(this, "storeUnsubscription", () => {
31
+ l(this, "store", M());
32
+ l(this, "storeUnsubscription", () => {
32
33
  });
34
+ l(this, "_debouncedRegenerateProductRows", A(() => {
35
+ this._regenerateProductRows();
36
+ }, 500));
33
37
  }
34
38
  getId() {
35
39
  return B;
@@ -42,19 +46,19 @@ class K extends N {
42
46
  text: this.api.translate("Products in One Row"),
43
47
  name: e.PRODUCT_IN_ROW_LABEL
44
48
  }),
45
- this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: b }),
49
+ this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: C }),
46
50
  this._GuLabel({
47
51
  text: this.api.translate("Products in One Row on Desktop"),
48
52
  name: e.PRODUCT_IN_ROW_DESKTOP_LABEL
49
53
  }),
50
- this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue: b }),
54
+ this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue: C }),
51
55
  this._GuLabel({
52
56
  text: this.api.translate("Products in One Row on Mobile"),
53
57
  name: e.MOBILE_CARDS_IN_ROW_LABEL
54
58
  }),
55
59
  this._GuCounter({
56
60
  name: e.MOBILE_CARDS_IN_ROW,
57
- maxValue: M
61
+ maxValue: D
58
62
  }),
59
63
  this._GuLabel({
60
64
  text: this.api.translate("Mobile Layout Optimization"),
@@ -82,14 +86,14 @@ class K extends N {
82
86
  * these inputs there. Disabling coexists with the visibility logic above.
83
87
  */
84
88
  _syncDisabledState() {
85
- const t = w(this.currentNode);
86
- this.api.setUIEAttribute(e.PRODUCT_IN_ROW, _.COUNTER.disabled, t), this.api.setUIEAttribute(e.PRODUCT_IN_ROW_DESKTOP, _.COUNTER.disabled, t), this.api.setUIEAttribute(e.MOBILE_CARDS_IN_ROW, _.COUNTER.disabled, t), this.api.setUIEAttribute(e.MOBILE_LAYOUT_TOGGLE, _.SWITCHER.disabled, t);
89
+ const t = y(this.currentNode);
90
+ this.api.setUIEAttribute(e.PRODUCT_IN_ROW, d.COUNTER.disabled, t), this.api.setUIEAttribute(e.PRODUCT_IN_ROW_DESKTOP, d.COUNTER.disabled, t), this.api.setUIEAttribute(e.MOBILE_CARDS_IN_ROW, d.COUNTER.disabled, t), this.api.setUIEAttribute(e.MOBILE_LAYOUT_TOGGLE, d.SWITCHER.disabled, t);
87
91
  }
88
92
  onDestroy() {
89
93
  this.storeUnsubscription();
90
94
  }
91
95
  _setFormValues() {
92
- const t = r.getConfig(this.currentNode);
96
+ const t = s.getConfig(this.currentNode);
93
97
  this.api.updateValues({
94
98
  [e.PRODUCT_IN_ROW]: t.cardsInRow,
95
99
  [e.PRODUCT_IN_ROW_DESKTOP]: t.cardsInRow,
@@ -101,7 +105,7 @@ class K extends N {
101
105
  * Returns true when the editor preview is in mobile mode.
102
106
  */
103
107
  _isMobilePreview() {
104
- return this.api.getEditorState()[g.previewDeviceMode] === y.MOBILE;
108
+ return this.api.getEditorState()[b.previewDeviceMode] === N.MOBILE;
105
109
  }
106
110
  /**
107
111
  * Updates counter visibility based on layout, mobileLayoutEnabled, and editor preview mode.
@@ -116,22 +120,22 @@ class K extends N {
116
120
  */
117
121
  _updateProductsInRowVisibility() {
118
122
  var p;
119
- const t = r.getConfig(this.currentNode), i = (t.layout || U(this.currentNode)) === "grid", { mobileLayoutEnabled: o } = t, n = this._isMobilePreview();
123
+ const t = s.getConfig(this.currentNode), i = (t.layout || w(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, u = this._isMobilePreview();
120
124
  this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE, i), this.api.setVisibility(e.MOBILE_LAYOUT_LABEL, i);
121
- const d = i && !o, l = i && o && !n, u = i && o && n;
122
- 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, l), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP_LABEL, l), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, u), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, u);
123
- const m = (p = this.getContainer()) == null ? void 0 : p.querySelector("[data-product-layout-control]");
124
- m && (m.style.display = i ? "" : "none");
125
+ const c = i && !r, h = i && r && !u, R = i && r && u;
126
+ 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, h), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP_LABEL, h), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, R), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, R);
127
+ const O = (p = this.getContainer()) == null ? void 0 : p.querySelector("[data-product-layout-control]");
128
+ O && (O.style.display = i ? "" : "none");
125
129
  }
126
130
  /**
127
131
  * Initializes the mobile layout toggle using the same pattern as shuffle.ts.
128
132
  * Sets the initial UI attribute value from the node config.
129
133
  */
130
134
  _initializeMobileLayoutToggle() {
131
- const t = r.getConfig(this.currentNode);
135
+ const t = s.getConfig(this.currentNode);
132
136
  this.api.setUIEAttribute(
133
137
  e.MOBILE_LAYOUT_TOGGLE,
134
- _.SELECTPICKER.items,
138
+ d.SELECTPICKER.items,
135
139
  t.mobileLayoutEnabled
136
140
  );
137
141
  }
@@ -143,91 +147,85 @@ class K extends N {
143
147
  _onMobileLayoutToggleChange(t) {
144
148
  if (!this.currentNode)
145
149
  return;
146
- const s = r.getConfig(this.currentNode);
147
- if (s.mobileLayoutEnabled !== t) {
148
- if (t) {
149
- const o = { mobileLayoutEnabled: !0, mobileCardsInRow: s.previousMobileCardsInRow || R }, n = parseInt(s.size) || 6, d = L(this.store.recommendationProducts, n);
150
- this._commitMobileLayoutToggle(
151
- o,
152
- !1,
153
- "Enabled mobile layout optimization",
154
- (u) => {
155
- C(this.api, u), I({
156
- currentNode: this.currentNode,
157
- documentModifier: u,
158
- products: d,
159
- configOverrides: o,
160
- stageOnly: !0
161
- });
162
- }
163
- ) && this.store.patchCurrentBlockConfig(o, { triggerRefetch: !1 });
164
- } else {
165
- const i = {
150
+ const o = s.getConfig(this.currentNode);
151
+ if (o.mobileLayoutEnabled === t)
152
+ return;
153
+ const i = U(this.currentNode);
154
+ if (t) {
155
+ const r = o.previousMobileCardsInRow || _;
156
+ s.updateConfig(
157
+ this.api,
158
+ this.currentNode,
159
+ {
160
+ mobileLayoutEnabled: !0,
161
+ mobileCardsInRow: r
162
+ },
163
+ "Enabled mobile layout optimization"
164
+ ), this.store.patchCurrentBlockConfig(
165
+ {
166
+ mobileLayoutEnabled: !0,
167
+ mobileCardsInRow: r
168
+ },
169
+ { triggerRefetch: !1 }
170
+ ), i && m(this.api, i, !1), L(this.api);
171
+ const u = parseInt(o.size) || 6, c = I(this.store.recommendationProducts, u);
172
+ g({
173
+ currentNode: this.currentNode,
174
+ documentModifier: this.api.getDocumentModifier(),
175
+ products: c
176
+ });
177
+ } else {
178
+ const r = o.mobileCardsInRow;
179
+ s.updateConfig(
180
+ this.api,
181
+ this.currentNode,
182
+ {
166
183
  mobileLayoutEnabled: !1,
167
- // Snapshot current mobile cards value before resetting
168
- previousMobileCardsInRow: s.mobileCardsInRow,
169
- mobileCardsInRow: R
170
- };
171
- this._commitMobileLayoutToggle(
172
- i,
173
- !0,
174
- "Disabled mobile layout optimization",
175
- (n) => {
176
- E({
177
- currentNode: this.currentNode,
178
- documentModifier: n,
179
- configOverrides: i,
180
- stageOnly: !0
181
- });
182
- }
183
- ) && this.store.patchCurrentBlockConfig(
184
- { mobileLayoutEnabled: !1, mobileCardsInRow: R },
185
- { triggerRefetch: !1 }
186
- );
187
- }
188
- this._setFormValues(), this._updateProductsInRowVisibility();
189
- }
190
- }
191
- // One apply: a config/class mismatch between two applies makes the block's self-heal write its own entry.
192
- // Reports false when nothing reached the node, so the caller keeps the store aligned with it.
193
- _commitMobileLayoutToggle(t, s, i, o) {
194
- if (!this.currentNode)
195
- return !1;
196
- const n = this.api.getDocumentModifier(), d = A(this.currentNode);
197
- try {
198
- return r.stageConfig(n, this.currentNode, t), d && D(n, d, s), o(n), n.apply(new O(i)), !0;
199
- } catch (l) {
200
- return console.warn("[recommendation] mobile layout toggle write failed", l), !1;
184
+ previousMobileCardsInRow: r,
185
+ mobileCardsInRow: _
186
+ },
187
+ "Disabled mobile layout optimization"
188
+ ), this.store.patchCurrentBlockConfig(
189
+ {
190
+ mobileLayoutEnabled: !1,
191
+ mobileCardsInRow: _
192
+ },
193
+ { triggerRefetch: !1 }
194
+ ), i && m(this.api, i, !0), E({
195
+ currentNode: this.currentNode,
196
+ documentModifier: this.api.getDocumentModifier()
197
+ });
201
198
  }
199
+ this._setFormValues(), this._updateProductsInRowVisibility();
202
200
  }
203
201
  _onProductsInRowChange(t) {
204
- if (!this.currentNode || r.getConfig(this.currentNode).cardsInRow === t)
205
- return;
206
- const i = { cardsInRow: t }, o = this.api.getDocumentModifier();
207
- r.stageConfig(o, this.currentNode, i), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._regenerateProductRows(o, i), o.apply(new O(`Changed products per row to ${t}`));
202
+ !this.currentNode || s.getConfig(this.currentNode).cardsInRow === t || (s.updateConfig(
203
+ this.api,
204
+ this.currentNode,
205
+ { cardsInRow: t },
206
+ `Changed products per row to ${t}`
207
+ ), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows());
208
208
  }
209
209
  _onMobileCardsInRowChange(t) {
210
- if (!this.currentNode || r.getConfig(this.currentNode).mobileCardsInRow === t)
211
- return;
212
- const i = { mobileCardsInRow: t }, o = this.api.getDocumentModifier();
213
- r.stageConfig(o, this.currentNode, i), C(this.api, o), this.store.patchCurrentBlockConfig(
210
+ !this.currentNode || s.getConfig(this.currentNode).mobileCardsInRow === t || (s.updateConfig(
211
+ this.api,
212
+ this.currentNode,
213
+ { mobileCardsInRow: t },
214
+ `Changed mobile products per row to ${t}`
215
+ ), L(this.api), this.store.patchCurrentBlockConfig(
214
216
  { mobileCardsInRow: t },
215
217
  { triggerRefetch: !1 }
216
218
  ), E({
217
219
  currentNode: this.currentNode,
218
- documentModifier: o,
219
- configOverrides: i,
220
- stageOnly: !0
221
- }), o.apply(new O(`Changed mobile products per row to ${t}`));
220
+ documentModifier: this.api.getDocumentModifier()
221
+ }));
222
222
  }
223
- _regenerateProductRows(t, s) {
224
- const i = r.getConfig(this.currentNode), o = parseInt(i.size) || 6, n = L(this.store.recommendationProducts, o);
225
- I({
223
+ _regenerateProductRows() {
224
+ const t = s.getConfig(this.currentNode), o = parseInt(t.size) || 6, i = I(this.store.recommendationProducts, o);
225
+ g({
226
226
  currentNode: this.currentNode,
227
- documentModifier: t,
228
- products: n,
229
- configOverrides: s,
230
- stageOnly: !0
227
+ documentModifier: this.api.getDocumentModifier(),
228
+ products: i
231
229
  });
232
230
  }
233
231
  _listenToFormUpdates() {
@@ -248,8 +246,8 @@ class K extends N {
248
246
  _listenStateUpdates() {
249
247
  let t = this.store.recommendationConfigs.orientation;
250
248
  this.storeUnsubscription = this.store.$subscribe(() => {
251
- const s = this.store.recommendationConfigs.orientation;
252
- s !== t && (t = s, this._updateProductsInRowVisibility());
249
+ const o = this.store.recommendationConfigs.orientation;
250
+ o !== t && (t = o, this._updateProductsInRowVisibility());
253
251
  });
254
252
  }
255
253
  /**
@@ -259,14 +257,14 @@ class K extends N {
259
257
  */
260
258
  _listenEditorModeChanges() {
261
259
  this.api.onEditorStatePropUpdated(
262
- g.previewDeviceMode,
260
+ b.previewDeviceMode,
263
261
  () => {
264
- r.getConfig(this.currentNode).mobileLayoutEnabled && this._updateProductsInRowVisibility();
262
+ s.getConfig(this.currentNode).mobileLayoutEnabled && this._updateProductsInRowVisibility();
265
263
  }
266
264
  );
267
265
  }
268
266
  }
269
267
  export {
270
268
  B as PRODUCT_LAYOUT_CONTROL_ID,
271
- K as ProductLayoutControl
269
+ F as ProductLayoutControl
272
270
  };
@@ -1,28 +1,28 @@
1
1
  var r = Object.defineProperty;
2
- var l = (o, t, e) => t in o ? r(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var i = (o, t, e) => l(o, typeof t != "symbol" ? t + "" : t, e);
2
+ var f = (o, t, e) => t in o ? r(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var n = (o, t, e) => f(o, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { UEAttr as u } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as f } from "../../../common-control.js";
6
- import { RecommendationConfigService as n } from "../../services/configService.js";
7
- import { useRecommendationExtensionStore as a } from "../../store/recommendation.js";
8
- const d = "recommendation-shuffle-control", s = {
5
+ import { CommonControl as l } from "../../../common-control.js";
6
+ import { RecommendationConfigService as s } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
8
+ const h = "recommendation-shuffle-control", i = {
9
9
  SHUFFLE_PRODUCTS: "shuffleProducts"
10
10
  };
11
- class p extends f {
11
+ class S extends l {
12
12
  constructor() {
13
13
  super(...arguments);
14
14
  // Store is used for backward compatibility with product fetching
15
- i(this, "store", a());
15
+ n(this, "store", d());
16
16
  }
17
17
  getId() {
18
- return d;
18
+ return h;
19
19
  }
20
20
  getTemplate() {
21
21
  return `
22
22
  <div class="shuffle-control-container" style="border-bottom: 1px solid #e0e0e0;">
23
23
  ${this._GuTwoColumns([
24
24
  this._GuLabel({ text: this.api.translate("Shuffle Recommended Products") }),
25
- this._GuToggle(s.SHUFFLE_PRODUCTS)
25
+ this._GuToggle(i.SHUFFLE_PRODUCTS)
26
26
  ])}
27
27
  </div>
28
28
  `;
@@ -34,29 +34,34 @@ class p extends f {
34
34
  super.onTemplateNodeUpdated(e), this._setFormValues();
35
35
  }
36
36
  _setFormValues() {
37
- const e = n.getConfig(this.currentNode);
37
+ const e = s.getConfig(this.currentNode);
38
38
  this.api.updateValues({
39
- [s.SHUFFLE_PRODUCTS]: e.shuffleProducts
39
+ [i.SHUFFLE_PRODUCTS]: e.shuffleProducts
40
40
  });
41
41
  }
42
42
  _initializeToggle() {
43
- const e = n.getConfig(this.currentNode);
43
+ const e = s.getConfig(this.currentNode);
44
44
  this.api.setUIEAttribute(
45
- s.SHUFFLE_PRODUCTS,
45
+ i.SHUFFLE_PRODUCTS,
46
46
  u.SELECTPICKER.items,
47
47
  e.shuffleProducts
48
48
  );
49
49
  }
50
50
  _onShuffleChange(e) {
51
- this.currentNode && this.store.recommendationConfigs.shuffleProducts !== e && this.store.patchCurrentBlockConfig({ shuffleProducts: e });
51
+ !this.currentNode || s.getConfig(this.currentNode).shuffleProducts === e || (s.updateConfig(
52
+ this.api,
53
+ this.currentNode,
54
+ { shuffleProducts: e },
55
+ `${e ? "Enabled" : "Disabled"} product shuffle`
56
+ ), this.store.patchCurrentBlockConfig({ shuffleProducts: e }));
52
57
  }
53
58
  _listenToFormUpdates() {
54
- this.api.onValueChanged(s.SHUFFLE_PRODUCTS, (e) => {
59
+ this.api.onValueChanged(i.SHUFFLE_PRODUCTS, (e) => {
55
60
  this._onShuffleChange(!!e);
56
61
  });
57
62
  }
58
63
  }
59
64
  export {
60
- d as SHUFFLE_CONTROL_ID,
61
- p as ShuffleControl
65
+ h as SHUFFLE_CONTROL_ID,
66
+ S as ShuffleControl
62
67
  };