@duxweb/dvha-core 1.0.18 → 1.0.20

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.
Files changed (38) hide show
  1. package/dist/cjs/components/loader/loader.cjs +1 -1
  2. package/dist/cjs/components/loader/remote/loader.cjs +1 -1
  3. package/dist/cjs/hooks/auth.cjs +1 -1
  4. package/dist/cjs/hooks/data.cjs +1 -1
  5. package/dist/cjs/hooks/export.cjs +1 -1
  6. package/dist/cjs/hooks/exportCsv.cjs +2 -2
  7. package/dist/cjs/hooks/form.cjs +1 -1
  8. package/dist/cjs/hooks/formExtend.cjs +1 -1
  9. package/dist/cjs/hooks/i18n.cjs +1 -1
  10. package/dist/cjs/hooks/list.cjs +1 -1
  11. package/dist/cjs/hooks/tree.cjs +1 -1
  12. package/dist/cjs/preset/i18nProvider.cjs +1 -1
  13. package/dist/cjs/provider/app.cjs +1 -1
  14. package/dist/cjs/stores/jsonSchema.cjs +1 -1
  15. package/dist/cjs/stores/route.cjs +1 -1
  16. package/dist/esm/components/loader/loader.js +19 -30
  17. package/dist/esm/components/loader/remote/loader.js +22 -24
  18. package/dist/esm/hooks/auth.js +26 -24
  19. package/dist/esm/hooks/data.js +272 -258
  20. package/dist/esm/hooks/export.js +12 -12
  21. package/dist/esm/hooks/exportCsv.js +16 -24
  22. package/dist/esm/hooks/form.js +48 -39
  23. package/dist/esm/hooks/formExtend.js +11 -9
  24. package/dist/esm/hooks/i18n.js +6 -2
  25. package/dist/esm/hooks/list.js +12 -12
  26. package/dist/esm/hooks/tree.js +20 -26
  27. package/dist/esm/preset/i18nProvider.js +14 -13
  28. package/dist/esm/provider/app.js +76 -77
  29. package/dist/esm/stores/jsonSchema.js +22 -26
  30. package/dist/esm/stores/route.js +26 -23
  31. package/dist/types/hooks/auth.d.ts +1 -1
  32. package/dist/types/hooks/export.d.ts +2 -3
  33. package/dist/types/hooks/form.d.ts +2 -2
  34. package/dist/types/hooks/formExtend.d.ts +1 -1
  35. package/dist/types/hooks/i18n.d.ts +1 -0
  36. package/dist/types/types/config.d.ts +0 -1
  37. package/dist/types/types/i18n.d.ts +1 -0
  38. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
- import { defineComponent as U, inject as V, createVNode as q } from "vue";
2
- import { OverlaysProvider as B } from "@overlastic/vue";
3
- import { useRouter as G } from "vue-router";
4
- import { useCan as H } from "../hooks/auth.js";
5
- import { useConfig as K } from "../hooks/config.js";
1
+ import { defineComponent as T, inject as U, createVNode as V } from "vue";
2
+ import { OverlaysProvider as q } from "@overlastic/vue";
3
+ import { useRouter as B } from "vue-router";
4
+ import { useCan as G } from "../hooks/auth.js";
5
+ import { useConfig as H } from "../hooks/config.js";
6
6
  import "@tanstack/vue-query";
7
- import { useManage as Q } from "../hooks/manage.js";
7
+ import { useManage as K } from "../hooks/manage.js";
8
8
  import "json-2-csv";
9
9
  import "lodash-es";
10
10
  import "@vee-validate/rules";
11
11
  import "vee-validate";
12
- import { useAuthStore as T } from "../stores/auth.js";
12
+ import { useAuthStore as Q } from "../stores/auth.js";
13
13
  import { useI18nStore as W } from "../stores/i18n.js";
14
14
  import "pinia";
15
15
  import { useManageStore as X } from "../stores/manage.js";
@@ -22,49 +22,49 @@ import "colorizr";
22
22
  import "axios";
23
23
  import "clsx";
24
24
  import { DuxError as x } from "../components/status/error.js";
