@useinsider/guido 3.8.0-beta.84f6c0a → 3.8.0-beta.bf9ea20

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 (38) hide show
  1. package/dist/config/compiler/utils/recommendationCompilerUtils.js +25 -19
  2. package/dist/extensions/Blocks/Items/block.js +48 -29
  3. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +62 -45
  4. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +10 -11
  5. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +26 -24
  6. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +39 -30
  7. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +34 -28
  8. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +333 -285
  9. package/dist/extensions/Blocks/Recommendation/extension.js +5 -6
  10. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +2 -3
  11. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +173 -142
  12. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -56
  13. package/dist/extensions/Blocks/Recommendation/templates/index.js +8 -29
  14. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +105 -132
  15. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +23 -44
  16. package/dist/extensions/Blocks/Recommendation/templates/utils.js +64 -112
  17. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +19 -24
  18. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +22 -30
  19. package/dist/extensions/Blocks/controlFactories.js +133 -159
  20. package/dist/src/extensions/Blocks/Items/block.d.ts +8 -0
  21. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
  22. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
  23. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  24. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -2
  25. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
  26. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +1 -2
  27. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +47 -20
  28. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  29. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  30. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +2 -3
  31. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +11 -165
  32. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -15
  33. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  34. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +9 -29
  35. package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -11
  36. package/package.json +1 -1
  37. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +0 -219
  38. package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +0 -78
