@useinsider/guido 3.21.0 → 3.21.1-beta.18ab939

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 (33) hide show
  1. package/README.md +34 -4
  2. package/dist/components/Guido.vue.js +3 -3
  3. package/dist/components/Guido.vue2.js +118 -108
  4. package/dist/composables/useEditorOpenMetrics.js +164 -0
  5. package/dist/composables/useStripo.js +94 -82
  6. package/dist/config/compiler/htmlCompilerRules.js +1 -1
  7. package/dist/extensions/Blocks/Recommendation/block.js +209 -139
  8. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +18 -23
  9. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +171 -141
  10. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +68 -59
  11. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +249 -248
  12. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +62 -45
  13. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +52 -31
  14. package/dist/guido.css +1 -1
  15. package/dist/library.js +12 -10
  16. package/dist/package.json.js +6 -4
  17. package/dist/public/prefetchRuntime.js +4 -0
  18. package/dist/src/composables/useEditorOpenMetrics.d.ts +27 -0
  19. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +23 -7
  20. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +6 -0
  21. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +5 -2
  22. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +6 -0
  23. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +4 -0
  24. package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +11 -0
  25. package/dist/src/library.d.ts +1 -0
  26. package/dist/src/public/prefetchRuntime.d.ts +1 -0
  27. package/dist/src/utils/runtimePrefetch.d.ts +4 -0
  28. package/dist/src/utils/stripoRuntime.d.ts +2 -0
  29. package/dist/static/stripo-runtime-manifest.json.js +9 -0
  30. package/dist/static/styles/components/tabs.css.js +5 -0
  31. package/dist/utils/runtimePrefetch.js +26 -0
  32. package/dist/utils/stripoRuntime.js +9 -0
  33. package/package.json +7 -2
