@useinsider/guido 3.8.0-beta.bf9ea20 → 3.8.0-beta.eb4074b

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 (56) hide show
  1. package/dist/composables/useHtmlValidator.js +180 -133
  2. package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -69
  3. package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
  4. package/dist/config/migrator/recommendation/extractors.js +44 -22
  5. package/dist/config/migrator/recommendation/htmlBuilder.js +175 -169
  6. package/dist/config/migrator/recommendationMigrator.js +30 -31
  7. package/dist/extensions/Blocks/Items/block.js +29 -48
  8. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +45 -62
  9. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +22 -15
  10. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +55 -41
  11. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +42 -43
  12. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +48 -45
  13. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
  14. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +64 -60
  15. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +294 -335
  16. package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
  17. package/dist/extensions/Blocks/Recommendation/extension.js +7 -5
  18. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +4 -2
  19. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -2
  20. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +142 -173
  21. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +56 -29
  22. package/dist/extensions/Blocks/Recommendation/templates/index.js +30 -8
  23. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +132 -105
  24. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +44 -23
  25. package/dist/extensions/Blocks/Recommendation/templates/utils.js +112 -64
  26. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +219 -0
  27. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +24 -19
  28. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +30 -22
  29. package/dist/extensions/Blocks/Unsubscribe/block.js +1 -1
  30. package/dist/extensions/Blocks/controlFactories.js +159 -133
  31. package/dist/src/composables/useHtmlValidator.d.ts +27 -0
  32. package/dist/src/composables/useHtmlValidator.test.d.ts +1 -0
  33. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
  34. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
  35. package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
  36. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
  37. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -8
  38. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
  39. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
  40. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +23 -0
  42. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
  43. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +7 -0
  44. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +7 -1
  45. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
  46. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +29 -47
  47. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  48. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  49. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -2
  50. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +165 -11
  51. package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +78 -0
  52. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +15 -0
  53. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +29 -9
  54. package/dist/src/extensions/Blocks/controlFactories.d.ts +11 -1
  55. package/package.json +1 -1
  56. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
