@useinsider/guido 1.0.0-beta.02a8faf → 1.0.0-beta.070ce4c

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,13 +1,3 @@
1
1
  export type GuidoConfig = {
2
2
  translationsPath: string;
3
3
  };
4
- export interface User {
5
- id: number;
6
- name: string;
7
- email: string;
8
- }
9
- export interface ApiResponse<T> {
10
- data: T;
11
- message: string;
12
- success: boolean;
13
- }
@@ -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';
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";
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: "modal-wrapper", "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 s } 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: "small" },
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: s };
39
+ }
40
+ });
41
+ export {
42
+ i as default
43
+ };
@@ -3,7 +3,7 @@ import o from "./RightSlot.vue2.js";
3
3
  import i from "../../../_virtual/_plugin-vue2_normalizer.js";
4
4
  var r = function() {
5
5
  var s = this, e = s._self._c, t = s._self._setupProxy;
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 } }), 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
8
  } } }) : e(t.InButtonV2, { attrs: { id: "guido__save-button", "label-text": "Save" } })], 1);
9
9
  }, n = [], a = /* @__PURE__ */ i(
@@ -12,9 +12,9 @@ var r = function() {
12
12
  n,
13
13
  !1,
14
14
  null,
15
- "fefca98f"
15
+ "78791c47"
16
16
  );
17
- const f = a.exports;
17
+ const p = a.exports;
18
18
  export {
19
- f as default
19
+ p as default
20
20
  };
@@ -1,24 +1,26 @@
1
1
  import { defineComponent as n } from "vue";
2
- import { useExport as m } from "../../../composables/useExport.js";
3
- import { useVersionHistoryApi as p } from "../../../composables/useVersionHistoryApi.js";
4
- import { useEditorStore as f } from "../../../stores/editor.js";
5
- import { useVersionHistoryStore as V } from "../../../stores/version-history.js";
6
- import { InButtonV2 as u } from "@useinsider/design-system-vue";
7
- import H from "./version-history/ViewOptions.vue.js";
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
8
  import c from "./ViewOptions.vue.js";
9
- const E = /* @__PURE__ */ n({
9
+ const T = /* @__PURE__ */ n({
10
10
  __name: "RightSlot",
11
- setup(y) {
12
- const { exportHtml: e } = m(), { openVersionHistory: o, closeVersionHistory: r, restoreVersion: i } = p(), t = f(), s = V();
13
- return { __sfc: !0, exportHtml: e, openVersionHistory: o, closeVersionHistory: r, restoreVersion: i, editorStore: t, versionHistoryStore: s, handleVersionHistory: () => {
14
- if (t.isVersionHistoryOpen) {
15
- r();
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();
16
16
  return;
17
17
  }
18
- o();
19
- }, InButtonV2: u, VersionHistoryViewOptions: H, ViewOptions: c };
18
+ r();
19
+ }, handleSaveAsTemplate: async () => {
20
+ o.isSaveTemplateModalOpen = !0;
21
+ }, InButtonV2: l, VersionHistoryViewOptions: V, ViewOptions: c };
20
22
  }
21
23
  });
22
24
  export {
23
- E as default
25
+ T as default
24
26
  };
@@ -0,0 +1,16 @@
1
+ interface TemplateModalProps {
2
+ isOpen: boolean;
3
+ }
4
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<TemplateModalProps>, {}, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
5
+ close: () => void;
6
+ }, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<TemplateModalProps>>>, {}>;
7
+ export default _default;
8
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
9
+ type __VLS_TypePropsToOption<T> = {
10
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
11
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
12
+ } : {
13
+ type: import('vue').PropType<T[K]>;
14
+ required: true;
15
+ };
16
+ };
@@ -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.saveState.saving || 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", 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,90 @@
1
+ import { defineComponent as j, ref as o, watch as I } from "vue";
2
+ import { useActionsApi as x } from "../../../composables/useActionsApi.js";
3
+ import { useTemplateCategories as A } from "../../../composables/useTemplateCategories.js";
4
+ import { useTemplateSave as E } from "../../../composables/useTemplateSave.js";
5
+ import { useTemplateValidation as N } from "../../../composables/useTemplateValidation.js";
6
+ import { useToaster as R } from "../../../composables/useToaster.js";
7
+ import { useTranslations as V } from "../../../composables/useTranslations.js";
8
+ import B from "../base/ModalWrapper.vue.js";
9
+ import { InMultiSelect as P, InTextInput as W } from "@useinsider/design-system-vue";
10
+ const Y = /* @__PURE__ */ j({
11
+ __name: "SaveTemplateModal",
12
+ props: {
13
+ isOpen: { type: Boolean }
14
+ },
15
+ emits: ["close"],
16
+ setup(w, { emit: u }) {
17
+ const p = w, l = V(), { showToaster: r } = R(), { getCompiledEmail: v } = x(), {
18
+ data: _,
19
+ fetchCategories: f,
20
+ createCategory: d,
21
+ setSelectedCategories: y,
22
+ resetSelection: g,
23
+ getSelectedCategoryIds: T
24
+ } = A(), {
25
+ state: M,
26
+ saveTemplate: h
27
+ } = E(), t = o(""), a = o(!1), n = o(!1), s = o(""), b = 40, {
28
+ validationError: D,
29
+ validateTemplateName: i,
30
+ clearValidation: c
31
+ } = N(), m = () => {
32
+ t.value = "", g(), c(), s.value = "";
33
+ }, C = () => {
34
+ m(), u("close");
35
+ }, H = async () => {
36
+ if (t.value.trim()) {
37
+ a.value = !0;
38
+ try {
39
+ if (!(await i(t.value)).isValid) {
40
+ a.value = !1;
41
+ return;
42
+ }
43
+ await h({
44
+ name: t.value,
45
+ htmlContent: s.value,
46
+ categoryIds: T.value
47
+ }) && (r({
48
+ message: l(
49
+ "journey-builder.template-saved-successfully",
50
+ { name: t.value }
51
+ ),
52
+ type: "success"
53
+ }), C(), a.value = !1);
54
+ } catch {
55
+ r({
56
+ message: l("journey-builder.template-save-error", { name: t.value }),
57
+ type: "error"
58
+ }), a.value = !1;
59
+ }
60
+ }
61
+ };
62
+ I(t, (e) => {
63
+ e.trim() ? i(e) : c();
64
+ });
65
+ const S = async () => {
66
+ n.value = !0;
67
+ try {
68
+ const { html: e } = await v();
69
+ s.value = e || "";
70
+ } catch {
71
+ s.value = "";
72
+ } finally {
73
+ n.value = !1;
74
+ }
75
+ }, L = (e) => {
76
+ y(e);
77
+ }, O = async (e) => {
78
+ await d(e);
79
+ };
80
+ return I(() => p.isOpen, async (e) => {
81
+ e ? await Promise.all([
82
+ S(),
83
+ f()
84
+ ]) : m();
85
+ }), { __sfc: !0, props: p, emit: u, trans: l, showToaster: r, getCompiledEmail: v, categoriesData: _, fetchCategories: f, createCategory: d, setSelectedCategories: y, resetSelection: g, getSelectedCategoryIds: T, saveState: M, saveTemplateToLibrary: h, templateNameInput: t, isSaving: a, isLoadingHtml: n, htmlData: s, templateCategorySearchInputLimit: b, validationError: D, validateTemplateName: i, clearValidation: c, resetModalState: m, closeModal: C, saveTemplate: H, fetchHtmlData: S, categoryChangeHandler: L, addOption: O, ModalWrapper: B, InTextInput: W, InMultiSelect: P };
86
+ }
87
+ });
88
+ export {
89
+ Y as default
90
+ };
@@ -1,7 +1,8 @@
1
- /**
2
- * @deprecated - It's added for example purposes.
3
- */
4
- import type { User } from '../@types/generic';
1
+ interface User {
2
+ id: number;
3
+ name: string;
4
+ email: string;
5
+ }
5
6
  export declare const useApiExample: () => {
6
7
  loading: import("vue").ComputedRef<boolean>;
7
8
  error: import("vue").ComputedRef<{
@@ -59,3 +60,4 @@ export declare const useApiExample: () => {
59
60
  uploadFile: (file: File) => Promise<string>;
60
61
  clearError: () => void;
61
62
  };
63
+ export {};
@@ -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
+ };
@@ -0,0 +1,17 @@
1
+ import type { StripoConfig, RecommendationConfig, RecommendationCampaignUrls } from '@@/Types/template-save';
2
+ interface SaveTemplateData {
3
+ name: string;
4
+ htmlContent: string;
5
+ categoryIds: number[];
6
+ css?: string;
7
+ stripoConfig?: StripoConfig;
8
+ recommendationConfigs?: RecommendationConfig;
9
+ recommendationCampaignUrls?: RecommendationCampaignUrls;
10
+ }
11
+ export declare const useTemplateSave: () => {
12
+ state: {
13
+ saving: boolean;
14
+ };
15
+ saveTemplate: (data: SaveTemplateData) => Promise<boolean>;
16
+ };
17
+ export {};
@@ -0,0 +1,44 @@
1
+ import { useHttp as o } from "./useHttp.js";
2
+ import { base64EncodeWithSpecialChars as n } from "../utils/base64.js";
3
+ import { reactive as a } from "vue";
4
+ const l = () => {
5
+ const { post: i } = o(), r = a({
6
+ saving: !1
7
+ });
8
+ return {
9
+ state: r,
10
+ saveTemplate: async (e) => {
11
+ r.saving = !0;
12
+ try {
13
+ const t = {
14
+ name: e.name,
15
+ categories: e.categoryIds,
16
+ productId: 60,
17
+ editorType: 2,
18
+ content: n(e.htmlContent),
19
+ unsubscriptionPreferencePages: [],
20
+ unsubscriptionPreferencePageStatus: !1
21
+ };
22
+ e.css && (t.css = n(e.css)), e.stripoConfig && (t.stripoConfig = n(
23
+ JSON.stringify(e.stripoConfig)
24
+ )), e.recommendationConfigs && (t.recommendationConfigs = n(
25
+ JSON.stringify(e.recommendationConfigs)
26
+ )), e.recommendationCampaignUrls && (t.recommendationCampaignUrls = n(
27
+ JSON.stringify(e.recommendationCampaignUrls)
28
+ ));
29
+ const s = await i(
30
+ "/newsletter/template-library/create-template",
31
+ t
32
+ );
33
+ return !(!s.data || s.data.type === "error");
34
+ } catch {
35
+ return !1;
36
+ } finally {
37
+ r.saving = !1;
38
+ }
39
+ }
40
+ };
41
+ };
42
+ export {
43
+ l as useTemplateSave
44
+ };
@@ -0,0 +1,13 @@
1
+ export interface ValidationResult {
2
+ isValid: boolean;
3
+ message: string;
4
+ }
5
+ export declare const useTemplateValidation: () => {
6
+ validationError: import("vue").ComputedRef<string>;
7
+ isValidating: import("vue").ComputedRef<boolean>;
8
+ validateTemplateName: (name: string) => Promise<ValidationResult>;
9
+ clearValidation: () => void;
10
+ VALIDATION_RULES: {
11
+ readonly DEBOUNCE_TIME: 500;
12
+ };
13
+ };
@@ -0,0 +1,57 @@
1
+ import { useHttp as T } from "./useHttp.js";
2
+ import { useToaster as V } from "./useToaster.js";
3
+ import { useTranslations as N } from "./useTranslations.js";
4
+ import { ref as m, computed as u } from "vue";
5
+ const c = {
6
+ DEBOUNCE_TIME: 500
7
+ }, I = () => {
8
+ const { get: d } = T(), { handleError: p } = V(), l = N(), s = m(""), o = m(!1), r = m(null), v = (a) => a.trim() ? {
9
+ isValid: !0,
10
+ message: ""
11
+ } : {
12
+ isValid: !1,
13
+ message: l("validation.required-product-name-to-continue", { product: "template" })
14
+ }, f = async (a) => {
15
+ try {
16
+ const i = `/template-library/template-name-exists?name=${encodeURIComponent(a)}`;
17
+ return (await d(i)).data.status;
18
+ } catch (e) {
19
+ return p(e, "Error checking template name:"), !1;
20
+ }
21
+ }, E = (a) => (r.value && clearTimeout(r.value), new Promise((e) => {
22
+ const i = v(a);
23
+ if (!i.isValid) {
24
+ s.value = i.message, e(i);
25
+ return;
26
+ }
27
+ o.value = !0, r.value = setTimeout(async () => {
28
+ try {
29
+ const t = await f(a.trim()), n = {
30
+ isValid: !t,
31
+ message: t ? l("whatsapp-business.template-name-exists") : ""
32
+ };
33
+ s.value = n.message, e(n);
34
+ } catch (t) {
35
+ const n = {
36
+ isValid: !1,
37
+ message: t instanceof Error ? t.message : l("validation.unknown-error")
38
+ };
39
+ s.value = n.message, e(n);
40
+ } finally {
41
+ o.value = !1;
42
+ }
43
+ }, c.DEBOUNCE_TIME);
44
+ })), g = () => {
45
+ s.value = "", o.value = !1, r.value && clearTimeout(r.value);
46
+ };
47
+ return {
48
+ validationError: u(() => s.value),
49
+ isValidating: u(() => o.value),
50
+ validateTemplateName: E,
51
+ clearValidation: g,
52
+ VALIDATION_RULES: c
53
+ };
54
+ };
55
+ export {
56
+ I as useTemplateValidation
57
+ };
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-fefca98f]{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}
@@ -0,0 +1,2 @@
1
+ declare const _default: import("msw").HttpHandler[];
2
+ export default _default;
@@ -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 {
@@ -0,0 +1 @@
1
+ export declare const base64EncodeWithSpecialChars: (input: string) => string;
@@ -0,0 +1,14 @@
1
+ const c = (e) => {
2
+ try {
3
+ const n = new TextEncoder().encode(e);
4
+ let o = "";
5
+ return n.forEach((r) => {
6
+ o += String.fromCharCode(r);
7
+ }), window.btoa(o);
8
+ } catch {
9
+ return window.btoa(unescape(encodeURIComponent(e)));
10
+ }
11
+ };
12
+ export {
13
+ c as base64EncodeWithSpecialChars
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "1.0.0-beta.02a8faf",
3
+ "version": "1.0.0-beta.070ce4c",
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",