@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,4 @@
|
|
|
1
|
+
var t = /* @__PURE__ */ ((c) => (c.TEXT_ALIGN = "coupon-block-text-align-control", c.TEXT_COLOR = "coupon-block-text-color-control", c.TEXT_SIZE = "coupon-block-text-size-control", c.TEXT_STYLE = "coupon-block-text-style-control", c.TEXT_FONT_FAMILY = "coupon-block-text-font-family-control", c.TEXT_BACKGROUND = "coupon-block-text-background-control", c.TEXT_PADDINGS = "coupon-block-text-paddings-control", c.TEXT_LINE_SPACING = "coupon-block-text-line-spacing-control", c))(t || {});
|
|
2
|
+
export {
|
|
3
|
+
t as CouponControlId
|
|
4
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createTextAlignControl as t, createTextColorControl as e, createTextSizeControl as n, createTextStyleControl as r, createTextFontFamilyControl as T, createTextBackgroundColorControl as l, createPaddingsControl as C, createTextLineSpacingControl as c } from "../../controlFactories.js";
|
|
2
|
+
import { CouponControlId as o } from "../constants.js";
|
|
3
|
+
const i = t(
|
|
4
|
+
o.TEXT_ALIGN
|
|
5
|
+
), E = e(
|
|
6
|
+
o.TEXT_COLOR
|
|
7
|
+
), s = n(
|
|
8
|
+
o.TEXT_SIZE
|
|
9
|
+
), S = r(
|
|
10
|
+
o.TEXT_STYLE
|
|
11
|
+
), _ = T(
|
|
12
|
+
o.TEXT_FONT_FAMILY
|
|
13
|
+
), g = l(
|
|
14
|
+
o.TEXT_BACKGROUND
|
|
15
|
+
), X = C(
|
|
16
|
+
o.TEXT_PADDINGS
|
|
17
|
+
), d = c(
|
|
18
|
+
o.TEXT_LINE_SPACING
|
|
19
|
+
);
|
|
20
|
+
export {
|
|
21
|
+
i as TextAlignControl,
|
|
22
|
+
g as TextBackgroundControl,
|
|
23
|
+
E as TextColorControl,
|
|
24
|
+
_ as TextFontFamilyControl,
|
|
25
|
+
d as TextLineSpacingControl,
|
|
26
|
+
X as TextPaddingsControl,
|
|
27
|
+
s as TextSizeControl,
|
|
28
|
+
S as TextStyleControl
|
|
29
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ExtensionBuilder as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { CouponBlock as t } from "./block.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { TextAlignControl as n, TextColorControl as r, TextSizeControl as l, TextStyleControl as d, TextFontFamilyControl as e, TextBackgroundControl as i, TextPaddingsControl as C, TextLineSpacingControl as a } from "./controls/index.js";
|
|
4
|
+
import { CouponIconsRegistry as s } from "./iconsRegistry.js";
|
|
5
|
+
import { CouponBlockSettings as m } from "./settingsPanel.js";
|
|
6
|
+
const u = new o().addBlock(t).withSettingsPanelRegistry(m).addControl(n).addControl(r).addControl(l).addControl(d).addControl(e).addControl(i).addControl(C).addControl(a).withIconsRegistry(s).build();
|
|
6
7
|
export {
|
|
7
|
-
|
|
8
|
+
u as default
|
|
8
9
|
};
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
import { SettingsPanelRegistry as
|
|
2
|
-
import { COUPON_BLOCK_ID as
|
|
3
|
-
|
|
1
|
+
import { SettingsPanelRegistry as n, SettingsPanelTab as o, SettingsTab as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { COUPON_BLOCK_ID as E } from "./block.js";
|
|
3
|
+
import { CouponControlId as T } from "./constants.js";
|
|
4
|
+
class i extends n {
|
|
4
5
|
registerBlockControls(e) {
|
|
5
|
-
e[
|
|
6
|
+
e[E] = [
|
|
6
7
|
new o(
|
|
7
|
-
|
|
8
|
+
t.SETTINGS,
|
|
8
9
|
[
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
T.TEXT_STYLE,
|
|
11
|
+
T.TEXT_ALIGN,
|
|
12
|
+
T.TEXT_PADDINGS
|
|
13
|
+
]
|
|
14
|
+
),
|
|
15
|
+
new o(
|
|
16
|
+
t.STYLES,
|
|
17
|
+
[
|
|
18
|
+
T.TEXT_BACKGROUND,
|
|
19
|
+
T.TEXT_FONT_FAMILY,
|
|
20
|
+
T.TEXT_LINE_SPACING,
|
|
21
|
+
T.TEXT_SIZE,
|
|
22
|
+
T.TEXT_COLOR
|
|
17
23
|
]
|
|
18
24
|
)
|
|
19
25
|
];
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
export {
|
|
23
|
-
|
|
29
|
+
i as CouponBlockSettings
|
|
24
30
|
};
|
|
@@ -1,18 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
esd-extension-block-id="
|
|
1
|
+
import { BlockType as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { COUPON_BLOCK_ID as e } from "./block.js";
|
|
3
|
+
const t = `
|
|
4
|
+
<${o.BLOCK_TEXT}
|
|
5
|
+
class="coupon-block ins-coupon-code coupon-block-v2 es-p10"
|
|
6
|
+
align="center"
|
|
7
|
+
esd-extension-block-id="${e}">
|
|
8
|
+
<p
|
|
9
|
+
path="1"
|
|
10
|
+
contenteditable="false"
|
|
11
|
+
style="font-size: 16px; color: #333333;">
|
|
12
|
+
<strong path="1,0">{@COUPON_CODE}</strong>
|
|
13
|
+
</p>
|
|
14
|
+
</${o.BLOCK_TEXT}>
|
|
15
|
+
`, l = `
|
|
16
|
+
<td
|
|
17
|
+
class="coupon-block coupon-block-v2 ins-coupon-code esd-block-text esd-extension-block"
|
|
18
|
+
esd-extension-block-id="${e}"
|
|
8
19
|
>
|
|
9
20
|
<p class="ins-title" contenteditable="false">{@COUPON_CODE}</p>
|
|
10
21
|
</td>
|
|
11
22
|
`;
|
|
12
|
-
function
|
|
13
|
-
return
|
|
23
|
+
function s() {
|
|
24
|
+
return t;
|
|
14
25
|
}
|
|
15
26
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
l as default,
|
|
28
|
+
s as getDefaultTemplate
|
|
18
29
|
};
|
|
@@ -1,103 +1,187 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{ key:
|
|
8
|
-
{ key:
|
|
9
|
-
{ key:
|
|
10
|
-
{ key:
|
|
11
|
-
{ key:
|
|
1
|
+
import { ModificationDescription as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as _ } from "../common-control.js";
|
|
3
|
+
import { ATTR_PRODUCT_IMAGE as m, ATTR_PRODUCT_NAME as y, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OLD_PRICE as h, ATTR_PRODUCT_OMNIBUS_PRICE as C, ATTR_PRODUCT_OMNIBUS_DISCOUNT as f, ATTR_PRODUCT_BUTTON as g } from "./constants.js";
|
|
4
|
+
const R = "ui-elements-recommendation-card-composition", l = ".recommendation-attribute-row", A = "tr.recommendation-product-row", c = "data-card-composition", a = "data-attribute-type", d = "data-visibility", s = [
|
|
5
|
+
{ key: m, label: "Product Image", visible: !0 },
|
|
6
|
+
{ key: y, label: "Product Name", visible: !0 },
|
|
7
|
+
{ key: T, label: "Product Price", visible: !0 },
|
|
8
|
+
{ key: h, label: "Product Original Price", visible: !0 },
|
|
9
|
+
{ key: C, label: "Omnibus Price", visible: !1 },
|
|
10
|
+
{ key: f, label: "Omnibus Discount", visible: !1 },
|
|
11
|
+
{ key: g, label: "Product Button", visible: !0 }
|
|
12
12
|
];
|
|
13
|
-
class
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
a(this, "currentComposition", []);
|
|
17
|
-
a(this, "currentVisibility", {});
|
|
18
|
-
}
|
|
13
|
+
class N extends _ {
|
|
19
14
|
getId() {
|
|
20
|
-
return
|
|
15
|
+
return R;
|
|
21
16
|
}
|
|
22
17
|
getTemplate() {
|
|
23
|
-
const
|
|
24
|
-
key:
|
|
25
|
-
label:
|
|
26
|
-
content:
|
|
27
|
-
<div style="display: flex; align-items: center; justify-content: space-between;
|
|
28
|
-
padding: 8px; gap: 8px;">
|
|
29
|
-
<span style="flex: 1;">${e.label}</span>
|
|
30
|
-
${this._GuToggle(`visibility_${e.key}`)}
|
|
31
|
-
</div>
|
|
32
|
-
`
|
|
18
|
+
const t = s.map((i) => ({
|
|
19
|
+
key: i.key,
|
|
20
|
+
label: i.label,
|
|
21
|
+
content: this._createItemContent(i.label, i.key)
|
|
33
22
|
}));
|
|
34
23
|
return `
|
|
35
24
|
<div class="container">
|
|
36
25
|
${this._GuLabel({ text: "Card Element Order & Visibility" })}
|
|
37
|
-
${this._GuOrderable("cardComposition",
|
|
26
|
+
${this._GuOrderable("cardComposition", t)}
|
|
38
27
|
</div>
|
|
39
28
|
`;
|
|
40
29
|
}
|
|
41
30
|
onRender() {
|
|
42
|
-
this._initializeComposition(), this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
this._initializeComposition(), this._registerValueChangeListeners();
|
|
32
|
+
}
|
|
33
|
+
onTemplateNodeUpdated(t) {
|
|
34
|
+
super.onTemplateNodeUpdated(t), this._initializeComposition();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates the HTML content for an orderable item with label and toggle
|
|
38
|
+
*/
|
|
39
|
+
_createItemContent(t, i) {
|
|
40
|
+
return `
|
|
41
|
+
<div style="display: flex; align-items: center; justify-content: space-between;
|
|
42
|
+
padding: 8px; gap: 8px;">
|
|
43
|
+
<span style="flex: 1;">${t}</span>
|
|
44
|
+
${this._GuToggle(`visibility_${i}`)}
|
|
45
|
+
</div>
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Registers event listeners for composition and visibility changes
|
|
50
|
+
*/
|
|
51
|
+
_registerValueChangeListeners() {
|
|
52
|
+
this.api.onValueChanged("cardComposition", (t) => {
|
|
53
|
+
this._applyCompositionToBlock(t);
|
|
54
|
+
}), s.forEach((t) => {
|
|
55
|
+
this.api.onValueChanged(`visibility_${t.key}`, (i) => {
|
|
56
|
+
this._applyVisibilityToBlock(t.key, i);
|
|
47
57
|
});
|
|
48
58
|
});
|
|
49
59
|
}
|
|
50
|
-
onTemplateNodeUpdated(i) {
|
|
51
|
-
super.onTemplateNodeUpdated(i), this._initializeComposition();
|
|
52
|
-
}
|
|
53
60
|
/**
|
|
54
|
-
*
|
|
61
|
+
* Initializes composition order and visibility state from the current node
|
|
55
62
|
*/
|
|
56
63
|
_initializeComposition() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (i && "getAttribute" in i && (e = i.getAttribute("data-card-composition"), l = i.getAttribute("data-card-visibility")), e) {
|
|
61
|
-
const t = e.split(",").filter(Boolean), r = s.map((c) => c.key);
|
|
62
|
-
t.every((c) => r.includes(c)) && t.length > 0 ? this.currentComposition = t : this.currentComposition = r;
|
|
63
|
-
} else
|
|
64
|
-
this.currentComposition = s.map((t) => t.key);
|
|
65
|
-
if (l)
|
|
66
|
-
try {
|
|
67
|
-
const t = JSON.parse(l);
|
|
68
|
-
this.currentVisibility = t;
|
|
69
|
-
} catch {
|
|
70
|
-
this.currentVisibility = s.reduce((t, r) => (t[r.key] = r.visible, t), {});
|
|
71
|
-
}
|
|
72
|
-
else
|
|
73
|
-
this.currentVisibility = s.reduce((t, r) => (t[r.key] = r.visible, t), {});
|
|
74
|
-
const d = {
|
|
75
|
-
cardComposition: this.currentComposition
|
|
64
|
+
const t = this._readCompositionFromNode(), i = this._readVisibilityFromRows(), e = {
|
|
65
|
+
cardComposition: t,
|
|
66
|
+
...this._buildVisibilityValues(i)
|
|
76
67
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
this.api.updateValues(e);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Reads composition order from node's data-card-composition attribute
|
|
72
|
+
* Falls back to default order if attribute is not present
|
|
73
|
+
*/
|
|
74
|
+
_readCompositionFromNode() {
|
|
75
|
+
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
76
|
+
return s.map((i) => i.key);
|
|
77
|
+
const t = this.currentNode.getAttribute(c);
|
|
78
|
+
return t ? t.split(",").filter(Boolean) : s.map((i) => i.key);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Builds visibility values object from the visibility map
|
|
82
|
+
*/
|
|
83
|
+
_buildVisibilityValues(t) {
|
|
84
|
+
return s.reduce((i, e) => (i[`visibility_${e.key}`] = t[e.key] ?? !0, i), {});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Read visibility state from individual row elements' data-visibility attributes
|
|
88
|
+
* This ensures toggles reflect the actual DOM state
|
|
89
|
+
*/
|
|
90
|
+
_readVisibilityFromRows() {
|
|
91
|
+
if (!this.currentNode)
|
|
92
|
+
return this._getDefaultVisibilities();
|
|
93
|
+
const t = Array.from(this.currentNode.querySelectorAll(l));
|
|
94
|
+
console.debug("_readVisibilityFromRows - found attribute rows:", t.length);
|
|
95
|
+
const i = this._extractVisibilityFromRows(t);
|
|
96
|
+
return this._mergeWithDefaults(i);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns default visibility values for all items
|
|
100
|
+
*/
|
|
101
|
+
_getDefaultVisibilities() {
|
|
102
|
+
return s.reduce((t, i) => (t[i.key] = i.visible, t), {});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Extracts visibility values from DOM nodes
|
|
106
|
+
*/
|
|
107
|
+
_extractVisibilityFromRows(t) {
|
|
108
|
+
const i = {};
|
|
109
|
+
return t.forEach((e) => {
|
|
110
|
+
if (!("getAttribute" in e))
|
|
111
|
+
return;
|
|
112
|
+
const o = e.getAttribute(a), r = e.getAttribute(d);
|
|
113
|
+
o && r !== null && (i[o] = this._parseVisibilityValue(r), console.debug(
|
|
114
|
+
`_readVisibilityFromRows - ${o}: ${i[o]} (raw: ${r})`
|
|
115
|
+
));
|
|
116
|
+
}), i;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Parses visibility value from string to boolean
|
|
120
|
+
* Accepts "1", "true" as true, everything else as false
|
|
121
|
+
*/
|
|
122
|
+
_parseVisibilityValue(t) {
|
|
123
|
+
return t === "1" || t === "true";
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Merges extracted visibilities with default values for missing keys
|
|
127
|
+
*/
|
|
128
|
+
_mergeWithDefaults(t) {
|
|
129
|
+
return s.forEach((i) => {
|
|
130
|
+
i.key in t || (t[i.key] = i.visible, console.debug(`_readVisibilityFromRows - ${i.key}: using default ${i.visible}`));
|
|
131
|
+
}), t;
|
|
80
132
|
}
|
|
81
133
|
/**
|
|
82
134
|
* Apply the reordered composition to the block's HTML structure
|
|
135
|
+
* Updates the data-card-composition attribute and reorders product attributes
|
|
136
|
+
*/
|
|
137
|
+
_applyCompositionToBlock(t) {
|
|
138
|
+
if (console.debug("_applyCompositionToBlock - composition:", t), !this.currentNode) {
|
|
139
|
+
console.debug("_applyCompositionToBlock - no current node");
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(c, t.join(",")).apply(new n("Update card composition")), this._reorderProductAttributes(t);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Reorders attribute rows within each product row based on composition order
|
|
83
146
|
*/
|
|
84
|
-
|
|
147
|
+
_reorderProductAttributes(t) {
|
|
85
148
|
if (!this.currentNode)
|
|
86
149
|
return;
|
|
87
|
-
const
|
|
88
|
-
|
|
150
|
+
const i = this.currentNode.querySelectorAll(A);
|
|
151
|
+
if (!(i != null && i.length))
|
|
152
|
+
return;
|
|
153
|
+
const e = this.api.getDocumentModifier();
|
|
154
|
+
i.forEach((o) => {
|
|
155
|
+
const r = this._buildCompositionHtml(o, t);
|
|
156
|
+
e.modifyHtml(o).setInnerHtml(r);
|
|
157
|
+
}), e.apply(new n("Reorder product attributes"));
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Builds HTML string with attributes ordered according to composition
|
|
161
|
+
*/
|
|
162
|
+
_buildCompositionHtml(t, i) {
|
|
163
|
+
return i.reduce((e, o) => {
|
|
164
|
+
const r = t.querySelector(`${l}[${a}="${o}"]`);
|
|
165
|
+
return r && "getOuterHTML" in r ? e + r.getOuterHTML() : e;
|
|
166
|
+
}, "");
|
|
89
167
|
}
|
|
90
168
|
/**
|
|
91
169
|
* Apply visibility changes to the block's HTML structure
|
|
170
|
+
* Updates display style and data-visibility attribute for all matching rows
|
|
92
171
|
*/
|
|
93
|
-
_applyVisibilityToBlock() {
|
|
94
|
-
if (!this.currentNode)
|
|
172
|
+
_applyVisibilityToBlock(t, i) {
|
|
173
|
+
if (console.debug("_applyVisibilityToBlock", t, i), !this.currentNode)
|
|
174
|
+
return;
|
|
175
|
+
const e = this.currentNode.querySelectorAll(`${l}[${a}="${t}"]`);
|
|
176
|
+
if (!(e != null && e.length))
|
|
95
177
|
return;
|
|
96
|
-
const i = this.
|
|
97
|
-
|
|
178
|
+
const o = i ? "table-row" : "none", r = i ? "1" : "0", p = `Set ${t} visibility to ${i ? "visible" : "hidden"}`, u = this.api.getDocumentModifier();
|
|
179
|
+
e.forEach((b) => {
|
|
180
|
+
u.modifyHtml(b).setStyle("display", o).setAttribute(d, r);
|
|
181
|
+
}), u.apply(new n(p));
|
|
98
182
|
}
|
|
99
183
|
}
|
|
100
184
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
185
|
+
R as COMPOSITION_CONTROL_BLOCK_ID,
|
|
186
|
+
N as RecommendationCardCompositionControl
|
|
103
187
|
};
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
const _ = "productImage", b = "productName", n = "productPrice", i = "productOldPrice", O = "productOmnibusPrice", T = "productOmnibusDiscount", t = "productButton";
|
|
2
|
+
var o = /* @__PURE__ */ ((c) => (c.BUTTON = "recommendation-block-button", c.NAME = "recommendation-block-name", c.PRICE = "recommendation-block-price", c.OLD_PRICE = "recommendation-block-old-price", c.OMNIBUS_PRICE = "recommendation-block-omnibus-price", c.OMNIBUS_DISCOUNT = "recommendation-block-omnibus-discount", c.IMAGE = "recommendation-block-image", c))(o || {}), r = /* @__PURE__ */ ((c) => (c.BUTTON_ALIGN = "recommendation-block-button-align-control", c.BUTTON_BORDER = "recommendation-block-button-border-control", c.BUTTON_BORDER_RADIUS = "recommendation-block-button-border-radius-control", c.BUTTON_COLOR = "recommendation-block-button-color-control", c.BUTTON_FIT_TO_CONTENT = "recommendation-block-button-fit-to-content-control", c.BUTTON_FONT_FAMILY = "recommendation-block-button-font-family-control", c.BUTTON_MARGINS = "recommendation-block-button-margins-control", c.BUTTON_PADDINGS = "recommendation-block-button-paddings-control", c.BUTTON_TEXT = "recommendation-block-button-text-control", c.BUTTON_TEXT_SIZE = "recommendation-block-button-text-size-control", c.BUTTON_TEXT_STYLE_AND_FONT_COLOR = "recommendation-block-button-text-style-and-font-color-control", c.NAME_ALIGN = "recommendation-block-name-align-control", c.NAME_BACKGROUND = "recommendation-block-name-background-control", c.NAME_COLOR = "recommendation-block-name-color-control", c.NAME_FONT_FAMILY = "recommendation-block-name-font-family-control", c.NAME_PADDINGS = "recommendation-block-name-paddings-control", c.NAME_SIZE = "recommendation-block-name-size-control", c.NAME_STYLE = "recommendation-block-name-style-control", c.NAME_TEXT_TRIM = "recommendation-block-name-text-trim-control", c.PRICE_ALIGN = "recommendation-block-price-align-control", c.PRICE_BACKGROUND = "recommendation-block-price-background-control", c.PRICE_COLOR = "recommendation-block-price-color-control", c.PRICE_FONT_FAMILY = "recommendation-block-price-font-family-control", c.PRICE_PADDINGS = "recommendation-block-price-paddings-control", c.PRICE_SIZE = "recommendation-block-price-size-control", c.PRICE_STYLE = "recommendation-block-price-style-control", c.OLD_PRICE_ALIGN = "recommendation-block-old-price-align-control", c.OLD_PRICE_BACKGROUND = "recommendation-block-old-price-background-control", c.OLD_PRICE_COLOR = "recommendation-block-old-price-color-control", c.OLD_PRICE_FONT_FAMILY = "recommendation-block-old-price-font-family-control", c.OLD_PRICE_PADDINGS = "recommendation-block-old-price-paddings-control", c.OLD_PRICE_SIZE = "recommendation-block-old-price-size-control", c.OLD_PRICE_STYLE = "recommendation-block-old-price-style-control", c.OMNIBUS_PRICE_ALIGN = "recommendation-block-omnibus-price-align-control", c.OMNIBUS_PRICE_BACKGROUND = "recommendation-block-omnibus-price-background-control", c.OMNIBUS_PRICE_COLOR = "recommendation-block-omnibus-price-color-control", c.OMNIBUS_PRICE_FONT_FAMILY = "recommendation-block-omnibus-price-font-family-control", c.OMNIBUS_PRICE_PADDINGS = "recommendation-block-omnibus-price-paddings-control", c.OMNIBUS_PRICE_SIZE = "recommendation-block-omnibus-price-size-control", c.OMNIBUS_PRICE_STYLE = "recommendation-block-omnibus-price-style-control", c.OMNIBUS_PRICE_TEXT_BEFORE = "recommendation-block-omnibus-price-text-before-control", c.OMNIBUS_PRICE_TEXT_AFTER = "recommendation-block-omnibus-price-text-after-control", c.OMNIBUS_DISCOUNT_ALIGN = "recommendation-block-omnibus-discount-align-control", c.OMNIBUS_DISCOUNT_BACKGROUND = "recommendation-block-omnibus-discount-background-control", c.OMNIBUS_DISCOUNT_COLOR = "recommendation-block-omnibus-discount-color-control", c.OMNIBUS_DISCOUNT_FONT_FAMILY = "recommendation-block-omnibus-discount-font-family-control", c.OMNIBUS_DISCOUNT_PADDINGS = "recommendation-block-omnibus-discount-paddings-control", c.OMNIBUS_DISCOUNT_SIZE = "recommendation-block-omnibus-discount-size-control", c.OMNIBUS_DISCOUNT_STYLE = "recommendation-block-omnibus-discount-style-control", c.OMNIBUS_DISCOUNT_TEXT_BEFORE = "recommendation-block-omnibus-discount-text-before-control", c.OMNIBUS_DISCOUNT_TEXT_AFTER = "recommendation-block-omnibus-discount-text-after-control", c.IMAGE_SIZE = "recommendation-block-image-size-control", c.IMAGE_MARGINS = "recommendation-block-image-margins-control", c))(r || {});
|
|
2
3
|
export {
|
|
4
|
+
t as ATTR_PRODUCT_BUTTON,
|
|
5
|
+
_ as ATTR_PRODUCT_IMAGE,
|
|
6
|
+
b as ATTR_PRODUCT_NAME,
|
|
7
|
+
i as ATTR_PRODUCT_OLD_PRICE,
|
|
8
|
+
T as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
|
|
9
|
+
O as ATTR_PRODUCT_OMNIBUS_PRICE,
|
|
10
|
+
n as ATTR_PRODUCT_PRICE,
|
|
3
11
|
o as RecommendationBlockId,
|
|
4
12
|
r as RecommendationControlId
|
|
5
13
|
};
|