@useinsider/guido 1.0.0-beta.401ddbd → 1.0.0-beta.419f6b3

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.
@@ -1,18 +1,18 @@
1
1
  import o from "./Guido.vue2.js";
2
2
  /* empty css */
3
- import i from "../_virtual/_plugin-vue2_normalizer.js";
3
+ import a from "../_virtual/_plugin-vue2_normalizer.js";
4
4
  var s = function() {
5
- var e = this, r = e._self._c, t = e._self._setupProxy;
6
- return r("div", { staticClass: "guido-editor__wrapper" }, [r(t.HeaderWrapper), r("div", { staticClass: "guido-editor__container", attrs: { id: "guido-editor" } })], 1);
7
- }, _ = [], a = /* @__PURE__ */ i(
5
+ var t = this, e = t._self._c, r = t._self._setupProxy;
6
+ return e("div", { staticClass: "guido-editor__wrapper" }, [e(r.HeaderWrapper), e("div", { staticClass: "guido-editor__container", attrs: { id: "guido-editor" } }), e(r.SaveTemplateModal, { attrs: { "is-open": r.editorStore.isSaveTemplateModalOpen }, on: { close: r.handleCloseSaveTemplateModal } })], 1);
7
+ }, i = [], n = /* @__PURE__ */ a(
8
8
  o,
9
9
  s,
10
- _,
10
+ i,
11
11
  !1,
12
12
  null,
13
- "d4a5c957"
13
+ "f20b186e"
14
14
  );
15
- const f = a.exports;
15
+ const c = n.exports;
16
16
  export {
17
- f as default
17
+ c as default
18
18
  };
