@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.
- package/README.md +41 -2
- package/dist/@types/config/schemas.js +1 -1
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +66 -66
- 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/components/organisms/extensions/recommendation/FilterItem.vue.js +11 -13
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +54 -23
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +7 -5
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +34 -21
- package/dist/components/organisms/extensions/recommendation/Filters.vue.js +11 -11
- package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +48 -36
- package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue2.js +11 -9
- package/dist/composables/useRecommendation.js +9 -9
- package/dist/composables/useSave.js +16 -12
- package/dist/composables/useStripo.js +66 -62
- package/dist/composables/useStripoEventHandler.js +27 -12
- package/dist/composables/useSyncModuleExtractor.js +45 -0
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +1 -1
- package/dist/config/migrator/recommendationMigrator.js +1 -1
- package/dist/enums/unsubscribe.js +25 -21
- package/dist/extensions/Blocks/Recommendation/block.js +1 -1
- 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 +15 -13
- 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 +41 -29
- 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 +194 -104
- 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 +291 -217
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +14 -14
- 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 +13 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +223 -99
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +172 -85
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +2 -2
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +1 -1
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +2 -2
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +32 -32
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +8 -8
- package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +29 -0
- package/dist/guido.css +1 -1
- package/dist/services/stripoApi.js +55 -19
- package/dist/src/@types/config/schemas.d.ts +1 -1
- package/dist/src/@types/events.d.ts +38 -2
- package/dist/src/App.vue.d.ts +0 -1
- package/dist/src/components/Guido.vue.d.ts +2 -2
- package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +1 -0
- package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
- package/dist/src/composables/useGuidoActions.d.ts +1 -1
- package/dist/src/composables/useSave.d.ts +2 -2
- package/dist/src/composables/useStripo.d.ts +2 -2
- package/dist/src/composables/useSyncModuleExtractor.d.ts +4 -0
- package/dist/src/enums/unsubscribe.d.ts +3 -0
- 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 +8 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +38 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +27 -14
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +50 -17
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +19 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/migration.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +4 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/filterSchema.d.ts +15 -0
- package/dist/src/main.d.ts +3 -1
- package/dist/src/mock/api/settings.d.ts +2 -0
- package/dist/src/services/stripoApi.d.ts +5 -0
- package/dist/src/stores/editor.d.ts +23 -0
- package/dist/src/utils/templatePreparation.d.ts +1 -1
- package/dist/static/styles/customEditorStyle.css.js +50 -23
- package/dist/stores/editor.js +2 -1
- package/dist/utils/templatePreparation.js +1 -1
- package/package.json +2 -2
|
@@ -1,140 +1,195 @@
|
|
|
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 {
|
|
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
|
|
9
|
-
import { safeGetStyle as
|
|
10
|
-
import { getCurrentLayout as
|
|
11
|
-
import { useDebounceFn as
|
|
12
|
-
const
|
|
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(p, c) {
|
|
29
|
+
if (!p)
|
|
30
|
+
return c;
|
|
31
|
+
const t = parseFloat(p);
|
|
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 }),
|
|
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:
|
|
56
|
-
minValue:
|
|
57
|
-
maxValue:
|
|
58
|
-
step:
|
|
81
|
+
name: i.ROW_SPACING,
|
|
82
|
+
minValue: N,
|
|
83
|
+
maxValue: _,
|
|
84
|
+
step: S
|
|
59
85
|
}),
|
|
60
|
-
this._GuLabel({
|
|
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:
|
|
63
|
-
minValue:
|
|
64
|
-
maxValue:
|
|
65
|
-
step:
|
|
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
|
-
* 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
|
-
|
|
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,
|
|
89
|
-
this.api.setVisibility(
|
|
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.
|
|
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
|
-
[
|
|
100
|
-
[
|
|
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
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
|
120
|
-
if (!
|
|
121
|
-
return
|
|
122
|
-
const
|
|
123
|
-
return
|
|
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
|
|
131
|
-
const
|
|
132
|
-
return
|
|
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
|
-
*
|
|
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.
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
).forEach((
|
|
152
|
-
|
|
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
|
-
|
|
155
|
-
).forEach((
|
|
156
|
-
"parent" in
|
|
157
|
-
}),
|
|
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
|
|
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.
|
|
172
|
-
const e =
|
|
173
|
-
|
|
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 (!
|
|
233
|
+
if (!n.length)
|
|
176
234
|
return;
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}),
|
|
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
|
-
*
|
|
244
|
+
* Handles column spacing changes for mobile.
|
|
245
|
+
* Applies horizontal padding only to the mobile container elements.
|
|
184
246
|
*/
|
|
185
|
-
|
|
247
|
+
_onMobileColumnSpacingChange(t) {
|
|
186
248
|
if (!this.currentNode)
|
|
187
249
|
return;
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
*
|
|
268
|
+
* Handles row spacing changes for mobile.
|
|
269
|
+
* Applies height only to spacer elements in the mobile container.
|
|
193
270
|
*/
|
|
194
|
-
|
|
271
|
+
_onMobileRowSpacingChange(t) {
|
|
195
272
|
if (!this.currentNode)
|
|
196
273
|
return;
|
|
197
|
-
|
|
198
|
-
|
|
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(
|
|
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(
|
|
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
|
|
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.
|
|
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
|
-
|
|
221
|
-
|
|
344
|
+
W as SPACING_CONTROL_ID,
|
|
345
|
+
X as SpacingControl
|
|
222
346
|
};
|