@useinsider/guido 1.0.0-beta.71f7f07 → 1.0.0-beta.738e9f2

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,3 +1,29 @@
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
+ }
14
+ export type ToasterType = 'success' | 'error' | 'info' | 'warning';
15
+ export interface ToasterActionButton {
16
+ text: string;
17
+ onClick: () => void;
18
+ }
19
+ export interface ToasterOptions {
20
+ type?: ToasterType;
21
+ message: string;
22
+ actionButton?: ToasterActionButton;
23
+ }
24
+ export interface Translations {
25
+ [key: string]: string;
26
+ }
27
+ export interface TranslationValues {
28
+ [key: string]: string | number | boolean;
29
+ }
@@ -0,0 +1,19 @@
1
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
2
+ export interface HttpOptions extends Omit<RequestInit, 'method' | 'body'> {
3
+ baseURL?: string;
4
+ timeout?: number;
5
+ retry?: number;
6
+ retryDelay?: number;
7
+ }
8
+ export interface HttpResponse<T = unknown> {
9
+ data: T;
10
+ status: number;
11
+ statusText: string;
12
+ headers: Headers;
13
+ }
14
+ export interface HttpError {
15
+ message: string;
16
+ status?: number;
17
+ statusText?: string;
18
+ response?: Response;
19
+ }
@@ -1,18 +1,18 @@
1
1
  import o from "./Guido.vue2.js";
2
2
  /* empty css */
3
- import a from "../_virtual/_plugin-vue2_normalizer.js";
3
+ import i from "../_virtual/_plugin-vue2_normalizer.js";
4
4
  var s = function() {
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(
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(
8
8
  o,
9
9
  s,
10
- i,
10
+ _,
11
11
  !1,
12
12
  null,
13
- "f20b186e"
13
+ "d4a5c957"
14
14
  );
15
- const c = n.exports;
15
+ const f = a.exports;
16
16
  export {
17
- c as default
17
+ f as default
18
18
  };
@@ -1,12 +1,10 @@
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({
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({
10
8
  __name: "Guido",
11
9
  props: {
12
10
  emailId: null,
@@ -16,32 +14,30 @@ const F = /* @__PURE__ */ g({
16
14
  username: null,
17
15
  guidoConfig: null
18
16
  },
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
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
27
25
  } = o;
28
26
  window.GuidoConfig = {
29
- ...w,
30
- ...i
27
+ ...T,
28
+ ...a
31
29
  };
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 () => {
30
+ const { initPlugin: l } = _({ emailId: n, userId: i, username: m, partnerName: u, productType: p }), { getDefaultTemplate: s } = y();
31
+ return c(async () => {
36
32
  try {
37
33
  const e = await s();
38
- await u(e);
34
+ await l(e);
39
35
  } catch (e) {
40
36
  console.error("Failed to initialize Stripo editor:", e);
41
37
  }
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 };
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 };
43
39
  }
44
40
  });
45
41
  export {
46
- F as default
42
+ h as default
47
43
  };
@@ -3,18 +3,18 @@ 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", [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 } }), 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)]);
8
+ } } }) : e(t.InButtonV2, { attrs: { id: "guido__save-button", "label-text": "Save" } })], 1);
9
9
  }, n = [], a = /* @__PURE__ */ i(
10
10
  o,
11
11
  r,
12
12
  n,
13
13
  !1,
14
14
  null,
15
- "0318cf78"
15
+ "fefca98f"
16
16
  );
17
- const p = a.exports;
17
+ const f = a.exports;
18
18
  export {
19
- p as default
19
+ f as default
20
20
  };
@@ -1,26 +1,24 @@
1
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";
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";
8
8
  import c from "./ViewOptions.vue.js";
9
- const T = /* @__PURE__ */ n({
9
+ const E = /* @__PURE__ */ n({
10
10
  __name: "RightSlot",
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();
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();
16
16
  return;
17
17
  }
18
- r();
19
- }, handleSaveAsTemplate: async () => {
20
- o.isSaveTemplateModalOpen = !0;
21
- }, InButtonV2: l, VersionHistoryViewOptions: V, ViewOptions: c };
18
+ o();
19
+ }, InButtonV2: u, VersionHistoryViewOptions: H, ViewOptions: c };
22
20
  }
