@useinsider/guido 2.2.0-beta.fa4cec8 → 3.0.0-beta.2235a35

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 (95) hide show
  1. package/README.md +41 -2
  2. package/dist/@types/config/schemas.js +1 -1
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +66 -66
  5. package/dist/components/organisms/base/Toaster.vue.js +4 -4
  6. package/dist/components/organisms/base/Toaster.vue2.js +12 -9
  7. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
  8. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  9. package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +11 -13
  10. package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +54 -23
  11. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +7 -5
  12. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +34 -21
  13. package/dist/components/organisms/extensions/recommendation/Filters.vue.js +11 -11
  14. package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +48 -36
  15. package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue2.js +11 -9
  16. package/dist/composables/useRecommendation.js +9 -9
  17. package/dist/composables/useSave.js +16 -12
  18. package/dist/composables/useStripo.js +66 -62
  19. package/dist/composables/useStripoEventHandler.js +27 -12
  20. package/dist/composables/useSyncModuleExtractor.js +45 -0
  21. package/dist/config/compiler/utils/recommendationCompilerUtils.js +1 -1
  22. package/dist/config/migrator/recommendationMigrator.js +1 -1
  23. package/dist/enums/unsubscribe.js +25 -21
  24. package/dist/extensions/Blocks/Recommendation/block.js +1 -1
  25. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +36 -33
  26. package/dist/extensions/Blocks/Recommendation/constants/layout.js +16 -14
  27. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -13
  28. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +9 -9
  29. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +1 -1
  30. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +41 -29
  31. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +16 -16
  32. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +30 -32
  33. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +194 -104
  34. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +9 -9
  35. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +46 -38
  36. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +16 -16
  37. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +291 -217
  38. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +14 -14
  39. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +10 -10
  40. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
  41. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +14 -14
  42. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +9 -9
  43. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +3 -3
  44. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +1 -1
  45. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +9 -9
  46. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +3 -3
  47. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +13 -13
  48. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +3 -3
  49. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +223 -99
  50. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +172 -85
  51. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +2 -2
  52. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +1 -1
  53. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +2 -2
  54. package/dist/extensions/Blocks/Recommendation/templates/utils.js +32 -32
  55. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +8 -8
  56. package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +29 -0
  57. package/dist/guido.css +1 -1
  58. package/dist/services/stripoApi.js +55 -19
  59. package/dist/src/@types/config/schemas.d.ts +1 -1
  60. package/dist/src/@types/events.d.ts +38 -2
  61. package/dist/src/App.vue.d.ts +0 -1
  62. package/dist/src/components/Guido.vue.d.ts +2 -2
  63. package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +1 -0
  64. package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +17 -1
  65. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  66. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  67. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  68. package/dist/src/composables/useGuidoActions.d.ts +1 -1
  69. package/dist/src/composables/useSave.d.ts +2 -2
  70. package/dist/src/composables/useStripo.d.ts +2 -2
  71. package/dist/src/composables/useSyncModuleExtractor.d.ts +4 -0
  72. package/dist/src/enums/unsubscribe.d.ts +3 -0
  73. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +6 -0
  74. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -3
  75. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -2
  76. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +8 -1
  77. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +38 -10
  78. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +27 -14
  79. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +50 -17
  80. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +19 -2
  81. package/dist/src/extensions/Blocks/Recommendation/templates/grid/migration.d.ts +1 -1
  82. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +4 -2
  83. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +1 -1
  84. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -1
  85. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +8 -0
  86. package/dist/src/extensions/Blocks/Recommendation/validation/filterSchema.d.ts +15 -0
  87. package/dist/src/main.d.ts +3 -1
  88. package/dist/src/mock/api/settings.d.ts +2 -0
  89. package/dist/src/services/stripoApi.d.ts +5 -0
  90. package/dist/src/stores/editor.d.ts +23 -0
  91. package/dist/src/utils/templatePreparation.d.ts +1 -1
  92. package/dist/static/styles/customEditorStyle.css.js +50 -23
  93. package/dist/stores/editor.js +2 -1
  94. package/dist/utils/templatePreparation.js +1 -1
  95. package/package.json +2 -2