@@ -1,15 +1,16 @@
1
- var E = Object.defineProperty;
2
- var f = (a, n, t) => n in a ? E(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
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";
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";
7
8
  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 = {
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";
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",
15
16
  PRODUCT_IN_ROW_LABEL: "cardsInRowLabel",
@@ -23,19 +24,19 @@ const S = "recommendation-product-layout-control", e = {
23
24
  MOBILE_LAYOUT_TOGGLE: "mobileLayoutEnabled",
24
25
  MOBILE_LAYOUT_LABEL: "mobileLayoutLabel"
25
26
  };
26
- class v extends M {
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
- c(this, "store", D());
31
- c(this, "storeUnsubscription", () => {
31
+ l(this, "store", M());
32
+ l(this, "storeUnsubscription", () => {
32
33
  });
33
- c(this, "_debouncedRegenerateProductRows", B(() => {
34
+ l(this, "_debouncedRegenerateProductRows", A(() => {
34
35
  this._regenerateProductRows();
35
36
  }, 500));
36
37
  }
37
38
  getId() {
38
- return S;
39
+ return B;
39
40
  }
40
41
  getTemplate() {
41
42
  return `
@@ -45,19 +46,19 @@ class v extends M {
45
46
  text: this.api.translate("Products in One Row"),
46
47
  name: e.PRODUCT_IN_ROW_LABEL
47
48
  }),
48
- this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: m }),
49
+ this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: C }),
49
50
  this._GuLabel({
50
51
  text: this.api.translate("Products in One Row on Desktop"),
51
52
  name: e.PRODUCT_IN_ROW_DESKTOP_LABEL
52
53
  }),
53
- this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue: m }),
54
+ this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue: C }),
54
55
  this._GuLabel({
55
56
  text: this.api.translate("Products in One Row on Mobile"),
56
57
  name: e.MOBILE_CARDS_IN_ROW_LABEL
57
58
  }),
58
59
  this._GuCounter({
59
60
  name: e.MOBILE_CARDS_IN_ROW,
60
- maxValue: P
61
+ maxValue: D
61
62
  }),
62
63
  this._GuLabel({
63
64
  text: this.api.translate("Mobile Layout Optimization"),
@@ -74,10 +75,19 @@ class v extends M {
74
75
  `;
75
76
  }
76
77
  onRender() {
77
- this._initializeMobileLayoutToggle(), this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates(), this._listenEditorModeChanges();
78
+ this._initializeMobileLayoutToggle(), this._setFormValues(), this._updateProductsInRowVisibility(), this._syncDisabledState(), this._listenToFormUpdates(), this._listenStateUpdates(), this._listenEditorModeChanges();
78
79
  }
79
80
  onTemplateNodeUpdated(t) {
80
- super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
81
+ super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility(), this._syncDisabledState();
82
+ }
83
+ /**
84
+ * Products-per-row and mobile-layout restructure the block, which is
85
+ * meaningless for partner-managed (`ins-skip-compile`) blocks — disable
86
+ * these inputs there. Disabling coexists with the visibility logic above.
87
+ */
88
+ _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);
81
91
  }
82
92
  onDestroy() {
83
93
  this.storeUnsubscription();
@@ -95,7 +105,7 @@ class v extends M {
95
105
  * Returns true when the editor preview is in mobile mode.
96
106
  */
97
107
  _isMobilePreview() {
98
- return this.api.getEditorState()[O.previewDeviceMode] === N.MOBILE;
108
+ return this.api.getEditorState()[b.previewDeviceMode] === N.MOBILE;
99
109
  }
100
110
  /**
101
111
  * Updates counter visibility based on layout, mobileLayoutEnabled, and editor preview mode.
@@ -110,12 +120,12 @@ class v extends M {
110
120
  */
111
121
  _updateProductsInRowVisibility() {
112
122
  var p;
113
- const t = s.getConfig(this.currentNode), o = (t.layout || U(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, u = this._isMobilePreview();
114
- this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE, o), this.api.setVisibility(e.MOBILE_LAYOUT_LABEL, o);
115
- const d = o && !r, _ = o && r && !u, h = o && r && u;
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);
117
- const R = (p = this.getContainer()) == null ? void 0 : p.querySelector("[data-product-layout-control]");
118
- R && (R.style.display = o ? "" : "none");
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");
119
129
  }
120
130
  /**
121
131
  * Initializes the mobile layout toggle using the same pattern as shuffle.ts.
@@ -125,7 +135,7 @@ class v extends M {
125
135
  const t = s.getConfig(this.currentNode);
126
136
  this.api.setUIEAttribute(
127
137
  e.MOBILE_LAYOUT_TOGGLE,
128
- T.SELECTPICKER.items,
138
+ d.SELECTPICKER.items,
129
139
  t.mobileLayoutEnabled
130
140
  );
131
141
  }
@@ -137,12 +147,12 @@ class v extends M {
137
147
  _onMobileLayoutToggleChange(t) {
138
148
  if (!this.currentNode)
139
149
  return;
140
- const i = s.getConfig(this.currentNode);
141
- if (i.mobileLayoutEnabled === t)
150
+ const o = s.getConfig(this.currentNode);
151
+ if (o.mobileLayoutEnabled === t)
142
152
  return;
143
- const o = A(this.currentNode);
153
+ const i = U(this.currentNode);
144
154
  if (t) {
145
- const r = i.previousMobileCardsInRow || l;
155
+ const r = o.previousMobileCardsInRow || _;
146
156
  s.updateConfig(
147
157
  this.api,
148
158
  this.currentNode,
@@ -157,31 +167,31 @@ class v extends M {
157
167
  mobileCardsInRow: r
158
168
  },
159
169
  { 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);
170
+ ), i && m(this.api, i, !1), L(this.api);
171
+ const u = parseInt(o.size) || 6, c = I(this.store.recommendationProducts, u);
162
172
  g({
163
173
  currentNode: this.currentNode,
164
174
  documentModifier: this.api.getDocumentModifier(),
165
- products: d
175
+ products: c
166
176
  });
167
177
  } else {
168
- const r = i.mobileCardsInRow;
178
+ const r = o.mobileCardsInRow;
169
179
  s.updateConfig(
170
180
  this.api,
171
181
  this.currentNode,
172
182
  {
173
183
  mobileLayoutEnabled: !1,
174
184
  previousMobileCardsInRow: r,
175
- mobileCardsInRow: l
185
+ mobileCardsInRow: _
176
186
  },
177
187
  "Disabled mobile layout optimization"
178
188
  ), this.store.patchCurrentBlockConfig(
179
189
  {
180
190
  mobileLayoutEnabled: !1,
181
- mobileCardsInRow: l
191
+ mobileCardsInRow: _
182
192
  },
183
193
  { triggerRefetch: !1 }
184
- ), o && C(this.api, o, !0), I({
194
+ ), i && m(this.api, i, !0), E({
185
195
  currentNode: this.currentNode,
186
196
  documentModifier: this.api.getDocumentModifier()
187
197
  });
@@ -189,39 +199,33 @@ class v extends M {
189
199
  this._setFormValues(), this._updateProductsInRowVisibility();
190
200
  }
191
201
  _onProductsInRowChange(t) {
192
- if (!this.currentNode || s.getConfig(this.currentNode).cardsInRow === t)
193
- return;
194
- const o = t === 1 ? 0 : w;
195
- s.updateConfig(
202
+ !this.currentNode || s.getConfig(this.currentNode).cardsInRow === t || (s.updateConfig(
196
203
  this.api,
197
204
  this.currentNode,
198
- { cardsInRow: t, columnSpacing: o },
205
+ { cardsInRow: t },
199
206
  `Changed products per row to ${t}`
200
- ), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows();
207
+ ), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows());
201
208
  }
202
209
  _onMobileCardsInRowChange(t) {
203
- if (!this.currentNode || s.getConfig(this.currentNode).mobileCardsInRow === t)
204
- return;
205
- const o = t === 1 ? 0 : y;
206
- s.updateConfig(
210
+ !this.currentNode || s.getConfig(this.currentNode).mobileCardsInRow === t || (s.updateConfig(
207
211
  this.api,
208
212
  this.currentNode,
209
- { mobileCardsInRow: t, mobileColumnSpacing: o },
213
+ { mobileCardsInRow: t },
210
214
  `Changed mobile products per row to ${t}`
211
215
  ), L(this.api), this.store.patchCurrentBlockConfig(
212
216
  { mobileCardsInRow: t },
213
217
  { triggerRefetch: !1 }
214
- ), I({
218
+ ), E({
215
219
  currentNode: this.currentNode,
216
220
  documentModifier: this.api.getDocumentModifier()
217
- });
221
+ }));
218
222
  }
219
223
  _regenerateProductRows() {
220
- const t = s.getConfig(this.currentNode), i = parseInt(t.size) || 6, o = b(this.store.recommendationProducts, i);
224
+ const t = s.getConfig(this.currentNode), o = parseInt(t.size) || 6, i = I(this.store.recommendationProducts, o);
221
225
  g({
222
226
  currentNode: this.currentNode,
223
227
  documentModifier: this.api.getDocumentModifier(),
224
- products: o
228
+ products: i
225
229
  });
226
230
  }
227
231
  _listenToFormUpdates() {
@@ -242,8 +246,8 @@ class v extends M {
242
246
  _listenStateUpdates() {
243
247
  let t = this.store.recommendationConfigs.orientation;
244
248
  this.storeUnsubscription = this.store.$subscribe(() => {
245
- const i = this.store.recommendationConfigs.orientation;
246
- i !== t && (t = i, this._updateProductsInRowVisibility());
249
+ const o = this.store.recommendationConfigs.orientation;
250
+ o !== t && (t = o, this._updateProductsInRowVisibility());
247
251
  });
248
252
  }
249
253
  /**
@@ -253,7 +257,7 @@ class v extends M {
253
257
  */
254
258
  _listenEditorModeChanges() {
255
259
  this.api.onEditorStatePropUpdated(
256
- O.previewDeviceMode,
260
+ b.previewDeviceMode,
257
261
  () => {
258
262
  s.getConfig(this.currentNode).mobileLayoutEnabled && this._updateProductsInRowVisibility();
259
263
  }
@@ -261,6 +265,6 @@ class v extends M {
261
265
  }
262
266
  }
263
267
  export {
264
- S as PRODUCT_LAYOUT_CONTROL_ID,
265
- v as ProductLayoutControl
268
+ B as PRODUCT_LAYOUT_CONTROL_ID,
269
+ F as ProductLayoutControl
266
270
  };