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