@useinsider/guido 1.0.3-beta.538b804 → 1.0.3-beta.5402bce
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 +3 -0
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/organisms/LoadingWrapper.vue.js +1 -1
- package/dist/components/organisms/header/RightSlot.vue2.js +13 -13
- package/dist/composables/useStripo.js +29 -25
- package/dist/enums/defaults.js +5 -4
- package/dist/extensions/Blocks/Checkbox/control.js +15 -14
- package/dist/extensions/Blocks/Checkbox/template.js +14 -9
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +25 -25
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +92 -0
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +73 -78
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
- package/dist/extensions/Blocks/Items/enums/productEnums.js +3 -2
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +3 -2
- package/dist/extensions/Blocks/Items/extension.js +7 -6
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +2 -2
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +17 -5
- package/dist/extensions/Blocks/Items/settingsPanel.js +8 -8
- package/dist/extensions/Blocks/Items/store/items-block.js +8 -4
- package/dist/extensions/Blocks/Items/template.js +65 -59
- package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +35 -26
- package/dist/extensions/Blocks/Items/utils/updateAttributes.js +29 -27
- package/dist/extensions/Blocks/RadioButton/control.js +18 -17
- package/dist/extensions/Blocks/RadioButton/template.js +18 -9
- package/dist/extensions/Blocks/Unsubscribe/block.js +34 -30
- package/dist/guido.css +1 -1
- package/dist/services/stripoApi.js +15 -16
- package/dist/src/enums/defaults.d.ts +1 -0
- package/dist/src/extensions/Blocks/Checkbox/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +15 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -2
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.d.ts +6 -0
- package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +3 -4
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -600,6 +600,9 @@ Create a `.env` file with the following variables: (You can get env variables fr
|
|
|
600
600
|
VITE_STRIPO_PLUGIN_ID=your_plugin_id
|
|
601
601
|
VITE_STRIPO_SECRET_KEY=your_secret_key
|
|
602
602
|
VITE_STRIPO_ROLE=your_role
|
|
603
|
+
|
|
604
|
+
# Playwright Test Configuration (Optional - for local debugging only)
|
|
605
|
+
HEADED=false # Set to 'true' to run tests with visible browser
|
|
603
606
|
```
|
|
604
607
|
|
|
605
608
|
### Project Structure
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as H, ref as
|
|
1
|
+
import { defineComponent as H, ref as m, computed as _ } from "vue";
|
|
2
2
|
import { useConfig as h } from "../../../composables/useConfig.js";
|
|
3
3
|
import { useExport as V } from "../../../composables/useExport.js";
|
|
4
4
|
import { useTestEmailClick as x } from "../../../composables/useGuidoActions.js";
|
|
@@ -10,25 +10,25 @@ import { getTooltipOptions as O } from "../../../utils/tooltipUtils.js";
|
|
|
10
10
|
import { InButtonV2 as A } from "@useinsider/design-system-vue";
|
|
11
11
|
const J = /* @__PURE__ */ H({
|
|
12
12
|
__name: "RightSlot",
|
|
13
|
-
setup(k, { expose:
|
|
14
|
-
const { config:
|
|
15
|
-
if (
|
|
13
|
+
setup(k, { expose: c }) {
|
|
14
|
+
const { config: u } = h(), { exportHtml: r } = V(), { save: n } = E(), { openVersionHistory: i, closeVersionHistory: a } = w(), o = C(), t = T(), e = m(!1), s = m(!1), f = x(), v = () => {
|
|
15
|
+
if (o.isVersionHistoryOpen) {
|
|
16
16
|
a();
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
i();
|
|
20
|
-
},
|
|
20
|
+
}, d = async () => {
|
|
21
21
|
e.value = !0, await r(), e.value = !1;
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
s.value = !0,
|
|
26
|
-
const g = await n(
|
|
27
|
-
return s.value = !1,
|
|
22
|
+
}, y = () => {
|
|
23
|
+
o.isSaveAsTemplateDrawerOpen = !0;
|
|
24
|
+
}, S = _(() => o.isVersionHistoryOpen ? t("newsletter.close-version-history") : t("newsletter.version-history")), l = async (p) => {
|
|
25
|
+
s.value = !0, o.loadingStatus = !0;
|
|
26
|
+
const g = await n(p);
|
|
27
|
+
return s.value = !1, p && (o.loadingStatus = !1), g;
|
|
28
28
|
};
|
|
29
|
-
return
|
|
29
|
+
return c({
|
|
30
30
|
handleSave: l
|
|
31
|
-
}), { __sfc: !0, config:
|
|
31
|
+
}), { __sfc: !0, config: u, exportHtml: r, save: n, openVersionHistory: i, closeVersionHistory: a, editorStore: o, trans: t, isExporting: e, isSaving: s, testEmailClick: f, handleVersionHistory: v, handleExport: d, handleSaveAs: y, versionHistoryTooltipText: S, handleSave: l, getTooltipOptions: O, InButtonV2: A };
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
export {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
1
|
+
import { useActionsApi as w } from "./useActionsApi.js";
|
|
2
2
|
import { useBlocksConfig as b } from "./useBlocksConfig.js";
|
|
3
3
|
import { useConfig as k } from "./useConfig.js";
|
|
4
4
|
import { useCustomInterfaceAppearance as V } from "./useCustomInterfaceAppearance.js";
|
|
5
5
|
import { useStripoEventHandler as _ } from "./useStripoEventHandler.js";
|
|
6
6
|
import { useToaster as B } from "./useToaster.js";
|
|
7
|
-
import { displayConditions as
|
|
8
|
-
import { useStripoApi as
|
|
9
|
-
import
|
|
10
|
-
import { useEditorStore as
|
|
11
|
-
import { dynamicContentToMergeTags as
|
|
12
|
-
import
|
|
13
|
-
const
|
|
14
|
-
const { config: u } = k(), { handleError: l } = B(), { getToken: f, getCustomFonts:
|
|
7
|
+
import { displayConditions as T } from "../enums/displayConditions.js";
|
|
8
|
+
import { useStripoApi as A } from "../services/stripoApi.js";
|
|
9
|
+
import F from "../static/styles/customEditorStyle.css.js";
|
|
10
|
+
import { useEditorStore as M } from "../stores/editor.js";
|
|
11
|
+
import { dynamicContentToMergeTags as U } from "../utils/genericUtil.js";
|
|
12
|
+
import v from "../package.json.js";
|
|
13
|
+
const J = (c) => {
|
|
14
|
+
const { config: u } = k(), { handleError: l } = B(), { getToken: f, getCustomFonts: y } = A(), { handleEvent: S } = _(), { getStripoBlocksConfig: C } = b(), E = async (i, r = []) => {
|
|
15
15
|
var m, g;
|
|
16
|
-
const t =
|
|
16
|
+
const t = M(), { html: n, css: p, forceRecreate: a } = i, { baseBlocks: e, extensions: d } = await C();
|
|
17
17
|
window.UIEditor.initEditor(
|
|
18
18
|
document.querySelector("#guido-editor"),
|
|
19
19
|
{
|
|
20
|
-
metadata:
|
|
20
|
+
metadata: c,
|
|
21
21
|
html: n,
|
|
22
22
|
css: p,
|
|
23
23
|
forceRecreate: a,
|
|
@@ -30,12 +30,16 @@ const N = (d) => {
|
|
|
30
30
|
customAppearanceMergetags: !0,
|
|
31
31
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
32
32
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
33
|
-
customViewStyles:
|
|
33
|
+
customViewStyles: F,
|
|
34
34
|
conditionsEnabled: ((m = u.features) == null ? void 0 : m.displayConditions) ?? !0,
|
|
35
35
|
customConditionsEnabled: ((g = u.features) == null ? void 0 : g.displayConditions) ?? !0,
|
|
36
|
-
conditionCategories:
|
|
36
|
+
conditionCategories: T,
|
|
37
37
|
enableXSSSecurity: !0,
|
|
38
|
-
messageSettingsEnabled: !
|
|
38
|
+
messageSettingsEnabled: !0,
|
|
39
|
+
displayGmailAnnotations: !0,
|
|
40
|
+
displayHiddenPreheader: !1,
|
|
41
|
+
displayTitle: !1,
|
|
42
|
+
displayUTM: !1,
|
|
39
43
|
selectElementAfterDrop: !0,
|
|
40
44
|
...e ? { baseBlocks: e } : {},
|
|
41
45
|
editorFonts: {
|
|
@@ -45,7 +49,7 @@ const N = (d) => {
|
|
|
45
49
|
},
|
|
46
50
|
mergeTags: [
|
|
47
51
|
{
|
|
48
|
-
entries:
|
|
52
|
+
entries: U(c.preselectedDynamicContentList)
|
|
49
53
|
}
|
|
50
54
|
],
|
|
51
55
|
async onTokenRefreshRequest(o) {
|
|
@@ -58,8 +62,8 @@ const N = (d) => {
|
|
|
58
62
|
},
|
|
59
63
|
onTemplateLoaded() {
|
|
60
64
|
try {
|
|
61
|
-
const { importCss: o } = V(), { activateCustomViewStyles: s } =
|
|
62
|
-
o(), s(),
|
|
65
|
+
const { importCss: o } = V(), { activateCustomViewStyles: s } = w();
|
|
66
|
+
o(), s(), c.onReady(), t.isStripoInitialized = !0, t.loadingStatus = !1, setTimeout(() => {
|
|
63
67
|
t.hasChanges = !1;
|
|
64
68
|
}, 1e3);
|
|
65
69
|
} catch (o) {
|
|
@@ -78,22 +82,22 @@ const N = (d) => {
|
|
|
78
82
|
onDataChanged() {
|
|
79
83
|
t.hasChanges = !0;
|
|
80
84
|
},
|
|
81
|
-
onEvent:
|
|
85
|
+
onEvent: S,
|
|
82
86
|
ignoreClickOutsideSelectors: [
|
|
83
87
|
"#guido-dynamic-content-modal",
|
|
84
88
|
".in-on-board-wrapper",
|
|
85
89
|
".in-drawer__container"
|
|
86
90
|
],
|
|
87
|
-
extensions:
|
|
91
|
+
extensions: d
|
|
88
92
|
}
|
|
89
93
|
);
|
|
90
|
-
},
|
|
91
|
-
var
|
|
94
|
+
}, h = (i) => new Promise((r, t) => {
|
|
95
|
+
var d;
|
|
92
96
|
if (document.getElementById("UiEditorScript")) {
|
|
93
97
|
i(), r();
|
|
94
98
|
return;
|
|
95
99
|
}
|
|
96
|
-
const n =
|
|
100
|
+
const n = v.guido, a = `https://email-static.useinsider.com/guido/${(d = n == null ? void 0 : n.stripo) == null ? void 0 : d.version}/UIEditor.js`, e = document.createElement("script");
|
|
97
101
|
e.id = "UiEditorScript", e.type = "module", e.src = a, e.onload = () => {
|
|
98
102
|
i(), r();
|
|
99
103
|
}, e.onerror = () => {
|
|
@@ -101,12 +105,12 @@ const N = (d) => {
|
|
|
101
105
|
}, document.body.appendChild(e);
|
|
102
106
|
});
|
|
103
107
|
return { initPlugin: async (i) => {
|
|
104
|
-
await
|
|
105
|
-
const r = await
|
|
108
|
+
await h(async () => {
|
|
109
|
+
const r = await y();
|
|
106
110
|
await E(i, r);
|
|
107
111
|
});
|
|
108
112
|
} };
|
|
109
113
|
};
|
|
110
114
|
export {
|
|
111
|
-
|
|
115
|
+
J as useStripo
|
|
112
116
|
};
|
package/dist/enums/defaults.js
CHANGED
|
@@ -23,11 +23,11 @@ const e = {
|
|
|
23
23
|
}, t = {
|
|
24
24
|
promotional: 1,
|
|
25
25
|
transactional: 2
|
|
26
|
-
}, a = "email", o = "Guido User", s = t.promotional, n = 2, i = {
|
|
26
|
+
}, a = "email", o = "Guido User", s = t.promotional, n = 2, i = 13, u = {
|
|
27
27
|
email: 60,
|
|
28
28
|
architect: 49,
|
|
29
29
|
unsubscribePages: 97
|
|
30
|
-
},
|
|
30
|
+
}, r = [
|
|
31
31
|
"alfredtesting",
|
|
32
32
|
"electio",
|
|
33
33
|
"eurekatest",
|
|
@@ -65,7 +65,8 @@ export {
|
|
|
65
65
|
a as DefaultProductType,
|
|
66
66
|
o as DefaultUsername,
|
|
67
67
|
n as EditorType,
|
|
68
|
-
i as
|
|
69
|
-
u as
|
|
68
|
+
i as MAX_DEFAULT_TEMPLATE_ID,
|
|
69
|
+
u as ProductIds,
|
|
70
|
+
r as TEST_PARTNER_LIST,
|
|
70
71
|
t as TemplateTypes
|
|
71
72
|
};
|
|
@@ -2,9 +2,9 @@ var d = Object.defineProperty;
|
|
|
2
2
|
var l = (r, n, e) => n in r ? d(r, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[n] = e;
|
|
3
3
|
var o = (r, n, e) => l(r, typeof n != "symbol" ? n + "" : n, e);
|
|
4
4
|
import { useHttp as L } from "../../../composables/useHttp.js";
|
|
5
|
-
import { DEFAULT_UNSUBSCRIBE_GROUP as
|
|
5
|
+
import { DEFAULT_UNSUBSCRIBE_GROUP as c } from "../../../enums/unsubscribe.js";
|
|
6
6
|
import { Control as h, UIElementType as i, UEAttr as t, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
-
const m = "ui-elements-checkbox",
|
|
7
|
+
const m = "ui-elements-checkbox", u = "select", { get: C } = L();
|
|
8
8
|
class S extends h {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
@@ -16,15 +16,16 @@ class S extends h {
|
|
|
16
16
|
return m;
|
|
17
17
|
}
|
|
18
18
|
_setFormValues() {
|
|
19
|
-
if (this.currentNode && "getAttribute" in this.currentNode) {
|
|
19
|
+
if (this.selectedUnsubGroup = "", this.currentNode && "getAttribute" in this.currentNode) {
|
|
20
20
|
const e = this.currentNode.getAttribute("id");
|
|
21
21
|
if (e) {
|
|
22
|
-
const s = e ===
|
|
23
|
-
s && (this.selectedUnsubGroup = s
|
|
24
|
-
[a]: this.selectedUnsubGroup
|
|
25
|
-
}));
|
|
22
|
+
const s = e === c.sendGridId ? e : Number(e);
|
|
23
|
+
s && (this.selectedUnsubGroup = s);
|
|
26
24
|
}
|
|
27
25
|
}
|
|
26
|
+
this.api.updateValues({
|
|
27
|
+
[u]: this.selectedUnsubGroup
|
|
28
|
+
});
|
|
28
29
|
}
|
|
29
30
|
_getLabel(e, s = `${Math.random()}`) {
|
|
30
31
|
return `
|
|
@@ -54,7 +55,7 @@ class S extends h {
|
|
|
54
55
|
</${i.LABEL}>
|
|
55
56
|
|
|
56
57
|
<${i.SELECTPICKER}
|
|
57
|
-
${t.SELECTPICKER.name}="${
|
|
58
|
+
${t.SELECTPICKER.name}="${u}"
|
|
58
59
|
${t.SELECTPICKER.placeholder}="${this.api.translate("Select Unsubscribe Group")}">
|
|
59
60
|
${this._getSelect()}
|
|
60
61
|
</${i.SELECTPICKER}>
|
|
@@ -66,21 +67,21 @@ class S extends h {
|
|
|
66
67
|
this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute("id", e.toString()).apply(new p(`Updated text to ${e}`));
|
|
67
68
|
}
|
|
68
69
|
_listenToFormUpdates() {
|
|
69
|
-
this.api.onValueChanged(
|
|
70
|
+
this.api.onValueChanged(u, (e) => this._onSelectChange(e));
|
|
70
71
|
}
|
|
71
72
|
onTemplateNodeUpdated(e) {
|
|
72
|
-
this.currentNode = e;
|
|
73
|
+
this.currentNode = e, this._setFormValues();
|
|
73
74
|
}
|
|
74
75
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
75
76
|
async onRender() {
|
|
76
77
|
const e = await C(
|
|
77
78
|
"/unsubscribe-groups/unsubscribe-list"
|
|
78
|
-
), s = [
|
|
79
|
-
[t.SELECT_ITEM.text]:
|
|
80
|
-
[t.SELECT_ITEM.value]:
|
|
79
|
+
), s = [c, ...e.data], E = s.map((a) => ({
|
|
80
|
+
[t.SELECT_ITEM.text]: a.name,
|
|
81
|
+
[t.SELECT_ITEM.value]: a.sendGridId
|
|
81
82
|
}));
|
|
82
83
|
this.unsubList = s, this.api.setUIEAttribute(
|
|
83
|
-
|
|
84
|
+
u,
|
|
84
85
|
t.SELECTPICKER.items,
|
|
85
86
|
E
|
|
86
87
|
), this._setFormValues(), this._listenToFormUpdates();
|
|
@@ -3,7 +3,7 @@ const e = {
|
|
|
3
3
|
TITLE: "Unsubscribe From All Email Lists",
|
|
4
4
|
DESCRIPTION: "You will still receive important transactional and billing-related emails."
|
|
5
5
|
}, l = `
|
|
6
|
-
<td align="left" class="checkbox-block-v2 esd-block-checkbox es-p20">
|
|
6
|
+
<td align="left" class="checkbox-block checkbox-block-v2 esd-block-checkbox es-p20">
|
|
7
7
|
<table cellpadding="0" cellspacing="0" role="presentation" width="100%">
|
|
8
8
|
<tbody>
|
|
9
9
|
<tr>
|
|
@@ -26,11 +26,16 @@ const e = {
|
|
|
26
26
|
</tbody>
|
|
27
27
|
</table>
|
|
28
28
|
</td>
|
|
29
|
-
`,
|
|
30
|
-
<td
|
|
31
|
-
align="left"
|
|
32
|
-
esd-extension-block-id="checkbox-block"
|
|
33
|
-
class="
|
|
29
|
+
`, o = `
|
|
30
|
+
<td
|
|
31
|
+
align="left"
|
|
32
|
+
esd-extension-block-id="checkbox-block"
|
|
33
|
+
class="
|
|
34
|
+
checkbox-block
|
|
35
|
+
checkbox-block-v2
|
|
36
|
+
esd-block-checkbox
|
|
37
|
+
esd-checkbox-block
|
|
38
|
+
esd-extension-block es-p20"
|
|
34
39
|
>
|
|
35
40
|
<table cellpadding="0" cellspacing="0" role="presentation" width="100%">
|
|
36
41
|
<tbody>
|
|
@@ -55,10 +60,10 @@ const e = {
|
|
|
55
60
|
</table>
|
|
56
61
|
</td>
|
|
57
62
|
`;
|
|
58
|
-
function
|
|
63
|
+
function a() {
|
|
59
64
|
return l.replace("{-{-TITLE-}-}", `<p path="1">${e.TITLE}</p>`).replace("{-{-DESCRIPTION-}-}", `<p path="1">${e.DESCRIPTION}</p>`);
|
|
60
65
|
}
|
|
61
66
|
export {
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
o as default,
|
|
68
|
+
a as getDefaultTemplate
|
|
64
69
|
};
|
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
2
|
var h = (i, t, e) => t in i ? d(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
-
var
|
|
4
|
-
import { ModificationDescription as
|
|
3
|
+
var n = (i, t, e) => h(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { ModificationDescription as a, UIElementType as l, UEAttr as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as c } from "../../../common-control.js";
|
|
6
|
-
import { ItemsBlockControlId as
|
|
6
|
+
import { ItemsBlockControlId as p } from "../../enums/controlEnums.js";
|
|
7
7
|
import { SETTINGS_ENUMS as I } from "../../enums/settingsEnums.js";
|
|
8
8
|
import { useItemsBlockStore as N } from "../../store/items-block.js";
|
|
9
|
-
import { syncNameTrimmingFromAttributes as
|
|
10
|
-
import { updateConfigBlockAttributes as
|
|
11
|
-
const
|
|
9
|
+
import { syncNameTrimmingFromAttributes as M } from "../../utils/syncAttributesFromConfigBlock.js";
|
|
10
|
+
import { updateConfigBlockAttributes as u } from "../../utils/updateAttributes.js";
|
|
11
|
+
const y = p.NAME_TRIMMING, o = {
|
|
12
12
|
TRIMMING: "trimming"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class _ extends c {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
|
-
|
|
17
|
+
n(this, "store", N());
|
|
18
18
|
}
|
|
19
19
|
getId() {
|
|
20
|
-
return
|
|
20
|
+
return y;
|
|
21
21
|
}
|
|
22
22
|
getTemplate() {
|
|
23
23
|
return `
|
|
24
|
-
<div class="${
|
|
24
|
+
<div class="${p.NAME_TRIMMING}">
|
|
25
25
|
${this._getTextTrimming()}
|
|
26
26
|
</div>
|
|
27
27
|
`;
|
|
28
28
|
}
|
|
29
29
|
onRender() {
|
|
30
|
-
this.api.updateValues({ [
|
|
30
|
+
this.api.updateValues({ [o.TRIMMING]: this.store.nameTrimming }), this.api.onValueChanged(o.TRIMMING, (e) => {
|
|
31
31
|
this._onTrimmingChange(e);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
onTemplateNodeUpdated(e) {
|
|
35
35
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
|
|
36
|
-
() =>
|
|
36
|
+
() => M(this.currentNode),
|
|
37
37
|
() => {
|
|
38
|
-
this.api.updateValues({ [
|
|
38
|
+
this.api.updateValues({ [o.TRIMMING]: this.store.nameTrimming });
|
|
39
39
|
}
|
|
40
|
-
)
|
|
40
|
+
);
|
|
41
41
|
}
|
|
42
42
|
_onTrimmingChange(e) {
|
|
43
|
-
this.store.setNameTrimming(e),
|
|
43
|
+
this.store.setNameTrimming(e), u(this.currentNode, this.api), this.api.updateValues({ [o.TRIMMING]: e }), this._applyTrimmingStyles(e);
|
|
44
44
|
}
|
|
45
45
|
_applyTrimmingStyles(e) {
|
|
46
|
-
var
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
46
|
+
var s;
|
|
47
|
+
const r = (s = this.currentNode) == null ? void 0 : s.querySelector("p > a");
|
|
48
|
+
if (!r)
|
|
49
49
|
return;
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
const T = e !== void 0 ? e : this.store.nameTrimming, m = this.store.orientation === I.ORIENTATION.VERTICAL;
|
|
51
|
+
T ? this.api.getDocumentModifier().modifyHtml(r).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", m ? "130px" : "520px").apply(new a("Text Trimming Enabled")) : this.api.getDocumentModifier().modifyHtml(r).removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow").removeStyle("max-width").setStyle("max-width", m ? "130px" : "520px").apply(new a("Text Trimming Disabled"));
|
|
52
52
|
}
|
|
53
53
|
_getTextTrimming() {
|
|
54
54
|
return `
|
|
55
55
|
<div class="container">
|
|
56
56
|
<div class="display-flex align-items-center justify-content-between">
|
|
57
|
-
<${
|
|
57
|
+
<${l.LABEL}
|
|
58
58
|
${g.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
59
59
|
>
|
|
60
|
-
</${
|
|
61
|
-
${this._GuToggle(
|
|
60
|
+
</${l.LABEL}>
|
|
61
|
+
${this._GuToggle(o.TRIMMING)}
|
|
62
62
|
</div>
|
|
63
63
|
</div>
|
|
64
64
|
`;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
export {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
y as CONTROL_BLOCK_ID,
|
|
69
|
+
_ as NameTrimmingControl
|
|
70
70
|
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var I = Object.defineProperty;
|
|
2
|
+
var y = (n, o, t) => o in n ? I(n, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[o] = t;
|
|
3
|
+
var m = (n, o, t) => y(n, typeof o != "symbol" ? o + "" : o, t);
|
|
4
|
+
import { ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as E } from "../../../common-control.js";
|
|
6
|
+
import { ItemsBlockControlId as O } from "../../enums/controlEnums.js";
|
|
7
|
+
import { SETTINGS_ENUMS as N } from "../../enums/settingsEnums.js";
|
|
8
|
+
import { useItemsBlockStore as f } from "../../store/items-block.js";
|
|
9
|
+
import { syncPriceOrientationFromAttributes as T } from "../../utils/syncAttributesFromConfigBlock.js";
|
|
10
|
+
import { updateConfigBlockAttributes as P } from "../../utils/updateAttributes.js";
|
|
11
|
+
const _ = O.PRICE_ORIENTATION, p = {
|
|
12
|
+
PRICE_ORIENTATION: "priceOrientation"
|
|
13
|
+
}, C = [
|
|
14
|
+
{ icon: "vertical-orientation", value: "vertical" },
|
|
15
|
+
{ icon: "horizontal-orientation", value: "horizontal" }
|
|
16
|
+
];
|
|
17
|
+
class v extends E {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
m(this, "store", f());
|
|
21
|
+
}
|
|
22
|
+
getId() {
|
|
23
|
+
return _;
|
|
24
|
+
}
|
|
25
|
+
getTemplate() {
|
|
26
|
+
return `
|
|
27
|
+
<div class="${O.PRICE_ORIENTATION}">
|
|
28
|
+
${this._getPriceOrientation()}
|
|
29
|
+
</div>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
onRender() {
|
|
33
|
+
this.api.updateValues({ [p.PRICE_ORIENTATION]: this.store.priceOrientation }), this.api.onValueChanged(p.PRICE_ORIENTATION, (t) => {
|
|
34
|
+
this._onPriceOrientationChange(t);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
onTemplateNodeUpdated(t) {
|
|
38
|
+
super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(
|
|
39
|
+
() => {
|
|
40
|
+
T(this.currentNode);
|
|
41
|
+
},
|
|
42
|
+
() => {
|
|
43
|
+
this.api.updateValues({ [p.PRICE_ORIENTATION]: this.store.priceOrientation });
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
_onPriceOrientationChange(t) {
|
|
48
|
+
if (console.debug("Price orientation changed to: ", t), this.store.setPriceOrientation(t), P(this.currentNode, this.api), !this.currentNode)
|
|
49
|
+
return;
|
|
50
|
+
const { orientation: i } = this.store, r = i === N.ORIENTATION.VERTICAL, e = t === "horizontal";
|
|
51
|
+
r ? this._updateVerticalLayout(e) : this._updateHorizontalLayout(e);
|
|
52
|
+
}
|
|
53
|
+
_updateHorizontalLayout(t) {
|
|
54
|
+
var c, l, d, a;
|
|
55
|
+
const i = ((l = (c = this.currentNode) == null ? void 0 : c.closest(".ins-product-td")) == null ? void 0 : l.querySelectorAll(".product-price-class")) || [], r = ((a = (d = this.currentNode) == null ? void 0 : d.closest(".ins-product-td")) == null ? void 0 : a.querySelectorAll(".product-original-price-class")) || [];
|
|
56
|
+
if (!i || !r)
|
|
57
|
+
return;
|
|
58
|
+
const e = t ? "50%" : "100%", s = this.api.getDocumentModifier();
|
|
59
|
+
i.forEach((u) => {
|
|
60
|
+
s.modifyHtml(u).setAttribute("width", e).setStyle("width", e);
|
|
61
|
+
}), r.forEach((u) => {
|
|
62
|
+
s.modifyHtml(u).setAttribute("width", e).setStyle("width", e);
|
|
63
|
+
}), s.apply(new h(`Updated original price element width to ${e}`));
|
|
64
|
+
}
|
|
65
|
+
_updateVerticalLayout(t) {
|
|
66
|
+
var s, c, l, d;
|
|
67
|
+
const i = ((c = (s = this.currentNode) == null ? void 0 : s.closest(".ins-product-td")) == null ? void 0 : c.querySelectorAll(".horizontal-price")) || [], r = (d = (l = this.currentNode) == null ? void 0 : l.closest(".ins-product-td")) == null ? void 0 : d.querySelector(".vertical-price");
|
|
68
|
+
if (!i || !r || i.length === 0)
|
|
69
|
+
return;
|
|
70
|
+
const e = this.api.getDocumentModifier();
|
|
71
|
+
t ? (i.forEach((a) => {
|
|
72
|
+
e.modifyHtml(a).setStyle("display", "table-cell");
|
|
73
|
+
}), e.modifyHtml(r).setStyle("display", "none").apply(new h("Hide vertical price element"))) : (i.forEach((a) => {
|
|
74
|
+
e.modifyHtml(a).setStyle("display", "none");
|
|
75
|
+
}), e.modifyHtml(r).setStyle("display", "table-cell").apply(new h("Show vertical price element")));
|
|
76
|
+
}
|
|
77
|
+
_getPriceOrientation() {
|
|
78
|
+
return `
|
|
79
|
+
${this._GuTwoColumns([
|
|
80
|
+
this._GuLabel({ text: "Price Orientation" }),
|
|
81
|
+
this._GuRadioButton({
|
|
82
|
+
name: p.PRICE_ORIENTATION,
|
|
83
|
+
buttons: C
|
|
84
|
+
})
|
|
85
|
+
])}
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
_ as CONTROL_BLOCK_ID,
|
|
91
|
+
v as PriceOrientationControl
|
|
92
|
+
};
|