@@ -1,10 +1,12 @@
1
- import { defineComponent as f, onMounted as c } from "vue";
2
- import { usePartner as g } from "../composables/usePartner.js";
3
- import { useStripo as _ } from "../composables/useStripo.js";
4
- import { useTemplates as y } from "../composables/useTemplates.js";
5
- import { DefaultUsername as C, DefaultGuidoConfig as T } from "../enums/defaults.js";
6
- import w from "./organisms/header/HeaderWrapper.vue.js";
7
- const h = /* @__PURE__ */ f({
1
+ import { defineComponent as g, onMounted as T } from "vue";
2
+ import { usePartner as S } from "../composables/usePartner.js";
3
+ import { useStripo as C } from "../composables/useStripo.js";
4
+ import { useTemplates as _ } from "../composables/useTemplates.js";
5
+ import { DefaultUsername as y, DefaultGuidoConfig as w } from "../enums/defaults.js";
6
+ import I from "./organisms/header/HeaderWrapper.vue.js";
7
+ import M from "./organisms/save-template/SaveTemplateModal.vue.js";
8
+ import { useEditorStore as P } from "../stores/editor.js";
9
+ const F = /* @__PURE__ */ g({
8
10
  __name: "Guido",
9
11
  props: {
10
12
  emailId: null,
@@ -14,30 +16,32 @@ const h = /* @__PURE__ */ f({
14
16
  username: null,
15
17
  guidoConfig: null
16
18
  },
17
- setup(d) {
18
- const o = d, { getPartnerName: r, getProductType: t } = g(), {
19
- emailId: n,
20
- userId: i,
21
- guidoConfig: a,
22
- partnerName: u = r(),
23
- productType: p = t(),
24
- username: m = C
19
+ setup(f) {
20
+ const o = f, { getPartnerName: t, getProductType: r } = S(), {
21
+ emailId: a,
22
+ userId: n,
23
+ guidoConfig: i,
24
+ partnerName: l = t(),
25
+ productType: m = r(),
26
+ username: p = y
25
27
  } = o;
26
28
  window.GuidoConfig = {
27
- ...T,
28
- ...a
29
+ ...w,
30
+ ...i
29
31
  };
30
- const { initPlugin: l } = _({ emailId: n, userId: i, username: m, partnerName: u, productType: p }), { getDefaultTemplate: s } = y();
31
- return c(async () => {
32
+ const { initPlugin: u } = C({ emailId: a, userId: n, username: p, partnerName: l, productType: m }), { getDefaultTemplate: s } = _(), d = P(), c = () => {
33
+ d.isSaveTemplateModalOpen = !1;
34
+ };
35
+ return T(async () => {
32
36
  try {
33
37
  const e = await s();
34
- await l(e);
38
+ await u(e);
35
39
  } catch (e) {
36
40
  console.error("Failed to initialize Stripo editor:", e);
37
41
  }
38
- }), { __sfc: !0, props: o, getPartnerName: r, getProductType: t, emailId: n, userId: i, guidoConfig: a, partnerName: u, productType: p, username: m, initPlugin: l, getDefaultTemplate: s, HeaderWrapper: w };
42
+ }), { __sfc: !0, props: o, getPartnerName: t, getProductType: r, emailId: a, userId: n, guidoConfig: i, partnerName: l, productType: m, username: p, initPlugin: u, getDefaultTemplate: s, editorStore: d, handleCloseSaveTemplateModal: c, HeaderWrapper: I, SaveTemplateModal: M };
39
43
  }
40
44
  });
41
45
  export {
42
- h as default
46
+ F as default
43
47
  };
@@ -0,0 +1,72 @@
1
+ interface ModalWrapperProps {
2
+ isOpen: boolean;
3
+ title: string;
4
+ description?: string;
5
+ size?: 'small' | 'medium' | 'large' | 'extra-large';
6
+ primaryButtonText?: string;
7
+ primaryButtonDisabled?: boolean;
8
+ primaryButtonLoading?: boolean;
9
+ cancelButtonText?: string;
10
+ showCancelButton?: boolean;
11
+ className?: string;
12
+ }
13
+ declare var __VLS_12: {};
14
+ type __VLS_Slots = {} & {
15
+ default?: (props: typeof __VLS_12) => any;
16
+ };
17
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<ModalWrapperProps>, {
18
+ description: string;
19
+ size: string;
20
+ primaryButtonText: string;
21
+ primaryButtonDisabled: boolean;
22
+ primaryButtonLoading: boolean;
23
+ cancelButtonText: string;
24
+ showCancelButton: boolean;
25
+ className: string;
26
+ }>, {}, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
27
+ close: () => void;
28
+ save: () => void;
29
+ cancel: () => void;
30
+ }, string, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ModalWrapperProps>, {
31
+ description: string;
32
+ size: string;
33
+ primaryButtonText: string;
34
+ primaryButtonDisabled: boolean;
35
+ primaryButtonLoading: boolean;
36
+ cancelButtonText: string;
37
+ showCancelButton: boolean;
38
+ className: string;
39
+ }>>>, {
40
+ className: string;
41
+ size: "small" | "medium" | "large" | "extra-large";
42
+ description: string;
43
+ primaryButtonText: string;
44
+ primaryButtonDisabled: boolean;
45
+ primaryButtonLoading: boolean;
46
+ cancelButtonText: string;
47
+ showCancelButton: boolean;
48
+ }>;
49
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
50
+ export default _default;
51
+ type __VLS_WithDefaults<P, D> = {
52
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
53
+ default: D[K];
54
+ }> : P[K];
55
+ };
56
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
57
+ type __VLS_TypePropsToOption<T> = {
58
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
59
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
60
+ } : {
61
+ type: import('vue').PropType<T[K]>;
62
+ required: true;
63
+ };
64
+ };
65
+ type __VLS_WithSlots<T, S> = T & {
66
+ new (): {
67
+ $scopedSlots: S;
68
+ };
69
+ };
70
+ type __VLS_PrettifyLocal<T> = {
71
+ [K in keyof T]: T[K];
72
+ } & {};
@@ -0,0 +1,19 @@
1
+ import r from "./ModalWrapper.vue2.js";
2
+ import o from "../../../_virtual/_plugin-vue2_normalizer.js";
3
+ var s = function() {
4
+ var t = this, n = t._self._c, e = t._self._setupProxy;
5
+ return n(e.InDrawer, { attrs: { id: `drawer-${Math.random().toString(36).substr(2, 9)}`, "description-text": t.description, "footer-button-group-options": e.drawerFooterOptions, size: t.size, status: t.isOpen, "title-text": t.title }, on: { cancelOrBackButtonEvent: e.handleCancel, onCloseEvent: e.handleClose, primaryButtonEvent: e.handleSave }, scopedSlots: t._u([{ key: "contentSlot", fn: function() {
6
+ return [n("div", { staticClass: "modal-content-wrapper", class: t.className }, [t._t("default")], 2)];
7
+ }, proxy: !0 }], null, !0) });
8
+ }, a = [], l = /* @__PURE__ */ o(
9
+ r,
10
+ s,
11
+ a,
12
+ !1,
13
+ null,
14
+ null
15
+ );
16
+ const u = l.exports;
17
+ export {
18
+ u as default
19
+ };
@@ -0,0 +1,43 @@
1
+ import { defineComponent as o, computed as l } from "vue";
2
+ import { InDrawer as r } from "@useinsider/design-system-vue";
3
+ const i = /* @__PURE__ */ o({
4
+ __name: "ModalWrapper",
5
+ props: {
6
+ isOpen: { type: Boolean },
7
+ title: null,
8
+ description: { default: "" },
9
+ size: { default: "medium" },
10
+ primaryButtonText: { default: "Save" },
11
+ primaryButtonDisabled: { type: Boolean, default: !1 },
12
+ primaryButtonLoading: { type: Boolean, default: !1 },
13
+ cancelButtonText: { default: "Cancel" },
14
+ showCancelButton: { type: Boolean, default: !0 },
15
+ className: { default: "" }
16
+ },
17
+ emits: ["close", "save", "cancel"],
18
+ setup(a, { emit: t }) {
19
+ const e = a, n = l(() => ({
20
+ primaryButton: {
21
+ styling: "solid",
22
+ type: "primary",
23
+ labelText: e.primaryButtonText,
24
+ disabled: e.primaryButtonDisabled || e.primaryButtonLoading
25
+ },
26
+ cancelOrBackButton: e.showCancelButton ? {
27
+ type: "secondary",
28
+ styling: "ghost",
29
+ labelText: e.cancelButtonText
30
+ } : void 0
31
+ }));
32
+ return { __sfc: !0, props: e, emit: t, drawerFooterOptions: n, handleClose: () => {
33
+ t("close");
34
+ }, handleSave: () => {
35
+ t("save");
36
+ }, handleCancel: () => {
37
+ t("cancel");
38
+ }, InDrawer: r };
39
+ }
40
+ });
41
+ export {
42
+ i as default
43
+ };
@@ -1,20 +1,20 @@
1
1
  import o from "./RightSlot.vue2.js";
2
2
  /* empty css */
3
3
  import i from "../../../_virtual/_plugin-vue2_normalizer.js";
4
- var n = function() {
4
+ var r = function() {
5
5
  var s = this, e = s._self._c, t = s._self._setupProxy;
6
- return e("div", [e("div", { staticClass: "d-f header-right-slot" }, [e("div", { staticClass: "d-f" }, [t.editorStore.isVersionHistoryOpen ? e(t.VersionHistoryViewOptions) : e(t.ViewOptions)], 1), e("div", { staticClass: "d-f" }, [e(t.InButtonV2, { attrs: { id: "guido__history-button", "left-icon": "line-architect-version-history", styling: "ghost", type: "secondary", "label-text-status": !1, "selected-status": t.editorStore.isVersionHistoryOpen }, on: { click: t.handleVersionHistory } }), e(t.InButtonV2, { attrs: { id: "guido__export-button", "left-icon": "line-export", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isVersionHistoryOpen, "label-text-status": !1 }, on: { click: t.exportHtml } }), e(t.InButtonV2, { attrs: { id: "guido__save-as-button", "left-icon": "line-newsletter-save-as-template", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isVersionHistoryOpen, "label-text-status": !1 }, on: { click: t.handleSaveAsTemplate } }), e(t.InButtonV2, { attrs: { id: "guido__test-button", "left-icon": "line-architect-test-journey", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isVersionHistoryOpen, "label-text-status": !1 } })], 1), t.editorStore.isVersionHistoryOpen ? e(t.InButtonV2, { attrs: { id: "guido__restore-button", "label-text": "Restore" }, on: { click: function(d) {
6
+ return e("div", { staticClass: "d-f header-right-slot" }, [e("div", { staticClass: "d-f" }, [t.editorStore.isVersionHistoryOpen ? e(t.VersionHistoryViewOptions) : e(t.ViewOptions)], 1), e("div", { staticClass: "d-f" }, [e(t.InButtonV2, { attrs: { id: "guido__history-button", "left-icon": "line-architect-version-history", styling: "ghost", type: "secondary", "label-text-status": !1, "selected-status": t.editorStore.isVersionHistoryOpen }, on: { click: t.handleVersionHistory } }), e(t.InButtonV2, { attrs: { id: "guido__export-button", "left-icon": "line-export", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isVersionHistoryOpen, "label-text-status": !1 }, on: { click: t.exportHtml } }), e(t.InButtonV2, { attrs: { id: "guido__save-as-button", "left-icon": "line-newsletter-save-as-template", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isVersionHistoryOpen, "label-text-status": !1 }, on: { click: t.handleSaveAsTemplate } }), e(t.InButtonV2, { attrs: { id: "guido__test-button", "left-icon": "line-architect-test-journey", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isVersionHistoryOpen, "label-text-status": !1 } })], 1), t.editorStore.isVersionHistoryOpen ? e(t.InButtonV2, { attrs: { id: "guido__restore-button", "label-text": "Restore" }, on: { click: function(d) {
7
7
  return t.restoreVersion(t.versionHistoryStore.currentPatch.id);
8
- } } }) : e(t.InButtonV2, { attrs: { id: "guido__save-button", "label-text": "Save" } })], 1), e(t.SaveTemplateModal, { attrs: { "html-data": t.currentHtmlData, "is-open": t.isSaveTemplateModalOpen }, on: { close: t.handleCloseSaveTemplateModal } })], 1);
9
- }, r = [], a = /* @__PURE__ */ i(
8
+ } } }) : e(t.InButtonV2, { attrs: { id: "guido__save-button", "label-text": "Save" } })], 1);
9
+ }, n = [], a = /* @__PURE__ */ i(
10
10
  o,
11
- n,
12
11
  r,
12
+ n,
13
13
  !1,
14
14
  null,
15
- "8f49feef"
15
+ "78791c47"
16
16
  );
17
- const _ = a.exports;
17
+ const p = a.exports;
18
18
  export {
19
- _ as default
19
+ p as default
20
20
  };
@@ -1,34 +1,26 @@
1
- import { defineComponent as c, ref as n } from "vue";
2
- import { useActionsApi as f } from "../../../composables/useActionsApi.js";
3
- import { useExport as u } from "../../../composables/useExport.js";
4
- import { useVersionHistoryApi as d } from "../../../composables/useVersionHistoryApi.js";
5
- import { useEditorStore as V } from "../../../stores/editor.js";
6
- import { useVersionHistoryStore as y } from "../../../stores/version-history.js";
7
- import { InButtonV2 as H } from "@useinsider/design-system-vue";
8
- import S from "./SaveTemplateModal.vue.js";
9
- import v from "./version-history/ViewOptions.vue.js";
10
- import h from "./ViewOptions.vue.js";
11
- const b = /* @__PURE__ */ c({
1
+ import { defineComponent as n } from "vue";
2
+ import { useExport as p } from "../../../composables/useExport.js";
3
+ import { useVersionHistoryApi as m } from "../../../composables/useVersionHistoryApi.js";
4
+ import { useEditorStore as a } from "../../../stores/editor.js";
5
+ import { useVersionHistoryStore as f } from "../../../stores/version-history.js";
6
+ import { InButtonV2 as l } from "@useinsider/design-system-vue";
7
+ import V from "./version-history/ViewOptions.vue.js";
8
+ import c from "./ViewOptions.vue.js";
9
+ const T = /* @__PURE__ */ n({
12
10
  __name: "RightSlot",
13
- setup(_) {
14
- const { exportHtml: a } = u(), { openVersionHistory: e, closeVersionHistory: t, restoreVersion: m } = d(), { getCompiledEmail: r } = f(), s = V(), l = y(), o = n(!1), i = n("");
15
- return { __sfc: !0, exportHtml: a, openVersionHistory: e, closeVersionHistory: t, restoreVersion: m, getCompiledEmail: r, editorStore: s, versionHistoryStore: l, isSaveTemplateModalOpen: o, currentHtmlData: i, handleVersionHistory: () => {
16
- if (s.isVersionHistoryOpen) {
17
- t();
11
+ setup(u) {
12
+ const { exportHtml: t } = p(), { openVersionHistory: r, closeVersionHistory: e, restoreVersion: s } = m(), o = a(), i = f();
13
+ return { __sfc: !0, exportHtml: t, openVersionHistory: r, closeVersionHistory: e, restoreVersion: s, editorStore: o, versionHistoryStore: i, handleVersionHistory: () => {
14
+ if (o.isVersionHistoryOpen) {
15
+ e();
18
16
  return;
19
17
  }
20
- e();
18
+ r();
21
19
  }, handleSaveAsTemplate: async () => {
22
- try {
23
- const p = await r();
24
- i.value = p.html, o.value = !0;
25
- } catch {
26
- }
27
- }, handleCloseSaveTemplateModal: () => {
28
- o.value = !1;
29
- }, InButtonV2: H, SaveTemplateModal: S, VersionHistoryViewOptions: v, ViewOptions: h };
20
+ o.isSaveTemplateModalOpen = !0;
21
+ }, InButtonV2: l, VersionHistoryViewOptions: V, ViewOptions: c };
30
22
  }
31
23
  });
32
24
  export {
33
- b as default
25
+ T as default
34
26
  };
@@ -1,12 +1,12 @@
1
1
  interface TemplateModalProps {
2
2
  isOpen: boolean;
3
- htmlData: string;
4
3
  }
5
4
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<TemplateModalProps>, {}, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
6
5
  close: () => void;
7
6
  save: (data: {
8
7
  templateName: string;
9
8
  htmlData: string;
9
+ categoryIds: number[];
10
10
  }) => void;
11
11
  }, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<TemplateModalProps>>>, {}>;
12
12
  export default _default;
@@ -0,0 +1,22 @@
1
+ import n from "./SaveTemplateModal.vue2.js";
2
+ import s from "../../../_virtual/_plugin-vue2_normalizer.js";
3
+ var l = function() {
4
+ var r = this, e = r._self._c, t = r._self._setupProxy;
5
+ return e(t.ModalWrapper, { attrs: { "cancel-button-text": t.trans("products.cancel"), description: t.trans("newsletter.save-template-description"), "is-open": t.props.isOpen, "primary-button-loading": t.isSaving || t.isLoadingHtml, "primary-button-text": t.trans("products.save"), title: t.trans("products.save-template") }, on: { cancel: t.closeModal, close: t.closeModal, save: t.saveTemplate } }, [e(t.InTextInput, { staticClass: "mb-5 w-1", attrs: { id: "template-name-input", "with-label": "", name: "templateName", disabled: t.isSaving, invalid: !!t.validationError, "invalid-message": t.validationError, label: t.trans("products.template-name"), placeholder: t.trans("newsletter.enter-template-name") }, model: { value: t.templateNameInput, callback: function(a) {
6
+ t.templateNameInput = typeof a == "string" ? a.trim() : a;
7
+ }, expression: "templateNameInput" } }), e(t.InMultiSelect, { staticClass: "template-category-dropdown mb-5 w-1", attrs: { "create-option-status": "", "search-status": "", "button-status": !1, "character-limit-validation-text": t.trans("validation-v2.duration-value", {
8
+ min: 1,
9
+ max: t.templateCategorySearchInputLimit
10
+ }), "create-button-label": t.trans("products.create-new-category"), "label-text": t.trans("products.template-category"), "loading-state": t.categoriesData.loading || t.categoriesData.loadingCreate, "max-character-limit": t.templateCategorySearchInputLimit, options: t.categoriesData.mappedCategories, "placeholder-text": t.trans("products.select-template-category"), value: t.categoriesData.selectedCategories }, on: { addOption: t.addOption, change: t.categoryChangeHandler, resetAllOptions: t.categoryChangeHandler, selectAllOptions: t.categoryChangeHandler } })], 1);
11
+ }, o = [], i = /* @__PURE__ */ s(
12
+ n,
13
+ l,
14
+ o,
15
+ !1,
16
+ null,
17
+ null
18
+ );
19
+ const d = i.exports;
20
+ export {
21
+ d as default
22
+ };
@@ -0,0 +1,81 @@
1
+ import { defineComponent as N, ref as r, watch as C } from "vue";
2
+ import { useActionsApi as D } from "../../../composables/useActionsApi.js";
3
+ import { useTemplateCategories as O } from "../../../composables/useTemplateCategories.js";
4
+ import { useTemplateValidation as b } from "../../../composables/useTemplateValidation.js";
5
+ import { useToaster as x } from "../../../composables/useToaster.js";
6
+ import { useTranslations as A } from "../../../composables/useTranslations.js";
7
+ import R from "../base/ModalWrapper.vue.js";
8
+ import { InMultiSelect as V, InTextInput as W } from "@useinsider/design-system-vue";
9
+ const J = /* @__PURE__ */ N({
10
+ __name: "SaveTemplateModal",
11
+ props: {
12
+ isOpen: { type: Boolean }
13
+ },
14
+ emits: ["close", "save"],
15
+ setup(E, { emit: l }) {
16
+ const p = E, M = A(), { handleError: o } = x(), { getCompiledEmail: u } = D(), {
17
+ data: S,
18
+ fetchCategories: f,
19
+ createCategory: v,
20
+ setSelectedCategories: d,
21
+ resetSelection: g,
22
+ getSelectedCategoryIds: y
23
+ } = O(), a = r(""), s = r(!1), n = r(!1), t = r(""), I = 40, {
24
+ validationError: w,
25
+ validateTemplateName: i,
26
+ clearValidation: c
27
+ } = b(), m = () => {
28
+ a.value = "", g(), c(), t.value = "";
29
+ }, h = () => {
30
+ m(), l("close");
31
+ }, H = async () => {
32
+ if (a.value.trim()) {
33
+ s.value = !0;
34
+ try {
35
+ if (!(await i(a.value)).isValid)
36
+ return;
37
+ if (!t.value) {
38
+ o(new Error("No HTML data available"), "Error saving template:");
39
+ return;
40
+ }
41
+ l("save", {
42
+ templateName: a.value,
43
+ htmlData: t.value,
44
+ categoryIds: y.value
45
+ }), h();
46
+ } catch (e) {
47
+ o(e, "Error saving template:");
48
+ } finally {
49
+ s.value = !1;
50
+ }
51
+ }
52
+ };
53
+ C(a, (e) => {
54
+ e.trim() ? i(e) : c();
55
+ });
56
+ const T = async () => {
57
+ n.value = !0;
58
+ try {
59
+ const { html: e } = await u();
60
+ t.value = e || "", e || o(new Error("No HTML content available"), "Warning:");
61
+ } catch (e) {
62
+ o(e, "Error fetching HTML data:"), t.value = "";
63
+ } finally {
64
+ n.value = !1;
65
+ }
66
+ }, _ = (e) => {
67
+ d(e);
68
+ }, L = async (e) => {
69
+ await v(e);
70
+ };
71
+ return C(() => p.isOpen, async (e) => {
72
+ e ? await Promise.all([
73
+ T(),
74
+ f()
75
+ ]) : m();
76
+ }), { __sfc: !0, props: p, emit: l, trans: M, handleError: o, getCompiledEmail: u, categoriesData: S, fetchCategories: f, createCategory: v, setSelectedCategories: d, resetSelection: g, getSelectedCategoryIds: y, templateNameInput: a, isSaving: s, isLoadingHtml: n, htmlData: t, templateCategorySearchInputLimit: I, validationError: w, validateTemplateName: i, clearValidation: c, resetModalState: m, closeModal: h, saveTemplate: H, fetchHtmlData: T, categoryChangeHandler: _, addOption: L, ModalWrapper: R, InTextInput: W, InMultiSelect: V };
77
+ }
78
+ });
79
+ export {
80
+ J as default
81
+ };
@@ -0,0 +1,38 @@
1
+ import type { TemplateCategory } from '@@/Types/template-categories';
2
+ interface MappedCategory {
3
+ value: string;
4
+ text: string;
5
+ }
6
+ interface GetDataProps {
7
+ getInitialData?: boolean;
8
+ }
9
+ export declare const useTemplateCategories: ({ getInitialData }?: GetDataProps) => {
10
+ data: {
11
+ loading: boolean;
12
+ loadingCreate: boolean;
13
+ categories: {
14
+ id: number;
15
+ name: string;
16
+ partnerId: number;
17
+ isStripo: boolean;
18
+ templatesCount: number;
19
+ }[];
20
+ mappedCategories: {
21
+ value: string;
22
+ text: string;
23
+ }[];
24
+ selectedCategories: {
25
+ value: string;
26
+ text: string;
27
+ }[];
28
+ };
29
+ fetchCategories: () => Promise<void>;
30
+ createCategory: (name: string) => Promise<void>;
31
+ selectCategory: (category: MappedCategory) => void;
32
+ setSelectedCategories: (categories: MappedCategory[]) => void;
33
+ resetSelection: () => void;
34
+ getSelectedCategoryIds: import("vue").ComputedRef<number[]>;
35
+ getCategoryById: (id: number) => TemplateCategory | undefined;
36
+ getCategoryByName: (name: string) => TemplateCategory | undefined;
37
+ };
38
+ export {};
@@ -0,0 +1,80 @@
1
+ import { useHttp as x } from "./useHttp.js";
2
+ import { useToaster as v } from "./useToaster.js";
3
+ import { reactive as E, computed as I } from "vue";
4
+ const T = ({ getInitialData: l = !1 } = {}) => {
5
+ const { get: c, post: d } = x(), { handleError: o, showToaster: n } = v(), e = E({
6
+ loading: !1,
7
+ loadingCreate: !1,
8
+ categories: [],
9
+ mappedCategories: [],
10
+ selectedCategories: []
11
+ }), i = async () => {
12
+ e.loading = !0;
13
+ try {
14
+ const a = (await c("/newsletter/template-library/get-template-categories")).data || [];
15
+ e.categories = a, e.mappedCategories = a.map((s) => ({
16
+ value: s.id.toString(),
17
+ text: s.name
18
+ }));
19
+ } catch (t) {
20
+ o(t, "Error fetching template categories:"), e.categories = [], e.mappedCategories = [];
21
+ } finally {
22
+ e.loading = !1;
23
+ }
24
+ }, p = async (t) => {
25
+ try {
26
+ const s = `/newsletter/template-library/category-name-exists?name=${encodeURIComponent(t)}`;
27
+ return (await c(s)).data.status;
28
+ } catch (a) {
29
+ return o(a, "Error checking category name:"), !1;
30
+ }
31
+ }, m = async (t) => {
32
+ e.loadingCreate = !0;
33
+ try {
34
+ if (await p(t)) {
35
+ n({
36
+ type: "error",
37
+ message: "Category name already exists"
38
+ });
39
+ return;
40
+ }
41
+ const r = (await d("/newsletter/template-library/create-category", { name: t })).data;
42
+ if (r) {
43
+ e.categories.push(r);
44
+ const g = {
45
+ value: r.id.toString(),
46
+ text: r.name
47
+ };
48
+ e.mappedCategories.push(g), e.selectedCategories.push(g), n({
49
+ type: "success",
50
+ message: "Category created successfully"
51
+ });
52
+ }
53
+ } catch (a) {
54
+ o(a, "Error creating category:");
55
+ } finally {
56
+ e.loadingCreate = !1;
57
+ }
58
+ }, C = (t) => {
59
+ const a = e.selectedCategories.findIndex((s) => s.value === t.value);
60
+ a === -1 ? e.selectedCategories.push(t) : e.selectedCategories.splice(a, 1);
61
+ }, y = (t) => {
62
+ e.selectedCategories = [...t];
63
+ }, u = () => {
64
+ e.selectedCategories = [];
65
+ }, f = I(() => e.selectedCategories.map((t) => parseInt(t.value))), h = (t) => e.categories.find((a) => a.id === t), w = (t) => e.categories.find((a) => a.name.toLowerCase() === t.toLowerCase());
66
+ return l && i(), {
67
+ data: e,
68
+ fetchCategories: i,
69
+ createCategory: m,
70
+ selectCategory: C,
71
+ setSelectedCategories: y,
72
+ resetSelection: u,
73
+ getSelectedCategoryIds: f,
74
+ getCategoryById: h,
75
+ getCategoryByName: w
76
+ };
77
+ };
78
+ export {
79
+ T as useTemplateCategories
80
+ };
package/dist/guido.css CHANGED
@@ -1 +1 @@
1
- .version-history-item[data-v-0e2ff42d]{flex-basis:200px}.version-history-wrapper[data-v-187d41fa]{gap:8px}[data-v-6a2bde67] .guido__verion-history-view-option-selection-desktop svg,[data-v-6a2bde67] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-6a2bde67] .in-segments-wrapper__button_selected,[data-v-6a2bde67] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-0fff376c] .guido__view-option-selection-desktop svg,[data-v-0fff376c] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-0fff376c] .in-segments-wrapper__button_selected,[data-v-0fff376c] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}.header-right-slot[data-v-8f49feef]{gap:16px}.guido-editor__wrapper[data-v-d4a5c957],.guido-editor__container[data-v-d4a5c957]{width:100%;height:100vh}
1
+ .version-history-item[data-v-0e2ff42d]{flex-basis:200px}.version-history-wrapper[data-v-187d41fa]{gap:8px}[data-v-6a2bde67] .guido__verion-history-view-option-selection-desktop svg,[data-v-6a2bde67] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-6a2bde67] .in-segments-wrapper__button_selected,[data-v-6a2bde67] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-0fff376c] .guido__view-option-selection-desktop svg,[data-v-0fff376c] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-0fff376c] .in-segments-wrapper__button_selected,[data-v-0fff376c] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}.header-right-slot[data-v-78791c47]{gap:16px}.guido-editor__wrapper[data-v-f20b186e],.guido-editor__container[data-v-f20b186e]{width:100%;height:100vh}
@@ -2,4 +2,5 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"editor", {
2
2
  isCodeEditorOpen: boolean;
3
3
  isVersionHistoryOpen: boolean;
4
4
  editorVisualMode: string;
5
+ isSaveTemplateModalOpen: boolean;
5
6
  }, {}, {}>;
