@useinsider/guido 2.0.0-beta.b46bbf6 → 2.0.0-beta.b889d81
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/composables/useStripo.js +37 -35
- package/dist/config/migrator/index.js +8 -9
- 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/Items/block.js +40 -39
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +49 -46
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +26 -28
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +127 -132
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -2
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +48 -58
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +58 -48
- package/dist/extensions/Blocks/Items/store/items-block.js +2 -2
- package/dist/extensions/Blocks/Items/template.js +123 -296
- package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +20 -11
- package/dist/extensions/Blocks/Recommendation/control.js +1 -1
- package/dist/extensions/Blocks/common-control.js +53 -64
- package/dist/extensions/Blocks/controlFactories.js +122 -111
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +290 -364
- package/dist/package.json.js +7 -0
- 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/Items/controls/price/priceOrientation.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +4 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +1 -20
- package/dist/src/extensions/Blocks/common-control.d.ts +8 -13
- package/dist/src/extensions/Blocks/controlFactories.d.ts +30 -7
- package/package.json +3 -3
- package/dist/config/migrator/itemsBlockMigrator.js +0 -283
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +0 -172
- package/dist/src/config/migrator/itemsBlockMigrator.d.ts +0 -6
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +0 -71
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useBlocksConfig as
|
|
3
|
-
import { useConfig as
|
|
4
|
-
import { useCustomInterfaceAppearance as
|
|
5
|
-
import { useStripoEventHandler as
|
|
6
|
-
import { useToaster as
|
|
1
|
+
import { useActionsApi as T } from "./useActionsApi.js";
|
|
2
|
+
import { useBlocksConfig as V } from "./useBlocksConfig.js";
|
|
3
|
+
import { useConfig as _ } from "./useConfig.js";
|
|
4
|
+
import { useCustomInterfaceAppearance as B } from "./useCustomInterfaceAppearance.js";
|
|
5
|
+
import { useStripoEventHandler as v } from "./useStripoEventHandler.js";
|
|
6
|
+
import { useToaster as A } from "./useToaster.js";
|
|
7
7
|
import { displayConditions as F } from "../enums/displayConditions.js";
|
|
8
8
|
import { useStripoApi as D } from "../services/stripoApi.js";
|
|
9
9
|
import I from "../static/styles/customEditorStyle.css.js";
|
|
10
10
|
import { useEditorStore as M } from "../stores/editor.js";
|
|
11
11
|
import { dynamicContentToMergeTags as U } from "../utils/genericUtil.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
import P from "../package.json.js";
|
|
13
|
+
const K = (c) => {
|
|
14
|
+
const { features: l } = _(), { handleError: u } = A(), { getToken: y, getCustomFonts: S } = D(), { handleEvent: C } = v(), { getStripoBlocksConfig: E } = V(), h = async (i, n = []) => {
|
|
15
|
+
var g, f;
|
|
16
|
+
const o = M(), { html: r, css: p, forceRecreate: a } = i, { baseBlocks: t, extensions: d } = await E(), m = ((g = l.value) == null ? void 0 : g.displayConditions) ?? !0, b = ((f = l.value) == null ? void 0 : f.modulesDisabled) ?? !1;
|
|
16
17
|
window.UIEditor.initEditor(
|
|
17
18
|
document.querySelector("#guido-editor"),
|
|
18
19
|
{
|
|
19
|
-
metadata:
|
|
20
|
-
html:
|
|
21
|
-
css:
|
|
22
|
-
forceRecreate:
|
|
20
|
+
metadata: c,
|
|
21
|
+
html: r,
|
|
22
|
+
css: p,
|
|
23
|
+
forceRecreate: a,
|
|
23
24
|
locale: "en",
|
|
24
25
|
undoButtonSelector: "#guido__undo-button",
|
|
25
26
|
redoButtonSelector: "#guido__redo-button",
|
|
@@ -30,8 +31,8 @@ const $ = (a) => {
|
|
|
30
31
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
31
32
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
32
33
|
customViewStyles: I,
|
|
33
|
-
conditionsEnabled:
|
|
34
|
-
customConditionsEnabled:
|
|
34
|
+
conditionsEnabled: m,
|
|
35
|
+
customConditionsEnabled: m,
|
|
35
36
|
conditionCategories: F,
|
|
36
37
|
enableXSSSecurity: !0,
|
|
37
38
|
modulesDisabled: b,
|
|
@@ -41,7 +42,7 @@ const $ = (a) => {
|
|
|
41
42
|
displayTitle: !1,
|
|
42
43
|
displayUTM: !1,
|
|
43
44
|
selectElementAfterDrop: !0,
|
|
44
|
-
...
|
|
45
|
+
...t ? { baseBlocks: t } : {},
|
|
45
46
|
editorFonts: {
|
|
46
47
|
showDefaultStandardFonts: !0,
|
|
47
48
|
showDefaultNotStandardFonts: !0,
|
|
@@ -49,25 +50,25 @@ const $ = (a) => {
|
|
|
49
50
|
},
|
|
50
51
|
mergeTags: [
|
|
51
52
|
{
|
|
52
|
-
entries: U(
|
|
53
|
+
entries: U(c.preselectedDynamicContentList)
|
|
53
54
|
}
|
|
54
55
|
],
|
|
55
56
|
async onTokenRefreshRequest(e) {
|
|
56
57
|
try {
|
|
57
|
-
const
|
|
58
|
-
e(
|
|
59
|
-
} catch (
|
|
60
|
-
|
|
58
|
+
const s = await y();
|
|
59
|
+
e(s);
|
|
60
|
+
} catch (s) {
|
|
61
|
+
u(s, "Failed to refresh token");
|
|
61
62
|
}
|
|
62
63
|
},
|
|
63
64
|
onTemplateLoaded() {
|
|
64
65
|
try {
|
|
65
|
-
const { importCss: e } =
|
|
66
|
-
e(),
|
|
66
|
+
const { importCss: e } = B(), { activateCustomViewStyles: s, updateTimerInClonedTemplate: k } = T();
|
|
67
|
+
e(), s(), k(), c.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
|
|
67
68
|
o.hasChanges = !1;
|
|
68
69
|
}, 1e3);
|
|
69
70
|
} catch (e) {
|
|
70
|
-
|
|
71
|
+
u(e, "Failed to load custom interface appearance");
|
|
71
72
|
}
|
|
72
73
|
},
|
|
73
74
|
onCodeEditorVisibilityChanged(e) {
|
|
@@ -82,34 +83,35 @@ const $ = (a) => {
|
|
|
82
83
|
onDataChanged() {
|
|
83
84
|
o.hasChanges = !0;
|
|
84
85
|
},
|
|
85
|
-
onEvent:
|
|
86
|
+
onEvent: C,
|
|
86
87
|
ignoreClickOutsideSelectors: [
|
|
87
88
|
"#guido-dynamic-content-modal",
|
|
88
89
|
".in-on-board-wrapper",
|
|
89
90
|
".in-drawer__container"
|
|
90
91
|
],
|
|
91
|
-
extensions:
|
|
92
|
+
extensions: d
|
|
92
93
|
}
|
|
93
94
|
);
|
|
94
|
-
},
|
|
95
|
+
}, w = (i) => new Promise((n, o) => {
|
|
96
|
+
var d;
|
|
95
97
|
if (document.getElementById("UiEditorScript")) {
|
|
96
98
|
i(), n();
|
|
97
99
|
return;
|
|
98
100
|
}
|
|
99
|
-
const
|
|
100
|
-
t.id = "UiEditorScript", t.type = "module", t.src =
|
|
101
|
+
const r = P.guido, a = `https://email-static.useinsider.com/guido/${(d = r == null ? void 0 : r.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
|
|
102
|
+
t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
|
|
101
103
|
i(), n();
|
|
102
104
|
}, t.onerror = () => {
|
|
103
|
-
o(new Error(`Failed to load Stripo UIEditor script from S3: ${
|
|
105
|
+
o(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
|
|
104
106
|
}, document.body.appendChild(t);
|
|
105
107
|
});
|
|
106
108
|
return { initPlugin: async (i) => {
|
|
107
|
-
await
|
|
108
|
-
const n = await
|
|
109
|
-
await
|
|
109
|
+
await w(async () => {
|
|
110
|
+
const n = await S();
|
|
111
|
+
await h(i, n);
|
|
110
112
|
});
|
|
111
113
|
} };
|
|
112
114
|
};
|
|
113
115
|
export {
|
|
114
|
-
|
|
116
|
+
K as useStripo
|
|
115
117
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
1
|
+
import { migrateCheckbox as m } from "./checkboxMigrator.js";
|
|
2
2
|
import { migrateCouponBlock as o } from "./couponBlockMigrator.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return m = t(m), m = e(m), m = await g(m), m = o(m), m = a(m), m = i(m), m;
|
|
3
|
+
import { migrateRadioButton as i } from "./radioButtonMigrator.js";
|
|
4
|
+
import { migrateRecommendation as e } from "./recommendationMigrator.js";
|
|
5
|
+
import { migrateUnsubscribe as a } from "./unsubscribeMigrator.js";
|
|
6
|
+
const s = async (t) => {
|
|
7
|
+
let r = t;
|
|
8
|
+
return r = m(r), r = i(r), r = await a(r), r = o(r), r = e(r), r;
|
|
10
9
|
};
|
|
11
10
|
export {
|
|
12
|
-
|
|
11
|
+
s as migrate
|
|
13
12
|
};
|
|
@@ -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,20 +1,20 @@
|
|
|
1
|
-
import { useOnboardingStore as
|
|
2
|
-
import { Block as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useItemsBlockStore as
|
|
6
|
-
import { getDefaultTemplate as
|
|
7
|
-
import {
|
|
8
|
-
const
|
|
9
|
-
class
|
|
1
|
+
import { useOnboardingStore as y } from "../../../stores/onboarding.js";
|
|
2
|
+
import { Block as R, BlockCompositionType as L, ModificationDescription as a } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
3
|
+
import { configAttributes as t } from "./enums/productEnums.js";
|
|
4
|
+
import { DefaultConfigValues as e, SETTINGS_ENUMS as l } from "./enums/settingsEnums.js";
|
|
5
|
+
import { useItemsBlockStore as S } from "./store/items-block.js";
|
|
6
|
+
import { getDefaultTemplate as V } from "./template.js";
|
|
7
|
+
import { syncCurrencySymbolFromAttributes as B, syncCurrencyLocationFromAttributes as U, syncFormattedPriceFromAttributes as k } from "./utils/syncAttributesFromConfigBlock.js";
|
|
8
|
+
const M = "items-block";
|
|
9
|
+
class x extends R {
|
|
10
10
|
getId() {
|
|
11
|
-
return
|
|
11
|
+
return M;
|
|
12
12
|
}
|
|
13
13
|
getIcon() {
|
|
14
14
|
return "items-icon";
|
|
15
15
|
}
|
|
16
16
|
getBlockCompositionType() {
|
|
17
|
-
return
|
|
17
|
+
return L.CONTAINER;
|
|
18
18
|
}
|
|
19
19
|
getName() {
|
|
20
20
|
return this.api.translate("Items");
|
|
@@ -23,44 +23,45 @@ class O extends u {
|
|
|
23
23
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
24
24
|
}
|
|
25
25
|
getTemplate() {
|
|
26
|
-
return
|
|
27
|
-
orientation:
|
|
28
|
-
itemsType:
|
|
26
|
+
return V({
|
|
27
|
+
orientation: l.ORIENTATION.HORIZONTAL,
|
|
28
|
+
itemsType: l.ITEMS_TYPE.CART_ITEMS,
|
|
29
29
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
30
|
-
currencySymbol:
|
|
31
|
-
currencyLocation:
|
|
32
|
-
formattedPrice:
|
|
30
|
+
currencySymbol: e.productPriceCurrencySymbolControlValue,
|
|
31
|
+
currencyLocation: e.productPriceCurrencyLocationControlValue,
|
|
32
|
+
formattedPrice: e.productPriceFormattedControlValue === "1"
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
allowInnerBlocksDND() {
|
|
36
36
|
return !1;
|
|
37
37
|
}
|
|
38
|
-
onCreated(
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
38
|
+
onCreated(r) {
|
|
39
|
+
const n = r.querySelector("esd-config-block");
|
|
40
|
+
if (!n)
|
|
41
41
|
return;
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
const o = n, s = o.getAttribute("data-initialized") || "0", u = o.getAttribute(t.BLOCK_INSTANCE_ID), c = () => String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
43
|
+
if (Number(s)) {
|
|
44
|
+
if (!u) {
|
|
45
|
+
const i = c();
|
|
46
|
+
this.api.getDocumentModifier().modifyHtml(o).setAttribute(t.BLOCK_INSTANCE_ID, i).apply(new a("Assign block instance ID to legacy block"));
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
const i = e.itemsType, I = e.cartItemsSelectControlValue, d = e.cardOrientationControlValue, m = e.productNameTrimmingControlValue, C = e.productPriceHideDiscountControlValue, b = e.productPriceFormattedControlValue, T = e.productPriceCurrencySymbolControlValue, A = e.productPriceCurrencyLocationControlValue, E = e.productButtonLinkControlValue, O = e.productImageLinkControlValue, _ = e.productImageVisible, p = e.productNameVisible, N = e.productQuantityVisible, f = e.productPriceVisible, g = e.productOriginalPriceVisible, D = e.productButtonVisible, P = c();
|
|
50
|
+
this.api.getDocumentModifier().modifyHtml(o).setAttribute("data-source", i).setAttribute(t.TYPE, i).setAttribute(t.ITEMS_INDEX_SELECT_CONTROL_VALUE, I).setAttribute(t.ORIENTATION, d).setAttribute(t.PRODUCT_NAME_TRIMMING, m).setAttribute(t.PRODUCT_PRICE_HIDE_DISCOUNT, C).setAttribute(t.PRODUCT_PRICE_FORMATTED, b).setAttribute(t.PRODUCT_PRICE_CURRENCY_SYMBOL, T).setAttribute(t.PRODUCT_PRICE_CURRENCY_LOCATION, A).setAttribute(t.PRODUCT_BUTTON_LINK, E).setAttribute(t.PRODUCT_IMAGE_LINK, O).setAttribute(t.BLOCK_INSTANCE_ID, P).setAttribute("data-initialized", "1").setAttribute(t.NAME_CONTROL_ENABLED, e.productNameControlEnabled).setAttribute(
|
|
51
|
+
t.QUANTITY_CONTROL_ENABLED,
|
|
52
|
+
e.productQuantityControlEnabled
|
|
53
|
+
).setAttribute(t.PRICE_CONTROL_OPENED, e.productPriceControlOpened).setAttribute(t.PRODUCT_IMAGE_VISIBLE, _).setAttribute(t.PRODUCT_NAME_VISIBLE, p).setAttribute(t.PRODUCT_QUANTITY_VISIBLE, N).setAttribute(t.PRODUCT_PRICE_VISIBLE, f).setAttribute(t.PRODUCT_ORIGINAL_PRICE_VISIBLE, g).setAttribute(t.PRODUCT_BUTTON_VISIBLE, D).apply(new a("Initialize config block attributes with defaults")), y().startOnboarding("itemsOnboarding");
|
|
48
54
|
}
|
|
49
|
-
const s = `[esd-extension-block-id="${f.IMAGE}"] img`;
|
|
50
|
-
this.api.getDocumentModifier().modifyHtml(i.querySelector(s)).setStyle("object-fit", "contain").apply(new n("Updated image object-fit"));
|
|
51
55
|
}
|
|
52
|
-
onSelect(
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
), e.
|
|
57
|
-
|
|
58
|
-
), e.setFormattedPrice(
|
|
59
|
-
t.priceFormatted ?? o.productPriceFormattedControlValue === "1"
|
|
60
|
-
));
|
|
56
|
+
onSelect(r) {
|
|
57
|
+
const n = r.querySelector("esd-config-block"), o = S();
|
|
58
|
+
if (!n)
|
|
59
|
+
return;
|
|
60
|
+
const s = n, u = s.getAttribute(t.TYPE) || e.itemsType, c = s.getAttribute(t.ITEMS_INDEX_SELECT_CONTROL_VALUE) || e.cartItemsSelectControlValue, i = s.getAttribute(t.ORIENTATION) || e.cardOrientationControlValue;
|
|
61
|
+
o.setItemsType(u), o.setItemIds(c), o.setOrientation(i), B(r), U(r), k(r);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
export {
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
M as BLOCK_ID,
|
|
66
|
+
x as ItemsBlock
|
|
66
67
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { ModificationDescription as
|
|
5
|
-
import { CommonControl as
|
|
1
|
+
var c = Object.defineProperty;
|
|
2
|
+
var I = (a, n, t) => n in a ? c(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
|
|
3
|
+
var _ = (a, n, t) => I(a, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { ModificationDescription as l } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as R } from "../../common-control.js";
|
|
6
6
|
import { ItemsBlockId as s } from "../enums/controlEnums.js";
|
|
7
|
-
import {
|
|
7
|
+
import { configAttributes as C } from "../enums/productEnums.js";
|
|
8
|
+
import { SETTINGS_ENUMS as u } from "../enums/settingsEnums.js";
|
|
8
9
|
import { useItemsBlockStore as O } from "../store/items-block.js";
|
|
9
|
-
import {
|
|
10
|
-
const
|
|
10
|
+
import { getConfigBlock as P, attributeToBoolean as U } from "../utils/configBlockUtils.js";
|
|
11
|
+
const h = "ui-elements-items-card-composition-block", i = {
|
|
11
12
|
PRODUCT_IMAGE: "image",
|
|
12
13
|
PRODUCT_NAME: "name",
|
|
13
14
|
PRODUCT_QUANTITY: "quantity",
|
|
@@ -15,11 +16,11 @@ const I = "ui-elements-items-card-composition-block", i = {
|
|
|
15
16
|
PRODUCT_ORIGINAL_PRICE: "originalPrice",
|
|
16
17
|
PRODUCT_BUTTON: "button"
|
|
17
18
|
};
|
|
18
|
-
class
|
|
19
|
+
class g extends R {
|
|
19
20
|
constructor() {
|
|
20
21
|
super(...arguments);
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
_(this, "store", O());
|
|
23
|
+
_(this, "visibilityState", {
|
|
23
24
|
[i.PRODUCT_IMAGE]: !0,
|
|
24
25
|
[i.PRODUCT_NAME]: !0,
|
|
25
26
|
[i.PRODUCT_QUANTITY]: !0,
|
|
@@ -29,7 +30,7 @@ class N extends u {
|
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
getId() {
|
|
32
|
-
return
|
|
33
|
+
return h;
|
|
33
34
|
}
|
|
34
35
|
getTemplate() {
|
|
35
36
|
return `
|
|
@@ -82,20 +83,20 @@ class N extends u {
|
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
85
|
_syncVisibilityFromAttributes() {
|
|
85
|
-
const t =
|
|
86
|
+
const t = P(this.currentNode);
|
|
86
87
|
if (!t)
|
|
87
88
|
return;
|
|
88
89
|
const e = {
|
|
89
|
-
[i.PRODUCT_IMAGE]: "
|
|
90
|
-
[i.PRODUCT_NAME]: "
|
|
91
|
-
[i.PRODUCT_QUANTITY]: "
|
|
92
|
-
[i.PRODUCT_PRICE]: "
|
|
93
|
-
[i.PRODUCT_ORIGINAL_PRICE]: "
|
|
94
|
-
[i.PRODUCT_BUTTON]: "
|
|
90
|
+
[i.PRODUCT_IMAGE]: "PRODUCT_IMAGE_VISIBLE",
|
|
91
|
+
[i.PRODUCT_NAME]: "PRODUCT_NAME_VISIBLE",
|
|
92
|
+
[i.PRODUCT_QUANTITY]: "PRODUCT_QUANTITY_VISIBLE",
|
|
93
|
+
[i.PRODUCT_PRICE]: "PRODUCT_PRICE_VISIBLE",
|
|
94
|
+
[i.PRODUCT_ORIGINAL_PRICE]: "PRODUCT_ORIGINAL_PRICE_VISIBLE",
|
|
95
|
+
[i.PRODUCT_BUTTON]: "PRODUCT_BUTTON_VISIBLE"
|
|
95
96
|
};
|
|
96
|
-
Object.entries(e).forEach(([o,
|
|
97
|
-
const T = t[
|
|
98
|
-
this.visibilityState[o] = T
|
|
97
|
+
Object.entries(e).forEach(([o, r]) => {
|
|
98
|
+
const T = t.getAttribute(C[r]);
|
|
99
|
+
this.visibilityState[o] = U(T, !0);
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
/**
|
|
@@ -104,10 +105,11 @@ class N extends u {
|
|
|
104
105
|
* and mark it as '0'
|
|
105
106
|
*/
|
|
106
107
|
_handleBrowsedItemsQuantity() {
|
|
107
|
-
|
|
108
|
+
var r;
|
|
109
|
+
const t = this.store.itemsType !== u.ITEMS_TYPE.BROWSED_ITEMS, e = (r = this.currentNode) == null ? void 0 : r.querySelector("esd-config-block");
|
|
108
110
|
if (!e)
|
|
109
111
|
return;
|
|
110
|
-
const o = e.
|
|
112
|
+
const o = e.getAttribute(C.PRODUCT_QUANTITY_VISIBLE) === "1";
|
|
111
113
|
this.visibilityState[i.PRODUCT_QUANTITY] = t && o, this.api.setVisibility(`${i.PRODUCT_QUANTITY}Container`, t), this._updateVisibilityAttribute(i.PRODUCT_QUANTITY, t && o);
|
|
112
114
|
}
|
|
113
115
|
_applyVisibilityStyles() {
|
|
@@ -120,26 +122,27 @@ class N extends u {
|
|
|
120
122
|
[i.PRODUCT_BUTTON]: s.BUTTON
|
|
121
123
|
};
|
|
122
124
|
Object.entries(t).forEach(([e, o]) => {
|
|
123
|
-
var
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
125
|
+
var d;
|
|
126
|
+
const r = (d = this.currentNode) == null ? void 0 : d.querySelector(`[esd-extension-block-id="${o}"]`);
|
|
127
|
+
if (!r)
|
|
126
128
|
return;
|
|
127
129
|
const T = this.visibilityState[e];
|
|
128
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
130
|
+
this.api.getDocumentModifier().modifyHtml(r).setStyle("display", T ? "table-cell" : "none").apply(new l(`Applied ${e} visibility from attributes`));
|
|
129
131
|
});
|
|
130
132
|
}
|
|
131
133
|
_updateVisibilityAttribute(t, e) {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
[i.
|
|
137
|
-
[i.
|
|
138
|
-
[i.
|
|
134
|
+
const o = P(this.currentNode);
|
|
135
|
+
if (!o)
|
|
136
|
+
return;
|
|
137
|
+
const T = {
|
|
138
|
+
[i.PRODUCT_IMAGE]: "PRODUCT_IMAGE_VISIBLE",
|
|
139
|
+
[i.PRODUCT_NAME]: "PRODUCT_NAME_VISIBLE",
|
|
140
|
+
[i.PRODUCT_QUANTITY]: "PRODUCT_QUANTITY_VISIBLE",
|
|
141
|
+
[i.PRODUCT_PRICE]: "PRODUCT_PRICE_VISIBLE",
|
|
142
|
+
[i.PRODUCT_ORIGINAL_PRICE]: "PRODUCT_ORIGINAL_PRICE_VISIBLE",
|
|
143
|
+
[i.PRODUCT_BUTTON]: "PRODUCT_BUTTON_VISIBLE"
|
|
139
144
|
}[t];
|
|
140
|
-
|
|
141
|
-
[l]: e
|
|
142
|
-
});
|
|
145
|
+
T && this.api.getDocumentModifier().modifyHtml(o).setAttribute(C[T], e ? "1" : "0").apply(new l(`Updated ${t} visibility attribute`));
|
|
143
146
|
}
|
|
144
147
|
_listenToFormUpdates() {
|
|
145
148
|
this.api.onValueChanged(i.PRODUCT_IMAGE, (t) => this._onProductImageChange(t)), this.api.onValueChanged(i.PRODUCT_NAME, (t) => this._onProductNameChange(t)), this.api.onValueChanged(i.PRODUCT_QUANTITY, (t) => this._onProductQuantityChange(t)), this.api.onValueChanged(i.PRODUCT_PRICE, (t) => this._onProductPriceChange(t)), this.api.onValueChanged(
|
|
@@ -150,41 +153,41 @@ class N extends u {
|
|
|
150
153
|
_onProductImageChange(t) {
|
|
151
154
|
var o;
|
|
152
155
|
const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.IMAGE}"]`);
|
|
153
|
-
e && (this.visibilityState[i.PRODUCT_IMAGE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new
|
|
156
|
+
e && (this.visibilityState[i.PRODUCT_IMAGE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product image visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_IMAGE, t));
|
|
154
157
|
}
|
|
155
158
|
_onProductNameChange(t) {
|
|
156
159
|
var o;
|
|
157
160
|
const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.NAME}"]`);
|
|
158
|
-
e && (this.visibilityState[i.PRODUCT_NAME] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new
|
|
161
|
+
e && (this.visibilityState[i.PRODUCT_NAME] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product name visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_NAME, t));
|
|
159
162
|
}
|
|
160
163
|
_onProductQuantityChange(t) {
|
|
161
164
|
var o;
|
|
162
165
|
const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.QUANTITY}"]`);
|
|
163
|
-
e && (this.visibilityState[i.PRODUCT_QUANTITY] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new
|
|
166
|
+
e && (this.visibilityState[i.PRODUCT_QUANTITY] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(
|
|
164
167
|
`Product quantity visibility changed to ${t ? "visible" : "hidden"}`
|
|
165
168
|
)), this._updateVisibilityAttribute(i.PRODUCT_QUANTITY, t));
|
|
166
169
|
}
|
|
167
170
|
_onProductPriceChange(t) {
|
|
168
171
|
var o;
|
|
169
172
|
const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.PRICE}"]`);
|
|
170
|
-
e && (this.visibilityState[i.PRODUCT_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new
|
|
173
|
+
e && (this.visibilityState[i.PRODUCT_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product price visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_PRICE, t));
|
|
171
174
|
}
|
|
172
175
|
_onProductOriginalPriceChange(t) {
|
|
173
176
|
var o;
|
|
174
177
|
const e = (o = this.currentNode) == null ? void 0 : o.querySelector(
|
|
175
178
|
`[esd-extension-block-id="${s.ORIGINAL_PRICE}"]`
|
|
176
179
|
);
|
|
177
|
-
e && (this.visibilityState[i.PRODUCT_ORIGINAL_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new
|
|
180
|
+
e && (this.visibilityState[i.PRODUCT_ORIGINAL_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(
|
|
178
181
|
`Product original price visibility changed to ${t ? "visible" : "hidden"}`
|
|
179
182
|
)), this._updateVisibilityAttribute(i.PRODUCT_ORIGINAL_PRICE, t));
|
|
180
183
|
}
|
|
181
184
|
_onProductButtonChange(t) {
|
|
182
185
|
var o;
|
|
183
186
|
const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.BUTTON}"]`);
|
|
184
|
-
e && (this.visibilityState[i.PRODUCT_BUTTON] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new
|
|
187
|
+
e && (this.visibilityState[i.PRODUCT_BUTTON] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product button visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_BUTTON, t));
|
|
185
188
|
}
|
|
186
189
|
}
|
|
187
190
|
export {
|
|
188
|
-
|
|
189
|
-
|
|
191
|
+
h as COMPOSITION_CONTROL_BLOCK_ID,
|
|
192
|
+
g as ItemsBlockCardCompositionControl
|
|
190
193
|
};
|