@@ -1,140 +1,195 @@
1
1
  var G = Object.defineProperty;
2
- var I = (o, n, t) => n in o ? G(o, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[n] = t;
3
- var l = (o, n, t) => I(o, typeof n != "symbol" ? n + "" : n, t);
4
- import { ModificationDescription as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as L } from "../../../common-control.js";
6
- import { SPACING_STEP as b, MAX_SPACING as y, MIN_SPACING as A, DEFAULT_COLUMN_SPACING as a, DEFAULT_ROW_SPACING as m } from "../../constants/layout.js";
2
+ var R = (p, c, t) => c in p ? G(p, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[c] = t;
3
+ var h = (p, c, t) => R(p, typeof c != "symbol" ? c + "" : c, t);
4
+ import { EditorStatePropertyType as y, PreviewDeviceMode as w, ModificationDescription as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as V } from "../../../common-control.js";
6
+ import { DESKTOP_CONTAINER_SELECTOR as m, MOBILE_CONTAINER_SELECTOR as E } from "../../constants/selectors.js";
7
+ import { SPACING_STEP as S, MAX_SPACING as _, MIN_SPACING as N, DEFAULT_COLUMN_SPACING as C, DEFAULT_ROW_SPACING as P } from "../../constants/layout.js";
7
8
  import { RecommendationConfigService as d } from "../../services/configService.js";
8
- import { useRecommendationExtensionStore as w } from "../../store/recommendation.js";
9
- import { safeGetStyle as S, safeGetParent as V } from "../../utils/tagName.js";
10
- import { getCurrentLayout as C } from "../main/utils.js";
11
- import { useDebounceFn as O } from "../../../../../node_modules/@vueuse/shared/index.js";
12
- const R = "recommendation-spacing-control", s = {
9
+ import { useRecommendationExtensionStore as B } from "../../store/recommendation.js";
10
+ import { safeGetStyle as A, safeGetParent as U } from "../../utils/tagName.js";
11
+ import { getCurrentLayout as b, getBlockElement as x } from "../main/utils.js";
12
+ import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
13
+ const W = "recommendation-spacing-control", i = {
13
14
  COLUMN_SPACING: "columnSpacing",
14
15
  COLUMN_SPACING_LABEL: "columnSpacingLabel",
15
- ROW_SPACING: "rowSpacing"
16
- }, P = {
16
+ ROW_SPACING: "rowSpacing",
17
+ ROW_SPACING_LABEL: "rowSpacingLabel",
18
+ MOBILE_COLUMN_SPACING: "mobileColumnSpacing",
19
+ MOBILE_COLUMN_SPACING_LABEL: "mobileColumnSpacingLabel",
20
+ MOBILE_ROW_SPACING: "mobileRowSpacing",
21
+ MOBILE_ROW_SPACING_LABEL: "mobileRowSpacingLabel"
22
+ }, O = {
17
23
  COLUMN_SPACING: "data-column-spacing",
18
- ROW_SPACING: "data-row-spacing"
24
+ ROW_SPACING: "data-row-spacing",
25
+ MOBILE_COLUMN_SPACING: "data-mobile-column-spacing",
26
+ MOBILE_ROW_SPACING: "data-mobile-row-spacing"
19
27
  };
20
- function N(o, n) {
21
- if (!o)
22
- return n;
23
- const t = parseFloat(o);
24
- return Number.isNaN(t) ? n : t;
28
+ function L(p, c) {
29
+ if (!p)
30
+ return c;
31
+ const t = parseFloat(p);
32
+ return Number.isNaN(t) ? c : t;
25
33
  }
26
- class $ extends L {
34
+ class X extends V {
27
35
  constructor() {
28
36
  super(...arguments);
29
- l(this, "store", w());
30
- l(this, "unsubscribeOrientation", null);
37
+ h(this, "store", B());
38
+ h(this, "unsubscribeOrientation", null);
31
39
  /**
32
40
  * Debounced version of _onColumnSpacingChange
33
41
  * Prevents excessive DOM updates when user rapidly adjusts the counter
34
42
  */
35
- l(this, "_debouncedOnColumnSpacingChange", O((t) => {
43
+ h(this, "_debouncedOnColumnSpacingChange", f((t) => {
36
44
  this._onColumnSpacingChange(t);
37
45
  }, 300));
38
46
  /**
39
47
  * Debounced version of _onRowSpacingChange
40
- * Prevents excessive DOM updates when user rapidly adjusts the counter
41
48
  */
42
- l(this, "_debouncedOnRowSpacingChange", O((t) => {
49
+ h(this, "_debouncedOnRowSpacingChange", f((t) => {
43
50
  this._onRowSpacingChange(t);
44
51
  }, 300));
52
+ /**
53
+ * Debounced version of _onMobileColumnSpacingChange
54
+ */
55
+ h(this, "_debouncedOnMobileColumnSpacingChange", f((t) => {
56
+ this._onMobileColumnSpacingChange(t);
57
+ }, 300));
58
+ /**
59
+ * Debounced version of _onMobileRowSpacingChange
60
+ */
61
+ h(this, "_debouncedOnMobileRowSpacingChange", f((t) => {
62
+ this._onMobileRowSpacingChange(t);
63
+ }, 300));
45
64
  }
46
65
  getId() {
47
- return R;
66
+ return W;
48
67
  }
49
68
  getTemplate() {
50
69
  return `
51
70
  <div class="spacing-control-container">
52
71
  ${this._GuTwoColumns([
53
- this._GuLabel({ text: "Column Spacing (px)", name: s.COLUMN_SPACING_LABEL }),
72
+ this._GuLabel({ text: "Column Spacing on Desktop (px)", name: i.COLUMN_SPACING_LABEL }),
73
+ this._GuCounter({
74
+ name: i.COLUMN_SPACING,
75
+ minValue: N,
76
+ maxValue: _,
77
+ step: S
78
+ }),
79
+ this._GuLabel({ text: "Row Spacing on Desktop (px)", name: i.ROW_SPACING_LABEL }),
54
80
  this._GuCounter({
55
- name: s.COLUMN_SPACING,
56
- minValue: A,
57
- maxValue: y,
58
- step: b
81
+ name: i.ROW_SPACING,
82
+ minValue: N,
83
+ maxValue: _,
84
+ step: S
59
85
  }),
60
- this._GuLabel({ text: "Row Spacing (px)" }),
86
+ this._GuLabel({
87
+ text: "Column Spacing on Mobile (px)",
88
+ name: i.MOBILE_COLUMN_SPACING_LABEL
89
+ }),
90
+ this._GuCounter({
91
+ name: i.MOBILE_COLUMN_SPACING,
92
+ minValue: N,
93
+ maxValue: _,
94
+ step: S
95
+ }),
96
+ this._GuLabel({ text: "Row Spacing on Mobile (px)", name: i.MOBILE_ROW_SPACING_LABEL }),
61
97
  this._GuCounter({
62
- name: s.ROW_SPACING,
63
- minValue: A,
64
- maxValue: y,
65
- step: b
98
+ name: i.MOBILE_ROW_SPACING,
99
+ minValue: N,
100
+ maxValue: _,
101
+ step: S
66
102
  })
67
103
  ])}
68
104
  </div>
69
105
  `;
70
106
  }
71
107
  onRender() {
72
- this._setFormValues(), this._updateColumnSpacingVisibility(), this._listenToFormUpdates(), this._subscribeToOrientationChanges();
108
+ this._setFormValues(), this._updateSpacingVisibility(), this._listenToFormUpdates(), this._subscribeToOrientationChanges(), this._subscribeToEditorModeChanges();
73
109
  }
74
110
  onTemplateNodeUpdated(t) {
75
- super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateColumnSpacingVisibility();
111
+ super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateSpacingVisibility();
76
112
  }
77
113
  onDestroy() {
78
114
  this.unsubscribeOrientation && (this.unsubscribeOrientation(), this.unsubscribeOrientation = null);
79
115
  }
80
116
  /**
81
- * Updates column spacing visibility based on layout orientation
82
- * Column spacing is hidden for list layout (products are stacked vertically)
83
- * Reads from node config first, falls back to store then DOM
117
+ * Checks if the editor is currently in mobile preview mode
118
+ * using Stripo's EditorStatePropertyType API.
84
119
  */
85
- _updateColumnSpacingVisibility() {
120
+ _isMobileMode() {
121
+ return this.api.getEditorState()[y.previewDeviceMode] === w.MOBILE;
122
+ }
123
+ /**
124
+ * Updates spacing control visibility based on layout orientation, editor mode,
125
+ * and products-per-row count.
126
+ * - List layout: hide column spacing (products are full-width), hide ALL mobile
127
+ * spacing controls (list is responsive — single row spacing applies to both views)
128
+ * - Desktop mode: show desktop spacing, hide mobile spacing
129
+ * - Mobile mode: show mobile spacing, hide desktop spacing
130
+ * - 1 product per row: hide column spacing (no gap between single column)
131
+ */
132
+ _updateSpacingVisibility() {
86
133
  if (!this.api)
87
134
  return;
88
- const t = d.getConfig(this.currentNode), e = this.store.recommendationConfigs.orientation, i = (t.layout || e || C(this.currentNode)) === "grid";
89
- this.api.setVisibility(s.COLUMN_SPACING, i), this.api.setVisibility(s.COLUMN_SPACING_LABEL, i);
135
+ const t = d.getConfig(this.currentNode), e = this.store.recommendationConfigs.orientation, n = t.layout || e || b(this.currentNode), o = n === "grid", a = n === "list", r = this._isMobileMode(), l = t.cardsInRow > 1, u = t.mobileCardsInRow > 1;
136
+ this.api.setVisibility(i.COLUMN_SPACING, o && !r && l), this.api.setVisibility(i.COLUMN_SPACING_LABEL, o && !r && l), this.api.setVisibility(i.ROW_SPACING, a || !r), this.api.setVisibility(i.ROW_SPACING_LABEL, a || !r), this.api.setVisibility(i.MOBILE_COLUMN_SPACING, o && r && u), this.api.setVisibility(i.MOBILE_COLUMN_SPACING_LABEL, o && r && u), this.api.setVisibility(i.MOBILE_ROW_SPACING, !a && r), this.api.setVisibility(i.MOBILE_ROW_SPACING_LABEL, !a && r);
90
137
  }
91
138
  /**
92
- * Reads spacing values from node config first, falls back to DOM styles
139
+ * Reads spacing values from node config first, falls back to DOM styles.
140
+ * DOM fallback is only used for legacy templates that lack node config.
93
141
  */
94
142
  _setFormValues() {
95
143
  if (!this.api)
96
144
  return;
97
- const t = d.getConfig(this.currentNode), e = t.columnSpacing !== a ? t.columnSpacing : this._getStoredColumnSpacing(), r = t.rowSpacing !== m ? t.rowSpacing : this._getStoredRowSpacing();
145
+ const t = d.hasConfig(this.currentNode), e = d.getConfig(this.currentNode), n = t ? e.columnSpacing : this._getStoredColumnSpacing(), o = t ? e.rowSpacing : this._getStoredRowSpacing();
98
146
  this.api.updateValues({
99
- [s.COLUMN_SPACING]: e,
100
- [s.ROW_SPACING]: r
147
+ [i.COLUMN_SPACING]: n,
148
+ [i.ROW_SPACING]: o,
149
+ [i.MOBILE_COLUMN_SPACING]: e.mobileColumnSpacing,
150
+ [i.MOBILE_ROW_SPACING]: e.mobileRowSpacing
101
151
  });
102
152
  }
103
153
  /**
104
154
  * Gets stored column spacing from the first attribute row cell's padding.
155
+ * Scoped to the desktop container for accurate readings.
105
156
  * For grid layout: cells inside .recommendation-attribute-row have padding applied.
106
157
  * For list layout: the parent of .product-card-wrapper has the padding.
107
158
  * The padding is applied as "0 {halfSpacing}px", so we extract and multiply by 2.
108
159
  */
109
160
  _getStoredColumnSpacing() {
110
161
  if (!this.currentNode)
111
- return a;
112
- if (C(this.currentNode) === "grid") {
113
- const p = this.currentNode.querySelector(".recommendation-attribute-row"), c = p == null ? void 0 : p.querySelector("td"), f = S(c, "padding");
114
- if (!f)
115
- return a;
116
- const _ = f.trim().split(/\s+/);
117
- return _.length < 2 ? a : N(_[1], a / 2) * 2;
162
+ return C;
163
+ const t = this.currentNode.querySelector(m) ?? this.currentNode;
164
+ if (b(this.currentNode) === "grid") {
165
+ const u = t.querySelector(".recommendation-attribute-row"), s = u == null ? void 0 : u.querySelector("td"), I = A(s, "padding");
166
+ if (!I)
167
+ return C;
168
+ const M = I.trim().split(/\s+/);
169
+ return M.length < 2 ? C : L(M[1], C / 2) * 2;
118
170
  }
119
- const e = this.currentNode.querySelector(".product-card-wrapper"), r = V(e), i = S(r, "padding");
120
- if (!i)
121
- return a;
122
- const u = i.trim().split(/\s+/);
123
- return u.length < 2 ? a : N(u[1], a / 2) * 2;
171
+ const n = t.querySelector(".product-card-wrapper"), o = U(n), a = A(o, "padding");
172
+ if (!a)
173
+ return C;
174
+ const r = a.trim().split(/\s+/);
175
+ return r.length < 2 ? C : L(r[1], C / 2) * 2;
124
176
  }
125
177
  /**
126
178
  * Gets stored row spacing from the first spacer element's height style
179
+ * Scoped to the desktop container for accurate readings.
127
180
  */
128
181
  _getStoredRowSpacing() {
129
182
  if (!this.currentNode)
130
- return m;
131
- const t = this.currentNode.querySelector(".spacer"), e = S(t, "height");
132
- return N(e, m);
183
+ return P;
184
+ const e = (this.currentNode.querySelector(m) ?? this.currentNode).querySelector(".spacer"), n = A(e, "height");
185
+ return L(n, P);
133
186
  }
187
+ // ========================================================================
188
+ // Desktop Spacing Handlers
189
+ // ========================================================================
134
190
  /**
135
- * Handles column spacing changes.
136
- * For grid layout: applies horizontal padding to all cells inside attribute rows.
137
- * For list layout: applies padding to parent of product card wrappers.
191
+ * Handles column spacing changes for desktop.
192
+ * Applies horizontal padding only to the desktop container elements.
138
193
  */
139
194
  _onColumnSpacingChange(t) {
140
195
  if (!this.currentNode)
@@ -144,21 +199,21 @@ class $ extends L {
144
199
  this.currentNode,
145
200
  { columnSpacing: t },
146
201
  `Changed column spacing to ${t}px`
147
- ), this._storeColumnSpacing(t);
148
- const r = d.getConfig(this.currentNode).layout || C(this.currentNode), i = this.api.getDocumentModifier(), h = `0 ${t / 2}px`;
149
- r === "grid" ? Array.from(
150
- this.currentNode.querySelectorAll(".attribute-cell")
151
- ).forEach((c) => {
152
- i.modifyHtml(c).setStyle("padding", h);
202
+ ), this._storeDataAttribute(O.COLUMN_SPACING, t);
203
+ const n = d.getConfig(this.currentNode).layout || b(this.currentNode), o = this.api.getDocumentModifier(), r = `0 ${t / 2}px`, l = this.currentNode.querySelector(m);
204
+ l && (n === "grid" ? Array.from(
205
+ l.querySelectorAll(".attribute-cell")
206
+ ).forEach((s) => {
207
+ o.modifyHtml(s).setStyle("padding", r);
153
208
  }) : Array.from(
154
- this.currentNode.querySelectorAll(".product-card-wrapper")
155
- ).forEach((c) => {
156
- "parent" in c && c.parent() && i.modifyHtml(c.parent()).setStyle("padding", h);
157
- }), i.apply(new g(`Update column spacing to ${t}px`));
209
+ l.querySelectorAll(".product-card-wrapper")
210
+ ).forEach((s) => {
211
+ "parent" in s && s.parent() && o.modifyHtml(s.parent()).setStyle("padding", r);
212
+ }), o.apply(new g(`Update column spacing to ${t}px`)));
158
213
  }
159
214
  /**
160
- * Handles row spacing changes
161
- * Applies height to all spacer elements between product rows
215
+ * Handles row spacing changes for desktop.
216
+ * Applies height only to spacer elements in the desktop container.
162
217
  */
163
218
  _onRowSpacingChange(t) {
164
219
  if (!this.currentNode)
@@ -168,55 +223,124 @@ class $ extends L {
168
223
  this.currentNode,
169
224
  { rowSpacing: t },
170
225
  `Changed row spacing to ${t}px`
171
- ), this._storeRowSpacing(t);
172
- const e = Array.from(
173
- this.currentNode.querySelectorAll(".spacer")
226
+ ), this._storeDataAttribute(O.ROW_SPACING, t);
227
+ const e = this.currentNode.querySelector(m);
228
+ if (!e)
229
+ return;
230
+ const n = Array.from(
231
+ e.querySelectorAll(".spacer")
174
232
  );
175
- if (!e.length)
233
+ if (!n.length)
176
234
  return;
177
- const r = this.api.getDocumentModifier(), i = `${t}px`;
178
- e.forEach((u) => {
179
- r.modifyHtml(u).setStyle("height", i);
180
- }), r.apply(new g(`Update row spacing to ${t}px`));
235
+ const o = this.api.getDocumentModifier(), a = `${t}px`;
236
+ n.forEach((r) => {
237
+ o.modifyHtml(r).setStyle("height", a);
238
+ }), o.apply(new g(`Update row spacing to ${t}px`));
181
239
  }
240
+ // ========================================================================
241
+ // Mobile Spacing Handlers
242
+ // ========================================================================
182
243
  /**
183
- * Stores column spacing value in block data attribute
244
+ * Handles column spacing changes for mobile.
245
+ * Applies horizontal padding only to the mobile container elements.
184
246
  */
185
- _storeColumnSpacing(t) {
247
+ _onMobileColumnSpacingChange(t) {
186
248
  if (!this.currentNode)
187
249
  return;
188
- const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
189
- e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(P.COLUMN_SPACING, t.toString()).apply(new g("Store column spacing"));
250
+ d.updateConfig(
251
+ this.api,
252
+ this.currentNode,
253
+ { mobileColumnSpacing: t },
254
+ `Changed mobile column spacing to ${t}px`
255
+ ), this._storeDataAttribute(O.MOBILE_COLUMN_SPACING, t);
256
+ const n = d.getConfig(this.currentNode).layout || b(this.currentNode), o = this.api.getDocumentModifier(), r = `0 ${t / 2}px`, l = this.currentNode.querySelector(E);
257
+ l && (n === "grid" ? Array.from(
258
+ l.querySelectorAll(".attribute-cell")
259
+ ).forEach((s) => {
260
+ o.modifyHtml(s).setStyle("padding", r);
261
+ }) : Array.from(
262
+ l.querySelectorAll(".product-card-wrapper")
263
+ ).forEach((s) => {
264
+ "parent" in s && s.parent() && o.modifyHtml(s.parent()).setStyle("padding", r);
265
+ }), o.apply(new g(`Update mobile column spacing to ${t}px`)));
190
266
  }
191
267
  /**
192
- * Stores row spacing value in block data attribute
268
+ * Handles row spacing changes for mobile.
269
+ * Applies height only to spacer elements in the mobile container.
193
270
  */
194
- _storeRowSpacing(t) {
271
+ _onMobileRowSpacingChange(t) {
195
272
  if (!this.currentNode)
196
273
  return;
197
- const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
198
- e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(P.ROW_SPACING, t.toString()).apply(new g("Store row spacing"));
274
+ d.updateConfig(
275
+ this.api,
276
+ this.currentNode,
277
+ { mobileRowSpacing: t },
278
+ `Changed mobile row spacing to ${t}px`
279
+ ), this._storeDataAttribute(O.MOBILE_ROW_SPACING, t);
280
+ const e = this.currentNode.querySelector(E);
281
+ if (!e)
282
+ return;
283
+ const n = Array.from(
284
+ e.querySelectorAll(".spacer")
285
+ );
286
+ if (!n.length)
287
+ return;
288
+ const o = this.api.getDocumentModifier(), a = `${t}px`;
289
+ n.forEach((r) => {
290
+ o.modifyHtml(r).setStyle("height", a);
291
+ }), o.apply(new g(`Update mobile row spacing to ${t}px`));
199
292
  }
293
+ // ========================================================================
294
+ // Data Attribute Storage
295
+ // ========================================================================
296
+ /**
297
+ * Stores a spacing value as a data attribute on the block root element
298
+ */
299
+ _storeDataAttribute(t, e) {
300
+ const n = x(this.currentNode);
301
+ n && this.api.getDocumentModifier().modifyHtml(n).setAttribute(t, e.toString()).apply(new g(`Store ${t}`));
302
+ }
303
+ // ========================================================================
304
+ // Event Listeners
305
+ // ========================================================================
200
306
  _listenToFormUpdates() {
201
- this.api.onValueChanged(s.COLUMN_SPACING, (t) => {
307
+ this.api.onValueChanged(i.COLUMN_SPACING, (t) => {
202
308
  const e = parseInt(t);
203
309
  Number.isNaN(e) || this._debouncedOnColumnSpacingChange(e);
204
- }), this.api.onValueChanged(s.ROW_SPACING, (t) => {
310
+ }), this.api.onValueChanged(i.ROW_SPACING, (t) => {
205
311
  const e = parseInt(t);
206
312
  Number.isNaN(e) || this._debouncedOnRowSpacingChange(e);
313
+ }), this.api.onValueChanged(i.MOBILE_COLUMN_SPACING, (t) => {
314
+ const e = parseInt(t);
315
+ Number.isNaN(e) || this._debouncedOnMobileColumnSpacingChange(e);
316
+ }), this.api.onValueChanged(i.MOBILE_ROW_SPACING, (t) => {
317
+ const e = parseInt(t);
318
+ Number.isNaN(e) || this._debouncedOnMobileRowSpacingChange(e);
207
319
  });
208
320
  }
209
321
  /**
210
322
  * Subscribe to store orientation changes
211
- * Updates column spacing visibility when layout changes via the layout control
323
+ * Updates spacing visibility when layout changes via the layout control
212
324
  */
213
325
  _subscribeToOrientationChanges() {
214
326
  this.unsubscribeOrientation && this.unsubscribeOrientation(), this.unsubscribeOrientation = this.store.$subscribe((t) => {
215
- t.type === "patch object" && this._updateColumnSpacingVisibility();
327
+ t.type === "patch object" && (this._updateSpacingVisibility(), this._setFormValues());
216
328
  });
217
329
  }
330
+ /**
331
+ * Subscribes to editor preview mode changes via Stripo API.
332
+ * Toggles which spacing controls (desktop/mobile) are visible.
333
+ */
334
+ _subscribeToEditorModeChanges() {
335
+ this.api.onEditorStatePropUpdated(
336
+ y.previewDeviceMode,
337
+ () => {
338
+ this._updateSpacingVisibility();
339
+ }
340
+ );
341
+ }
218
342
  }
219
343
  export {
220
- R as SPACING_CONTROL_ID,
221
- $ as SpacingControl
344
+ W as SPACING_CONTROL_ID,
345
+ X as SpacingControl
222
346
  };