@@ -1,53 +1,64 @@
1
- var L = Object.defineProperty;
2
- var _ = (o, e, t) => e in o ? L(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var s = (o, e, t) => _(o, typeof e != "symbol" ? e + "" : e, t);
1
+ var p = Object.defineProperty;
2
+ var A = (o, e, t) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var r = (o, e, t) => A(o, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
5
  import { CommonControl as N } from "../../../common-control.js";
6
- import { LAYOUT_OPTIONS as O, DEFAULT_MOBILE_ROW_SPACING as m, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as l, DEFAULT_COLUMN_SPACING as g } from "../../constants/layout.js";
7
- import { RecommendationConfigService as a } from "../../services/configService.js";
8
- import { useRecommendationExtensionStore as A } from "../../store/recommendation.js";
9
- import { getCurrentLayout as C, getBlockElement as f, getCardComposition as S, regenerateProductRowsWithStyles as T } from "./utils.js";
10
- const I = "recommendation-layout-orientation-control", u = {
6
+ import { ATTR_DATA_CUSTOM_ATTRIBUTES as L } from "../../constants/selectors.js";
7
+ import { LAYOUT_OPTIONS as T, DEFAULT_MOBILE_ROW_SPACING as m, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as l, DEFAULT_COLUMN_SPACING as g } from "../../constants/layout.js";
8
+ import { DEFAULT_COMPOSITION as _ } from "../../constants/defaultConfig.js";
9
+ import { RecommendationConfigService as s } from "../../services/configService.js";
10
+ import { useRecommendationExtensionStore as f } from "../../store/recommendation.js";
11
+ import { getCurrentLayout as C, getBlockElement as I, regenerateProductRowsWithStyles as S } from "./utils.js";
12
+ const U = "recommendation-layout-orientation-control", O = "recommendationInfoBannerTest", a = {
11
13
  LAYOUT: "layout"
12
- }, n = {
14
+ }, y = "data-card-composition", n = {
13
15
  LAYOUT: "data-layout",
14
16
  COLUMN_SPACING: "data-column-spacing",
15
17
  ROW_SPACING: "data-row-spacing",
16
18
  MOBILE_COLUMN_SPACING: "data-mobile-column-spacing",
17
19
  MOBILE_ROW_SPACING: "data-mobile-row-spacing"
18
20
  };
19
- class w extends N {
21
+ class Y extends N {
20
22
  constructor() {
21
23
  super(...arguments);
22
- s(this, "store", A());
23
- s(this, "isChangingLayout", !1);
24
+ r(this, "store", f());
25
+ r(this, "isChangingLayout", !1);
24
26
  }
25
27
  getId() {
26
- return I;
28
+ return U;
27
29
  }
28
30
  getTemplate() {
29
31
  return `
30
32
  <div class="layout-control-container">
33
+ ${this._GuOnPageMessage({ name: O })}
34
+
31
35
  ${this._GuTwoColumns([
32
36
  this._GuLabel({ text: this.api.translate("Layout Orientation") }),
33
37
  this._GuRadioButton({
34
- name: u.LAYOUT,
35
- buttons: O
38
+ name: a.LAYOUT,
39
+ buttons: T
36
40
  })
37
41
  ])}
38
42
  </div>
39
43
  `;
40
44
  }
41
45
  onRender() {
42
- this._setFormValues(), this._listenToFormUpdates();
46
+ this._setInfoMessageValue(
47
+ O,
48
+ this.api.translate(
49
+ `Note that updating the Layout Orientation, Number of Products,
50
+ Products in One Row and Mobile Layout Optimization settings
51
+ resets the style of your Recommendation block.`
52
+ )
53
+ ), this._setFormValues(), this._listenToFormUpdates();
43
54
  }
44
55
  onTemplateNodeUpdated(t) {
45
56
  super.onTemplateNodeUpdated(t), this._setFormValues();
46
57
  }
47
58
  _setFormValues() {
48
- const r = a.getConfig(this.currentNode).layout || C(this.currentNode);
59
+ const u = s.getConfig(this.currentNode).layout || C(this.currentNode);
49
60
  this.api.updateValues({
50
- [u.LAYOUT]: r
61
+ [a.LAYOUT]: u
51
62
  });
52
63
  }
53
64
  /**
@@ -55,14 +66,13 @@ class w extends N {
55
66
  * Updates node config, data attribute and regenerates product rows
56
67
  */
57
68
  _onLayoutChange(t) {
58
- if (this.isChangingLayout || !this.currentNode || (a.getConfig(this.currentNode).layout || C(this.currentNode)) === t)
69
+ if (this.isChangingLayout || !this.currentNode || (s.getConfig(this.currentNode).layout || C(this.currentNode)) === t)
59
70
  return;
60
- const c = f(this.currentNode);
71
+ const c = I(this.currentNode);
61
72
  if (c) {
62
73
  this.isChangingLayout = !0;
63
74
  try {
64
- const p = S(this.currentNode);
65
- a.updateConfig(
75
+ s.updateConfig(
66
76
  this.api,
67
77
  this.currentNode,
68
78
  {
@@ -75,7 +85,7 @@ class w extends N {
75
85
  `Changed layout to ${t}`
76
86
  ), this.store.patchCurrentBlockConfig({ orientation: t });
77
87
  const i = this.api.getDocumentModifier().modifyHtml(c).setAttribute(n.LAYOUT, t).setAttribute(n.COLUMN_SPACING, g.toString()).setAttribute(n.ROW_SPACING, l.toString()).setAttribute(n.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(n.MOBILE_ROW_SPACING, m.toString());
78
- t === "list" ? (i.setClass("es-m-p0"), i.setClass("ins-recommendation-list-layout")) : (i.removeClass("es-m-p0"), i.removeClass("ins-recommendation-list-layout")), i.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t, p);
88
+ t === "list" ? (i.setClass("es-m-p0"), i.setClass("ins-recommendation-list-layout")) : (i.removeClass("es-m-p0"), i.removeClass("ins-recommendation-list-layout")), i.setAttribute(y, _.join(",")).setAttribute(L, "[]"), i.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t);
79
89
  } finally {
80
90
  this.isChangingLayout = !1;
81
91
  }
@@ -85,23 +95,22 @@ class w extends N {
85
95
  * Regenerates product rows based on the selected layout
86
96
  * Uses unified style-preserving regeneration to maintain user customizations
87
97
  * @param layout - The layout to use for regeneration (passed explicitly to avoid stale DOM reads)
88
- * @param composition - The preserved card composition, incl. customAttr:* entries
89
98
  */
90
- _regenerateProductRows(t, r) {
91
- this.currentNode && T({
99
+ _regenerateProductRows(t) {
100
+ this.currentNode && S({
92
101
  currentNode: this.currentNode,
93
102
  documentModifier: this.api.getDocumentModifier(),
94
103
  layout: t,
95
- composition: r
104
+ composition: _
96
105
  });
97
106
  }
98
107
  _listenToFormUpdates() {
99
- this.api.onValueChanged(u.LAYOUT, (t) => {
108
+ this.api.onValueChanged(a.LAYOUT, (t) => {
100
109
  this._onLayoutChange(t);
101
110
  });
102
111
  }
103
112
  }
104
113
  export {
105
- I as LAYOUT_ORIENTATION_CONTROL_ID,
106
- w as LayoutOrientationControl
114
+ U as LAYOUT_ORIENTATION_CONTROL_ID,
115
+ Y as LayoutOrientationControl
107
116
  };
@@ -1,15 +1,15 @@
1
1
  var E = Object.defineProperty;
2
2
  var f = (a, n, t) => n in a ? E(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
3
  var c = (a, n, t) => f(a, typeof n != "symbol" ? n + "" : n, t);
4
- import { EditorStatePropertyType as O, PreviewDeviceMode as T, UEAttr as N } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as P } from "../../../common-control.js";
6
- import { MAX_PRODUCTS_PER_ROW as m, MAX_MOBILE_PRODUCTS_PER_ROW as M, DEFAULT_MOBILE_CARDS_IN_ROW as l } from "../../constants/layout.js";
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";
7
7
  import { RecommendationConfigService as s } from "../../services/configService.js";
8
- import { useRecommendationExtensionStore as w } from "../../store/recommendation.js";
9
- import { setMobileLayoutOptOut as C, ensureMobileCssRulesExist as b } from "../mobileLayout/cssRules.js";
10
- import { getCurrentLayout as y, getBlockElement as D, adjustProductsToSize as L, regenerateProductRowsWithStyles as g, regenerateMobileProductRows as I } from "./utils.js";
11
- import { useDebounceFn as U } from "../../../../../node_modules/@vueuse/shared/index.js";
12
- const B = "recommendation-product-layout-control", e = {
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 = {
13
13
  // "Products in One Row" — shown when toggle is OFF
14
14
  PRODUCT_IN_ROW: "cardsInRow",
15
15
  PRODUCT_IN_ROW_LABEL: "cardsInRowLabel",
@@ -23,19 +23,19 @@ const B = "recommendation-product-layout-control", e = {
23
23
  MOBILE_LAYOUT_TOGGLE: "mobileLayoutEnabled",
24
24
  MOBILE_LAYOUT_LABEL: "mobileLayoutLabel"
25
25
  };
26
- class v extends P {
26
+ class v extends M {
27
27
  constructor() {
28
28
  super(...arguments);
29
29
  // Store is used for backward compatibility with product fetching and regeneration
30
- c(this, "store", w());
30
+ c(this, "store", D());
31
31
  c(this, "storeUnsubscription", () => {
32
32
  });
33
- c(this, "_debouncedRegenerateProductRows", U(() => {
33
+ c(this, "_debouncedRegenerateProductRows", B(() => {
34
34
  this._regenerateProductRows();
35
35
  }, 500));
36
36
  }
37
37
  getId() {
38
- return B;
38
+ return S;
39
39
  }
40
40
  getTemplate() {
41
41
  return `
@@ -57,7 +57,7 @@ class v extends P {
57
57
  }),
58
58
  this._GuCounter({
59
59
  name: e.MOBILE_CARDS_IN_ROW,
60
- maxValue: M
60
+ maxValue: P
61
61
  }),
62
62
  this._GuLabel({
63
63
  text: this.api.translate("Mobile Layout Optimization"),
@@ -95,7 +95,7 @@ class v extends P {
95
95
  * Returns true when the editor preview is in mobile mode.
96
96
  */
97
97
  _isMobilePreview() {
98
- return this.api.getEditorState()[O.previewDeviceMode] === T.MOBILE;
98
+ return this.api.getEditorState()[O.previewDeviceMode] === N.MOBILE;
99
99
  }
100
100
  /**
101
101
  * Updates counter visibility based on layout, mobileLayoutEnabled, and editor preview mode.
@@ -110,7 +110,7 @@ class v extends P {
110
110
  */
111
111
  _updateProductsInRowVisibility() {
112
112
  var p;
113
- const t = s.getConfig(this.currentNode), o = (t.layout || y(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, u = this._isMobilePreview();
113
+ const t = s.getConfig(this.currentNode), o = (t.layout || U(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, u = this._isMobilePreview();
114
114
  this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE, o), this.api.setVisibility(e.MOBILE_LAYOUT_LABEL, o);
115
115
  const d = o && !r, _ = o && r && !u, h = o && r && u;
116
116
  this.api.setVisibility(e.PRODUCT_IN_ROW, d), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, d), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP, _), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP_LABEL, _), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, h), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, h);
@@ -125,7 +125,7 @@ class v extends P {
125
125
  const t = s.getConfig(this.currentNode);
126
126
  this.api.setUIEAttribute(
127
127
  e.MOBILE_LAYOUT_TOGGLE,
128
- N.SELECTPICKER.items,
128
+ T.SELECTPICKER.items,
129
129
  t.mobileLayoutEnabled
130
130
  );
131
131
  }
@@ -140,7 +140,7 @@ class v extends P {
140
140
  const i = s.getConfig(this.currentNode);
141
141
  if (i.mobileLayoutEnabled === t)
142
142
  return;
143
- const o = D(this.currentNode);
143
+ const o = A(this.currentNode);
144
144
  if (t) {
145
145
  const r = i.previousMobileCardsInRow || l;
146
146
  s.updateConfig(
@@ -157,8 +157,8 @@ class v extends P {
157
157
  mobileCardsInRow: r
158
158
  },
159
159
  { triggerRefetch: !1 }
160
- ), o && C(this.api, o, !1), b(this.api);
161
- const u = parseInt(i.size) || 6, d = L(this.store.recommendationProducts, u);
160
+ ), o && C(this.api, o, !1), L(this.api);
161
+ const u = parseInt(i.size) || 6, d = b(this.store.recommendationProducts, u);
162
162
  g({
163
163
  currentNode: this.currentNode,
164
164
  documentModifier: this.api.getDocumentModifier(),
@@ -189,29 +189,35 @@ class v extends P {
189
189
  this._setFormValues(), this._updateProductsInRowVisibility();
190
190
  }
191
191
  _onProductsInRowChange(t) {
192
- !this.currentNode || s.getConfig(this.currentNode).cardsInRow === t || (s.updateConfig(
192
+ if (!this.currentNode || s.getConfig(this.currentNode).cardsInRow === t)
193
+ return;
194
+ const o = t === 1 ? 0 : w;
195
+ s.updateConfig(
193
196
  this.api,
194
197
  this.currentNode,
195
- { cardsInRow: t },
198
+ { cardsInRow: t, columnSpacing: o },
196
199
  `Changed products per row to ${t}`
197
- ), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows());
200
+ ), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows();
198
201
  }
199
202
  _onMobileCardsInRowChange(t) {
200
- !this.currentNode || s.getConfig(this.currentNode).mobileCardsInRow === t || (s.updateConfig(
203
+ if (!this.currentNode || s.getConfig(this.currentNode).mobileCardsInRow === t)
204
+ return;
205
+ const o = t === 1 ? 0 : y;
206
+ s.updateConfig(
201
207
  this.api,
202
208
  this.currentNode,
203
- { mobileCardsInRow: t },
209
+ { mobileCardsInRow: t, mobileColumnSpacing: o },
204
210
  `Changed mobile products per row to ${t}`
205
- ), b(this.api), this.store.patchCurrentBlockConfig(
211
+ ), L(this.api), this.store.patchCurrentBlockConfig(
206
212
  { mobileCardsInRow: t },
207
213
  { triggerRefetch: !1 }
208
214
  ), I({
209
215
  currentNode: this.currentNode,
210
216
  documentModifier: this.api.getDocumentModifier()
211
- }));
217
+ });
212
218
  }
213
219
  _regenerateProductRows() {
214
- const t = s.getConfig(this.currentNode), i = parseInt(t.size) || 6, o = L(this.store.recommendationProducts, i);
220
+ const t = s.getConfig(this.currentNode), i = parseInt(t.size) || 6, o = b(this.store.recommendationProducts, i);
215
221
  g({
216
222
  currentNode: this.currentNode,
217
223
  documentModifier: this.api.getDocumentModifier(),
@@ -255,6 +261,6 @@ class v extends P {
255
261
  }
256
262
  }
257
263
  export {
258
- B as PRODUCT_LAYOUT_CONTROL_ID,
264
+ S as PRODUCT_LAYOUT_CONTROL_ID,
259
265
  v as ProductLayoutControl
260
266
  };