@duxweb/dvha-core 0.1.6 → 0.1.7
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 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("lodash-es"),u=require("vue"),b=require("./data.cjs");function E(t){const c=u.ref(),r=u.ref(1),d=u.ref(typeof t.pagination=="number"?t.pagination:t.pagination?20:0),f=u.ref(!1),S=h.debounce(e=>{c.value=e},t.debounce||300),V=e=>{S(e)};u.watch([()=>t.path,()=>t.params,c],()=>{t.pagination&&(r.value=1)},{deep:!0});const{data:s,isLoading:w}=b.useCustom({get path(){return t.path||""},get filters(){return t.params},get query(){const e={};return t.pagination&&(e.page=r.value,e.pageSize=d.value),c.value&&(e[t.keywordField||"keyword"]=c.value),Object.keys(e).length?e:void 0}}),g=u.ref([]),v=e=>{const{optionField:n}=t;return typeof n=="string"?e[n]||e.value||e.id:e.value||e.id},q=e=>{const{optionLabel:n="label",optionValue:o="value"}=t;let l;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||"");let a;return typeof o=="function"?a=o(e):typeof o=="string"?a=e[o]||e.value||e.id:a=e.value||e.id,{label:l,value:a,raw:e}},y=u.computed(()=>{var o;const e=((o=s.value)==null?void 0:o.data)||[],n=[...g.value];return e.forEach(l=>{n.some(i=>v(i)===v(l))||n.push(l)}),n.map(l=>q(l))}),O=u.computed(()=>{var e;return((e=s.value)==null?void 0:e.meta)||{}}),{refetch:k}=b.useMany({get path(){return t.path||""},get ids(){return t.defaultValue?h.isArray(t.defaultValue)?t.defaultValue:[t.defaultValue]:[]},options:{enabled:!1}});u.watch(()=>t.defaultValue,async e=>{var l;if(!(f.value||!e||(f.value=!0,(Array.isArray(e)?e:[e]).every(a=>y.value.some(i=>i.value===a)))))try{const a=await k();g.value=((l=a==null?void 0:a.data)==null?void 0:l.data)||[]}catch(a){console.warn("Failed to fetch selected items:",a)}},{immediate:!0});const x=u.computed(()=>w.value&&!s.value);return{onSearch:V,options:y,meta:O,loading:x,page:r,pageSize:d}}exports.useSelect=E;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./main.cjs"),u=require("./hooks/auth.cjs"),t=require("./hooks/config.cjs"),e=require("./hooks/data.cjs"),o=require("./hooks/manage.cjs"),a=require("./hooks/menu.cjs"),n=require("./hooks/theme.cjs"),i=require("./hooks/overlay.cjs"),c=require("./hooks/i18n.cjs"),d=require("./router/route.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./main.cjs"),u=require("./hooks/auth.cjs"),t=require("./hooks/config.cjs"),e=require("./hooks/data.cjs"),o=require("./hooks/manage.cjs"),a=require("./hooks/menu.cjs"),n=require("./hooks/theme.cjs"),i=require("./hooks/overlay.cjs"),c=require("./hooks/i18n.cjs"),d=require("./hooks/select.cjs"),q=require("./router/route.cjs"),l=require("./stores/auth.cjs"),g=require("./stores/route.cjs"),v=require("./stores/tab.cjs"),D=require("./stores/manage.cjs"),m=require("./stores/i18n.cjs"),y=require("./components/common/logo.cjs"),C=require("./components/loader/iframe.cjs"),p=require("./components/overlay/overlay.cjs"),M=require("./components/auth/can.cjs"),r=require("./utils/tree.cjs"),h=require("./provider/app.cjs"),P=require("./provider/tab.cjs"),T=require("./preset/authProvider.cjs"),S=require("./preset/dataProvider.cjs"),x=require("./preset/i18nProvider.cjs");exports.createDux=s.createDux;exports.useCan=u.useCan;exports.useCheck=u.useCheck;exports.useError=u.useError;exports.useForgotPassword=u.useForgotPassword;exports.useGetAuth=u.useGetAuth;exports.useIsLogin=u.useIsLogin;exports.useLogin=u.useLogin;exports.useLogout=u.useLogout;exports.useRegister=u.useRegister;exports.useUpdatePassword=u.useUpdatePassword;exports.useConfig=t.useConfig;exports.useClient=e.useClient;exports.useCreate=e.useCreate;exports.useCreateMany=e.useCreateMany;exports.useCustom=e.useCustom;exports.useCustomMutation=e.useCustomMutation;exports.useDelete=e.useDelete;exports.useDeleteMany=e.useDeleteMany;exports.useInfiniteList=e.useInfiniteList;exports.useInvalidate=e.useInvalidate;exports.useList=e.useList;exports.useMany=e.useMany;exports.useOne=e.useOne;exports.useUpdate=e.useUpdate;exports.useUpdateMany=e.useUpdateMany;exports.useManage=o.useManage;exports.useMenu=a.useMenu;exports.useTheme=n.useTheme;exports.useOverlay=i.useOverlay;exports.useI18n=c.useI18n;exports.useSelect=d.useSelect;exports.initRouter=q.initRouter;exports.useAuthStore=l.useAuthStore;exports.useRouteStore=g.useRouteStore;exports.useTabStore=v.useTabStore;exports.useManageStore=D.useManageStore;exports.useI18nStore=m.useI18nStore;exports.DuxLogo=y.DuxLogo;exports.DuxLoaderIframe=C;exports.DuxOverlay=p.DuxOverlay;exports.DuxCan=M.DuxCan;exports.arrayToTree=r.arrayToTree;exports.searchTree=r.searchTree;exports.treeToArr=r.treeToArr;exports.DuxAppProvider=h.DuxAppProvider;exports.DuxTabRouterView=P.DuxTabRouterView;exports.simpleAuthProvider=T.simpleAuthProvider;exports.simpleDataProvider=S.simpleDataProvider;exports.i18nProvider=x.i18nProvider;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { debounce as A, isArray as E } from "lodash-es";
|
|
2
|
+
import { ref as o, watch as b, computed as d } from "vue";
|
|
3
|
+
import { useCustom as q, useMany as z } from "./data.js";
|
|
4
|
+
function p(a) {
|
|
5
|
+
const r = o(), c = o(1), f = o(
|
|
6
|
+
typeof a.pagination == "number" ? a.pagination : a.pagination ? 20 : 0
|
|
7
|
+
), g = o(!1), V = A((e) => {
|
|
8
|
+
r.value = e;
|
|
9
|
+
}, a.debounce || 300), S = (e) => {
|
|
10
|
+
V(e);
|
|
11
|
+
};
|
|
12
|
+
b([() => a.path, () => a.params, r], () => {
|
|
13
|
+
a.pagination && (c.value = 1);
|
|
14
|
+
}, { deep: !0 });
|
|
15
|
+
const { data: i, isLoading: w } = q({
|
|
16
|
+
get path() {
|
|
17
|
+
return a.path || "";
|
|
18
|
+
},
|
|
19
|
+
get filters() {
|
|
20
|
+
return a.params;
|
|
21
|
+
},
|
|
22
|
+
get query() {
|
|
23
|
+
const e = {};
|
|
24
|
+
return a.pagination && (e.page = c.value, e.pageSize = f.value), r.value && (e[a.keywordField || "keyword"] = r.value), Object.keys(e).length ? e : void 0;
|
|
25
|
+
}
|
|
26
|
+
}), v = o([]), y = (e) => {
|
|
27
|
+
const { optionField: n } = a;
|
|
28
|
+
return typeof n == "string" ? e[n] || e.value || e.id : e.value || e.id;
|
|
29
|
+
}, x = (e) => {
|
|
30
|
+
const { optionLabel: n = "label", optionValue: u = "value" } = a;
|
|
31
|
+
let l;
|
|
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 || "");
|
|
33
|
+
let t;
|
|
34
|
+
return typeof u == "function" ? t = u(e) : typeof u == "string" ? t = e[u] || e.value || e.id : t = e.value || e.id, {
|
|
35
|
+
label: l,
|
|
36
|
+
value: t,
|
|
37
|
+
raw: e
|
|
38
|
+
};
|
|
39
|
+
}, h = d(() => {
|
|
40
|
+
var u;
|
|
41
|
+
const e = ((u = i.value) == null ? void 0 : u.data) || [], n = [...v.value];
|
|
42
|
+
return e.forEach((l) => {
|
|
43
|
+
n.some(
|
|
44
|
+
(s) => y(s) === y(l)
|
|
45
|
+
) || n.push(l);
|
|
46
|
+
}), n.map((l) => x(l));
|
|
47
|
+
}), k = d(() => {
|
|
48
|
+
var e;
|
|
49
|
+
return ((e = i.value) == null ? void 0 : e.meta) || {};
|
|
50
|
+
}), { refetch: F } = z({
|
|
51
|
+
get path() {
|
|
52
|
+
return a.path || "";
|
|
53
|
+
},
|
|
54
|
+
get ids() {
|
|
55
|
+
return a.defaultValue ? E(a.defaultValue) ? a.defaultValue : [a.defaultValue] : [];
|
|
56
|
+
},
|
|
57
|
+
options: {
|
|
58
|
+
enabled: !1
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
b(() => a.defaultValue, async (e) => {
|
|
62
|
+
var l;
|
|
63
|
+
if (!(g.value || !e || (g.value = !0, (Array.isArray(e) ? e : [e]).every(
|
|
64
|
+
(t) => h.value.some((s) => s.value === t)
|
|
65
|
+
))))
|
|
66
|
+
try {
|
|
67
|
+
const t = await F();
|
|
68
|
+
v.value = ((l = t == null ? void 0 : t.data) == null ? void 0 : l.data) || [];
|
|
69
|
+
} catch (t) {
|
|
70
|
+
console.warn("Failed to fetch selected items:", t);
|
|
71
|
+
}
|
|
72
|
+
}, { immediate: !0 });
|
|
73
|
+
const O = d(() => w.value && !i.value);
|
|
74
|
+
return {
|
|
75
|
+
onSearch: S,
|
|
76
|
+
options: h,
|
|
77
|
+
meta: k,
|
|
78
|
+
loading: O,
|
|
79
|
+
page: c,
|
|
80
|
+
pageSize: f
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
p as useSelect
|
|
85
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
1
|
import { createDux as o } from "./main.js";
|
|
2
2
|
import { useCan as u, useCheck as s, useError as a, useForgotPassword as p, useGetAuth as x, useIsLogin as m, useLogin as f, useLogout as n, useRegister as i, useUpdatePassword as d } from "./hooks/auth.js";
|
|
3
|
-
import { useConfig as
|
|
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
|
|
3
|
+
import { useConfig as D } from "./hooks/config.js";
|
|
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
6
|
import { useMenu as k } from "./hooks/menu.js";
|
|
7
7
|
import { useTheme as F } 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
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
10
|
+
import { useSelect as B } from "./hooks/select.js";
|
|
11
|
+
import { initRouter as J } from "./router/route.js";
|
|
12
|
+
import { useAuthStore as N } from "./stores/auth.js";
|
|
13
|
+
import { useRouteStore as W } from "./stores/route.js";
|
|
14
|
+
import { useTabStore as Y } from "./stores/tab.js";
|
|
15
|
+
import { useManageStore as _ } from "./stores/manage.js";
|
|
16
|
+
import { useI18nStore as ee } from "./stores/i18n.js";
|
|
17
|
+
import { DuxLogo as oe } from "./components/common/logo.js";
|
|
18
|
+
import { default as ue } from "./components/loader/iframe.js";
|
|
19
|
+
import { DuxOverlay as ae } from "./components/overlay/overlay.js";
|
|
20
|
+
import { DuxCan as xe } from "./components/auth/can.js";
|
|
21
|
+
import { arrayToTree as fe, searchTree as ne, treeToArr as ie } from "./utils/tree.js";
|
|
22
|
+
import { DuxAppProvider as le } from "./provider/app.js";
|
|
23
|
+
import { DuxTabRouterView as ge } from "./provider/tab.js";
|
|
24
|
+
import { simpleAuthProvider as Me } from "./preset/authProvider.js";
|
|
25
|
+
import { simpleDataProvider as ye } from "./preset/dataProvider.js";
|
|
26
|
+
import { i18nProvider as Te } from "./preset/i18nProvider.js";
|
|
26
27
|
export {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
le as DuxAppProvider,
|
|
29
|
+
xe as DuxCan,
|
|
30
|
+
ue as DuxLoaderIframe,
|
|
31
|
+
oe as DuxLogo,
|
|
32
|
+
ae as DuxOverlay,
|
|
33
|
+
ge as DuxTabRouterView,
|
|
34
|
+
fe as arrayToTree,
|
|
34
35
|
o as createDux,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
Te as i18nProvider,
|
|
37
|
+
J as initRouter,
|
|
38
|
+
ne as searchTree,
|
|
39
|
+
Me as simpleAuthProvider,
|
|
40
|
+
ye as simpleDataProvider,
|
|
41
|
+
ie as treeToArr,
|
|
42
|
+
N as useAuthStore,
|
|
42
43
|
u as useCan,
|
|
43
44
|
s as useCheck,
|
|
44
45
|
C as useClient,
|
|
45
|
-
|
|
46
|
+
D as useConfig,
|
|
46
47
|
M as useCreate,
|
|
47
48
|
v as useCreateMany,
|
|
48
49
|
y as useCustom,
|
|
@@ -53,24 +54,25 @@ export {
|
|
|
53
54
|
p as useForgotPassword,
|
|
54
55
|
x as useGetAuth,
|
|
55
56
|
q as useI18n,
|
|
56
|
-
|
|
57
|
+
ee as useI18nStore,
|
|
57
58
|
I as useInfiniteList,
|
|
58
59
|
P as useInvalidate,
|
|
59
60
|
m as useIsLogin,
|
|
60
|
-
|
|
61
|
+
S as useList,
|
|
61
62
|
f as useLogin,
|
|
62
63
|
n as useLogout,
|
|
63
64
|
U as useManage,
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
_ as useManageStore,
|
|
66
|
+
A as useMany,
|
|
66
67
|
k as useMenu,
|
|
67
|
-
|
|
68
|
+
c as useOne,
|
|
68
69
|
V as useOverlay,
|
|
69
70
|
i as useRegister,
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
W as useRouteStore,
|
|
72
|
+
B as useSelect,
|
|
73
|
+
Y as useTabStore,
|
|
72
74
|
F as useTheme,
|
|
73
|
-
|
|
75
|
+
R as useUpdate,
|
|
74
76
|
w as useUpdateMany,
|
|
75
77
|
d as useUpdatePassword
|
|
76
78
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
type SelectValue = Array<string | number> | string | number | null | undefined;
|
|
2
2
|
interface UseSelectProps {
|
|
3
|
-
|
|
3
|
+
defaultValue?: SelectValue;
|
|
4
4
|
path?: string;
|
|
5
5
|
params?: Record<string, any>;
|
|
6
6
|
pagination?: boolean | number;
|
|
@@ -8,6 +8,7 @@ interface UseSelectProps {
|
|
|
8
8
|
optionValue?: string | ((item: Record<string, any>) => string);
|
|
9
9
|
optionField?: string;
|
|
10
10
|
keywordField?: string;
|
|
11
|
+
debounce?: number;
|
|
11
12
|
}
|
|
12
13
|
export declare function useSelect(props: UseSelectProps): {
|
|
13
14
|
onSearch: (searchValue: string) => void;
|