@useinsider/guido 2.0.0-beta.536ec84 → 2.0.0-beta.54d276a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/@types/config/schemas.js +3 -1
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +15 -17
- package/dist/components/organisms/email-preview/amp/AmpErrorModal.vue.js +7 -7
- package/dist/components/organisms/email-preview/amp/AmpToggle.vue.js +8 -7
- package/dist/components/organisms/email-preview/amp/AmpToggle.vue2.js +3 -4
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +14 -10
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue2.js +22 -18
- package/dist/components/organisms/email-preview/desktop-preview/EmailHeaderInfo.vue.js +17 -0
- package/dist/components/organisms/email-preview/desktop-preview/EmailHeaderInfo.vue2.js +20 -0
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +3 -3
- package/dist/components/organisms/email-preview/mobile-preview/MobilePreview.vue.js +10 -10
- package/dist/components/organisms/email-preview/mobile-preview/MobilePreview.vue2.js +14 -15
- package/dist/components/organisms/header/LeftSlot.vue.js +2 -2
- package/dist/components/organisms/header/MiddleSlot.vue.js +1 -1
- package/dist/components/organisms/header/MiddleSlot.vue2.js +13 -14
- package/dist/components/organisms/header/RightSlot.vue.js +7 -7
- package/dist/composables/useStripo.js +40 -40
- package/dist/config/migrator/recommendationMigrator.js +2 -2
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +13 -4
- package/dist/extensions/Blocks/Recommendation/block.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +11 -0
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +100 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +243 -0
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +154 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +372 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +76 -0
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +73 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +73 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +73 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +73 -0
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +224 -0
- package/dist/extensions/Blocks/Recommendation/extension.js +39 -43
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +5 -0
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +127 -72
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +20 -20
- package/dist/extensions/Blocks/Recommendation/templates/horizontal/elementRenderer.js +157 -0
- package/dist/extensions/Blocks/Recommendation/templates/horizontal/template.js +72 -0
- package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +173 -0
- package/dist/extensions/Blocks/Recommendation/templates/vertical/elementRenderer.js +186 -0
- package/dist/extensions/Blocks/Recommendation/templates/vertical/migration.js +251 -0
- package/dist/extensions/Blocks/Recommendation/templates/vertical/template.js +61 -0
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +25 -0
- package/dist/extensions/Blocks/controlFactories.js +155 -121
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +361 -291
- package/dist/package.json.js +1 -1
- package/dist/services/stripoApi.js +6 -10
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +19 -11
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +11 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +41 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +23 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +50 -0
- package/dist/src/extensions/Blocks/Recommendation/{control.d.ts → controls/main/index.d.ts} +19 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +16 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +77 -0
- package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/horizontal/elementRenderer.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/horizontal/migration.d.ts +25 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/horizontal/template.d.ts +18 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +39 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +45 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/vertical/elementRenderer.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → vertical/migration.d.ts} +11 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/vertical/template.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +19 -0
- package/dist/src/stores/config.d.ts +17 -0
- package/dist/static/assets/inbox-mockup.svg.js +4 -0
- package/dist/static/assets/phone-mockup.svg.js +4 -0
- package/dist/static/styles/components/wide-panel.css.js +0 -4
- package/dist/static/styles/customEditorStyle.css.js +38 -2
- package/package.json +3 -3
- package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -103
- package/dist/extensions/Blocks/Recommendation/constants.js +0 -5
- package/dist/extensions/Blocks/Recommendation/control.js +0 -306
- 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/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -160
- package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -152
- package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -180
- package/dist/src/extensions/Blocks/Recommendation/cardCompositionControl.d.ts +0 -28
- 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
- package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -44
- package/dist/static/assets/desktop/desktop-mockup-center.svg.js +0 -4
- package/dist/static/assets/desktop/desktop-mockup-left.svg.js +0 -4
- package/dist/static/assets/desktop/desktop-mockup-right.svg.js +0 -4
- package/dist/static/assets/mobile/email-mockup.svg.js +0 -4
- package/dist/static/assets/mobile/inbox-mockup.svg.js +0 -4
|
@@ -1,26 +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
|
|
7
|
-
import { displayConditions as
|
|
8
|
-
import { useStripoApi as
|
|
9
|
-
import
|
|
10
|
-
import { useEditorStore as
|
|
11
|
-
import { dynamicContentToMergeTags as
|
|
12
|
-
import
|
|
13
|
-
const
|
|
14
|
-
const { features: l } =
|
|
15
|
-
var g, f;
|
|
16
|
-
const o =
|
|
1
|
+
import { useActionsApi as _ } from "./useActionsApi.js";
|
|
2
|
+
import { useBlocksConfig as B } from "./useBlocksConfig.js";
|
|
3
|
+
import { useConfig as v } from "./useConfig.js";
|
|
4
|
+
import { useCustomInterfaceAppearance as A } from "./useCustomInterfaceAppearance.js";
|
|
5
|
+
import { useStripoEventHandler as F } from "./useStripoEventHandler.js";
|
|
6
|
+
import { useToaster as D } from "./useToaster.js";
|
|
7
|
+
import { displayConditions as I } from "../enums/displayConditions.js";
|
|
8
|
+
import { useStripoApi as M } from "../services/stripoApi.js";
|
|
9
|
+
import U from "../static/styles/customEditorStyle.css.js";
|
|
10
|
+
import { useEditorStore as P } from "../stores/editor.js";
|
|
11
|
+
import { dynamicContentToMergeTags as R } from "../utils/genericUtil.js";
|
|
12
|
+
import H from "../package.json.js";
|
|
13
|
+
const W = (c) => {
|
|
14
|
+
const { features: l, template: y } = v(), { handleError: u } = D(), { getToken: C, getCustomFonts: S } = M(), { handleEvent: E } = F(), { getStripoBlocksConfig: h } = B(), w = async (i, n = []) => {
|
|
15
|
+
var m, g, f;
|
|
16
|
+
const o = P(), { html: r, css: p } = i, { baseBlocks: s, extensions: t } = await h(), a = ((m = l.value) == null ? void 0 : m.displayConditions) ?? !0, k = ((g = l.value) == null ? void 0 : g.modulesDisabled) ?? !1, T = ((f = y.value) == null ? void 0 : f.forceRecreate) ?? !1;
|
|
17
17
|
window.UIEditor.initEditor(
|
|
18
18
|
document.querySelector("#guido-editor"),
|
|
19
19
|
{
|
|
20
20
|
metadata: c,
|
|
21
21
|
html: r,
|
|
22
22
|
css: p,
|
|
23
|
-
forceRecreate:
|
|
23
|
+
forceRecreate: T,
|
|
24
24
|
locale: "en",
|
|
25
25
|
undoButtonSelector: "#guido__undo-button",
|
|
26
26
|
redoButtonSelector: "#guido__redo-button",
|
|
@@ -30,19 +30,19 @@ const K = (c) => {
|
|
|
30
30
|
customAppearanceMergetags: !0,
|
|
31
31
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
32
32
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
33
|
-
customViewStyles:
|
|
34
|
-
conditionsEnabled:
|
|
35
|
-
customConditionsEnabled:
|
|
36
|
-
conditionCategories:
|
|
33
|
+
customViewStyles: U,
|
|
34
|
+
conditionsEnabled: a,
|
|
35
|
+
customConditionsEnabled: a,
|
|
36
|
+
conditionCategories: I,
|
|
37
37
|
enableXSSSecurity: !0,
|
|
38
|
-
modulesDisabled:
|
|
38
|
+
modulesDisabled: k,
|
|
39
39
|
messageSettingsEnabled: !0,
|
|
40
40
|
displayGmailAnnotations: !0,
|
|
41
41
|
displayHiddenPreheader: !1,
|
|
42
42
|
displayTitle: !1,
|
|
43
43
|
displayUTM: !1,
|
|
44
44
|
selectElementAfterDrop: !0,
|
|
45
|
-
...
|
|
45
|
+
...s ? { baseBlocks: s } : {},
|
|
46
46
|
editorFonts: {
|
|
47
47
|
showDefaultStandardFonts: !0,
|
|
48
48
|
showDefaultNotStandardFonts: !0,
|
|
@@ -50,21 +50,21 @@ const K = (c) => {
|
|
|
50
50
|
},
|
|
51
51
|
mergeTags: [
|
|
52
52
|
{
|
|
53
|
-
entries:
|
|
53
|
+
entries: R(c.preselectedDynamicContentList)
|
|
54
54
|
}
|
|
55
55
|
],
|
|
56
56
|
async onTokenRefreshRequest(e) {
|
|
57
57
|
try {
|
|
58
|
-
const
|
|
59
|
-
e(
|
|
60
|
-
} catch (
|
|
61
|
-
u(
|
|
58
|
+
const d = await C();
|
|
59
|
+
e(d);
|
|
60
|
+
} catch (d) {
|
|
61
|
+
u(d, "Failed to refresh token");
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
onTemplateLoaded() {
|
|
65
65
|
try {
|
|
66
|
-
const { importCss: e } =
|
|
67
|
-
e(),
|
|
66
|
+
const { importCss: e } = A(), { activateCustomViewStyles: d, updateTimerInClonedTemplate: V } = _();
|
|
67
|
+
e(), d(), V(), c.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
|
|
68
68
|
o.hasChanges = !1;
|
|
69
69
|
}, 1e3);
|
|
70
70
|
} catch (e) {
|
|
@@ -83,35 +83,35 @@ const K = (c) => {
|
|
|
83
83
|
onDataChanged() {
|
|
84
84
|
o.hasChanges = !0;
|
|
85
85
|
},
|
|
86
|
-
onEvent:
|
|
86
|
+
onEvent: E,
|
|
87
87
|
ignoreClickOutsideSelectors: [
|
|
88
88
|
"#guido-dynamic-content-modal",
|
|
89
89
|
".in-on-board-wrapper",
|
|
90
90
|
".in-drawer__container"
|
|
91
91
|
],
|
|
92
|
-
extensions:
|
|
92
|
+
extensions: t
|
|
93
93
|
}
|
|
94
94
|
);
|
|
95
|
-
},
|
|
96
|
-
var
|
|
95
|
+
}, b = (i) => new Promise((n, o) => {
|
|
96
|
+
var a;
|
|
97
97
|
if (document.getElementById("UiEditorScript")) {
|
|
98
98
|
i(), n();
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
const r =
|
|
102
|
-
t.id = "UiEditorScript", t.type = "module", t.src =
|
|
101
|
+
const r = H.guido, s = `https://email-static.useinsider.com/guido/${(a = r == null ? void 0 : r.stripo) == null ? void 0 : a.version}/UIEditor.js`, t = document.createElement("script");
|
|
102
|
+
t.id = "UiEditorScript", t.type = "module", t.src = s, t.onload = () => {
|
|
103
103
|
i(), n();
|
|
104
104
|
}, t.onerror = () => {
|
|
105
|
-
o(new Error(`Failed to load Stripo UIEditor script from S3: ${
|
|
105
|
+
o(new Error(`Failed to load Stripo UIEditor script from S3: ${s}`));
|
|
106
106
|
}, document.body.appendChild(t);
|
|
107
107
|
});
|
|
108
108
|
return { initPlugin: async (i) => {
|
|
109
|
-
await
|
|
109
|
+
await b(async () => {
|
|
110
110
|
const n = await S();
|
|
111
|
-
await
|
|
111
|
+
await w(i, n);
|
|
112
112
|
});
|
|
113
113
|
} };
|
|
114
114
|
};
|
|
115
115
|
export {
|
|
116
|
-
|
|
116
|
+
W as useStripo
|
|
117
117
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var h = Object.defineProperty;
|
|
2
2
|
var T = (A, e, t) => e in A ? h(A, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : A[e] = t;
|
|
3
3
|
var m = (A, e, t) => T(A, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import P, { prepareProductRows as S } from "../../extensions/Blocks/Recommendation/templates/
|
|
5
|
-
import { getDefaultProducts as q } from "../../extensions/Blocks/Recommendation/templates/
|
|
4
|
+
import P, { prepareProductRows as S } from "../../extensions/Blocks/Recommendation/templates/vertical/migration.js";
|
|
5
|
+
import { getDefaultProducts as q } from "../../extensions/Blocks/Recommendation/templates/utils.js";
|
|
6
6
|
class w {
|
|
7
7
|
constructor() {
|
|
8
8
|
m(this, "parser");
|
|
@@ -145,10 +145,19 @@ class g extends R {
|
|
|
145
145
|
T && this.api.getDocumentModifier().modifyHtml(o).setAttribute(C[T], e ? "1" : "0").apply(new l(`Updated ${t} visibility attribute`));
|
|
146
146
|
}
|
|
147
147
|
_listenToFormUpdates() {
|
|
148
|
-
this.api.onValueChanged(i.PRODUCT_IMAGE, (t) =>
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
this.api.onValueChanged(i.PRODUCT_IMAGE, (t) => {
|
|
149
|
+
this._onProductImageChange(t);
|
|
150
|
+
}), this.api.onValueChanged(i.PRODUCT_NAME, (t) => {
|
|
151
|
+
this._onProductNameChange(t);
|
|
152
|
+
}), this.api.onValueChanged(i.PRODUCT_QUANTITY, (t) => {
|
|
153
|
+
this._onProductQuantityChange(t);
|
|
154
|
+
}), this.api.onValueChanged(i.PRODUCT_PRICE, (t) => {
|
|
155
|
+
this._onProductPriceChange(t);
|
|
156
|
+
}), this.api.onValueChanged(i.PRODUCT_ORIGINAL_PRICE, (t) => {
|
|
157
|
+
this._onProductOriginalPriceChange(t);
|
|
158
|
+
}), this.api.onValueChanged(i.PRODUCT_BUTTON, (t) => {
|
|
159
|
+
this._onProductButtonChange(t);
|
|
160
|
+
});
|
|
152
161
|
}
|
|
153
162
|
_onProductImageChange(t) {
|
|
154
163
|
var o;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Block as e, BlockCompositionType as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
import { getDefaultTemplate as o } from "./templates/
|
|
2
|
+
import { getDefaultTemplate as o } from "./templates/vertical/template.js";
|
|
3
3
|
const n = "recommendation-block";
|
|
4
4
|
class m extends e {
|
|
5
5
|
constructor() {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var b = /* @__PURE__ */ ((r) => (r.BUTTON = "recommendation-block-button", r.NAME = "recommendation-block-name", r.PRICE = "recommendation-block-price", r.OLD_PRICE = "recommendation-block-old-price", r.OMNIBUS_PRICE = "recommendation-block-omnibus-price", r.OMNIBUS_DISCOUNT = "recommendation-block-omnibus-discount", r.IMAGE = "recommendation-block-image", r))(b || {});
|
|
2
|
+
export {
|
|
3
|
+
b as RecommendationBlockId
|
|
4
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var o = /* @__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))(o || {});
|
|
2
|
+
export {
|
|
3
|
+
o as RecommendationControlId
|
|
4
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const T = ".ins-recommendation-product-container", c = "productImage", o = "productName", t = "productPrice", R = "productOldPrice", _ = "productOmnibusPrice", n = "productOmnibusDiscount", O = "productButton";
|
|
2
|
+
export {
|
|
3
|
+
O as ATTR_PRODUCT_BUTTON,
|
|
4
|
+
c as ATTR_PRODUCT_IMAGE,
|
|
5
|
+
o as ATTR_PRODUCT_NAME,
|
|
6
|
+
R as ATTR_PRODUCT_OLD_PRICE,
|
|
7
|
+
n as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
|
|
8
|
+
_ as ATTR_PRODUCT_OMNIBUS_PRICE,
|
|
9
|
+
t as ATTR_PRODUCT_PRICE,
|
|
10
|
+
T as CONTAINER_SELECTOR
|
|
11
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createButtonFitToContainerControl as T, createButtonTextStyleAndFontColorControl as r, createButtonTextSizeControl as e, createButtonTextControl as B, createButtonPaddingsControl as l, createButtonMarginsControl as C, createButtonFontFamilyControl as O, createButtonColorControl as N, createButtonBorderRadiusControl as i, createButtonBorderControl as a, createButtonAlignControl as c } from "../../../controlFactories.js";
|
|
2
|
+
import { RecommendationBlockId as o } from "../../constants/blockIds.js";
|
|
3
|
+
import { RecommendationControlId as t } from "../../constants/controlIds.js";
|
|
4
|
+
import { CONTAINER_SELECTOR as n } from "../../constants/selectors.js";
|
|
5
|
+
const U = c(
|
|
6
|
+
t.BUTTON_ALIGN,
|
|
7
|
+
o.BUTTON,
|
|
8
|
+
n
|
|
9
|
+
), d = a(
|
|
10
|
+
t.BUTTON_BORDER,
|
|
11
|
+
o.BUTTON,
|
|
12
|
+
n
|
|
13
|
+
), s = i(
|
|
14
|
+
t.BUTTON_BORDER_RADIUS,
|
|
15
|
+
o.BUTTON,
|
|
16
|
+
n
|
|
17
|
+
), _ = N(
|
|
18
|
+
t.BUTTON_COLOR,
|
|
19
|
+
o.BUTTON,
|
|
20
|
+
n
|
|
21
|
+
), m = O(
|
|
22
|
+
t.BUTTON_FONT_FAMILY,
|
|
23
|
+
o.BUTTON,
|
|
24
|
+
n
|
|
25
|
+
), u = C(
|
|
26
|
+
t.BUTTON_MARGINS,
|
|
27
|
+
o.BUTTON,
|
|
28
|
+
n
|
|
29
|
+
), R = l(
|
|
30
|
+
t.BUTTON_PADDINGS,
|
|
31
|
+
o.BUTTON,
|
|
32
|
+
n
|
|
33
|
+
), F = B(
|
|
34
|
+
t.BUTTON_TEXT,
|
|
35
|
+
o.BUTTON,
|
|
36
|
+
n
|
|
37
|
+
), A = e(
|
|
38
|
+
t.BUTTON_TEXT_SIZE,
|
|
39
|
+
o.BUTTON,
|
|
40
|
+
n
|
|
41
|
+
), S = r(
|
|
42
|
+
t.BUTTON_TEXT_STYLE_AND_FONT_COLOR,
|
|
43
|
+
o.BUTTON,
|
|
44
|
+
n
|
|
45
|
+
), E = T(
|
|
46
|
+
t.BUTTON_FIT_TO_CONTENT,
|
|
47
|
+
o.BUTTON,
|
|
48
|
+
n
|
|
49
|
+
), p = {
|
|
50
|
+
align: U,
|
|
51
|
+
border: d,
|
|
52
|
+
borderRadius: s,
|
|
53
|
+
color: _,
|
|
54
|
+
fontFamily: m,
|
|
55
|
+
margins: u,
|
|
56
|
+
paddings: R,
|
|
57
|
+
text: F,
|
|
58
|
+
textSize: A,
|
|
59
|
+
textStyleAndFontColor: S,
|
|
60
|
+
fitToContent: E
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
p as ButtonControls
|
|
64
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ModificationDescription as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as i } from "../../../common-control.js";
|
|
3
|
+
const u = "recommendation-card-background-color-control", e = {
|
|
4
|
+
CARD_BACKGROUND_COLOR: "cardBackgroundColor"
|
|
5
|
+
}, c = {
|
|
6
|
+
VERTICAL: ".product-card-segment",
|
|
7
|
+
HORIZONTAL: ".product-card-wrapper"
|
|
8
|
+
};
|
|
9
|
+
class g extends i {
|
|
10
|
+
getId() {
|
|
11
|
+
return u;
|
|
12
|
+
}
|
|
13
|
+
getTemplate() {
|
|
14
|
+
return `
|
|
15
|
+
<div class="card-bg-control-container">
|
|
16
|
+
${this._GuTwoColumns([
|
|
17
|
+
this._GuLabel({ text: "Card Background Color" }),
|
|
18
|
+
this._GuColorPicker(e.CARD_BACKGROUND_COLOR)
|
|
19
|
+
])}
|
|
20
|
+
</div>
|
|
21
|
+
`;
|
|
22
|
+
}
|
|
23
|
+
onRender() {
|
|
24
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
25
|
+
}
|
|
26
|
+
onTemplateNodeUpdated(t) {
|
|
27
|
+
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
28
|
+
}
|
|
29
|
+
_setFormValues() {
|
|
30
|
+
const t = this._getCurrentCardBackgroundColor();
|
|
31
|
+
this.api.updateValues({
|
|
32
|
+
[e.CARD_BACKGROUND_COLOR]: t
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Gets the block element - either currentNode itself or as a descendant
|
|
37
|
+
* The currentNode could BE the block element or contain it
|
|
38
|
+
*/
|
|
39
|
+
_getBlockElement() {
|
|
40
|
+
if (!this.currentNode)
|
|
41
|
+
return null;
|
|
42
|
+
if ("getAttribute" in this.currentNode) {
|
|
43
|
+
const t = this.currentNode.getAttribute("class");
|
|
44
|
+
if (t && t.includes("ins-recommendation-v3-block-v2"))
|
|
45
|
+
return this.currentNode;
|
|
46
|
+
}
|
|
47
|
+
return "querySelector" in this.currentNode ? this.currentNode.querySelector(".ins-recommendation-v3-block-v2") : null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the current layout orientation from the block's data attribute
|
|
51
|
+
*/
|
|
52
|
+
_getCurrentLayout() {
|
|
53
|
+
const t = this._getBlockElement();
|
|
54
|
+
return !t || !("getAttribute" in t) ? "vertical" : t.getAttribute("data-layout") === "horizontal" ? "horizontal" : "vertical";
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Gets the appropriate selector based on layout
|
|
58
|
+
* Vertical: .product-card-segment (inner table per product cell)
|
|
59
|
+
* Horizontal: .product-card-wrapper (table per product row)
|
|
60
|
+
*/
|
|
61
|
+
_getCardSelector() {
|
|
62
|
+
return this._getCurrentLayout() === "vertical" ? c.VERTICAL : c.HORIZONTAL;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Reads the current background color from the first product card element
|
|
66
|
+
* @returns The background color value or 'transparent' if not found
|
|
67
|
+
*/
|
|
68
|
+
_getCurrentCardBackgroundColor() {
|
|
69
|
+
if (!this.currentNode || !("querySelectorAll" in this.currentNode))
|
|
70
|
+
return "transparent";
|
|
71
|
+
const t = this._getCardSelector(), r = this.currentNode.querySelector(t);
|
|
72
|
+
return !r || !("getStyle" in r) ? "transparent" : r.getStyle("background-color") || "transparent";
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Handles card background color changes
|
|
76
|
+
* Applies the color to all product card elements based on layout
|
|
77
|
+
*/
|
|
78
|
+
_onCardBackgroundColorChange(t) {
|
|
79
|
+
if (!this.currentNode || !("querySelectorAll" in this.currentNode))
|
|
80
|
+
return;
|
|
81
|
+
const r = this._getCardSelector(), o = Array.from(
|
|
82
|
+
this.currentNode.querySelectorAll(r)
|
|
83
|
+
);
|
|
84
|
+
if (o.length === 0)
|
|
85
|
+
return;
|
|
86
|
+
const n = this.api.getDocumentModifier();
|
|
87
|
+
o.forEach((a) => {
|
|
88
|
+
n.modifyHtml(a).setStyle("background-color", t);
|
|
89
|
+
}), n.apply(new l("Update card background color"));
|
|
90
|
+
}
|
|
91
|
+
_listenToFormUpdates() {
|
|
92
|
+
this.api.onValueChanged(e.CARD_BACKGROUND_COLOR, (t) => {
|
|
93
|
+
this._onCardBackgroundColorChange(t);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
u as CARD_BACKGROUND_COLOR_CONTROL_ID,
|
|
99
|
+
g as CardBackgroundColorControl
|
|
100
|
+
};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var C = (a, n, t) => n in a ? f(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
|
|
3
|
+
var c = (a, n, t) => C(a, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { ModificationDescription as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as g } from "../../../common-control.js";
|
|
6
|
+
import { ATTR_PRODUCT_IMAGE as O, ATTR_PRODUCT_NAME as A, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_OLD_PRICE as N, ATTR_PRODUCT_OMNIBUS_PRICE as E, ATTR_PRODUCT_OMNIBUS_DISCOUNT as D, ATTR_PRODUCT_BUTTON as v } from "../../constants/selectors.js";
|
|
7
|
+
import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
|
|
8
|
+
const V = "ui-elements-recommendation-card-composition", S = {
|
|
9
|
+
ORDERABLE: "cardComposition"
|
|
10
|
+
}, b = ".recommendation-attribute-row", P = ".product-card-wrapper > tbody", y = "data-card-composition", p = "data-attribute-type", h = "data-visibility", s = [
|
|
11
|
+
{ key: O, label: "Product Image", visible: !0 },
|
|
12
|
+
{ key: A, label: "Product Name", visible: !0 },
|
|
13
|
+
{ key: R, label: "Product Price", visible: !0 },
|
|
14
|
+
{ key: N, label: "Product Original Price", visible: !0 },
|
|
15
|
+
{ key: E, label: "Omnibus Price", visible: !1 },
|
|
16
|
+
{ key: D, label: "Omnibus Discount", visible: !1 },
|
|
17
|
+
{ key: v, label: "Product Button", visible: !0 }
|
|
18
|
+
];
|
|
19
|
+
class x extends g {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
c(this, "store", I());
|
|
23
|
+
c(this, "unsubscribeOrientation", null);
|
|
24
|
+
}
|
|
25
|
+
getId() {
|
|
26
|
+
return V;
|
|
27
|
+
}
|
|
28
|
+
getTemplate() {
|
|
29
|
+
const t = s.map((e) => ({
|
|
30
|
+
key: e.key,
|
|
31
|
+
label: e.label,
|
|
32
|
+
content: this._createItemContent(e.label, e.key)
|
|
33
|
+
}));
|
|
34
|
+
return `
|
|
35
|
+
<div class="container" data-card-composition-control>
|
|
36
|
+
${this._GuLabel({ text: "Card Element Order & Visibility" })}
|
|
37
|
+
${this._GuOrderable(S.ORDERABLE, t)}
|
|
38
|
+
</div>
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
onRender() {
|
|
42
|
+
this._initializeComposition(), this._registerValueChangeListeners(), this._updateOrderableState(), this._subscribeToOrientationChanges();
|
|
43
|
+
}
|
|
44
|
+
onTemplateNodeUpdated(t) {
|
|
45
|
+
super.onTemplateNodeUpdated(t), this._initializeComposition(), this._updateOrderableState();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates the HTML content for an orderable item with label and toggle
|
|
49
|
+
*/
|
|
50
|
+
_createItemContent(t, e) {
|
|
51
|
+
return `
|
|
52
|
+
<div style="display: flex; align-items: center; justify-content: space-between;
|
|
53
|
+
padding: 8px; gap: 8px;">
|
|
54
|
+
<span style="flex: 1;">${t}</span>
|
|
55
|
+
${this._GuToggle(`visibility_${e}`)}
|
|
56
|
+
</div>
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Registers event listeners for composition and visibility changes
|
|
61
|
+
*/
|
|
62
|
+
_registerValueChangeListeners() {
|
|
63
|
+
this.api.onValueChanged("cardComposition", (t) => {
|
|
64
|
+
this._applyCompositionToBlock(t);
|
|
65
|
+
}), s.forEach((t) => {
|
|
66
|
+
this.api.onValueChanged(`visibility_${t.key}`, (e) => {
|
|
67
|
+
this._applyVisibilityToBlock(t.key, e);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Initializes composition order and visibility state from the current node
|
|
73
|
+
*/
|
|
74
|
+
_initializeComposition() {
|
|
75
|
+
const t = this._readCompositionFromNode(), e = this._readVisibilityFromRows(), i = {
|
|
76
|
+
cardComposition: t,
|
|
77
|
+
...this._buildVisibilityValues(e)
|
|
78
|
+
};
|
|
79
|
+
this.api.updateValues(i);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Reads composition order from node's data-card-composition attribute
|
|
83
|
+
* Falls back to default order if attribute is not present
|
|
84
|
+
*/
|
|
85
|
+
_readCompositionFromNode() {
|
|
86
|
+
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
87
|
+
return s.map((e) => e.key);
|
|
88
|
+
const t = this.currentNode.getAttribute(y);
|
|
89
|
+
return t ? t.split(",").filter(Boolean) : s.map((e) => e.key);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Builds visibility values object from the visibility map
|
|
93
|
+
*/
|
|
94
|
+
_buildVisibilityValues(t) {
|
|
95
|
+
return s.reduce((e, i) => (e[`visibility_${i.key}`] = t[i.key] ?? !0, e), {});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Read visibility state from individual row elements' data-visibility attributes
|
|
99
|
+
* This ensures toggles reflect the actual DOM state
|
|
100
|
+
*/
|
|
101
|
+
_readVisibilityFromRows() {
|
|
102
|
+
if (!this.currentNode)
|
|
103
|
+
return this._getDefaultVisibilities();
|
|
104
|
+
const t = Array.from(this.currentNode.querySelectorAll(b)), e = this._extractVisibilityFromRows(t);
|
|
105
|
+
return this._mergeWithDefaults(e);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Returns default visibility values for all items
|
|
109
|
+
*/
|
|
110
|
+
_getDefaultVisibilities() {
|
|
111
|
+
return s.reduce((t, e) => (t[e.key] = e.visible, t), {});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Extracts visibility values from DOM nodes
|
|
115
|
+
*/
|
|
116
|
+
_extractVisibilityFromRows(t) {
|
|
117
|
+
const e = {};
|
|
118
|
+
return t.forEach((i) => {
|
|
119
|
+
if (!("getAttribute" in i))
|
|
120
|
+
return;
|
|
121
|
+
const o = i.getAttribute(p), r = i.getAttribute(h);
|
|
122
|
+
o && r !== null && (e[o] = this._parseVisibilityValue(r));
|
|
123
|
+
}), e;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Parses visibility value from string to boolean
|
|
127
|
+
* Accepts "1", "true" as true, everything else as false
|
|
128
|
+
*/
|
|
129
|
+
_parseVisibilityValue(t) {
|
|
130
|
+
return t === "1" || t === "true";
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Merges extracted visibilities with default values for missing keys
|
|
134
|
+
*/
|
|
135
|
+
_mergeWithDefaults(t) {
|
|
136
|
+
return s.forEach((e) => {
|
|
137
|
+
e.key in t || (t[e.key] = e.visible);
|
|
138
|
+
}), t;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Apply the reordered composition to the block's HTML structure
|
|
142
|
+
* Updates the data-card-composition attribute and reorders product attributes
|
|
143
|
+
* Note: Reordering is only applied for vertical layout
|
|
144
|
+
*/
|
|
145
|
+
_applyCompositionToBlock(t) {
|
|
146
|
+
if (!this.currentNode)
|
|
147
|
+
return;
|
|
148
|
+
const e = this._getCurrentLayout();
|
|
149
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(y, t.join(",")).apply(new d("Update card composition")), e === "vertical" && this._reorderProductAttributes(t);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Reorders attribute rows within each product card based on composition order
|
|
153
|
+
* Targets the tbody inside each product-attribute-cell to preserve card structure
|
|
154
|
+
*/
|
|
155
|
+
_reorderProductAttributes(t) {
|
|
156
|
+
if (!this.currentNode)
|
|
157
|
+
return;
|
|
158
|
+
const e = this.currentNode.querySelectorAll(P);
|
|
159
|
+
if (!(e != null && e.length))
|
|
160
|
+
return;
|
|
161
|
+
const i = this.api.getDocumentModifier();
|
|
162
|
+
e.forEach((o) => {
|
|
163
|
+
const r = this._buildCompositionHtml(o, t);
|
|
164
|
+
i.modifyHtml(o).setInnerHtml(r);
|
|
165
|
+
}), i.apply(new d("Reorder product attributes"));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Builds HTML string with attributes ordered according to composition
|
|
169
|
+
*/
|
|
170
|
+
_buildCompositionHtml(t, e) {
|
|
171
|
+
return e.reduce((i, o) => {
|
|
172
|
+
const r = t.querySelector(`${b}[${p}="${o}"]`);
|
|
173
|
+
return r && "getOuterHTML" in r ? i + r.getOuterHTML() : i;
|
|
174
|
+
}, "");
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Apply visibility changes to the block's HTML structure
|
|
178
|
+
* Updates display style and data-visibility attribute for all matching elements
|
|
179
|
+
* - <tr> elements: use display: none / table-row
|
|
180
|
+
* - <td> elements: use display: none / table-cell
|
|
181
|
+
*/
|
|
182
|
+
_applyVisibilityToBlock(t, e) {
|
|
183
|
+
if (!this.currentNode)
|
|
184
|
+
return;
|
|
185
|
+
const i = this.currentNode.querySelectorAll(`${b}[${p}="${t}"]`);
|
|
186
|
+
if (!(i != null && i.length))
|
|
187
|
+
return;
|
|
188
|
+
const o = e ? "1" : "0", r = `Set ${t} visibility to ${e ? "visible" : "hidden"}`, m = this.api.getDocumentModifier();
|
|
189
|
+
i.forEach((l) => {
|
|
190
|
+
let u = "TR";
|
|
191
|
+
if ("tagName" in l && l.tagName)
|
|
192
|
+
u = l.tagName.toUpperCase();
|
|
193
|
+
else if ("getTagName" in l) {
|
|
194
|
+
const _ = l;
|
|
195
|
+
typeof _.getTagName == "function" && (u = _.getTagName().toUpperCase());
|
|
196
|
+
}
|
|
197
|
+
const T = e ? u === "TD" || u === "BLOCK_IMAGE" || u === "BLOCK_BUTTON" ? "table-cell" : "table-row" : "none";
|
|
198
|
+
m.modifyHtml(l).setStyle("display", T).setAttribute(h, o);
|
|
199
|
+
}), m.apply(new d(r));
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Gets the current layout orientation from store or DOM
|
|
203
|
+
*/
|
|
204
|
+
_getCurrentLayout() {
|
|
205
|
+
const t = this.store.recommendationConfigs.orientation;
|
|
206
|
+
if (t)
|
|
207
|
+
return t;
|
|
208
|
+
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
209
|
+
return "vertical";
|
|
210
|
+
const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
|
|
211
|
+
return !e || !("getAttribute" in e) ? "vertical" : e.getAttribute("data-layout") === "horizontal" ? "horizontal" : "vertical";
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Updates orderable state based on layout orientation
|
|
215
|
+
* Adds/removes disabled class to hide drag icons for horizontal layout
|
|
216
|
+
*/
|
|
217
|
+
_updateOrderableState() {
|
|
218
|
+
const e = this._getCurrentLayout() === "horizontal", i = this.getContainer();
|
|
219
|
+
if (!i)
|
|
220
|
+
return;
|
|
221
|
+
const o = i.querySelector("[data-card-composition-control]");
|
|
222
|
+
if (!o)
|
|
223
|
+
return;
|
|
224
|
+
const r = o.querySelector("ue-orderable");
|
|
225
|
+
r && r.classList.toggle("orderable-disabled", e);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Subscribe to store orientation changes
|
|
229
|
+
* Updates orderable state when layout changes via the layout control
|
|
230
|
+
*/
|
|
231
|
+
_subscribeToOrientationChanges() {
|
|
232
|
+
this.unsubscribeOrientation && this.unsubscribeOrientation();
|
|
233
|
+
let t = this.store.recommendationConfigs.orientation;
|
|
234
|
+
this.unsubscribeOrientation = this.store.$subscribe(() => {
|
|
235
|
+
const e = this.store.recommendationConfigs.orientation;
|
|
236
|
+
e !== t && (t = e, this._updateOrderableState());
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
export {
|
|
241
|
+
V as COMPOSITION_CONTROL_BLOCK_ID,
|
|
242
|
+
x as RecommendationCardCompositionControl
|
|
243
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createImageMarginsControl as m, createImageSizeControl as n } from "../../../controlFactories.js";
|
|
2
|
+
import { RecommendationBlockId as o } from "../../constants/blockIds.js";
|
|
3
|
+
import { RecommendationControlId as r } from "../../constants/controlIds.js";
|
|
4
|
+
import { CONTAINER_SELECTOR as t } from "../../constants/selectors.js";
|
|
5
|
+
const e = n(
|
|
6
|
+
r.IMAGE_SIZE,
|
|
7
|
+
o.IMAGE,
|
|
8
|
+
t
|
|
9
|
+
), i = m(
|
|
10
|
+
r.IMAGE_MARGINS,
|
|
11
|
+
o.IMAGE,
|
|
12
|
+
t
|
|
13
|
+
), C = {
|
|
14
|
+
size: e,
|
|
15
|
+
margins: i
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
C as ImageControls
|
|
19
|
+
};
|