@@ -1,16 +1,16 @@
1
1
  var f = Object.defineProperty;
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
- import "../../constants/selectors.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";
2
+ var M = (d, n, t) => n in d ? f(d, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[n] = t;
3
+ var l = (d, n, t) => M(d, typeof n != "symbol" ? n + "" : n, t);
4
+ import { UEAttr as u, EditorStatePropertyType as O, PreviewDeviceMode as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as N } from "../../../common-control.js";
6
+ import { RECOMMENDATION_ID_ATTR as D } from "../../constants/selectors.js";
7
+ import { MAX_PRODUCTS_PER_ROW as L, MAX_MOBILE_PRODUCTS_PER_ROW as P, DEFAULT_MOBILE_CARDS_IN_ROW as h } from "../../constants/layout.js";
8
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";
9
+ import { useRecommendationExtensionStore as w } from "../../store/recommendation.js";
10
+ import { setMobileLayoutOptOut as C, ensureMobileCssRulesExist as g } from "../mobileLayout/cssRules.js";
11
+ import { isPartnerManagedBlock as U, getBlockElement as m, getCurrentLayout as B, adjustProductsToSize as I, regenerateProductRowsWithStyles as E, regenerateMobileProductRows as T } from "./utils.js";
12
12
  import { useDebounceFn as A } from "../../../../../node_modules/@vueuse/shared/index.js";
13
- const B = "recommendation-product-layout-control", e = {
13
+ const S = "recommendation-product-layout-control", e = {
14
14
  // "Products in One Row" — shown when toggle is OFF
15
15
  PRODUCT_IN_ROW: "cardsInRow",
16
16
  PRODUCT_IN_ROW_LABEL: "cardsInRowLabel",
@@ -24,19 +24,23 @@ const B = "recommendation-product-layout-control", e = {
24
24
  MOBILE_LAYOUT_TOGGLE: "mobileLayoutEnabled",
25
25
  MOBILE_LAYOUT_LABEL: "mobileLayoutLabel"
26
26
  };
27
- class F extends P {
27
+ class $ extends N {
28
28
  constructor() {
29
29
  super(...arguments);
30
30
  // Store is used for backward compatibility with product fetching and regeneration
31
- l(this, "store", M());
31
+ l(this, "store", w());
32
32
  l(this, "storeUnsubscription", () => {
33
33
  });
34
+ // Stripo 2.81 serves the pre-toggle config from currentNode and early node updates until the toggle lands.
35
+ l(this, "pendingMobileLayoutEnabled", null);
36
+ // Stripo reuses this control across blocks, so the pending toggle is scoped to the block that set it.
37
+ l(this, "pendingMobileLayoutBlockId", null);
34
38
  l(this, "_debouncedRegenerateProductRows", A(() => {
35
39
  this._regenerateProductRows();
36
40
  }, 500));
37
41
  }
38
42
  getId() {
39
- return B;
43
+ return S;
40
44
  }
41
45
  getTemplate() {
42
46
  return `
@@ -46,19 +50,19 @@ class F extends P {
46
50
  text: this.api.translate("Products in One Row"),
47
51
  name: e.PRODUCT_IN_ROW_LABEL
48
52
  }),
49
- this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: C }),
53
+ this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: L }),
50
54
  this._GuLabel({
51
55
  text: this.api.translate("Products in One Row on Desktop"),
52
56
  name: e.PRODUCT_IN_ROW_DESKTOP_LABEL
53
57
  }),
54
- this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue: C }),
58
+ this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue: L }),
55
59
  this._GuLabel({
56
60
  text: this.api.translate("Products in One Row on Mobile"),
57
61
  name: e.MOBILE_CARDS_IN_ROW_LABEL
58
62
  }),
59
63
  this._GuCounter({
60
64
  name: e.MOBILE_CARDS_IN_ROW,
61
- maxValue: D
65
+ maxValue: P
62
66
  }),
63
67
  this._GuLabel({
64
68
  text: this.api.translate("Mobile Layout Optimization"),
@@ -78,7 +82,7 @@ class F extends P {
78
82
  this._initializeMobileLayoutToggle(), this._setFormValues(), this._updateProductsInRowVisibility(), this._syncDisabledState(), this._listenToFormUpdates(), this._listenStateUpdates(), this._listenEditorModeChanges();
79
83
  }
80
84
  onTemplateNodeUpdated(t) {
81
- super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility(), this._syncDisabledState();
85
+ super.onTemplateNodeUpdated(t), (this._getBlockId(t) !== this.pendingMobileLayoutBlockId || s.getConfig(t).mobileLayoutEnabled === this.pendingMobileLayoutEnabled) && (this.pendingMobileLayoutEnabled = null), this.pendingMobileLayoutEnabled === null && (this._setFormValues(), this._updateProductsInRowVisibility()), this._syncDisabledState();
82
86
  }
83
87
  /**
84
88
  * Products-per-row and mobile-layout restructure the block, which is
@@ -86,14 +90,17 @@ class F extends P {
86
90
  * these inputs there. Disabling coexists with the visibility logic above.
87
91
  */
88
92
  _syncDisabledState() {
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);
93
+ const t = U(this.currentNode);
94
+ this.api.setUIEAttribute(e.PRODUCT_IN_ROW, u.COUNTER.disabled, t), this.api.setUIEAttribute(e.PRODUCT_IN_ROW_DESKTOP, u.COUNTER.disabled, t), this.api.setUIEAttribute(e.MOBILE_CARDS_IN_ROW, u.COUNTER.disabled, t), this.api.setUIEAttribute(e.MOBILE_LAYOUT_TOGGLE, u.SWITCHER.disabled, t);
91
95
  }
92
96
  onDestroy() {
93
97
  this.storeUnsubscription();
94
98
  }
95
- _setFormValues() {
96
- const t = s.getConfig(this.currentNode);
99
+ _getBlockId(t) {
100
+ const i = m(t);
101
+ return i && "getAttribute" in i ? i.getAttribute(D) ?? null : null;
102
+ }
103
+ _setFormValues(t = s.getConfig(this.currentNode)) {
97
104
  this.api.updateValues({
98
105
  [e.PRODUCT_IN_ROW]: t.cardsInRow,
99
106
  [e.PRODUCT_IN_ROW_DESKTOP]: t.cardsInRow,
@@ -105,7 +112,7 @@ class F extends P {
105
112
  * Returns true when the editor preview is in mobile mode.
106
113
  */
107
114
  _isMobilePreview() {
108
- return this.api.getEditorState()[b.previewDeviceMode] === N.MOBILE;
115
+ return this.api.getEditorState()[O.previewDeviceMode] === y.MOBILE;
109
116
  }
110
117
  /**
111
118
  * Updates counter visibility based on layout, mobileLayoutEnabled, and editor preview mode.
@@ -118,14 +125,14 @@ class F extends P {
118
125
  * Only one row is visible at a time. This avoids setUIEAttribute on hidden
119
126
  * elements, which Stripo does not apply reliably.
120
127
  */
121
- _updateProductsInRowVisibility() {
128
+ _updateProductsInRowVisibility(t = s.getConfig(this.currentNode)) {
122
129
  var p;
123
- const t = s.getConfig(this.currentNode), i = (t.layout || w(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, u = this._isMobilePreview();
124
- this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE, i), this.api.setVisibility(e.MOBILE_LAYOUT_LABEL, i);
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");
130
+ const o = (t.layout || B(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, a = this._isMobilePreview();
131
+ this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE, o), this.api.setVisibility(e.MOBILE_LAYOUT_LABEL, o);
132
+ const c = o && !r, _ = o && r && !a, b = o && r && a;
133
+ 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, b), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, b);
134
+ const R = (p = this.getContainer()) == null ? void 0 : p.querySelector("[data-product-layout-control]");
135
+ R && (R.style.display = o ? "" : "none");
129
136
  }
130
137
  /**
131
138
  * Initializes the mobile layout toggle using the same pattern as shuffle.ts.
@@ -135,7 +142,7 @@ class F extends P {
135
142
  const t = s.getConfig(this.currentNode);
136
143
  this.api.setUIEAttribute(
137
144
  e.MOBILE_LAYOUT_TOGGLE,
138
- d.SELECTPICKER.items,
145
+ u.SELECTPICKER.items,
139
146
  t.mobileLayoutEnabled
140
147
  );
141
148
  }
@@ -147,56 +154,58 @@ class F extends P {
147
154
  _onMobileLayoutToggleChange(t) {
148
155
  if (!this.currentNode)
149
156
  return;
150
- const o = s.getConfig(this.currentNode);
151
- if (o.mobileLayoutEnabled === t)
157
+ const i = s.getConfig(this.currentNode);
158
+ if ((this.pendingMobileLayoutEnabled ?? i.mobileLayoutEnabled) === t)
152
159
  return;
153
- const i = U(this.currentNode);
160
+ const o = m(this.currentNode);
161
+ let r;
154
162
  if (t) {
155
- const r = o.previousMobileCardsInRow || _;
156
- s.updateConfig(
163
+ const a = i.previousMobileCardsInRow || h;
164
+ r = s.updateConfig(
157
165
  this.api,
158
166
  this.currentNode,
159
167
  {
160
168
  mobileLayoutEnabled: !0,
161
- mobileCardsInRow: r
169
+ mobileCardsInRow: a
162
170
  },
163
171
  "Enabled mobile layout optimization"
164
172
  ), this.store.patchCurrentBlockConfig(
165
173
  {
166
174
  mobileLayoutEnabled: !0,
167
- mobileCardsInRow: r
175
+ mobileCardsInRow: a
168
176
  },
169
177
  { 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({
178
+ ), o && C(this.api, o, !1), g(this.api);
179
+ const c = parseInt(i.size) || 6, _ = I(this.store.recommendationProducts, c);
180
+ E({
173
181
  currentNode: this.currentNode,
174
182
  documentModifier: this.api.getDocumentModifier(),
175
- products: c
183
+ products: _
176
184
  });
177
185
  } else {
178
- const r = o.mobileCardsInRow;
179
- s.updateConfig(
186
+ const a = i.mobileCardsInRow;
187
+ r = s.updateConfig(
180
188
  this.api,
181
189
  this.currentNode,
182
190
  {
183
191
  mobileLayoutEnabled: !1,
184
- previousMobileCardsInRow: r,
185
- mobileCardsInRow: _
192
+ previousMobileCardsInRow: a,
193
+ mobileCardsInRow: h
186
194
  },
187
195
  "Disabled mobile layout optimization"
188
196
  ), this.store.patchCurrentBlockConfig(
189
197
  {
190
198
  mobileLayoutEnabled: !1,
191
- mobileCardsInRow: _
199
+ mobileCardsInRow: h
192
200
  },
193
201
  { triggerRefetch: !1 }
194
- ), i && m(this.api, i, !0), E({
202
+ ), o && C(this.api, o, !0), T({
195
203
  currentNode: this.currentNode,
196
- documentModifier: this.api.getDocumentModifier()
204
+ documentModifier: this.api.getDocumentModifier(),
205
+ mobileLayoutEnabled: !1
197
206
  });
198
207
  }
199
- this._setFormValues(), this._updateProductsInRowVisibility();
208
+ this.pendingMobileLayoutEnabled = t, this.pendingMobileLayoutBlockId = this._getBlockId(this.currentNode), this._setFormValues(r), this._updateProductsInRowVisibility(r);
200
209
  }
201
210
  _onProductsInRowChange(t) {
202
211
  !this.currentNode || s.getConfig(this.currentNode).cardsInRow === t || (s.updateConfig(
@@ -212,20 +221,20 @@ class F extends P {
212
221
  this.currentNode,
213
222
  { mobileCardsInRow: t },
214
223
  `Changed mobile products per row to ${t}`
215
- ), L(this.api), this.store.patchCurrentBlockConfig(
224
+ ), g(this.api), this.store.patchCurrentBlockConfig(
216
225
  { mobileCardsInRow: t },
217
226
  { triggerRefetch: !1 }
218
- ), E({
227
+ ), T({
219
228
  currentNode: this.currentNode,
220
229
  documentModifier: this.api.getDocumentModifier()
221
230
  }));
222
231
  }
223
232
  _regenerateProductRows() {
224
- const t = s.getConfig(this.currentNode), o = parseInt(t.size) || 6, i = I(this.store.recommendationProducts, o);
225
- g({
233
+ const t = s.getConfig(this.currentNode), i = parseInt(t.size) || 6, o = I(this.store.recommendationProducts, i);
234
+ E({
226
235
  currentNode: this.currentNode,
227
236
  documentModifier: this.api.getDocumentModifier(),
228
- products: i
237
+ products: o
229
238
  });
230
239
  }
231
240
  _listenToFormUpdates() {
@@ -246,8 +255,8 @@ class F extends P {
246
255
  _listenStateUpdates() {
247
256
  let t = this.store.recommendationConfigs.orientation;
248
257
  this.storeUnsubscription = this.store.$subscribe(() => {
249
- const o = this.store.recommendationConfigs.orientation;
250
- o !== t && (t = o, this._updateProductsInRowVisibility());
258
+ const i = this.store.recommendationConfigs.orientation;
259
+ i !== t && (t = i, this._updateProductsInRowVisibility());
251
260
  });
252
261
  }
253
262
  /**
@@ -257,7 +266,7 @@ class F extends P {
257
266
  */
258
267
  _listenEditorModeChanges() {
259
268
  this.api.onEditorStatePropUpdated(
260
- b.previewDeviceMode,
269
+ O.previewDeviceMode,
261
270
  () => {
262
271
  s.getConfig(this.currentNode).mobileLayoutEnabled && this._updateProductsInRowVisibility();
263
272
  }
@@ -265,6 +274,6 @@ class F extends P {
265
274
  }
266
275
  }
267
276
  export {
268
- B as PRODUCT_LAYOUT_CONTROL_ID,
269
- F as ProductLayoutControl
277
+ S as PRODUCT_LAYOUT_CONTROL_ID,
278
+ $ as ProductLayoutControl
270
279
  };