@useinsider/guido 2.0.0-beta.c2c0829 → 2.0.0-beta.d170da6
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/extensions/Blocks/CouponBlock/constants.js +4 -0
- package/dist/extensions/Blocks/CouponBlock/controls/index.js +29 -0
- package/dist/extensions/Blocks/CouponBlock/extension.js +5 -4
- package/dist/extensions/Blocks/CouponBlock/settingsPanel.js +20 -14
- package/dist/extensions/Blocks/CouponBlock/template.js +22 -11
- package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +153 -69
- package/dist/extensions/Blocks/Recommendation/constants.js +9 -1
- package/dist/extensions/Blocks/Recommendation/control.js +74 -59
- package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +68 -0
- package/dist/extensions/Blocks/Recommendation/controls/index.js +245 -0
- package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +74 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.js +71 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.js +71 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.js +71 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.js +71 -0
- package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +188 -0
- package/dist/extensions/Blocks/Recommendation/extension.js +16 -42
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +117 -72
- package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +85 -64
- package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +54 -17
- package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +74 -45
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +25 -0
- package/dist/extensions/Blocks/controlFactories.js +122 -111
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +14 -14
- package/dist/src/extensions/Blocks/CouponBlock/constants.d.ts +14 -0
- package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +108 -0
- package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/cardCompositionControl.d.ts +50 -3
- package/dist/src/extensions/Blocks/Recommendation/constants.d.ts +32 -0
- package/dist/src/extensions/Blocks/Recommendation/control.d.ts +5 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.d.ts +25 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +592 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +16 -0
- 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/spacingControl.d.ts +60 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +15 -7
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +19 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +30 -7
- package/dist/static/styles/components/wide-panel.css.js +0 -4
- package/dist/static/styles/customEditorStyle.css.js +13 -0
- package/package.json +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/button/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/border.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/borderRadius.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/fitToContent.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/margins.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/text.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/textSize.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/image/margins.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/image/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/background.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/style.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/background.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/style.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/background.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/style.js +0 -13
- package/dist/src/extensions/Blocks/Recommendation/controls/button/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/border.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/borderRadius.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/fitToContent.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/margins.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/text.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/textSize.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/image/margins.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/image/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/background.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/style.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/background.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/style.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/background.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/style.d.ts +0 -5
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ModificationDescription as m } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as a } from "../../common-control.js";
|
|
3
|
+
import { RecommendationControlId as l, RecommendationBlockId as d } from "../constants.js";
|
|
4
|
+
import { preserveTextStyles as T } from "../utils/preserveTextStyles.js";
|
|
5
|
+
const f = ".ins-recommendation-product-container", i = "data-text-before", u = "", p = ".omnibus-text-before";
|
|
6
|
+
class C extends a {
|
|
7
|
+
getId() {
|
|
8
|
+
return l.OMNIBUS_DISCOUNT_TEXT_BEFORE;
|
|
9
|
+
}
|
|
10
|
+
getTemplate() {
|
|
11
|
+
return `
|
|
12
|
+
<div class="omnibus-discount-text-before-control-container">
|
|
13
|
+
${this._GuTwoColumns([
|
|
14
|
+
this._GuLabel({ text: "Text Before" }),
|
|
15
|
+
this._GuTextInput({
|
|
16
|
+
name: "omnibusDiscountTextBefore",
|
|
17
|
+
placeholder: "e.g., Save ",
|
|
18
|
+
className: "es-180w"
|
|
19
|
+
})
|
|
20
|
+
])}
|
|
21
|
+
</div>
|
|
22
|
+
`;
|
|
23
|
+
}
|
|
24
|
+
onRender() {
|
|
25
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
26
|
+
}
|
|
27
|
+
onTemplateNodeUpdated(e) {
|
|
28
|
+
super.onTemplateNodeUpdated(e), this._setFormValues();
|
|
29
|
+
}
|
|
30
|
+
_setFormValues() {
|
|
31
|
+
const e = this._getCurrentText();
|
|
32
|
+
this.api.updateValues({
|
|
33
|
+
omnibusDiscountTextBefore: e
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
_getCurrentText() {
|
|
37
|
+
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
38
|
+
return u;
|
|
39
|
+
const e = this.currentNode.getAttribute(i);
|
|
40
|
+
return e === null ? u : e;
|
|
41
|
+
}
|
|
42
|
+
_onTextChange(e) {
|
|
43
|
+
if (!this.currentNode || !("closest" in this.currentNode))
|
|
44
|
+
return;
|
|
45
|
+
const t = this.currentNode.closest(f);
|
|
46
|
+
if (!t || !("querySelectorAll" in t))
|
|
47
|
+
return;
|
|
48
|
+
const n = Array.from(
|
|
49
|
+
t.querySelectorAll(`[esd-extension-block-id="${d.OMNIBUS_DISCOUNT}"]`)
|
|
50
|
+
);
|
|
51
|
+
if (!n.length)
|
|
52
|
+
return;
|
|
53
|
+
const o = this.api.getDocumentModifier();
|
|
54
|
+
n.forEach((s) => {
|
|
55
|
+
o.modifyHtml(s).setAttribute(i, e);
|
|
56
|
+
const r = s.querySelector(p);
|
|
57
|
+
if (r) {
|
|
58
|
+
const c = T(r, e);
|
|
59
|
+
o.modifyHtml(r).setInnerHtml(c);
|
|
60
|
+
}
|
|
61
|
+
}), o.apply(new m("Update omnibus discount text before"));
|
|
62
|
+
}
|
|
63
|
+
_listenToFormUpdates() {
|
|
64
|
+
this.api.onValueChanged("omnibusDiscountTextBefore", (e) => {
|
|
65
|
+
this._onTextChange(e);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
C as OmnibusDiscountTextBeforeControl
|
|
71
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ModificationDescription as a } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as m } from "../../common-control.js";
|
|
3
|
+
import { RecommendationControlId as l, RecommendationBlockId as d } from "../constants.js";
|
|
4
|
+
import { preserveTextStyles as T } from "../utils/preserveTextStyles.js";
|
|
5
|
+
const f = ".ins-recommendation-product-container", s = "data-text-after", c = "", p = ".omnibus-text-after";
|
|
6
|
+
class C extends m {
|
|
7
|
+
getId() {
|
|
8
|
+
return l.OMNIBUS_PRICE_TEXT_AFTER;
|
|
9
|
+
}
|
|
10
|
+
getTemplate() {
|
|
11
|
+
return `
|
|
12
|
+
<div class="omnibus-price-text-after-control-container">
|
|
13
|
+
${this._GuTwoColumns([
|
|
14
|
+
this._GuLabel({ text: "Text After" }),
|
|
15
|
+
this._GuTextInput({
|
|
16
|
+
name: "omnibusPriceTextAfter",
|
|
17
|
+
placeholder: "e.g., (incl. VAT)",
|
|
18
|
+
className: "es-180w"
|
|
19
|
+
})
|
|
20
|
+
])}
|
|
21
|
+
</div>
|
|
22
|
+
`;
|
|
23
|
+
}
|
|
24
|
+
onRender() {
|
|
25
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
26
|
+
}
|
|
27
|
+
onTemplateNodeUpdated(t) {
|
|
28
|
+
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
29
|
+
}
|
|
30
|
+
_setFormValues() {
|
|
31
|
+
const t = this._getCurrentText();
|
|
32
|
+
this.api.updateValues({
|
|
33
|
+
omnibusPriceTextAfter: t
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
_getCurrentText() {
|
|
37
|
+
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
38
|
+
return c;
|
|
39
|
+
const t = this.currentNode.getAttribute(s);
|
|
40
|
+
return t === null ? c : t;
|
|
41
|
+
}
|
|
42
|
+
_onTextChange(t) {
|
|
43
|
+
if (!this.currentNode || !("closest" in this.currentNode))
|
|
44
|
+
return;
|
|
45
|
+
const e = this.currentNode.closest(f);
|
|
46
|
+
if (!e || !("querySelectorAll" in e))
|
|
47
|
+
return;
|
|
48
|
+
const n = Array.from(
|
|
49
|
+
e.querySelectorAll(`[esd-extension-block-id="${d.OMNIBUS_PRICE}"]`)
|
|
50
|
+
);
|
|
51
|
+
if (!n.length)
|
|
52
|
+
return;
|
|
53
|
+
const r = this.api.getDocumentModifier();
|
|
54
|
+
n.forEach((i) => {
|
|
55
|
+
r.modifyHtml(i).setAttribute(s, t);
|
|
56
|
+
const o = i.querySelector(p);
|
|
57
|
+
if (o) {
|
|
58
|
+
const u = T(o, t);
|
|
59
|
+
r.modifyHtml(o).setInnerHtml(u);
|
|
60
|
+
}
|
|
61
|
+
}), r.apply(new a("Update omnibus price text after"));
|
|
62
|
+
}
|
|
63
|
+
_listenToFormUpdates() {
|
|
64
|
+
this.api.onValueChanged("omnibusPriceTextAfter", (t) => {
|
|
65
|
+
this._onTextChange(t);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
C as OmnibusPriceTextAfterControl
|
|
71
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ModificationDescription as m } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as a } from "../../common-control.js";
|
|
3
|
+
import { RecommendationControlId as l, RecommendationBlockId as d } from "../constants.js";
|
|
4
|
+
import { preserveTextStyles as T } from "../utils/preserveTextStyles.js";
|
|
5
|
+
const p = ".ins-recommendation-product-container", s = "data-text-before", c = "Lowest 30-day price: ", f = ".omnibus-text-before";
|
|
6
|
+
class C extends a {
|
|
7
|
+
getId() {
|
|
8
|
+
return l.OMNIBUS_PRICE_TEXT_BEFORE;
|
|
9
|
+
}
|
|
10
|
+
getTemplate() {
|
|
11
|
+
return `
|
|
12
|
+
<div class="omnibus-price-text-before-control-container">
|
|
13
|
+
${this._GuTwoColumns([
|
|
14
|
+
this._GuLabel({ text: "Text Before" }),
|
|
15
|
+
this._GuTextInput({
|
|
16
|
+
name: "omnibusPriceTextBefore",
|
|
17
|
+
placeholder: "e.g., Lowest 30-day price: ",
|
|
18
|
+
className: "es-180w"
|
|
19
|
+
})
|
|
20
|
+
])}
|
|
21
|
+
</div>
|
|
22
|
+
`;
|
|
23
|
+
}
|
|
24
|
+
onRender() {
|
|
25
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
26
|
+
}
|
|
27
|
+
onTemplateNodeUpdated(e) {
|
|
28
|
+
super.onTemplateNodeUpdated(e), this._setFormValues();
|
|
29
|
+
}
|
|
30
|
+
_setFormValues() {
|
|
31
|
+
const e = this._getCurrentText();
|
|
32
|
+
this.api.updateValues({
|
|
33
|
+
omnibusPriceTextBefore: e
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
_getCurrentText() {
|
|
37
|
+
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
38
|
+
return c;
|
|
39
|
+
const e = this.currentNode.getAttribute(s);
|
|
40
|
+
return e === null ? c : e;
|
|
41
|
+
}
|
|
42
|
+
_onTextChange(e) {
|
|
43
|
+
if (!this.currentNode || !("closest" in this.currentNode))
|
|
44
|
+
return;
|
|
45
|
+
const t = this.currentNode.closest(p);
|
|
46
|
+
if (!t || !("querySelectorAll" in t))
|
|
47
|
+
return;
|
|
48
|
+
const n = Array.from(
|
|
49
|
+
t.querySelectorAll(`[esd-extension-block-id="${d.OMNIBUS_PRICE}"]`)
|
|
50
|
+
);
|
|
51
|
+
if (!n.length)
|
|
52
|
+
return;
|
|
53
|
+
const o = this.api.getDocumentModifier();
|
|
54
|
+
n.forEach((i) => {
|
|
55
|
+
o.modifyHtml(i).setAttribute(s, e);
|
|
56
|
+
const r = i.querySelector(f);
|
|
57
|
+
if (r) {
|
|
58
|
+
const u = T(r, e);
|
|
59
|
+
o.modifyHtml(r).setInnerHtml(u);
|
|
60
|
+
}
|
|
61
|
+
}), o.apply(new m("Update omnibus price text before"));
|
|
62
|
+
}
|
|
63
|
+
_listenToFormUpdates() {
|
|
64
|
+
this.api.onValueChanged("omnibusPriceTextBefore", (e) => {
|
|
65
|
+
this._onTextChange(e);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
C as OmnibusPriceTextBeforeControl
|
|
71
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var g = (i, r, e) => r in i ? C(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
|
|
3
|
+
var S = (i, r, e) => g(i, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { ModificationDescription as l } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as m } from "../../common-control.js";
|
|
6
|
+
import { useDebounceFn as d } from "../../../../node_modules/@vueuse/shared/index.js";
|
|
7
|
+
const _ = "recommendation-spacing-control", c = {
|
|
8
|
+
COLUMN_SPACING: "columnSpacing",
|
|
9
|
+
ROW_SPACING: "rowSpacing"
|
|
10
|
+
}, N = {
|
|
11
|
+
COLUMN_SPACING: "data-column-spacing",
|
|
12
|
+
ROW_SPACING: "data-row-spacing"
|
|
13
|
+
}, n = {
|
|
14
|
+
COLUMN_SPACING: 10,
|
|
15
|
+
// 5px on each side = 10px total
|
|
16
|
+
ROW_SPACING: 20
|
|
17
|
+
}, p = {
|
|
18
|
+
MIN_SPACING: 0,
|
|
19
|
+
MAX_SPACING: 50,
|
|
20
|
+
STEP: 5
|
|
21
|
+
};
|
|
22
|
+
class G extends m {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
/**
|
|
26
|
+
* Debounced version of _onColumnSpacingChange
|
|
27
|
+
* Prevents excessive DOM updates when user rapidly adjusts the counter
|
|
28
|
+
*/
|
|
29
|
+
S(this, "_debouncedOnColumnSpacingChange", d((e) => {
|
|
30
|
+
this._onColumnSpacingChange(e);
|
|
31
|
+
}, 300));
|
|
32
|
+
/**
|
|
33
|
+
* Debounced version of _onRowSpacingChange
|
|
34
|
+
* Prevents excessive DOM updates when user rapidly adjusts the counter
|
|
35
|
+
*/
|
|
36
|
+
S(this, "_debouncedOnRowSpacingChange", d((e) => {
|
|
37
|
+
this._onRowSpacingChange(e);
|
|
38
|
+
}, 300));
|
|
39
|
+
}
|
|
40
|
+
getId() {
|
|
41
|
+
return _;
|
|
42
|
+
}
|
|
43
|
+
getTemplate() {
|
|
44
|
+
return `
|
|
45
|
+
<div class="spacing-control-container">
|
|
46
|
+
${this._GuTwoColumns([
|
|
47
|
+
this._GuLabel({ text: "Column Spacing (px)" }),
|
|
48
|
+
this._GuCounter({
|
|
49
|
+
name: c.COLUMN_SPACING,
|
|
50
|
+
minValue: p.MIN_SPACING,
|
|
51
|
+
maxValue: p.MAX_SPACING,
|
|
52
|
+
step: p.STEP
|
|
53
|
+
}),
|
|
54
|
+
this._GuLabel({ text: "Row Spacing (px)" }),
|
|
55
|
+
this._GuCounter({
|
|
56
|
+
name: c.ROW_SPACING,
|
|
57
|
+
minValue: p.MIN_SPACING,
|
|
58
|
+
maxValue: p.MAX_SPACING,
|
|
59
|
+
step: p.STEP
|
|
60
|
+
})
|
|
61
|
+
])}
|
|
62
|
+
</div>
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
onRender() {
|
|
66
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
67
|
+
}
|
|
68
|
+
onTemplateNodeUpdated(e) {
|
|
69
|
+
super.onTemplateNodeUpdated(e), this._setFormValues();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Reads spacing values from data attributes or returns defaults
|
|
73
|
+
*/
|
|
74
|
+
_setFormValues() {
|
|
75
|
+
const e = this._getStoredColumnSpacing(), t = this._getStoredRowSpacing();
|
|
76
|
+
this.api.updateValues({
|
|
77
|
+
[c.COLUMN_SPACING]: e,
|
|
78
|
+
[c.ROW_SPACING]: t
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Gets stored column spacing from the first product card wrapper's parent element's padding
|
|
83
|
+
* Reads the actual padding value instead of relying on data attributes
|
|
84
|
+
*
|
|
85
|
+
* The padding is applied as "0 {halfSpacing}px" on the parent TD element,
|
|
86
|
+
* so we need to extract the horizontal padding value and multiply by 2 to get total spacing.
|
|
87
|
+
*/
|
|
88
|
+
_getStoredColumnSpacing() {
|
|
89
|
+
if (!this.currentNode)
|
|
90
|
+
return n.COLUMN_SPACING;
|
|
91
|
+
const e = this.currentNode.querySelector(".product-card-wrapper");
|
|
92
|
+
if (!e || !("parent" in e) || typeof e.parent != "function")
|
|
93
|
+
return n.COLUMN_SPACING;
|
|
94
|
+
const t = e.parent();
|
|
95
|
+
if (!t || !("getStyle" in t))
|
|
96
|
+
return n.COLUMN_SPACING;
|
|
97
|
+
const o = t.getStyle("padding");
|
|
98
|
+
if (!o)
|
|
99
|
+
return n.COLUMN_SPACING;
|
|
100
|
+
const u = o.trim().split(/\s+/);
|
|
101
|
+
if (u.length < 2)
|
|
102
|
+
return n.COLUMN_SPACING;
|
|
103
|
+
const [, a] = u, s = parseFloat(a);
|
|
104
|
+
return Number.isNaN(s) ? n.COLUMN_SPACING : s * 2;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Gets stored row spacing from the first spacer element's height style
|
|
108
|
+
* Reads the actual height value instead of relying on data attributes
|
|
109
|
+
*/
|
|
110
|
+
_getStoredRowSpacing() {
|
|
111
|
+
if (!this.currentNode)
|
|
112
|
+
return n.ROW_SPACING;
|
|
113
|
+
const e = this.currentNode.querySelector(".spacer");
|
|
114
|
+
if (!e || !("getStyle" in e))
|
|
115
|
+
return n.ROW_SPACING;
|
|
116
|
+
const t = e.getStyle("height");
|
|
117
|
+
if (!t)
|
|
118
|
+
return n.ROW_SPACING;
|
|
119
|
+
const o = parseFloat(t);
|
|
120
|
+
return Number.isNaN(o) ? n.ROW_SPACING : o;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Handles column spacing changes
|
|
124
|
+
* Applies horizontal padding to all product card wrappers
|
|
125
|
+
*/
|
|
126
|
+
_onColumnSpacingChange(e) {
|
|
127
|
+
if (!this.currentNode)
|
|
128
|
+
return;
|
|
129
|
+
const t = Array.from(
|
|
130
|
+
this.currentNode.querySelectorAll(".product-card-wrapper")
|
|
131
|
+
);
|
|
132
|
+
if (!t)
|
|
133
|
+
return;
|
|
134
|
+
const o = this.api.getDocumentModifier(), a = `0 ${e / 2}px`;
|
|
135
|
+
console.debug("padding", a), t.forEach((s) => {
|
|
136
|
+
"parent" in s && s.parent() && o.modifyHtml(s.parent()).setStyle("padding", a);
|
|
137
|
+
}), o.apply(new l(`Update column spacing to ${e}px`));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Handles row spacing changes
|
|
141
|
+
* Applies height to all spacer elements between product rows
|
|
142
|
+
*/
|
|
143
|
+
_onRowSpacingChange(e) {
|
|
144
|
+
if (!this.currentNode)
|
|
145
|
+
return;
|
|
146
|
+
this._storeRowSpacing(e);
|
|
147
|
+
const t = Array.from(
|
|
148
|
+
this.currentNode.querySelectorAll(".spacer")
|
|
149
|
+
);
|
|
150
|
+
if (console.debug("spacerCells", t), console.debug("spacing", e), !t.length)
|
|
151
|
+
return;
|
|
152
|
+
const o = this.api.getDocumentModifier(), u = `${e}px`;
|
|
153
|
+
t.forEach((a) => {
|
|
154
|
+
o.modifyHtml(a).setStyle("height", u);
|
|
155
|
+
}), o.apply(new l(`Update row spacing to ${e}px`));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Stores column spacing value in block data attribute
|
|
159
|
+
*/
|
|
160
|
+
_storeColumnSpacing(e) {
|
|
161
|
+
if (!this.currentNode)
|
|
162
|
+
return;
|
|
163
|
+
const t = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
|
|
164
|
+
t && this.api.getDocumentModifier().modifyHtml(t).setAttribute(N.COLUMN_SPACING, e.toString()).apply(new l("Store column spacing"));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Stores row spacing value in block data attribute
|
|
168
|
+
*/
|
|
169
|
+
_storeRowSpacing(e) {
|
|
170
|
+
if (!this.currentNode)
|
|
171
|
+
return;
|
|
172
|
+
const t = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
|
|
173
|
+
t && this.api.getDocumentModifier().modifyHtml(t).setAttribute(N.ROW_SPACING, e.toString()).apply(new l("Store row spacing"));
|
|
174
|
+
}
|
|
175
|
+
_listenToFormUpdates() {
|
|
176
|
+
this.api.onValueChanged(c.COLUMN_SPACING, (e) => {
|
|
177
|
+
const t = parseInt(e);
|
|
178
|
+
Number.isNaN(t) || this._debouncedOnColumnSpacingChange(t);
|
|
179
|
+
}), this.api.onValueChanged(c.ROW_SPACING, (e) => {
|
|
180
|
+
const t = parseInt(e);
|
|
181
|
+
Number.isNaN(t) || this._debouncedOnRowSpacingChange(t);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
_ as SPACING_CONTROL_ID,
|
|
187
|
+
G as SpacingControl
|
|
188
|
+
};
|
|
@@ -1,45 +1,19 @@
|
|
|
1
1
|
import { ExtensionBuilder as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
import { RecommendationBlock as
|
|
3
|
-
import { RecommendationCardCompositionControl as
|
|
4
|
-
import { RecommendationBlockControl as
|
|
5
|
-
import { ButtonAlignControl as d } from "./controls/
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
import { ImageSizeControl as B } from "./controls/image/size.js";
|
|
18
|
-
import { NameAlignControl as P } from "./controls/name/align.js";
|
|
19
|
-
import { NameBackgroundControl as u } from "./controls/name/background.js";
|
|
20
|
-
import { NameColorControl as y } from "./controls/name/color.js";
|
|
21
|
-
import { NameFontFamilyControl as S } from "./controls/name/fontFamily.js";
|
|
22
|
-
import { NamePaddingsControl as F } from "./controls/name/paddings.js";
|
|
23
|
-
import { NameSizeControl as R } from "./controls/name/size.js";
|
|
24
|
-
import { NameStyleControl as N } from "./controls/name/style.js";
|
|
25
|
-
import { OldPriceAlignControl as O } from "./controls/oldPrice/align.js";
|
|
26
|
-
import { OldPriceBackgroundControl as k } from "./controls/oldPrice/background.js";
|
|
27
|
-
import { OldPriceColorControl as x } from "./controls/oldPrice/color.js";
|
|
28
|
-
import { OldPriceFontFamilyControl as z } from "./controls/oldPrice/fontFamily.js";
|
|
29
|
-
import { OldPricePaddingsControl as A } from "./controls/oldPrice/paddings.js";
|
|
30
|
-
import { OldPriceSizeControl as I } from "./controls/oldPrice/size.js";
|
|
31
|
-
import { OldPriceStyleControl as T } from "./controls/oldPrice/style.js";
|
|
32
|
-
import { PriceAlignControl as w } from "./controls/price/align.js";
|
|
33
|
-
import { PriceBackgroundControl as h } from "./controls/price/background.js";
|
|
34
|
-
import { PriceColorControl as M } from "./controls/price/color.js";
|
|
35
|
-
import { PriceFontFamilyControl as b } from "./controls/price/fontFamily.js";
|
|
36
|
-
import { PricePaddingsControl as E } from "./controls/price/paddings.js";
|
|
37
|
-
import { PriceSizeControl as j } from "./controls/price/size.js";
|
|
38
|
-
import { PriceStyleControl as q } from "./controls/price/style.js";
|
|
39
|
-
import { RecommendationIconsRegistry as v } from "./iconsRegistry.js";
|
|
40
|
-
import D from "./recommendation.css.js";
|
|
41
|
-
import { SettingsPanel as G } from "./settingsPanel.js";
|
|
42
|
-
const Io = new o().addBlock(r).withSettingsPanelRegistry(G).addControl(n).addControl(d).addControl(l).addControl(m).addControl(i).addControl(C).addControl(a).addControl(e).addControl(p).addControl(f).addControl(c).addControl(s).addControl(g).addControl(B).addControl(P).addControl(u).addControl(y).addControl(S).addControl(F).addControl(R).addControl(N).addControl(O).addControl(k).addControl(x).addControl(z).addControl(A).addControl(I).addControl(T).addControl(w).addControl(h).addControl(M).addControl(b).addControl(E).addControl(j).addControl(q).addControl(t).addStyles(D).withIconsRegistry(v).build();
|
|
2
|
+
import { RecommendationBlock as t } from "./block.js";
|
|
3
|
+
import { RecommendationCardCompositionControl as n } from "./cardCompositionControl.js";
|
|
4
|
+
import { RecommendationBlockControl as r } from "./control.js";
|
|
5
|
+
import { ButtonAlignControl as l, ButtonBorderControl as d, ButtonBorderRadiusControl as C, ButtonColorControl as i, ButtonFitToContentControl as a, ButtonFontFamilyControl as e, ButtonMarginsControl as m, ButtonPaddingsControl as s, ButtonTextControl as c, ButtonTextSizeControl as u, ButtonTextStyleAndFontColorControl as P, ImageMarginsControl as g, ImageSizeControl as B, NameAlignControl as O, NameBackgroundControl as f, NameColorControl as b, NameFontFamilyControl as p, NamePaddingsControl as y, NameSizeControl as S, NameStyleControl as F, OldPriceAlignControl as x, OldPriceBackgroundControl as T, OldPriceColorControl as k, OldPriceFontFamilyControl as A, OldPricePaddingsControl as D, OldPriceSizeControl as N, OldPriceStyleControl as R, OmnibusPriceAlignControl as z, OmnibusPriceBackgroundControl as I, OmnibusPriceColorControl as w, OmnibusPriceFontFamilyControl as h, OmnibusPricePaddingsControl as M, OmnibusPriceSizeControl as E, OmnibusPriceStyleControl as j, OmnibusDiscountAlignControl as q, OmnibusDiscountBackgroundControl as v, OmnibusDiscountColorControl as G, OmnibusDiscountFontFamilyControl as H, OmnibusDiscountPaddingsControl as J, OmnibusDiscountSizeControl as K, OmnibusDiscountStyleControl as L, PriceAlignControl as Q, PriceBackgroundControl as U, PriceColorControl as V, PriceFontFamilyControl as W, PricePaddingsControl as X, PriceSizeControl as Y, PriceStyleControl as Z } from "./controls/index.js";
|
|
6
|
+
import { RecommendationIconsRegistry as _ } from "./iconsRegistry.js";
|
|
7
|
+
import $ from "./recommendation.css.js";
|
|
8
|
+
import { SettingsPanel as oo } from "./settingsPanel.js";
|
|
9
|
+
import { CardBackgroundColorControl as to } from "./controls/cardBackgroundColorControl.js";
|
|
10
|
+
import { SpacingControl as no } from "./controls/spacingControl.js";
|
|
11
|
+
import { NameTextTrimControl as ro } from "./controls/nameTextTrimControl.js";
|
|
12
|
+
import { OmnibusPriceTextBeforeControl as lo } from "./controls/omnibusPriceTextBeforeControl.js";
|
|
13
|
+
import { OmnibusPriceTextAfterControl as Co } from "./controls/omnibusPriceTextAfterControl.js";
|
|
14
|
+
import { OmnibusDiscountTextBeforeControl as io } from "./controls/omnibusDiscountTextBeforeControl.js";
|
|
15
|
+
import { OmnibusDiscountTextAfterControl as ao } from "./controls/omnibusDiscountTextAfterControl.js";
|
|
16
|
+
const xo = new o().addBlock(t).withSettingsPanelRegistry(oo).addControl(r).addControl(to).addControl(no).addControl(l).addControl(d).addControl(C).addControl(i).addControl(a).addControl(e).addControl(m).addControl(s).addControl(c).addControl(u).addControl(P).addControl(g).addControl(B).addControl(O).addControl(f).addControl(b).addControl(p).addControl(y).addControl(S).addControl(F).addControl(ro).addControl(x).addControl(T).addControl(k).addControl(A).addControl(D).addControl(N).addControl(R).addControl(z).addControl(I).addControl(w).addControl(h).addControl(M).addControl(E).addControl(j).addControl(lo).addControl(Co).addControl(q).addControl(v).addControl(G).addControl(H).addControl(J).addControl(K).addControl(L).addControl(io).addControl(ao).addControl(Q).addControl(U).addControl(V).addControl(W).addControl(X).addControl(Y).addControl(Z).addControl(n).addStyles($).withIconsRegistry(_).build();
|
|
43
17
|
export {
|
|
44
|
-
|
|
18
|
+
xo as default
|
|
45
19
|
};
|