23
21
  });
24
22
  export {
25
- T as default
23
+ E as default
26
24
  };
@@ -1,8 +1,7 @@
1
- interface User {
2
- id: number;
3
- name: string;
4
- email: string;
5
- }
1
+ /**
2
+ * @deprecated - It's added for example purposes.
3
+ */
4
+ import type { User } from '../@types/generic';
6
5
  export declare const useApiExample: () => {
7
6
  loading: import("vue").ComputedRef<boolean>;
8
7
  error: import("vue").ComputedRef<{
@@ -60,4 +59,3 @@ export declare const useApiExample: () => {
60
59
  uploadFile: (file: File) => Promise<string>;
61
60
  clearError: () => void;
62
61
  };
63
- export {};
@@ -1,22 +1,4 @@
1
- export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
2
- export interface HttpOptions extends Omit<RequestInit, 'method' | 'body'> {
3
- baseURL?: string;
4
- timeout?: number;
5
- retry?: number;
6
- retryDelay?: number;
7
- }
8
- export interface HttpResponse<T = unknown> {
9
- data: T;
10
- status: number;
11
- statusText: string;
12
- headers: Headers;
13
- }
14
- export interface HttpError {
15
- message: string;
16
- status?: number;
17
- statusText?: string;
18
- response?: Response;
19
- }
1
+ import type { HttpMethod, HttpOptions, HttpResponse } from '@/@types/http';
20
2
  export declare const useHttp: (defaultOptions?: HttpOptions) => {
21
3
  loading: import("vue").ComputedRef<boolean>;
22
4
  error: import("vue").ComputedRef<{
@@ -1,14 +1,14 @@
1
- import { useCustomInterfaceAppearance as m } from "./useCustomInterfaceAppearance.js";
2
- import { useToaster as g } from "./useToaster.js";
3
- import { useStripoApi as E } from "../services/stripoApi.js";
4
- import { useEditorStore as S } from "../stores/editor.js";
5
- const _ = (c) => {
6
- const { handleError: d } = g(), { getToken: u, getCustomFonts: a } = E(), l = (e, i = []) => {
7
- const r = S(), { html: t, css: n } = e;
1
+ import { useCustomInterfaceAppearance as p } from "./useCustomInterfaceAppearance.js";
2
+ import { useToaster as m } from "./useToaster.js";
3
+ import c from "../services/stripoApi.js";
4
+ import { useEditorStore as g } from "../stores/editor.js";
5
+ const f = (a) => {
6
+ const { handleError: d } = m(), u = (e, i = []) => {
7
+ const r = g(), { html: t, css: n } = e;
8
8
  window.UIEditor.initEditor(
9
9
  document.querySelector("#guido-editor"),
10
10
  {
11
- metadata: c,
11
+ metadata: a,
12
12
  html: t,
13
13
  css: n,
14
14
  locale: "en",
@@ -24,7 +24,7 @@ const _ = (c) => {
24
24
  },
25
25
  async onTokenRefreshRequest(o) {
26
26
  try {
27
- const s = await u();
27
+ const s = await c.getToken();
28
28
  o(s);
29
29
  } catch (s) {
30
30
  d(s, "Failed to refresh token");
@@ -32,7 +32,7 @@ const _ = (c) => {
32
32
  },
33
33
  onTemplateLoaded() {
34
34
  try {
35
- const { importCss: o } = m();
35
+ const { importCss: o } = p();
36
36
  o();
37
37
  } catch (o) {
38
38
  d(o, "Failed to load custom interface appearance");
@@ -49,7 +49,7 @@ const _ = (c) => {
49
49
  }
50
50
  }
51
51
  );
52
- }, p = (e) => new Promise((i, r) => {
52
+ }, l = (e) => new Promise((i, r) => {
53
53
  if (document.getElementById("UiEditorScript")) {
54
54
  e(), i();
55
55
  return;
@@ -63,12 +63,12 @@ const _ = (c) => {
63
63
  }, document.body.appendChild(t);
64
64
  });
65
65
  return { initPlugin: async (e) => {
66
- await p(async () => {
67
- const i = await a();
68
- l(e, i);
66
+ await l(async () => {
67
+ const i = await c.getCustomFonts();
68
+ u(e, i);
69
69
  });
70
70
  } };
71
71
  };
72
72
  export {
73
- _ as useStripo
73
+ f as useStripo
74
74
  };
@@ -1,12 +1,4 @@
1
- export type ToasterType = 'success' | 'error' | 'info' | 'warning';
2
- export type ToasterOptions = {
3
- type?: ToasterType;
4
- message: string;
5
- actionButton?: {
6
- text: string;
7
- onClick: () => void;
8
- };
9
- };
1
+ import type { ToasterType, ToasterOptions } from '@/@types/generic';
10
2
  export declare const useToaster: () => {
11
3
  isToasterVisible: import("vue").Ref<boolean>;
12
4
  toasterMessage: import("vue").Ref<string>;
@@ -1,5 +1,2 @@
1
- interface TranslationValues {
2
- [key: string]: string | number | boolean;
3
- }
1
+ import type { TranslationValues } from '@/@types/generic';
4
2
  export declare const useTranslations: () => ((key: string, params?: TranslationValues) => string) & import("lodash").MemoizedFunction;
5
- export {};
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-0318cf78]{gap:16px}.guido-editor__wrapper[data-v-f20b186e],.guido-editor__container[data-v-f20b186e]{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-fefca98f]{gap:16px}.guido-editor__wrapper[data-v-d4a5c957],.guido-editor__container[data-v-d4a5c957]{width:100%;height:100vh}
@@ -1,7 +1,9 @@
1
1
  import type { CustomFont } from '@@/Types/stripo';
2
- export declare const useStripoApi: () => {
3
- getToken: () => Promise<string>;
4
- getCustomFonts: () => Promise<(CustomFont & {
2
+ export interface StripoApiService {
3
+ getToken(): Promise<string>;
4
+ getCustomFonts(): Promise<(CustomFont & {
5
5
  active: boolean;
6
6
  })[]>;
7
- };
7
+ }
8
+ declare const stripoApiService: StripoApiService;
9
+ export default stripoApiService;
@@ -1,29 +1,28 @@
1
- import { useHttp as s } from "../composables/useHttp.js";
2
- import { useToaster as n } from "../composables/useToaster.js";
3
- const m = () => {
4
- const { get: o } = s(), { handleError: r } = n();
5
- return {
6
- getToken: async () => {
7
- try {
8
- const t = Number(localStorage.getItem("ins-guido-test-instance")), { data: e } = await o(`/stripo/get-user-token?test=${t}`);
9
- return e.body.token;
10
- } catch (t) {
11
- return r(t, "Failed to fetch token"), "";
12
- }
13
- },
14
- getCustomFonts: async () => {
15
- try {
16
- const { data: t = [] } = await o("/stripo/get-partner-custom-fonts");
17
- return t.map((e) => ({
18
- ...e,
19
- active: !0
20
- }));
21
- } catch (t) {
22
- return r(t, "Failed to fetch custom fonts"), [];
23
- }
1
+ import { useHttp as r } from "../composables/useHttp.js";
2
+ import { useToaster as s } from "../composables/useToaster.js";
3
+ const c = {
4
+ async getToken() {
5
+ try {
6
+ const t = Number(localStorage.getItem("ins-guido-test-instance")), { get: e } = r(), { data: o } = await e(`/stripo/get-user-token?test=${t}`);
7
+ return o.body.token;
8
+ } catch (t) {
9
+ const { handleError: e } = s();
10
+ return e(t, "Failed to fetch token"), "";
24
11
  }
25
- };
12
+ },
13
+ async getCustomFonts() {
14
+ try {
15
+ const { get: t } = r(), { data: e = [] } = await t("/stripo/get-partner-custom-fonts");
16
+ return e.map((o) => ({
17
+ ...o,
18
+ active: !0
19
+ }));
20
+ } catch (t) {
21
+ const { handleError: e } = s();
22
+ return e(t, "Failed to fetch custom fonts"), [];
23
+ }
24
+ }
26
25
  };
27
26
  export {
28
- m as useStripoApi
27
+ c as default
29
28
  };
@@ -2,5 +2,4 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"editor", {
2
2
  isCodeEditorOpen: boolean;
3
3
  isVersionHistoryOpen: boolean;
4
4
  editorVisualMode: string;
5
- isSaveTemplateModalOpen: boolean;
6
5
  }, {}, {}>;
@@ -3,8 +3,7 @@ const t = e("editor", {
3
3
  state: () => ({
4
4
  isCodeEditorOpen: !1,
5
5
  isVersionHistoryOpen: !1,
6
- editorVisualMode: "desktop",
7
- isSaveTemplateModalOpen: !1
6
+ editorVisualMode: "desktop"
8
7
  })
9
8
  });
10
9
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "1.0.0-beta.71f7f07",
3
+ "version": "1.0.0-beta.738e9f2",
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,20 +0,0 @@
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
- save: (data: {
7
- templateName: string;
8
- htmlData: string;
9
- }) => void;
10
- }, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<TemplateModalProps>>>, {}>;
11
- export default _default;
12
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
13
- type __VLS_TypePropsToOption<T> = {
14
- [K in keyof T]-?: {} extends Pick<T, K> ? {
15
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
16
- } : {
17
- type: import('vue').PropType<T[K]>;
18
- required: true;
19
- };
20
- };
@@ -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,57 +0,0 @@
1
- import { defineComponent as T, ref as m, computed as g, watch as v } from "vue";
2
- import { useTemplateValidation as _ } from "../../../composables/useTemplateValidation.js";
3
- import { useToaster as w } from "../../../composables/useToaster.js";
4
- import { useTranslations as h } from "../../../composables/useTranslations.js";
5
- import { InTextInput as x, InDrawer as B } from "@useinsider/design-system-vue";
6
- const M = /* @__PURE__ */ T({
7
- __name: "SaveTemplateModal",
8
- props: {
9
- isOpen: { type: Boolean }
10
- },
11
- emits: ["close", "save"],
12
- setup(d, { emit: n }) {
13
- const i = d, s = h(), { handleError: p } = w(), a = m(""), t = m(!1), {
14
- validationError: l,
15
- isValidating: c,
16
- validateTemplateName: o,
17
- clearValidation: r
18
- } = _(), f = g(() => ({
19
- primaryButton: {
20
- styling: "solid",
21
- type: "primary",
22
- labelText: s(t.value ? "newsletter.saving" : "products.save"),
23
- disabled: t.value || c.value || !l.value
24
- },
25
- cancelOrBackButton: {
26
- type: "secondary",
27
- styling: "ghost",
28
- labelText: s("products.cancel")
29
- }
30
- })), u = () => {
31
- a.value = "", r(), n("close");
32
- }, y = async () => {
33
- if (!l.value) {
34
- await o(a.value);
35
- return;
36
- }
37
- t.value = !0;
38
- try {
39
- if (!(await o(a.value)).isValid)
40
- return;
41
- u();
42
- } catch (e) {
43
- p(e, "Error saving template:");
44
- } finally {
45
- t.value = !1;
46
- }
47
- };
48
- return v(a, (e) => {
49
- e.trim() ? o(e) : r();
50
- }), v(() => i.isOpen, (e) => {
51
- e || (a.value = "", r());
52
- }), { __sfc: !0, props: i, emit: n, trans: s, handleError: p, templateNameInput: a, isSaving: t, validationError: l, isValidating: c, validateTemplateName: o, clearValidation: r, drawerFooterOptions: f, closeModal: u, saveTemplate: y, InDrawer: B, InTextInput: x };
53
- }
54
- });
55
- export {
56
- M as default
57
- };
@@ -1,13 +0,0 @@
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
- };
@@ -1,57 +0,0 @@
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
- };
@@ -1,2 +0,0 @@
1
- declare const _default: import("msw").HttpHandler[];
2
- export default _default;