25
- import { DuxNotAuthorized as ee } from "../components/status/notAuthorized.js";
26
- import { DuxNotFound as oe } from "../components/status/notFound.js";
27
- const Ie = /* @__PURE__ */ U({
25
+ import { DuxNotAuthorized as tt } from "../components/status/notAuthorized.js";
26
+ import { DuxNotFound as ot } from "../components/status/notFound.js";
27
+ const Et = /* @__PURE__ */ T({
28
28
  name: "DuxAppProvider",
29
29
  props: {},
30
- setup(te, {
31
- slots: c
30
+ setup(et, {
31
+ slots: h
32
32
  }) {
33
- const f = V("dux.manage"), u = K(), s = G();
34
- return s.beforeEach(async (n, re, a) => {
35
- var P, b, R, A, S, $, k, M, z, D, w, C, I, N;
33
+ const l = U("dux.manage"), f = H(), d = B();
34
+ return d.beforeEach(async (n, rt, i) => {
35
+ var A, S, $, k, M, w, z, D, C, E, I, N, F, L;
36
36
  const o = n.meta.manageName, J = n.meta.authorization === !1;
37
37
  if (!o) {
38
- const e = u.defaultManage || ((b = (P = u.manages) == null ? void 0 : P[0]) == null ? void 0 : b.name) || "";
39
- return a({
40
- path: `/${e}`,
38
+ const t = f.defaultManage || ((S = (A = f.manages) == null ? void 0 : A[0]) == null ? void 0 : S.name) || "";
39
+ return i({
40
+ path: `/${t}`,
41
41
  replace: !0
42
42
  });
43
43
  }
44
- f && (f.value = o);
45
- const h = X(o);
46
- h.isInit() || h.setConfig((R = u.manages) == null ? void 0 : R.find((e) => e.name === o), u);
47
- const i = Y(o), r = Q(o), d = T(o), l = W(o);
48
- if ((A = r.config) != null && A.i18nProvider && !l.isInit()) {
49
- const e = l.getLocale();
50
- e && ((S = r.config) == null || S.i18nProvider.changeLocale(e));
44
+ l && (l.value = o);
45
+ const P = X(o);
46
+ P.isInit() || P.setConfig(($ = f.manages) == null ? void 0 : $.find((t) => t.name === o), f);
47
+ const c = Y(o), e = K(o), g = Q(o), v = W(o);
48
+ if ((k = e.config) != null && k.i18nProvider && !v.isInit()) {
49
+ const t = v.getLocale();
50
+ t && ((M = e.config) == null || M.i18nProvider.changeLocale(t));
51
51
  }
52
- if (Z(u, o), !d.isLogin())
53
- return J ? a() : a({
54
- path: r.getRoutePath("login"),
52
+ if (Z(f, o), !g.isLogin())
53
+ return J ? i() : i({
54
+ path: e.getRoutePath("login"),
55
55
  replace: !0
56
56
  });
57
- const g = (e) => e == null ? void 0 : e.map((p) => ({
57
+ const R = (t) => t == null ? void 0 : t.map((p) => ({
58
58
  ...p,
59
- path: p.path ? r.getRoutePath(p.path) : void 0
59
+ path: p.path ? e.getRoutePath(p.path) : void 0
60
60
  }));
61
- if (!i.getRouteInit()) {
62
- const e = (($ = r.config) == null ? void 0 : $.components) || {}, p = [];
63
- if (p.push({
61
+ if (!c.getRouteInit()) {
62
+ const t = ((w = e.config) == null ? void 0 : w.components) || {}, p = [];
63
+ return p.push({
64
64
  name: `${o}.notFound`,
65
65
  label: "404",
66
66
  path: ":pathMatch(.*)*",
67
- component: e.notFound || oe,
67
+ component: t.notFound || ot,
68
68
  hidden: !0,
69
69
  meta: {
70
70
  can: !1
@@ -73,7 +73,7 @@ const Ie = /* @__PURE__ */ U({
73
73
  name: `${o}.notAuthorized`,
74
74
  label: "403",
75
75
  path: "notAuthorized",
76
- component: e.notAuthorized || ee,
76
+ component: t.notAuthorized || tt,
77
77
  hidden: !0,
78
78
  meta: {
79
79
  can: !1
@@ -82,79 +82,78 @@ const Ie = /* @__PURE__ */ U({
82
82
  name: `${o}.error`,
83
83
  label: "500",
84
84
  path: "error",
85
- component: e.error || x,
85
+ component: t.error || x,
86
86
  hidden: !0,
87
87
  meta: {
88
88
  can: !1
89
89
  }
90
- }), i.setRoutes(g(((k = r.config) == null ? void 0 : k.menus) || [])), (M = r.config) != null && M.apiRoutePath)
91
- try {
92
- await ((w = (D = (z = r.config) == null ? void 0 : z.dataProvider) == null ? void 0 : D.default) == null ? void 0 : w.custom({
93
- path: r.config.apiRoutePath,
94
- meta: {
95
- timeout: 5e3
96
- }
97
- }, r, d.getUser()).then((t) => {
98
- i.appendRoutes(g(t.data || []));
99
- }));
100
- } catch (t) {
101
- console.error(t);
90
+ }), c.setRoutes(R(((z = e.config) == null ? void 0 : z.menus) || [])), (D = e.config) != null && D.apiRoutePath && await ((I = (E = (C = e.config) == null ? void 0 : C.dataProvider) == null ? void 0 : E.default) == null ? void 0 : I.custom({
91
+ path: e.config.apiRoutePath,
92
+ meta: {
93
+ timeout: 5e3
102
94
  }
103
- return i.appendRoutes(p), i.getRoutes().forEach((t) => {
104
- var E, F, y, L;
105
- if (!t.path)
95
+ }, e, g.getUser()).then((r) => {
96
+ c.appendRoutes(R(r.data || []));
97
+ }).catch((r) => {
98
+ var a, m, s;
99
+ throw (s = (m = (a = e.config) == null ? void 0 : a.authProvider) == null ? void 0 : m.onError) == null || s.call(m, r).then((u) => {
100
+ u != null && u.logout && (g.logout(), d.push(e.getRoutePath(u.redirectTo || "/login")));
101
+ }), r;
102
+ })), c.appendRoutes(p), c.getRoutes().forEach((r) => {
103
+ var m, s, u, _;
104
+ if (!r.path)
106
105
  return;
107
- const m = {
108
- name: t.name,
109
- path: t.path,
110
- meta: t.meta
106
+ const a = {
107
+ name: r.name,
108
+ path: r.path,
109
+ meta: r.meta
111
110
  };
112
- switch (t.loader) {
111
+ switch (r.loader) {
113
112
  case "iframe":
114
- m.component = ((F = (E = r.config) == null ? void 0 : E.components) == null ? void 0 : F.iframe) || (() => import("../components/loader/iframe.js"));
113
+ a.component = ((s = (m = e.config) == null ? void 0 : m.components) == null ? void 0 : s.iframe) || (() => import("../components/loader/iframe.js"));
115
114
  break;
116
115
  case "remote":
117
- m.component = ((L = (y = r.config) == null ? void 0 : y.components) == null ? void 0 : L.remote) || (() => import("../components/loader/loader.js"));
116
+ a.component = ((_ = (u = e.config) == null ? void 0 : u.components) == null ? void 0 : _.remote) || (() => import("../components/loader/loader.js"));
118
117
  break;
119
118
  case "link":
120
- m.beforeEnter = () => {
119
+ a.beforeEnter = () => {
121
120
  var j;
122
- const _ = ((j = t.meta) == null ? void 0 : j.url) || t.path;
123
- return _ && window.open(_, "_blank"), !1;
124
- }, m.component = () => Promise.resolve({
121
+ const y = ((j = r.meta) == null ? void 0 : j.url) || r.path;
122
+ return y && window.open(y, "_blank"), !1;
123
+ }, a.component = () => Promise.resolve({
125
124
  template: "<div></div>"
126
125
  });
127
126
  break;
128
127
  default:
129
- t.component && (m.component = t.component);
128
+ r.component && (a.component = r.component);
130
129
  break;
131
130
  }
132
- s.addRoute(`${o}.auth`, m);
133
- }), a({
134
- path: ((C = n.redirectedFrom) == null ? void 0 : C.path) || n.path,
131
+ d.addRoute(`${o}.auth`, a);
132
+ }), i({
133
+ path: ((N = n.redirectedFrom) == null ? void 0 : N.path) || n.path,
135
134
  replace: !0
136
135
  });
137
136
  }
138
- const v = ["", "/", `/${o}`, `/${o}/`];
139
- if (v.includes(n.path)) {
140
- const e = i.getIndexRoute();
141
- return !(e != null && e.path) || v.includes(e == null ? void 0 : e.path) ? (console.warn("[Dux] index route not found, skip redirect"), a()) : a({
142
- path: (e == null ? void 0 : e.path) || "/",
137
+ const b = ["", "/", `/${o}`, `/${o}/`];
138
+ if (b.includes(n.path)) {
139
+ const t = c.getIndexRoute();
140
+ return !(t != null && t.path) || b.includes(t == null ? void 0 : t.path) ? (console.warn("[Dux] index route not found, skip redirect"), i()) : i({
141
+ path: (t == null ? void 0 : t.path) || "/",
143
142
  replace: !0
144
143
  });
145
144
  }
146
- const O = H(o);
147
- return (((I = n.meta) == null ? void 0 : I.can) === void 0 || ((N = n.meta) == null ? void 0 : N.can) === !0) && !O(n.name) ? a({
145
+ const O = G(o);
146
+ return (((F = n.meta) == null ? void 0 : F.can) === void 0 || ((L = n.meta) == null ? void 0 : L.can) === !0) && !O(n.name) ? i({
148
147
  name: `${o}.notAuthorized`
149
- }) : a();
150
- }), () => q(B, null, {
148
+ }) : i();
149
+ }), () => V(q, null, {
151
150
  default: () => {
152
151
  var n;
153
- return [(n = c.default) == null ? void 0 : n.call(c)];
152
+ return [(n = h.default) == null ? void 0 : n.call(h)];
154
153
  }
155
154
  });
156
155
  }
157
156
  });
158
157
  export {
159
- Ie as DuxAppProvider
158
+ Et as DuxAppProvider
160
159
  };
@@ -1,43 +1,39 @@
1
1
  import { defineStore as u } from "pinia";
2
- import { inject as i, ref as a } from "vue";
3
- function h(t, e) {
4
- const o = t.toString ? t.toString() : String(t);
5
- return `${e}-${o.slice(0, 32)}`;
6
- }
7
- function y(t) {
8
- const e = i("dux.manage");
9
- if (t || (t = (e == null ? void 0 : e.value) || ""), !t)
2
+ import { inject as h, ref as a } from "vue";
3
+ function d(o) {
4
+ const e = h("dux.manage");
5
+ if (o || (o = (e == null ? void 0 : e.value) || ""), !o)
10
6
  throw new Error("manage not found");
11
- return l(t)();
7
+ return i(o)();
12
8
  }
13
- function l(t) {
14
- return u(`jsonSchema-${t}`, () => {
15
- const e = a(/* @__PURE__ */ new Map()), o = a(/* @__PURE__ */ new Map());
9
+ function i(o) {
10
+ return u(`jsonSchema-${o}`, () => {
11
+ const e = a(/* @__PURE__ */ new Map()), r = a(/* @__PURE__ */ new Map());
16
12
  return {
17
13
  componentCache: e,
18
- componentsByName: o,
19
- addComponent: (n, r, s) => {
20
- const c = h(n, r);
14
+ componentsByName: r,
15
+ addComponent: (t, n, s) => {
16
+ const c = n;
21
17
  return e.value.has(c) || (e.value.set(c, {
22
- component: n,
23
- name: r,
24
- originalName: s || r,
18
+ component: t,
19
+ name: n,
20
+ originalName: s || n,
25
21
  cacheKey: c
26
- }), o.value.set(r, n)), c;
22
+ }), r.value.set(n, t)), c;
27
23
  },
28
- getComponent: (n) => {
29
- var r;
30
- return (r = e.value.get(n)) == null ? void 0 : r.component;
24
+ getComponent: (t) => {
25
+ var n;
26
+ return (n = e.value.get(t)) == null ? void 0 : n.component;
31
27
  },
32
- getComponentByName: (n) => o.value.get(n),
33
- hasComponent: (n) => e.value.has(n),
28
+ getComponentByName: (t) => r.value.get(t),
29
+ hasComponent: (t) => e.value.has(t),
34
30
  clearCache: () => {
35
- e.value.clear(), o.value.clear();
31
+ e.value.clear(), r.value.clear();
36
32
  },
37
33
  getCacheSize: () => e.value.size
38
34
  };
39
35
  });
40
36
  }
41
37
  export {
42
- y as useJsonSchemaStore
38
+ d as useJsonSchemaStore
43
39
  };
@@ -1,19 +1,19 @@
1
1
  import { defineStore as w } from "pinia";
2
2
  import { inject as j, ref as R } from "vue";
3
- function b(n) {
3
+ function b(u) {
4
4
  const t = j("dux.manage");
5
- if (n || (n = (t == null ? void 0 : t.value) || ""), !n)
5
+ if (u || (u = (t == null ? void 0 : t.value) || ""), !u)
6
6
  throw new Error("manage not found");
7
- return E(n)();
7
+ return E(u)();
8
8
  }
9
- function E(n) {
10
- return w(`routes-${n}`, () => {
11
- const t = R([]), a = (e) => {
9
+ function E(u) {
10
+ return w(`routes-${u}`, () => {
11
+ const t = R([]), l = (e) => {
12
12
  var o;
13
- return (o = t.value) == null ? void 0 : o.find((u) => u.path === e);
13
+ return (o = t.value) == null ? void 0 : o.find((s) => s.path === e);
14
14
  }, p = (e) => {
15
15
  var o;
16
- return (o = t.value) == null ? void 0 : o.find((u) => u.name === e);
16
+ return (o = t.value) == null ? void 0 : o.find((s) => s.name === e);
17
17
  }, h = (e) => {
18
18
  var o;
19
19
  (o = t.value) == null || o.push(e);
@@ -24,27 +24,30 @@ function E(n) {
24
24
  }, x = () => t.value, g = () => {
25
25
  t.value = [];
26
26
  }, m = () => {
27
- var u, f;
28
- const e = (f = (u = t.value) == null ? void 0 : u.filter((r) => !r.parent && !r.name.includes("404") && !r.name.includes("403"))) == null ? void 0 : f.sort((r, s) => (r.sort || 0) - (s.sort || 0)), o = (r) => {
29
- var d, v;
27
+ var s, d;
28
+ const e = (d = (s = t.value) == null ? void 0 : s.filter((r) => {
29
+ var n, c;
30
+ return !r.parent && !((n = r.name) != null && n.includes("404")) && !((c = r.name) != null && c.includes("403"));
31
+ })) == null ? void 0 : d.sort((r, n) => (r.sort || 0) - (n.sort || 0)), o = (r) => {
32
+ var c, v;
30
33
  if (r.path)
31
34
  return r;
32
- const s = (v = (d = t.value) == null ? void 0 : d.filter((c) => c.parent === r.name)) == null ? void 0 : v.sort((c, i) => (c.sort || 0) - (i.sort || 0));
33
- for (const c of s || []) {
34
- const i = o(c);
35
- if (i)
36
- return i;
35
+ const n = (v = (c = t.value) == null ? void 0 : c.filter((i) => i.parent === r.name)) == null ? void 0 : v.sort((i, a) => (i.sort || 0) - (a.sort || 0));
36
+ for (const i of n || []) {
37
+ const a = o(i);
38
+ if (a)
39
+ return a;
37
40
  }
38
41
  };
39
42
  for (const r of e || []) {
40
- const s = o(r);
41
- if (s)
42
- return s;
43
+ const n = o(r);
44
+ if (n)
45
+ return n;
43
46
  }
44
- }, l = R(!1);
47
+ }, f = R(!1);
45
48
  return {
46
49
  routes: t,
47
- searchRoute: a,
50
+ searchRoute: l,
48
51
  searchRouteName: p,
49
52
  appendRoute: h,
50
53
  appendRoutes: S,
@@ -53,8 +56,8 @@ function E(n) {
53
56
  clearRoutes: g,
54
57
  getIndexRoute: m,
55
58
  getRouteInit: () => {
56
- const e = l.value;
57
- return l.value = !0, e;
59
+ const e = f.value;
60
+ return f.value = !0, e;
58
61
  }
59
62
  };
60
63
  });
@@ -93,7 +93,7 @@ export declare function useUpdatePassword(props?: IAuthActionParams): {
93
93
  * @returns Error method
94
94
  */
95
95
  export declare function useError(onCallback?: (data?: IAuthErrorResponse) => void): {
96
- mutate: (error: IDataProviderError) => Promise<void>;
96
+ mutate: (error?: IDataProviderError) => Promise<void>;
97
97
  };
98
98
  /**
99
99
  * Get auth
@@ -1,9 +1,8 @@
1
- import type { InfiniteData } from '@tanstack/vue-query';
2
1
  import type { IDataProviderPagination, IDataProviderResponse } from '../types';
3
2
  import type { IInfiniteListParams } from './data';
4
3
  export interface IUseExportProps extends IInfiniteListParams {
5
- onSuccess?: (data: InfiniteData<IDataProviderResponse | undefined> | undefined) => void;
6
- onProgress?: (data: IDataProviderPagination) => void;
4
+ onSuccess?: (data?: IDataProviderResponse) => void;
5
+ onProgress?: (data?: IDataProviderPagination) => void;
7
6
  interval?: number;
8
7
  maxPage?: number | (() => number);
9
8
  }
@@ -3,7 +3,7 @@ import type { IDataProviderError, IDataProviderResponse } from '../types';
3
3
  type Key = string | number | undefined;
4
4
  export interface IUseFormProps {
5
5
  path?: string;
6
- id?: Key;
6
+ id?: MaybeRef<Key>;
7
7
  form?: MaybeRef<Record<string, any>>;
8
8
  onSuccess?: (data: IDataProviderResponse) => void;
9
9
  onError?: (error: IDataProviderError) => void;
@@ -14,7 +14,7 @@ export declare function useForm(props: IUseFormProps): {
14
14
  form: import("vue").Ref<MaybeRef<Record<string, any>>, MaybeRef<Record<string, any>>>;
15
15
  initData: any;
16
16
  isLoading: import("vue").ComputedRef<boolean>;
17
- isEdit: import("vue").ComputedRef<true | Key>;
17
+ isEdit: import("vue").ComputedRef<boolean>;
18
18
  onSubmit: (data?: Record<string, any>) => void;
19
19
  onReset: () => void;
20
20
  };
@@ -5,7 +5,7 @@ export interface UseExtendFormProps extends IUseFormProps {
5
5
  }
6
6
  export declare function useExtendForm(props: UseExtendFormProps): {
7
7
  isLoading: import("vue").ComputedRef<boolean>;
8
- isEdit: import("vue").ComputedRef<true | (string | number | undefined)>;
8
+ isEdit: import("vue").ComputedRef<boolean>;
9
9
  form: import("vue").Ref<import("vue").MaybeRef<Record<string, any>>, import("vue").MaybeRef<Record<string, any>>>;
10
10
  onSubmit: (data?: Record<string, any>) => void;
11
11
  onReset: () => void;
@@ -4,4 +4,5 @@ export declare function useI18n(): {
4
4
  getLocale: () => string | undefined;
5
5
  loadLocale: (lang: string, messages: Record<string, unknown>) => Promise<any> | undefined;
6
6
  mergeLocale: (lang: string, messages: Record<string, unknown>) => void | undefined;
7
+ getLocales: () => string[] | undefined;
7
8
  };
@@ -42,7 +42,6 @@ export interface IConfigComponent {
42
42
  notAuthorized?: RouteComponent;
43
43
  error?: RouteComponent;
44
44
  exception?: RouteComponent;
45
- loading?: RouteComponent;
46
45
  iframe?: RouteComponent;
47
46
  remote?: RouteComponent;
48
47
  }
@@ -8,4 +8,5 @@ export interface I18nProvider {
8
8
  loadLocale: (lang: string, files: Record<string, unknown>) => Promise<any>;
9
9
  mergeLocale: (lang: string, messages: Record<string, unknown>) => void;
10
10
  getLocale: () => string;
11
+ getLocales: () => string[];
11
12
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@duxweb/dvha-core",
3
3
  "type": "module",
4
- "version": "1.0.18",
4
+ "version": "1.0.20",
5
5
  "author": "DuxWeb",
6
6
  "license": "MIT",
7
7
  "repository": {