@useinsider/guido 3.0.0-beta.34a1600 → 3.0.0-beta.39155d9
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/@types/config/schemas.js +10 -8
- package/dist/components/Guido.vue.js +3 -3
- package/dist/components/Guido.vue2.js +61 -60
- package/dist/components/organisms/header/EditorActions.vue.js +1 -1
- package/dist/components/organisms/header/EditorActions.vue2.js +6 -6
- package/dist/composables/useCustomFieldAttributes.js +16 -0
- package/dist/composables/useHtmlValidator.js +40 -38
- package/dist/config/compiler/unsubscribeCompilerRules.js +14 -14
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +29 -18
- package/dist/extensions/Blocks/Recommendation/block.js +40 -55
- package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +34 -36
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -12
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +4 -4
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +693 -144
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +78 -0
- package/dist/extensions/Blocks/Recommendation/controls/{main/layoutOrientation.js → layout/index.js} +27 -32
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +15 -15
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +24 -24
- package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +2 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +78 -107
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +2 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +64 -150
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +2 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +191 -177
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +8 -25
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -6
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +21 -21
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +13 -13
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +17 -17
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +100 -94
- package/dist/extensions/Blocks/Recommendation/extension.js +27 -25
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +125 -36
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +111 -99
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +2 -2
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +63 -34
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -33
- package/dist/extensions/Blocks/Recommendation/templates/index.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +28 -13
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +25 -44
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +62 -38
- package/dist/extensions/Blocks/common-control.js +41 -90
- package/dist/guido.css +1 -1
- package/dist/services/customFieldAttributesApi.js +21 -0
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/components/Guido.vue.d.ts +1 -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/useConfig.d.ts +2 -0
- package/dist/src/composables/useCustomFieldAttributes.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +2 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +7 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.d.ts +25 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +134 -44
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +105 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +3 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/{main/layoutOrientation.d.ts → layout/index.d.ts} +3 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +20 -38
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +1 -23
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +18 -8
- package/dist/src/extensions/Blocks/Recommendation/controls/spacingControl.d.ts +60 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +10 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +37 -2
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -13
- package/dist/src/extensions/Blocks/common-control.d.ts +2 -24
- package/dist/src/mock/api/custom-field-attributes.d.ts +2 -0
- package/dist/src/services/customFieldAttributesApi.d.ts +3 -0
- package/dist/src/stores/config.d.ts +18 -0
- package/dist/static/styles/components/wide-panel.css.js +0 -1
- package/dist/static/styles/customEditorStyle.css.js +0 -9
- package/dist/static/styles/variables.css.js +3 -0
- package/package.json +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +0 -58
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +0 -65
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productCount.d.ts +0 -28
- package/dist/src/extensions/Blocks/Recommendation/controls/syncInfoMessage.d.ts +0 -34
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
1
|
+
import { ModificationDescription as c } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as a } from "../../../common-control.js";
|
|
3
3
|
import { RecommendationBlockId as l } from "../../constants/blockIds.js";
|
|
4
4
|
import { RecommendationControlId as d } from "../../constants/controlIds.js";
|
|
5
5
|
import { BLOCK_ROOT_SELECTOR as T } from "../../constants/selectors.js";
|
|
6
6
|
import { preserveTextStyles as f } from "../../utils/preserveTextStyles.js";
|
|
7
7
|
const i = "data-text-after", u = "", p = ".omnibus-text-after";
|
|
8
|
-
class g extends
|
|
8
|
+
class g extends a {
|
|
9
9
|
getId() {
|
|
10
10
|
return d.OMNIBUS_DISCOUNT_TEXT_AFTER;
|
|
11
11
|
}
|
|
@@ -13,10 +13,10 @@ class g extends c {
|
|
|
13
13
|
return `
|
|
14
14
|
<div class="omnibus-discount-text-after-control-container">
|
|
15
15
|
${this._GuTwoColumns([
|
|
16
|
-
this._GuLabel({ text:
|
|
16
|
+
this._GuLabel({ text: "Text After" }),
|
|
17
17
|
this._GuTextInput({
|
|
18
18
|
name: "omnibusDiscountTextAfter",
|
|
19
|
-
placeholder:
|
|
19
|
+
placeholder: "e.g., off!",
|
|
20
20
|
className: "es-180w"
|
|
21
21
|
})
|
|
22
22
|
])}
|
|
@@ -57,10 +57,10 @@ class g extends c {
|
|
|
57
57
|
o.modifyHtml(s).setAttribute(i, t);
|
|
58
58
|
const r = s.querySelector(p);
|
|
59
59
|
if (r) {
|
|
60
|
-
const
|
|
61
|
-
o.modifyHtml(r).setInnerHtml(
|
|
60
|
+
const m = f(r, t);
|
|
61
|
+
o.modifyHtml(r).setInnerHtml(m);
|
|
62
62
|
}
|
|
63
|
-
}), o.apply(new
|
|
63
|
+
}), o.apply(new c("Update omnibus discount text after"));
|
|
64
64
|
}
|
|
65
65
|
_listenToFormUpdates() {
|
|
66
66
|
this.api.onValueChanged("omnibusDiscountTextAfter", (t) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { RecommendationBlockId as
|
|
1
|
+
import { ModificationDescription as c } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as l } from "../../../common-control.js";
|
|
3
|
+
import { RecommendationBlockId as a } from "../../constants/blockIds.js";
|
|
4
4
|
import { RecommendationControlId as d } from "../../constants/controlIds.js";
|
|
5
5
|
import { BLOCK_ROOT_SELECTOR as T } from "../../constants/selectors.js";
|
|
6
6
|
import { preserveTextStyles as f } from "../../utils/preserveTextStyles.js";
|
|
7
7
|
const i = "data-text-before", u = "", p = ".omnibus-text-before";
|
|
8
|
-
class g extends
|
|
8
|
+
class g extends l {
|
|
9
9
|
getId() {
|
|
10
10
|
return d.OMNIBUS_DISCOUNT_TEXT_BEFORE;
|
|
11
11
|
}
|
|
@@ -13,10 +13,10 @@ class g extends c {
|
|
|
13
13
|
return `
|
|
14
14
|
<div class="omnibus-discount-text-before-control-container">
|
|
15
15
|
${this._GuTwoColumns([
|
|
16
|
-
this._GuLabel({ text:
|
|
16
|
+
this._GuLabel({ text: "Text Before" }),
|
|
17
17
|
this._GuTextInput({
|
|
18
18
|
name: "omnibusDiscountTextBefore",
|
|
19
|
-
placeholder:
|
|
19
|
+
placeholder: "e.g., Save ",
|
|
20
20
|
className: "es-180w"
|
|
21
21
|
})
|
|
22
22
|
])}
|
|
@@ -26,45 +26,45 @@ class g extends c {
|
|
|
26
26
|
onRender() {
|
|
27
27
|
this._setFormValues(), this._listenToFormUpdates();
|
|
28
28
|
}
|
|
29
|
-
onTemplateNodeUpdated(
|
|
30
|
-
super.onTemplateNodeUpdated(
|
|
29
|
+
onTemplateNodeUpdated(e) {
|
|
30
|
+
super.onTemplateNodeUpdated(e), this._setFormValues();
|
|
31
31
|
}
|
|
32
32
|
_setFormValues() {
|
|
33
|
-
const
|
|
33
|
+
const e = this._getCurrentText();
|
|
34
34
|
this.api.updateValues({
|
|
35
|
-
omnibusDiscountTextBefore:
|
|
35
|
+
omnibusDiscountTextBefore: e
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
_getCurrentText() {
|
|
39
39
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
40
40
|
return u;
|
|
41
|
-
const
|
|
42
|
-
return
|
|
41
|
+
const e = this.currentNode.getAttribute(i);
|
|
42
|
+
return e === null ? u : e;
|
|
43
43
|
}
|
|
44
|
-
_onTextChange(
|
|
44
|
+
_onTextChange(e) {
|
|
45
45
|
if (!this.currentNode || !("closest" in this.currentNode))
|
|
46
46
|
return;
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
47
|
+
const t = this.currentNode.closest(T);
|
|
48
|
+
if (!t || !("querySelectorAll" in t))
|
|
49
49
|
return;
|
|
50
50
|
const n = Array.from(
|
|
51
|
-
|
|
51
|
+
t.querySelectorAll(`[esd-extension-block-id="${a.OMNIBUS_DISCOUNT}"]`)
|
|
52
52
|
);
|
|
53
53
|
if (!n.length)
|
|
54
54
|
return;
|
|
55
55
|
const o = this.api.getDocumentModifier();
|
|
56
56
|
n.forEach((s) => {
|
|
57
|
-
o.modifyHtml(s).setAttribute(i,
|
|
57
|
+
o.modifyHtml(s).setAttribute(i, e);
|
|
58
58
|
const r = s.querySelector(p);
|
|
59
59
|
if (r) {
|
|
60
|
-
const m = f(r,
|
|
60
|
+
const m = f(r, e);
|
|
61
61
|
o.modifyHtml(r).setInnerHtml(m);
|
|
62
62
|
}
|
|
63
|
-
}), o.apply(new
|
|
63
|
+
}), o.apply(new c("Update omnibus discount text before"));
|
|
64
64
|
}
|
|
65
65
|
_listenToFormUpdates() {
|
|
66
|
-
this.api.onValueChanged("omnibusDiscountTextBefore", (
|
|
67
|
-
typeof
|
|
66
|
+
this.api.onValueChanged("omnibusDiscountTextBefore", (e) => {
|
|
67
|
+
typeof e == "string" && this._onTextChange(e);
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
1
|
+
import { ModificationDescription as c } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as a } from "../../../common-control.js";
|
|
3
3
|
import { RecommendationBlockId as l } from "../../constants/blockIds.js";
|
|
4
4
|
import { RecommendationControlId as d } from "../../constants/controlIds.js";
|
|
5
5
|
import { BLOCK_ROOT_SELECTOR as T } from "../../constants/selectors.js";
|
|
6
|
-
import { preserveTextStyles as
|
|
7
|
-
const s = "data-text-after",
|
|
8
|
-
class g extends
|
|
6
|
+
import { preserveTextStyles as f } from "../../utils/preserveTextStyles.js";
|
|
7
|
+
const s = "data-text-after", m = "", p = ".omnibus-text-after";
|
|
8
|
+
class g extends a {
|
|
9
9
|
getId() {
|
|
10
10
|
return d.OMNIBUS_PRICE_TEXT_AFTER;
|
|
11
11
|
}
|
|
@@ -13,10 +13,10 @@ class g extends c {
|
|
|
13
13
|
return `
|
|
14
14
|
<div class="omnibus-price-text-after-control-container">
|
|
15
15
|
${this._GuTwoColumns([
|
|
16
|
-
this._GuLabel({ text:
|
|
16
|
+
this._GuLabel({ text: "Text After" }),
|
|
17
17
|
this._GuTextInput({
|
|
18
18
|
name: "omnibusPriceTextAfter",
|
|
19
|
-
placeholder:
|
|
19
|
+
placeholder: "e.g., (incl. VAT)",
|
|
20
20
|
className: "es-180w"
|
|
21
21
|
})
|
|
22
22
|
])}
|
|
@@ -37,9 +37,9 @@ class g extends c {
|
|
|
37
37
|
}
|
|
38
38
|
_getCurrentText() {
|
|
39
39
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
40
|
-
return
|
|
40
|
+
return m;
|
|
41
41
|
const t = this.currentNode.getAttribute(s);
|
|
42
|
-
return t === null ?
|
|
42
|
+
return t === null ? m : t;
|
|
43
43
|
}
|
|
44
44
|
_onTextChange(t) {
|
|
45
45
|
if (!this.currentNode || !("closest" in this.currentNode))
|
|
@@ -55,12 +55,12 @@ class g extends c {
|
|
|
55
55
|
const r = this.api.getDocumentModifier();
|
|
56
56
|
n.forEach((i) => {
|
|
57
57
|
r.modifyHtml(i).setAttribute(s, t);
|
|
58
|
-
const o = i.querySelector(
|
|
58
|
+
const o = i.querySelector(p);
|
|
59
59
|
if (o) {
|
|
60
|
-
const
|
|
61
|
-
r.modifyHtml(o).setInnerHtml(
|
|
60
|
+
const u = f(o, t);
|
|
61
|
+
r.modifyHtml(o).setInnerHtml(u);
|
|
62
62
|
}
|
|
63
|
-
}), r.apply(new
|
|
63
|
+
}), r.apply(new c("Update omnibus price text after"));
|
|
64
64
|
}
|
|
65
65
|
_listenToFormUpdates() {
|
|
66
66
|
this.api.onValueChanged("omnibusPriceTextAfter", (t) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { RecommendationBlockId as
|
|
1
|
+
import { ModificationDescription as c } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as l } from "../../../common-control.js";
|
|
3
|
+
import { RecommendationBlockId as a } from "../../constants/blockIds.js";
|
|
4
4
|
import { RecommendationControlId as d } from "../../constants/controlIds.js";
|
|
5
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
6
|
-
import { preserveTextStyles as
|
|
7
|
-
const s = "data-text-before",
|
|
8
|
-
class g extends
|
|
5
|
+
import { BLOCK_ROOT_SELECTOR as T } from "../../constants/selectors.js";
|
|
6
|
+
import { preserveTextStyles as f } from "../../utils/preserveTextStyles.js";
|
|
7
|
+
const s = "data-text-before", m = "", p = ".omnibus-text-before";
|
|
8
|
+
class g extends l {
|
|
9
9
|
getId() {
|
|
10
10
|
return d.OMNIBUS_PRICE_TEXT_BEFORE;
|
|
11
11
|
}
|
|
@@ -13,10 +13,10 @@ class g extends c {
|
|
|
13
13
|
return `
|
|
14
14
|
<div class="omnibus-price-text-before-control-container">
|
|
15
15
|
${this._GuTwoColumns([
|
|
16
|
-
this._GuLabel({ text:
|
|
16
|
+
this._GuLabel({ text: "Text Before" }),
|
|
17
17
|
this._GuTextInput({
|
|
18
18
|
name: "omnibusPriceTextBefore",
|
|
19
|
-
placeholder:
|
|
19
|
+
placeholder: "e.g., Lowest 30-day price: ",
|
|
20
20
|
className: "es-180w"
|
|
21
21
|
})
|
|
22
22
|
])}
|
|
@@ -37,30 +37,30 @@ class g extends c {
|
|
|
37
37
|
}
|
|
38
38
|
_getCurrentText() {
|
|
39
39
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
40
|
-
return
|
|
40
|
+
return m;
|
|
41
41
|
const e = this.currentNode.getAttribute(s);
|
|
42
|
-
return e === null ?
|
|
42
|
+
return e === null ? m : e;
|
|
43
43
|
}
|
|
44
44
|
_onTextChange(e) {
|
|
45
45
|
if (!this.currentNode || !("closest" in this.currentNode))
|
|
46
46
|
return;
|
|
47
|
-
const t = this.currentNode.closest(
|
|
47
|
+
const t = this.currentNode.closest(T);
|
|
48
48
|
if (!t || !("querySelectorAll" in t))
|
|
49
49
|
return;
|
|
50
50
|
const n = Array.from(
|
|
51
|
-
t.querySelectorAll(`[esd-extension-block-id="${
|
|
51
|
+
t.querySelectorAll(`[esd-extension-block-id="${a.OMNIBUS_PRICE}"]`)
|
|
52
52
|
);
|
|
53
53
|
if (!n.length)
|
|
54
54
|
return;
|
|
55
55
|
const o = this.api.getDocumentModifier();
|
|
56
56
|
n.forEach((i) => {
|
|
57
57
|
o.modifyHtml(i).setAttribute(s, e);
|
|
58
|
-
const r = i.querySelector(
|
|
58
|
+
const r = i.querySelector(p);
|
|
59
59
|
if (r) {
|
|
60
|
-
const
|
|
61
|
-
o.modifyHtml(r).setInnerHtml(
|
|
60
|
+
const u = f(r, e);
|
|
61
|
+
o.modifyHtml(r).setInnerHtml(u);
|
|
62
62
|
}
|
|
63
|
-
}), o.apply(new
|
|
63
|
+
}), o.apply(new c("Update omnibus price text before"));
|
|
64
64
|
}
|
|
65
65
|
_listenToFormUpdates() {
|
|
66
66
|
this.api.onValueChanged("omnibusPriceTextBefore", (e) => {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var G = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var h = (
|
|
4
|
-
import { ModificationDescription as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { DESKTOP_CONTAINER_SELECTOR as m, MOBILE_CONTAINER_SELECTOR as
|
|
7
|
-
import { SPACING_STEP as S, MAX_SPACING as _, MIN_SPACING as N, DEFAULT_COLUMN_SPACING as C, DEFAULT_ROW_SPACING as
|
|
8
|
-
import { RecommendationConfigService as
|
|
9
|
-
import { useRecommendationExtensionStore as
|
|
10
|
-
import { safeGetStyle as A, safeGetParent as
|
|
11
|
-
import { getCurrentLayout as b, getBlockElement as
|
|
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";
|
|
8
|
+
import { RecommendationConfigService as d } 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
12
|
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
13
|
-
const
|
|
13
|
+
const W = "recommendation-spacing-control", i = {
|
|
14
14
|
COLUMN_SPACING: "columnSpacing",
|
|
15
15
|
COLUMN_SPACING_LABEL: "columnSpacingLabel",
|
|
16
16
|
ROW_SPACING: "rowSpacing",
|
|
@@ -25,16 +25,16 @@ const U = "recommendation-spacing-control", n = {
|
|
|
25
25
|
MOBILE_COLUMN_SPACING: "data-mobile-column-spacing",
|
|
26
26
|
MOBILE_ROW_SPACING: "data-mobile-row-spacing"
|
|
27
27
|
};
|
|
28
|
-
function L(
|
|
29
|
-
if (!
|
|
28
|
+
function L(p, c) {
|
|
29
|
+
if (!p)
|
|
30
30
|
return c;
|
|
31
|
-
const t = parseFloat(
|
|
31
|
+
const t = parseFloat(p);
|
|
32
32
|
return Number.isNaN(t) ? c : t;
|
|
33
33
|
}
|
|
34
|
-
class
|
|
34
|
+
class X extends V {
|
|
35
35
|
constructor() {
|
|
36
36
|
super(...arguments);
|
|
37
|
-
h(this, "store",
|
|
37
|
+
h(this, "store", B());
|
|
38
38
|
h(this, "unsubscribeOrientation", null);
|
|
39
39
|
/**
|
|
40
40
|
* Debounced version of _onColumnSpacingChange
|
|
@@ -63,48 +63,39 @@ class j extends R {
|
|
|
63
63
|
}, 300));
|
|
64
64
|
}
|
|
65
65
|
getId() {
|
|
66
|
-
return
|
|
66
|
+
return W;
|
|
67
67
|
}
|
|
68
68
|
getTemplate() {
|
|
69
69
|
return `
|
|
70
70
|
<div class="spacing-control-container">
|
|
71
71
|
${this._GuTwoColumns([
|
|
72
|
-
this._GuLabel({
|
|
73
|
-
text: this.api.translate("Column Spacing (px)"),
|
|
74
|
-
name: n.COLUMN_SPACING_LABEL
|
|
75
|
-
}),
|
|
72
|
+
this._GuLabel({ text: "Column Spacing on Desktop (px)", name: i.COLUMN_SPACING_LABEL }),
|
|
76
73
|
this._GuCounter({
|
|
77
|
-
name:
|
|
74
|
+
name: i.COLUMN_SPACING,
|
|
78
75
|
minValue: N,
|
|
79
76
|
maxValue: _,
|
|
80
77
|
step: S
|
|
81
78
|
}),
|
|
82
|
-
this._GuLabel({
|
|
83
|
-
text: this.api.translate("Row Spacing (px)"),
|
|
84
|
-
name: n.ROW_SPACING_LABEL
|
|
85
|
-
}),
|
|
79
|
+
this._GuLabel({ text: "Row Spacing on Desktop (px)", name: i.ROW_SPACING_LABEL }),
|
|
86
80
|
this._GuCounter({
|
|
87
|
-
name:
|
|
81
|
+
name: i.ROW_SPACING,
|
|
88
82
|
minValue: N,
|
|
89
83
|
maxValue: _,
|
|
90
84
|
step: S
|
|
91
85
|
}),
|
|
92
86
|
this._GuLabel({
|
|
93
|
-
text:
|
|
94
|
-
name:
|
|
87
|
+
text: "Column Spacing on Mobile (px)",
|
|
88
|
+
name: i.MOBILE_COLUMN_SPACING_LABEL
|
|
95
89
|
}),
|
|
96
90
|
this._GuCounter({
|
|
97
|
-
name:
|
|
91
|
+
name: i.MOBILE_COLUMN_SPACING,
|
|
98
92
|
minValue: N,
|
|
99
93
|
maxValue: _,
|
|
100
94
|
step: S
|
|
101
95
|
}),
|
|
102
|
-
this._GuLabel({
|
|
103
|
-
text: this.api.translate("Row Spacing on Mobile (px)"),
|
|
104
|
-
name: n.MOBILE_ROW_SPACING_LABEL
|
|
105
|
-
}),
|
|
96
|
+
this._GuLabel({ text: "Row Spacing on Mobile (px)", name: i.MOBILE_ROW_SPACING_LABEL }),
|
|
106
97
|
this._GuCounter({
|
|
107
|
-
name:
|
|
98
|
+
name: i.MOBILE_ROW_SPACING,
|
|
108
99
|
minValue: N,
|
|
109
100
|
maxValue: _,
|
|
110
101
|
step: S
|
|
@@ -114,7 +105,7 @@ class j extends R {
|
|
|
114
105
|
`;
|
|
115
106
|
}
|
|
116
107
|
onRender() {
|
|
117
|
-
this._setFormValues(), this._updateSpacingVisibility(), this._listenToFormUpdates(), this._subscribeToOrientationChanges();
|
|
108
|
+
this._setFormValues(), this._updateSpacingVisibility(), this._listenToFormUpdates(), this._subscribeToOrientationChanges(), this._subscribeToEditorModeChanges();
|
|
118
109
|
}
|
|
119
110
|
onTemplateNodeUpdated(t) {
|
|
120
111
|
super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateSpacingVisibility();
|
|
@@ -123,23 +114,26 @@ class j extends R {
|
|
|
123
114
|
this.unsubscribeOrientation && (this.unsubscribeOrientation(), this.unsubscribeOrientation = null);
|
|
124
115
|
}
|
|
125
116
|
/**
|
|
126
|
-
*
|
|
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.
|
|
127
126
|
* - List layout: hide column spacing (products are full-width), hide ALL mobile
|
|
128
127
|
* spacing controls (list is responsive — single row spacing applies to both views)
|
|
129
|
-
* - Desktop
|
|
130
|
-
* - Mobile
|
|
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
131
|
*/
|
|
132
132
|
_updateSpacingVisibility() {
|
|
133
133
|
if (!this.api)
|
|
134
134
|
return;
|
|
135
|
-
const t =
|
|
136
|
-
this.api.setVisibility(
|
|
137
|
-
n.MOBILE_COLUMN_SPACING,
|
|
138
|
-
i && a && l
|
|
139
|
-
), this.api.setVisibility(
|
|
140
|
-
n.MOBILE_COLUMN_SPACING_LABEL,
|
|
141
|
-
i && a && l
|
|
142
|
-
), this.api.setVisibility(n.MOBILE_ROW_SPACING, i && a), this.api.setVisibility(n.MOBILE_ROW_SPACING_LABEL, i && a);
|
|
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);
|
|
143
137
|
}
|
|
144
138
|
/**
|
|
145
139
|
* Reads spacing values from node config first, falls back to DOM styles.
|
|
@@ -148,12 +142,12 @@ class j extends R {
|
|
|
148
142
|
_setFormValues() {
|
|
149
143
|
if (!this.api)
|
|
150
144
|
return;
|
|
151
|
-
const t =
|
|
145
|
+
const t = d.hasConfig(this.currentNode), e = d.getConfig(this.currentNode), n = t ? e.columnSpacing : this._getStoredColumnSpacing(), o = t ? e.rowSpacing : this._getStoredRowSpacing();
|
|
152
146
|
this.api.updateValues({
|
|
153
|
-
[
|
|
154
|
-
[
|
|
155
|
-
[
|
|
156
|
-
[
|
|
147
|
+
[i.COLUMN_SPACING]: n,
|
|
148
|
+
[i.ROW_SPACING]: o,
|
|
149
|
+
[i.MOBILE_COLUMN_SPACING]: e.mobileColumnSpacing,
|
|
150
|
+
[i.MOBILE_ROW_SPACING]: e.mobileRowSpacing
|
|
157
151
|
});
|
|
158
152
|
}
|
|
159
153
|
/**
|
|
@@ -168,13 +162,13 @@ class j extends R {
|
|
|
168
162
|
return C;
|
|
169
163
|
const t = this.currentNode.querySelector(m) ?? this.currentNode;
|
|
170
164
|
if (b(this.currentNode) === "grid") {
|
|
171
|
-
const
|
|
165
|
+
const u = t.querySelector(".recommendation-attribute-row"), s = u == null ? void 0 : u.querySelector("td"), I = A(s, "padding");
|
|
172
166
|
if (!I)
|
|
173
167
|
return C;
|
|
174
|
-
const
|
|
175
|
-
return
|
|
168
|
+
const M = I.trim().split(/\s+/);
|
|
169
|
+
return M.length < 2 ? C : L(M[1], C / 2) * 2;
|
|
176
170
|
}
|
|
177
|
-
const
|
|
171
|
+
const n = t.querySelector(".product-card-wrapper"), o = U(n), a = A(o, "padding");
|
|
178
172
|
if (!a)
|
|
179
173
|
return C;
|
|
180
174
|
const r = a.trim().split(/\s+/);
|
|
@@ -186,9 +180,9 @@ class j extends R {
|
|
|
186
180
|
*/
|
|
187
181
|
_getStoredRowSpacing() {
|
|
188
182
|
if (!this.currentNode)
|
|
189
|
-
return
|
|
190
|
-
const e = (this.currentNode.querySelector(m) ?? this.currentNode).querySelector(".spacer"),
|
|
191
|
-
return L(
|
|
183
|
+
return P;
|
|
184
|
+
const e = (this.currentNode.querySelector(m) ?? this.currentNode).querySelector(".spacer"), n = A(e, "height");
|
|
185
|
+
return L(n, P);
|
|
192
186
|
}
|
|
193
187
|
// ========================================================================
|
|
194
188
|
// Desktop Spacing Handlers
|
|
@@ -200,22 +194,22 @@ class j extends R {
|
|
|
200
194
|
_onColumnSpacingChange(t) {
|
|
201
195
|
if (!this.currentNode)
|
|
202
196
|
return;
|
|
203
|
-
|
|
197
|
+
d.updateConfig(
|
|
204
198
|
this.api,
|
|
205
199
|
this.currentNode,
|
|
206
200
|
{ columnSpacing: t },
|
|
207
201
|
`Changed column spacing to ${t}px`
|
|
208
202
|
), this._storeDataAttribute(O.COLUMN_SPACING, t);
|
|
209
|
-
const
|
|
210
|
-
l && (
|
|
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(
|
|
211
205
|
l.querySelectorAll(".attribute-cell")
|
|
212
206
|
).forEach((s) => {
|
|
213
|
-
|
|
207
|
+
o.modifyHtml(s).setStyle("padding", r);
|
|
214
208
|
}) : Array.from(
|
|
215
209
|
l.querySelectorAll(".product-card-wrapper")
|
|
216
210
|
).forEach((s) => {
|
|
217
|
-
"parent" in s && s.parent() &&
|
|
218
|
-
}),
|
|
211
|
+
"parent" in s && s.parent() && o.modifyHtml(s.parent()).setStyle("padding", r);
|
|
212
|
+
}), o.apply(new g(`Update column spacing to ${t}px`)));
|
|
219
213
|
}
|
|
220
214
|
/**
|
|
221
215
|
* Handles row spacing changes for desktop.
|
|
@@ -224,7 +218,7 @@ class j extends R {
|
|
|
224
218
|
_onRowSpacingChange(t) {
|
|
225
219
|
if (!this.currentNode)
|
|
226
220
|
return;
|
|
227
|
-
|
|
221
|
+
d.updateConfig(
|
|
228
222
|
this.api,
|
|
229
223
|
this.currentNode,
|
|
230
224
|
{ rowSpacing: t },
|
|
@@ -233,15 +227,15 @@ class j extends R {
|
|
|
233
227
|
const e = this.currentNode.querySelector(m);
|
|
234
228
|
if (!e)
|
|
235
229
|
return;
|
|
236
|
-
const
|
|
230
|
+
const n = Array.from(
|
|
237
231
|
e.querySelectorAll(".spacer")
|
|
238
232
|
);
|
|
239
|
-
if (!
|
|
233
|
+
if (!n.length)
|
|
240
234
|
return;
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}),
|
|
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`));
|
|
245
239
|
}
|
|
246
240
|
// ========================================================================
|
|
247
241
|
// Mobile Spacing Handlers
|
|
@@ -253,22 +247,22 @@ class j extends R {
|
|
|
253
247
|
_onMobileColumnSpacingChange(t) {
|
|
254
248
|
if (!this.currentNode)
|
|
255
249
|
return;
|
|
256
|
-
|
|
250
|
+
d.updateConfig(
|
|
257
251
|
this.api,
|
|
258
252
|
this.currentNode,
|
|
259
253
|
{ mobileColumnSpacing: t },
|
|
260
254
|
`Changed mobile column spacing to ${t}px`
|
|
261
255
|
), this._storeDataAttribute(O.MOBILE_COLUMN_SPACING, t);
|
|
262
|
-
const
|
|
263
|
-
l && (
|
|
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(
|
|
264
258
|
l.querySelectorAll(".attribute-cell")
|
|
265
259
|
).forEach((s) => {
|
|
266
|
-
|
|
260
|
+
o.modifyHtml(s).setStyle("padding", r);
|
|
267
261
|
}) : Array.from(
|
|
268
262
|
l.querySelectorAll(".product-card-wrapper")
|
|
269
263
|
).forEach((s) => {
|
|
270
|
-
"parent" in s && s.parent() &&
|
|
271
|
-
}),
|
|
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`)));
|
|
272
266
|
}
|
|
273
267
|
/**
|
|
274
268
|
* Handles row spacing changes for mobile.
|
|
@@ -277,24 +271,24 @@ class j extends R {
|
|
|
277
271
|
_onMobileRowSpacingChange(t) {
|
|
278
272
|
if (!this.currentNode)
|
|
279
273
|
return;
|
|
280
|
-
|
|
274
|
+
d.updateConfig(
|
|
281
275
|
this.api,
|
|
282
276
|
this.currentNode,
|
|
283
277
|
{ mobileRowSpacing: t },
|
|
284
278
|
`Changed mobile row spacing to ${t}px`
|
|
285
279
|
), this._storeDataAttribute(O.MOBILE_ROW_SPACING, t);
|
|
286
|
-
const e = this.currentNode.querySelector(
|
|
280
|
+
const e = this.currentNode.querySelector(E);
|
|
287
281
|
if (!e)
|
|
288
282
|
return;
|
|
289
|
-
const
|
|
283
|
+
const n = Array.from(
|
|
290
284
|
e.querySelectorAll(".spacer")
|
|
291
285
|
);
|
|
292
|
-
if (!
|
|
286
|
+
if (!n.length)
|
|
293
287
|
return;
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}),
|
|
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`));
|
|
298
292
|
}
|
|
299
293
|
// ========================================================================
|
|
300
294
|
// Data Attribute Storage
|
|
@@ -303,23 +297,23 @@ class j extends R {
|
|
|
303
297
|
* Stores a spacing value as a data attribute on the block root element
|
|
304
298
|
*/
|
|
305
299
|
_storeDataAttribute(t, e) {
|
|
306
|
-
const
|
|
307
|
-
|
|
300
|
+
const n = x(this.currentNode);
|
|
301
|
+
n && this.api.getDocumentModifier().modifyHtml(n).setAttribute(t, e.toString()).apply(new g(`Store ${t}`));
|
|
308
302
|
}
|
|
309
303
|
// ========================================================================
|
|
310
304
|
// Event Listeners
|
|
311
305
|
// ========================================================================
|
|
312
306
|
_listenToFormUpdates() {
|
|
313
|
-
this.api.onValueChanged(
|
|
307
|
+
this.api.onValueChanged(i.COLUMN_SPACING, (t) => {
|
|
314
308
|
const e = parseInt(t);
|
|
315
309
|
Number.isNaN(e) || this._debouncedOnColumnSpacingChange(e);
|
|
316
|
-
}), this.api.onValueChanged(
|
|
310
|
+
}), this.api.onValueChanged(i.ROW_SPACING, (t) => {
|
|
317
311
|
const e = parseInt(t);
|
|
318
312
|
Number.isNaN(e) || this._debouncedOnRowSpacingChange(e);
|
|
319
|
-
}), this.api.onValueChanged(
|
|
313
|
+
}), this.api.onValueChanged(i.MOBILE_COLUMN_SPACING, (t) => {
|
|
320
314
|
const e = parseInt(t);
|
|
321
315
|
Number.isNaN(e) || this._debouncedOnMobileColumnSpacingChange(e);
|
|
322
|
-
}), this.api.onValueChanged(
|
|
316
|
+
}), this.api.onValueChanged(i.MOBILE_ROW_SPACING, (t) => {
|
|
323
317
|
const e = parseInt(t);
|
|
324
318
|
Number.isNaN(e) || this._debouncedOnMobileRowSpacingChange(e);
|
|
325
319
|
});
|
|
@@ -333,8 +327,20 @@ class j extends R {
|
|
|
333
327
|
t.type === "patch object" && (this._updateSpacingVisibility(), this._setFormValues());
|
|
334
328
|
});
|
|
335
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
|
+
}
|
|
336
342
|
}
|
|
337
343
|
export {
|
|
338
|
-
|
|
339
|
-
|
|
344
|
+
W as SPACING_CONTROL_ID,
|
|
345
|
+
X as SpacingControl
|
|
340
346
|
};
|