@duxweb/dvha-core 0.1.8 → 0.1.10

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.
@@ -0,0 +1,33 @@
1
+ import { ref as P, computed as t } from "vue";
2
+ import { useInfiniteList as d } from "./data.js";
3
+ const w = (e) => new Promise((a) => setTimeout(a, e));
4
+ function N(e) {
5
+ const a = P(!1), i = t(() => {
6
+ const { onSuccess: n, interval: h, maxPage: y, ...x } = e;
7
+ return x;
8
+ }), o = t(() => e.maxPage || 100), l = t(() => e.interval || 300), { data: u, isLoading: r, fetchNextPage: c, hasNextPage: v, refetch: g, pagination: s } = d({
9
+ ...i.value,
10
+ options: {
11
+ ...i.value.options,
12
+ enabled: !1
13
+ }
14
+ }), f = async () => {
15
+ var n;
16
+ if (!a.value)
17
+ try {
18
+ for (a.value = !0, s.value.page = 1, await g(); v.value && s.value.page < o.value; )
19
+ l.value > 0 && await w(l.value), await c();
20
+ (n = e.onSuccess) == null || n.call(e, u.value);
21
+ } finally {
22
+ a.value = !1;
23
+ }
24
+ }, m = t(() => r.value || a.value);
25
+ return {
26
+ data: u,
27
+ isLoading: m,
28
+ trigger: f
29
+ };
30
+ }
31
+ export {
32
+ N as useExport
33
+ };
@@ -1,33 +1,32 @@
1
- import { debounce as N, isArray as O } from "lodash-es";
2
- import { ref as o, watch as b, computed as d } from "vue";
3
- import { useCustom as A, useMany as E } from "./data.js";
4
- function j(a) {
5
- const r = o(), i = o(1), f = o(
6
- typeof a.pagination == "number" ? a.pagination : a.pagination ? 20 : 0
7
- ), v = o(!1), V = N((e) => {
1
+ import { debounce as N, isArray as k } from "lodash-es";
2
+ import { ref as o, computed as s, watch as m } from "vue";
3
+ import { useList as p, useMany as A } from "./data.js";
4
+ function z(a) {
5
+ const r = o(), d = o({
6
+ page: 1,
7
+ pageSize: typeof a.pagination == "number" ? a.pagination : a.pagination ? 20 : 0
8
+ }), f = o(!1), h = N((e) => {
8
9
  r.value = e;
9
- }, a.debounce || 300), S = (e) => {
10
- V(e);
11
- };
12
- b([() => a.path, () => a.params, r], () => {
13
- a.pagination && (i.value = 1);
14
- }, { deep: !0 });
15
- const { data: c, isLoading: w } = A({
10
+ }, a.debounce || 300), b = (e) => {
11
+ h(e);
12
+ }, { data: i, isLoading: V } = p({
16
13
  get path() {
17
14
  return a.path || "";
18
15
  },
19
16
  get filters() {
20
- return a.params;
17
+ const e = { ...a.params };
18
+ return r.value && (e[a.keywordField || "keyword"] = r.value), e;
21
19
  },
22
- get query() {
23
- const e = {};
24
- return a.pagination && (e.page = i.value, e.pageSize = f.value), r.value && (e[a.keywordField || "keyword"] = r.value), Object.keys(e).length ? e : void 0;
20
+ get pagination() {
21
+ return a.pagination ? d.value : void 0;
25
22
  },
26
- providerName: a.providerName
27
- }), g = o([]), y = (e) => {
23
+ get providerName() {
24
+ return a.providerName;
25
+ }
26
+ }), v = o([]), g = (e) => {
28
27
  const { optionField: n } = a;
29
28
  return typeof n == "string" ? e[n] || e.value || e.id : e.value || e.id;
30
- }, m = (e) => {
29
+ }, w = (e) => {
31
30
  const { optionLabel: n = "label", optionValue: u = "value" } = a;
32
31
  let l;
33
32
  typeof n == "function" ? l = n(e) : typeof n == "string" ? l = e[n] || e.label || e.name || e.title || String(e.value || e.id || "") : l = e.label || e.name || e.title || String(e.value || e.id || "");
@@ -37,51 +36,50 @@ function j(a) {
37
36
  value: t,
38
37
  raw: e
39
38
  };
40
- }, h = d(() => {
39
+ }, y = s(() => {
41
40
  var u;
42
- const e = ((u = c.value) == null ? void 0 : u.data) || [], n = [...g.value];
41
+ const e = ((u = i.value) == null ? void 0 : u.data) || [], n = [...v.value];
43
42
  return e.forEach((l) => {
44
43
  n.some(
45
- (s) => y(s) === y(l)
44
+ (c) => g(c) === g(l)
46
45
  ) || n.push(l);
47
- }), n.map((l) => m(l));
48
- }), x = d(() => {
46
+ }), n.map((l) => w(l));
47
+ }), S = s(() => {
49
48
  var e;
50
- return ((e = c.value) == null ? void 0 : e.meta) || {};
51
- }), { refetch: k } = E({
49
+ return ((e = i.value) == null ? void 0 : e.meta) || {};
50
+ }), { refetch: x } = A({
52
51
  get path() {
53
52
  return a.path || "";
54
53
  },
55
54
  get ids() {
56
- return a.defaultValue ? O(a.defaultValue) ? a.defaultValue : [a.defaultValue] : [];
55
+ return a.defaultValue ? k(a.defaultValue) ? a.defaultValue : [a.defaultValue] : [];
57
56
  },
58
57
  options: {
59
58
  enabled: !1
60
59
  },
61
60
  providerName: a.providerName
62
61
  });
63
- b(() => a.defaultValue, async (e) => {
62
+ m(() => a.defaultValue, async (e) => {
64
63
  var l;
65
- if (!(v.value || !e || (v.value = !0, (Array.isArray(e) ? e : [e]).every(
66
- (t) => h.value.some((s) => s.value === t)
64
+ if (!(f.value || !e || (f.value = !0, (Array.isArray(e) ? e : [e]).every(
65
+ (t) => y.value.some((c) => c.value === t)
67
66
  ))))
68
67
  try {
69
- const t = await k();
70
- g.value = ((l = t == null ? void 0 : t.data) == null ? void 0 : l.data) || [];
68
+ const t = await x();
69
+ v.value = ((l = t == null ? void 0 : t.data) == null ? void 0 : l.data) || [];
71
70
  } catch (t) {
72
71
  console.warn("Failed to fetch selected items:", t);
73
72
  }
74
73
  }, { immediate: !0 });
75
- const F = d(() => w.value && !c.value);
74
+ const F = s(() => V.value && !i.value);
76
75
  return {
77
- onSearch: S,
78
- options: h,
79
- meta: x,
76
+ onSearch: b,
77
+ options: y,
78
+ meta: S,
80
79
  loading: F,
81
- page: i,
82
- pageSize: f
80
+ pagination: d
83
81
  };
84
82
  }
85
83
  export {
86
- j as useSelect
84
+ z as useSelect
87
85
  };
package/dist/esm/index.js CHANGED
@@ -1,46 +1,47 @@
1
1
  import { createDux as o } from "./main.js";
2
- import { useCan as u, useCheck as s, useError as a, useForgotPassword as m, useGetAuth as p, useIsLogin as x, useLogin as f, useLogout as n, useRegister as i, useUpdatePassword as d } from "./hooks/auth.js";
2
+ import { useCan as u, useCheck as s, useError as p, useForgotPassword as x, useGetAuth as m, useIsLogin as a, useLogin as f, useLogout as n, useRegister as i, useUpdatePassword as d } from "./hooks/auth.js";
3
3
  import { useConfig as D } from "./hooks/config.js";
4
4
  import { useClient as C, useCreate as M, useCreateMany as v, useCustom as y, useCustomMutation as L, useDelete as T, useDeleteMany as h, useInfiniteList as I, useInvalidate as P, useList as S, useMany as A, useOne as c, useUpdate as R, useUpdateMany as w } from "./hooks/data.js";
5
5
  import { useManage as U } from "./hooks/manage.js";
6
- import { useMenu as F } from "./hooks/menu.js";
7
- import { useTheme as E } from "./hooks/theme.js";
6
+ import { useMenu as E } from "./hooks/menu.js";
7
+ import { useTheme as k } from "./hooks/theme.js";
8
8
  import { useOverlay as V } from "./hooks/overlay.js";
9
9
  import { useI18n as q } from "./hooks/i18n.js";
10
10
  import { useSelect as B } from "./hooks/select.js";
11
11
  import { useForm as J } from "./hooks/form.js";
12
- import { initRouter as N } from "./router/route.js";
13
- import { useAuthStore as W } from "./stores/auth.js";
14
- import { useRouteStore as Y } from "./stores/route.js";
15
- import { useTabStore as _ } from "./stores/tab.js";
16
- import { useManageStore as ee } from "./stores/manage.js";
17
- import { useI18nStore as oe } from "./stores/i18n.js";
18
- import { DuxLogo as ue } from "./components/common/logo.js";
19
- import { default as ae } from "./components/loader/iframe.js";
20
- import { DuxOverlay as pe } from "./components/overlay/overlay.js";
21
- import { DuxCan as fe } from "./components/auth/can.js";
22
- import { arrayToTree as ie, searchTree as de, treeToArr as le } from "./utils/tree.js";
23
- import { DuxAppProvider as ge } from "./provider/app.js";
24
- import { DuxTabRouterView as Me } from "./provider/tab.js";
25
- import { simpleAuthProvider as ye } from "./preset/authProvider.js";
26
- import { simpleDataProvider as Te } from "./preset/dataProvider.js";
27
- import { i18nProvider as Ie } from "./preset/i18nProvider.js";
12
+ import { useExport as N } from "./hooks/export.js";
13
+ import { initRouter as W } from "./router/route.js";
14
+ import { useAuthStore as Y } from "./stores/auth.js";
15
+ import { useRouteStore as _ } from "./stores/route.js";
16
+ import { useTabStore as ee } from "./stores/tab.js";
17
+ import { useManageStore as oe } from "./stores/manage.js";
18
+ import { useI18nStore as ue } from "./stores/i18n.js";
19
+ import { DuxLogo as pe } from "./components/common/logo.js";
20
+ import { default as me } from "./components/loader/iframe.js";
21
+ import { DuxOverlay as fe } from "./components/overlay/overlay.js";
22
+ import { DuxCan as ie } from "./components/auth/can.js";
23
+ import { arrayToTree as le, searchTree as De, treeToArr as ge } from "./utils/tree.js";
24
+ import { DuxAppProvider as Me } from "./provider/app.js";
25
+ import { DuxTabRouterView as ye } from "./provider/tab.js";
26
+ import { simpleAuthProvider as Te } from "./preset/authProvider.js";
27
+ import { simpleDataProvider as Ie } from "./preset/dataProvider.js";
28
+ import { i18nProvider as Se } from "./preset/i18nProvider.js";
28
29
  export {
29
- ge as DuxAppProvider,
30
- fe as DuxCan,
31
- ae as DuxLoaderIframe,
32
- ue as DuxLogo,
33
- pe as DuxOverlay,
34
- Me as DuxTabRouterView,
35
- ie as arrayToTree,
30
+ Me as DuxAppProvider,
31
+ ie as DuxCan,
32
+ me as DuxLoaderIframe,
33
+ pe as DuxLogo,
34
+ fe as DuxOverlay,
35
+ ye as DuxTabRouterView,
36
+ le as arrayToTree,
36
37
  o as createDux,
37
- Ie as i18nProvider,
38
- N as initRouter,
39
- de as searchTree,
40
- ye as simpleAuthProvider,
41
- Te as simpleDataProvider,
42
- le as treeToArr,
43
- W as useAuthStore,
38
+ Se as i18nProvider,
39
+ W as initRouter,
40
+ De as searchTree,
41
+ Te as simpleAuthProvider,
42
+ Ie as simpleDataProvider,
43
+ ge as treeToArr,
44
+ Y as useAuthStore,
44
45
  u as useCan,
45
46
  s as useCheck,
46
47
  C as useClient,
@@ -51,29 +52,30 @@ export {
51
52
  L as useCustomMutation,
52
53
  T as useDelete,
53
54
  h as useDeleteMany,
54
- a as useError,
55
- m as useForgotPassword,
55
+ p as useError,
56
+ N as useExport,
57
+ x as useForgotPassword,
56
58
  J as useForm,
57
- p as useGetAuth,
59
+ m as useGetAuth,
58
60
  q as useI18n,
59
- oe as useI18nStore,
61
+ ue as useI18nStore,
60
62
  I as useInfiniteList,
61
63
  P as useInvalidate,
62
- x as useIsLogin,
64
+ a as useIsLogin,
63
65
  S as useList,
64
66
  f as useLogin,
65
67
  n as useLogout,
66
68
  U as useManage,
67
- ee as useManageStore,
69
+ oe as useManageStore,
68
70
  A as useMany,
69
- F as useMenu,
71
+ E as useMenu,
70
72
  c as useOne,
71
73
  V as useOverlay,
72
74
  i as useRegister,
73
- Y as useRouteStore,
75
+ _ as useRouteStore,
74
76
  B as useSelect,
75
- _ as useTabStore,
76
- E as useTheme,
77
+ ee as useTabStore,
78
+ k as useTheme,
77
79
  R as useUpdate,
78
80
  w as useUpdateMany,
79
81
  d as useUpdatePassword
@@ -8,55 +8,57 @@ const k = /* @__PURE__ */ c({
8
8
  name: "DuxTabRouterView",
9
9
  props: {},
10
10
  setup() {
11
- const r = b(), u = w(), i = R(), n = /* @__PURE__ */ new Map(), p = (e, t) => {
12
- let a;
13
- const o = e;
14
- return n.has(o) ? a = n.get(o) : (a = {
11
+ const r = b(), u = w(), p = R(), n = /* @__PURE__ */ new Map(), i = (t, a) => {
12
+ let e;
13
+ const o = t;
14
+ return n.has(o) ? e = n.get(o) : (e = {
15
15
  name: o,
16
16
  render() {
17
- return t;
17
+ return a;
18
18
  }
19
- }, n.set(o, a)), a;
19
+ }, n.set(o, e)), e;
20
20
  };
21
- u.$subscribe((e, t) => {
22
- n.forEach((a) => {
23
- t.tabs.some((o) => o.path === a.name) || n.delete(a.name);
21
+ u.$subscribe((t, a) => {
22
+ n.forEach((e) => {
23
+ a.tabs.some((o) => o.path === e.name) || n.delete(e.name);
24
24
  });
25
25
  });
26
- const s = i.getIndexRoute();
26
+ const s = p.getIndexRoute();
27
27
  return s && u.addTab({
28
28
  ...s,
29
29
  meta: {
30
30
  ...s.meta,
31
31
  lock: !0
32
32
  }
33
- }), d([r, () => i.routes], () => {
34
- const e = i.searchRouteName(r.name);
35
- if (!e)
33
+ }), d([r, () => p.routes], () => {
34
+ const t = p.searchRouteName(r.name);
35
+ if (!t)
36
36
  return;
37
- const t = {
38
- label: e.label,
37
+ const a = {
38
+ label: t.label,
39
39
  path: r.path,
40
- name: e.name
40
+ name: t.name
41
41
  };
42
- u.addTab(t);
42
+ u.addTab(a);
43
43
  }, {
44
44
  immediate: !0
45
45
  }), () => m(h, null, {
46
46
  default: ({
47
- Component: e
48
- }) => m(l, {
49
- name: "tab-fade",
50
- mode: "out-in",
51
- appear: !0
52
- }, {
53
- default: () => [m(f, {
54
- include: u.tabs.map((t) => t.path || "")
55
- }, [m(e, {
56
- is: p(r.path, e),
57
- key: r.path
58
- }, null)])]
59
- })
47
+ Component: t
48
+ }) => {
49
+ const a = i(r.path, t);
50
+ return m(l, {
51
+ name: "tab-fade",
52
+ mode: "out-in",
53
+ appear: !0
54
+ }, {
55
+ default: () => [m(f, {
56
+ include: u.tabs.map((e) => e.path || "")
57
+ }, [m(a, {
58
+ key: r.path
59
+ }, null)])]
60
+ });
61
+ }
60
62
  });
61
63
  }
62
64
  });