@@ -3,7 +3,8 @@ const t = e("editor", {
3
3
  state: () => ({
4
4
  isCodeEditorOpen: !1,
5
5
  isVersionHistoryOpen: !1,
6
- editorVisualMode: "desktop"
6
+ editorVisualMode: "desktop",
7
+ isSaveTemplateModalOpen: !1
7
8
  })
8
9
  });
9
10
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "1.0.0-beta.401ddbd",
3
+ "version": "1.0.0-beta.419f6b3",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",
@@ -1,21 +0,0 @@
1
- import r from "./SaveTemplateModal.vue2.js";
2
- import o from "../../../_virtual/_plugin-vue2_normalizer.js";
3
- var s = function() {
4
- var t = this, n = t._self._c, e = t._self._setupProxy;
5
- return n(e.InDrawer, { attrs: { id: "save-template-modal", size: "medium", "description-text": e.trans("newsletter.save-template-description"), "footer-button-group-options": e.drawerFooterOptions, status: e.props.isOpen, "title-text": e.trans("products.save-template") }, on: { cancelOrBackButtonEvent: e.closeModal, onCloseEvent: e.closeModal, primaryButtonEvent: e.saveTemplate }, scopedSlots: t._u([{ key: "contentSlot", fn: function() {
6
- return [n(e.InTextInput, { staticClass: "mb-5 w-1", attrs: { id: "template-name-input", "with-label": "", name: "templateName", disabled: e.isSaving, invalid: !!e.validationError, "invalid-message": e.validationError, label: e.trans("products.template-name"), placeholder: e.trans("newsletter.enter-template-name") }, model: { value: e.templateNameInput, callback: function(a) {
7
- e.templateNameInput = typeof a == "string" ? a.trim() : a;
8
- }, expression: "templateNameInput" } })];
9
- }, proxy: !0 }]) });
10
- }, l = [], p = /* @__PURE__ */ o(
11
- r,
12
- s,
13
- l,
14
- !1,
15
- null,
16
- null
17
- );
18
- const u = p.exports;
19
- export {
20
- u as default
21
- };
@@ -1,61 +0,0 @@
1
- import { defineComponent as T, ref as m, computed as g, watch as v } from "vue";
2
- import { useTemplateValidation as h } from "../../../composables/useTemplateValidation.js";
3
- import { useToaster as _ } from "../../../composables/useToaster.js";
4
- import { useTranslations as w } from "../../../composables/useTranslations.js";
5
- import { InTextInput as x, InDrawer as B } from "@useinsider/design-system-vue";
6
- const N = /* @__PURE__ */ T({
7
- __name: "SaveTemplateModal",
8
- props: {
9
- isOpen: { type: Boolean },
10
- htmlData: null
11
- },
12
- emits: ["close", "save"],
13
- setup(d, { emit: r }) {
14
- const s = d, n = w(), { handleError: p } = _(), a = m(""), t = m(!1), {
15
- validationError: i,
16
- isValidating: u,
17
- validateTemplateName: l,
18
- clearValidation: o
19
- } = h(), f = g(() => ({
20
- primaryButton: {
21
- styling: "solid",
22
- type: "primary",
23
- labelText: n(t.value ? "newsletter.saving" : "products.save"),
24
- disabled: t.value || u.value || !i.value
25
- },
26
- cancelOrBackButton: {
27
- type: "secondary",
28
- styling: "ghost",
29
- labelText: n("products.cancel")
30
- }
31
- })), c = () => {
32
- a.value = "", o(), r("close");
33
- }, y = async () => {
34
- if (!i.value) {
35
- await l(a.value);
36
- return;
37
- }
38
- t.value = !0;
39
- try {
40
- if (!(await l(a.value)).isValid)
41
- return;
42
- r("save", {
43
- templateName: a.value.trim(),
44
- htmlData: s.htmlData
45
- }), c();
46
- } catch (e) {
47
- p(e, "Error saving template:");
48
- } finally {
49
- t.value = !1;
50
- }
51
- };
52
- return v(a, (e) => {
53
- e.trim() ? l(e) : o();
54
- }), v(() => s.isOpen, (e) => {
55
- e || (a.value = "", o());
56
- }), { __sfc: !0, props: s, emit: r, trans: n, handleError: p, templateNameInput: a, isSaving: t, validationError: i, isValidating: u, validateTemplateName: l, clearValidation: o, drawerFooterOptions: f, closeModal: c, saveTemplate: y, InDrawer: B, InTextInput: x };
57
- }
58
- });
59
- export {
60
- N as default
61
- };