@duxweb/dvha-core 0.1.19 → 0.1.21
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.
- package/dist/cjs/_virtual/_commonjsHelpers.cjs +1 -0
- package/dist/cjs/_virtual/dayjs.min.cjs +1 -0
- package/dist/cjs/_virtual/dayjs.min2.cjs +1 -0
- package/dist/cjs/components/auth/can.cjs +1 -1
- package/dist/cjs/components/loader/iframe.cjs +1 -1
- package/dist/cjs/components/loader/loader.cjs +1 -0
- package/dist/cjs/components/loader/remote/loader.cjs +1 -0
- package/dist/cjs/components/loader/remote/render.cjs +1 -0
- package/dist/cjs/components/status/error.cjs +1 -1
- package/dist/cjs/components/status/exception.cjs +1 -0
- package/dist/cjs/components/status/notAuthorized.cjs +1 -1
- package/dist/cjs/components/status/notFound.cjs +1 -1
- package/dist/cjs/directive/permission.cjs +1 -1
- package/dist/cjs/hooks/auth.cjs +1 -1
- package/dist/cjs/hooks/data.cjs +1 -1
- package/dist/cjs/hooks/export.cjs +1 -1
- package/dist/cjs/hooks/form.cjs +1 -1
- package/dist/cjs/hooks/formExtend.cjs +1 -0
- package/dist/cjs/hooks/formValidate.cjs +1 -0
- package/dist/cjs/hooks/i18n.cjs +1 -1
- package/dist/cjs/hooks/importCsv.cjs +1 -1
- package/dist/cjs/hooks/json/index.cjs +1 -0
- package/dist/cjs/hooks/json/utils/contextManager.cjs +1 -0
- package/dist/cjs/hooks/json/utils/expressionParser.cjs +1 -0
- package/dist/cjs/hooks/json/vFor.cjs +1 -0
- package/dist/cjs/hooks/json/vIf.cjs +1 -0
- package/dist/cjs/hooks/json/vModel.cjs +1 -0
- package/dist/cjs/hooks/json/vOn.cjs +1 -0
- package/dist/cjs/hooks/json/vShow.cjs +1 -0
- package/dist/cjs/hooks/json/vText.cjs +1 -0
- package/dist/cjs/hooks/json.cjs +1 -0
- package/dist/cjs/hooks/list.cjs +1 -0
- package/dist/cjs/hooks/manage.cjs +1 -1
- package/dist/cjs/hooks/menu.cjs +1 -1
- package/dist/cjs/hooks/overlay.cjs +1 -1
- package/dist/cjs/hooks/select.cjs +1 -1
- package/dist/cjs/hooks/theme.cjs +2 -2
- package/dist/cjs/hooks/upload.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/main.cjs +1 -1
- package/dist/cjs/node_modules/dayjs/dayjs.min.cjs +1 -0
- package/dist/cjs/node_modules/jsep/dist/jsep.cjs +2 -0
- package/dist/cjs/node_modules/mitt/dist/mitt.cjs +1 -0
- package/dist/cjs/preset/dataProvider.cjs +1 -1
- package/dist/cjs/preset/i18nProvider.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/cjs/stores/manage.cjs +1 -1
- package/dist/cjs/stores/tab.cjs +1 -1
- package/dist/cjs/stores/theme.cjs +1 -1
- package/dist/cjs/utils/theme.cjs +9 -1
- package/dist/esm/_virtual/_commonjsHelpers.js +6 -0
- package/dist/esm/_virtual/dayjs.min.js +7 -0
- package/dist/esm/_virtual/dayjs.min2.js +4 -0
- package/dist/esm/components/auth/can.js +11 -8
- package/dist/esm/components/loader/loader.js +47 -0
- package/dist/esm/components/loader/remote/loader.js +150 -0
- package/dist/esm/components/loader/remote/render.js +19 -0
- package/dist/esm/components/status/error.js +3 -3
- package/dist/esm/components/status/exception.js +23 -0
- package/dist/esm/components/status/notAuthorized.js +2 -2
- package/dist/esm/components/status/notFound.js +4 -4
- package/dist/esm/directive/permission.js +6 -3
- package/dist/esm/hooks/auth.js +67 -67
- package/dist/esm/hooks/data.js +187 -183
- package/dist/esm/hooks/export.js +26 -23
- package/dist/esm/hooks/form.js +38 -35
- package/dist/esm/hooks/formExtend.js +38 -0
- package/dist/esm/hooks/formValidate.js +28 -0
- package/dist/esm/hooks/i18n.js +16 -8
- package/dist/esm/hooks/json/index.js +23 -0
- package/dist/esm/hooks/json/utils/contextManager.js +31 -0
- package/dist/esm/hooks/json/utils/expressionParser.js +134 -0
- package/dist/esm/hooks/json/vFor.js +57 -0
- package/dist/esm/hooks/json/vIf.js +17 -0
- package/dist/esm/hooks/json/vModel.js +78 -0
- package/dist/esm/hooks/json/vOn.js +32 -0
- package/dist/esm/hooks/json/vShow.js +24 -0
- package/dist/esm/hooks/json/vText.js +54 -0
- package/dist/esm/hooks/json.js +80 -0
- package/dist/esm/hooks/list.js +179 -0
- package/dist/esm/hooks/manage.js +19 -14
- package/dist/esm/hooks/overlay.js +7 -4
- package/dist/esm/hooks/theme.js +72 -72
- package/dist/esm/index.js +132 -100
- package/dist/esm/main.js +22 -12
- package/dist/esm/node_modules/dayjs/dayjs.min.js +282 -0
- package/dist/esm/node_modules/jsep/dist/jsep.js +737 -0
- package/dist/esm/node_modules/mitt/dist/mitt.js +19 -0
- package/dist/esm/preset/i18nProvider.js +21 -13
- package/dist/esm/provider/app.js +62 -53
- package/dist/esm/stores/manage.js +23 -15
- package/dist/esm/stores/tab.js +58 -49
- package/dist/esm/utils/theme.js +89 -76
- package/dist/types/components/index.d.ts +2 -1
- package/dist/types/components/loader/loader.d.ts +2 -0
- package/dist/types/components/loader/remote/index.d.ts +2 -0
- package/dist/types/components/loader/remote/loader.d.ts +1 -0
- package/dist/types/components/loader/remote/render.d.ts +1 -0
- package/dist/types/components/status/error.d.ts +1 -2
- package/dist/types/components/status/exception.d.ts +3 -0
- package/dist/types/components/status/index.d.ts +4 -0
- package/dist/types/components/status/notAuthorized.d.ts +1 -2
- package/dist/types/components/status/notFound.d.ts +1 -2
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types/hooks/auth.d.ts +6 -6
- package/dist/types/hooks/data.d.ts +30 -30
- package/dist/types/hooks/form.d.ts +6 -3
- package/dist/types/hooks/formExtend.d.ts +12 -0
- package/dist/types/hooks/formValidate.d.ts +14 -0
- package/dist/types/hooks/i18n.d.ts +2 -0
- package/dist/types/hooks/import.d.ts +1 -2
- package/dist/types/hooks/index.d.ts +6 -1
- package/dist/types/hooks/json/types.d.ts +1 -0
- package/dist/types/hooks/json.d.ts +2 -3
- package/dist/types/hooks/list.d.ts +66 -0
- package/dist/types/hooks/manage.d.ts +1 -0
- package/dist/types/hooks/overlay.d.ts +4 -0
- package/dist/types/index.d.ts +6 -5
- package/dist/types/preset/i18nProvider.d.ts +1 -1
- package/dist/types/stores/route.d.ts +180 -180
- package/dist/types/stores/tab.d.ts +1112 -73
- package/dist/types/types/config.d.ts +9 -0
- package/dist/types/types/data.d.ts +1 -1
- package/dist/types/types/i18n.d.ts +1 -0
- package/dist/types/types/manage.d.ts +6 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/theme.d.ts +4 -49
- package/package.json +11 -5
- /package/dist/cjs/{hooks/themeColor.cjs → config/color.cjs} +0 -0
- /package/dist/esm/{hooks/themeColor.js → config/color.js} +0 -0
- /package/dist/types/{hooks/themeColor.d.ts → config/color.d.ts} +0 -0
package/dist/esm/hooks/export.js
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useInfiniteList as
|
|
1
|
+
import { ref as h, computed as u } from "vue";
|
|
2
|
+
import { useInfiniteList as w } from "./data.js";
|
|
3
3
|
const y = (e) => new Promise((a) => setTimeout(a, e));
|
|
4
|
-
function
|
|
5
|
-
const a =
|
|
6
|
-
const { onSuccess: n, onProgress: i, interval: l, maxPage:
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
function E(e) {
|
|
5
|
+
const a = h(!1), r = u(() => {
|
|
6
|
+
const { onSuccess: n, onProgress: i, interval: l, maxPage: s, ...f } = e;
|
|
7
|
+
return {
|
|
8
|
+
...f,
|
|
9
|
+
options: {
|
|
10
|
+
...f.options,
|
|
11
|
+
enabled: !1,
|
|
12
|
+
refetchOnMount: !1,
|
|
13
|
+
refetchOnWindowFocus: !1,
|
|
14
|
+
refetchOnReconnect: !1
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}), c = u(() => e.interval || 300), { data: o, isLoading: g, fetchNextPage: v, hasNextPage: m, refetch: P, pagination: t } = w(r.value), x = async () => {
|
|
15
18
|
var n, i, l;
|
|
16
19
|
if (!a.value)
|
|
17
20
|
try {
|
|
18
|
-
a.value = !0, t.value.page = 1, (n = e.onProgress) == null || n.call(e, t.value), await
|
|
19
|
-
const
|
|
20
|
-
for (;
|
|
21
|
-
c.value > 0 && await y(c.value), await
|
|
22
|
-
(l = e.onSuccess) == null || l.call(e,
|
|
21
|
+
a.value = !0, t.value.page = 1, (n = e.onProgress) == null || n.call(e, t.value), await P();
|
|
22
|
+
const s = typeof e.maxPage == "function" ? e.maxPage() : e.maxPage || 100;
|
|
23
|
+
for (; m.value && t.value.page < s; )
|
|
24
|
+
c.value > 0 && await y(c.value), await v(), (i = e.onProgress) == null || i.call(e, t.value);
|
|
25
|
+
(l = e.onSuccess) == null || l.call(e, o.value);
|
|
23
26
|
} finally {
|
|
24
27
|
a.value = !1;
|
|
25
28
|
}
|
|
26
|
-
},
|
|
29
|
+
}, d = u(() => g.value || a.value);
|
|
27
30
|
return {
|
|
28
|
-
data:
|
|
29
|
-
isLoading:
|
|
30
|
-
trigger:
|
|
31
|
+
data: o,
|
|
32
|
+
isLoading: d,
|
|
33
|
+
trigger: x
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
export {
|
|
34
|
-
|
|
37
|
+
E as useExport
|
|
35
38
|
};
|
package/dist/esm/hooks/form.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { cloneDeep as
|
|
2
|
-
import { toRef as N, ref as
|
|
3
|
-
import { useOne as
|
|
4
|
-
function
|
|
5
|
-
const i = N(e
|
|
1
|
+
import { cloneDeep as c } from "lodash-es";
|
|
2
|
+
import { toRef as N, ref as b, computed as o, watch as E } from "vue";
|
|
3
|
+
import { useOne as L, useCreate as O, useUpdate as S } from "./data.js";
|
|
4
|
+
function w(e) {
|
|
5
|
+
const i = N(e, "form", {}), n = b(c(e.form || {})), d = o(() => e.action === "edit" || e.id), { data: v, isLoading: l, refetch: f } = L({
|
|
6
6
|
path: e.path || "",
|
|
7
7
|
id: e.id,
|
|
8
8
|
options: {
|
|
@@ -10,58 +10,61 @@ function x(e) {
|
|
|
10
10
|
},
|
|
11
11
|
providerName: e.providerName
|
|
12
12
|
});
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
if (
|
|
13
|
+
E([() => e.action, () => e.id], async () => {
|
|
14
|
+
var t;
|
|
15
|
+
if (!d.value)
|
|
16
16
|
return;
|
|
17
|
-
await
|
|
18
|
-
const a =
|
|
19
|
-
i.value
|
|
17
|
+
await f();
|
|
18
|
+
const a = c(((t = v.value) == null ? void 0 : t.data) || {});
|
|
19
|
+
Object.assign(i.value, a), Object.assign(n.value, a);
|
|
20
20
|
}, {
|
|
21
21
|
immediate: !0
|
|
22
22
|
});
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const r = () => {
|
|
24
|
+
const a = c(n.value);
|
|
25
|
+
Object.assign(i.value, a);
|
|
26
|
+
}, u = O({
|
|
26
27
|
path: e.path ?? "",
|
|
27
28
|
data: i.value,
|
|
28
|
-
onSuccess: (
|
|
29
|
-
var
|
|
30
|
-
(
|
|
29
|
+
onSuccess: (a) => {
|
|
30
|
+
var t;
|
|
31
|
+
(t = e.onSuccess) == null || t.call(e, a);
|
|
31
32
|
},
|
|
32
|
-
onError: (
|
|
33
|
-
var
|
|
34
|
-
(
|
|
33
|
+
onError: (a) => {
|
|
34
|
+
var t;
|
|
35
|
+
(t = e.onError) == null || t.call(e, a);
|
|
35
36
|
},
|
|
36
37
|
providerName: e.providerName
|
|
37
|
-
}),
|
|
38
|
+
}), m = S({
|
|
38
39
|
path: e.path ?? "",
|
|
39
40
|
id: e.id,
|
|
40
41
|
data: i.value,
|
|
41
|
-
onSuccess: (
|
|
42
|
-
var
|
|
43
|
-
(
|
|
42
|
+
onSuccess: (a) => {
|
|
43
|
+
var t;
|
|
44
|
+
(t = e.onSuccess) == null || t.call(e, a);
|
|
44
45
|
},
|
|
45
|
-
onError: (
|
|
46
|
-
var
|
|
47
|
-
(
|
|
46
|
+
onError: (a) => {
|
|
47
|
+
var t;
|
|
48
|
+
(t = e.onError) == null || t.call(e, a);
|
|
48
49
|
},
|
|
49
50
|
providerName: e.providerName
|
|
50
|
-
}),
|
|
51
|
+
}), g = (a) => {
|
|
51
52
|
e.action === "create" ? u.mutate({
|
|
52
|
-
data: i.value
|
|
53
|
-
}) :
|
|
53
|
+
data: a || i.value
|
|
54
|
+
}) : m.mutate({
|
|
54
55
|
id: e.id,
|
|
55
|
-
data: i.value
|
|
56
|
+
data: a || i.value
|
|
56
57
|
});
|
|
57
|
-
}, h =
|
|
58
|
+
}, h = o(() => l.value || u.isLoading.value || m.isLoading.value);
|
|
58
59
|
return {
|
|
59
60
|
form: i,
|
|
61
|
+
initData: n,
|
|
60
62
|
isLoading: h,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
isEdit: d,
|
|
64
|
+
onSubmit: g,
|
|
65
|
+
onReset: r
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
68
|
export {
|
|
66
|
-
|
|
69
|
+
w as useForm
|
|
67
70
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { toRef as d, computed as c } from "vue";
|
|
2
|
+
import { useForm as l } from "./form.js";
|
|
3
|
+
import { useValidateForm as E } from "./formValidate.js";
|
|
4
|
+
function F(t) {
|
|
5
|
+
const n = d(t, "form", {}), { validate: m, reset: s } = E({
|
|
6
|
+
data: n,
|
|
7
|
+
rules: t.rules
|
|
8
|
+
}), u = c(() => {
|
|
9
|
+
const { form: o, ...r } = t;
|
|
10
|
+
return {
|
|
11
|
+
...r,
|
|
12
|
+
form: o
|
|
13
|
+
};
|
|
14
|
+
}), e = l(u.value), a = (o) => {
|
|
15
|
+
m().then((r) => {
|
|
16
|
+
var i;
|
|
17
|
+
if (!r.valid) {
|
|
18
|
+
(i = t.onError) == null || i.call(t, {
|
|
19
|
+
message: "表单验证失败"
|
|
20
|
+
});
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
e.onSubmit(o);
|
|
24
|
+
});
|
|
25
|
+
}, f = () => {
|
|
26
|
+
e.onReset(), s();
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
isLoading: e.isLoading,
|
|
30
|
+
isEdit: e.isEdit,
|
|
31
|
+
form: n,
|
|
32
|
+
onSubmit: a,
|
|
33
|
+
onReset: f
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
F as useExtendForm
|
|
38
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { all as m } from "@vee-validate/rules";
|
|
2
|
+
import { cloneDeep as n } from "lodash-es";
|
|
3
|
+
import { useForm as s, defineRule as u } from "vee-validate";
|
|
4
|
+
import { toRef as c, watch as f } from "vue";
|
|
5
|
+
function b(e) {
|
|
6
|
+
const t = c(e, "data"), { setValues: a, validate: o, resetForm: r, handleSubmit: i } = s({
|
|
7
|
+
initialValues: n(t.value || {}),
|
|
8
|
+
validationSchema: e.rules
|
|
9
|
+
});
|
|
10
|
+
return f(t, (l) => {
|
|
11
|
+
a(l || {}, !1);
|
|
12
|
+
}, { deep: !0 }), {
|
|
13
|
+
validate: o,
|
|
14
|
+
reset: () => {
|
|
15
|
+
r();
|
|
16
|
+
},
|
|
17
|
+
submit: i
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function v() {
|
|
21
|
+
Object.entries(m).forEach(([e, t]) => {
|
|
22
|
+
u(e, t);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
v as initFormValidate,
|
|
27
|
+
b as useValidateForm
|
|
28
|
+
};
|
package/dist/esm/hooks/i18n.js
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import "pinia";
|
|
2
2
|
import "vue";
|
|
3
3
|
import "lodash-es";
|
|
4
|
-
import { useI18nStore as
|
|
4
|
+
import { useI18nStore as i } from "../stores/i18n.js";
|
|
5
5
|
import { useManage as g } from "./manage.js";
|
|
6
6
|
function h() {
|
|
7
|
-
const
|
|
7
|
+
const a = i(), c = g();
|
|
8
8
|
return {
|
|
9
|
-
t: (e, o,
|
|
10
|
-
var
|
|
11
|
-
return (
|
|
9
|
+
t: (e, o, r) => {
|
|
10
|
+
var n, t;
|
|
11
|
+
return (t = (n = c.config) == null ? void 0 : n.i18nProvider) == null ? void 0 : t.t(e, o, r);
|
|
12
12
|
},
|
|
13
13
|
changeLocale: (e) => {
|
|
14
|
-
var o,
|
|
15
|
-
return
|
|
14
|
+
var o, r;
|
|
15
|
+
return a.setLocale(e), (r = (o = c.config) == null ? void 0 : o.i18nProvider) == null ? void 0 : r.changeLocale(e);
|
|
16
16
|
},
|
|
17
17
|
getLocale: () => {
|
|
18
18
|
var e, o;
|
|
19
|
-
return (o = (e =
|
|
19
|
+
return (o = (e = c.config) == null ? void 0 : e.i18nProvider) == null ? void 0 : o.getLocale();
|
|
20
|
+
},
|
|
21
|
+
loadLocale: (e, o) => {
|
|
22
|
+
var r, n;
|
|
23
|
+
return (n = (r = c.config) == null ? void 0 : r.i18nProvider) == null ? void 0 : n.loadLocale(e, o);
|
|
24
|
+
},
|
|
25
|
+
mergeLocale: (e, o) => {
|
|
26
|
+
var r, n;
|
|
27
|
+
return (n = (r = c.config) == null ? void 0 : r.i18nProvider) == null ? void 0 : n.mergeLocale(e, o);
|
|
20
28
|
}
|
|
21
29
|
};
|
|
22
30
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { vForAdaptor as t } from "./vFor.js";
|
|
2
|
+
import { vIfAdaptor as p } from "./vIf.js";
|
|
3
|
+
import { vModelAdaptor as m } from "./vModel.js";
|
|
4
|
+
import { vOnAdaptor as i } from "./vOn.js";
|
|
5
|
+
import { vShowAdaptor as d } from "./vShow.js";
|
|
6
|
+
import { vTextAdaptor as a } from "./vText.js";
|
|
7
|
+
const n = [
|
|
8
|
+
p,
|
|
9
|
+
d,
|
|
10
|
+
t,
|
|
11
|
+
m,
|
|
12
|
+
i,
|
|
13
|
+
a
|
|
14
|
+
].sort((o, r) => r.priority - o.priority);
|
|
15
|
+
export {
|
|
16
|
+
n as defaultAdaptors,
|
|
17
|
+
t as vForAdaptor,
|
|
18
|
+
p as vIfAdaptor,
|
|
19
|
+
m as vModelAdaptor,
|
|
20
|
+
i as vOnAdaptor,
|
|
21
|
+
d as vShowAdaptor,
|
|
22
|
+
a as vTextAdaptor
|
|
23
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function o(e) {
|
|
2
|
+
return e._context || {};
|
|
3
|
+
}
|
|
4
|
+
function c(e, n) {
|
|
5
|
+
return Object.keys(n).length === 0 ? e : {
|
|
6
|
+
...e,
|
|
7
|
+
_context: n
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function u(e) {
|
|
11
|
+
const { _context: n, ...t } = e;
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
function a(e, n = {}) {
|
|
15
|
+
const t = { ...e };
|
|
16
|
+
return n.cleanKeys && n.cleanKeys.forEach((r) => delete t[r]), {
|
|
17
|
+
props: t,
|
|
18
|
+
skip: n.skip,
|
|
19
|
+
nodes: n.nodes
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function i(e, n, t) {
|
|
23
|
+
return typeof e == "string" ? !!t(e, n) : !!e;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
u as cleanProps,
|
|
27
|
+
a as createAdaptorResult,
|
|
28
|
+
i as evaluateCondition,
|
|
29
|
+
o as extractContext,
|
|
30
|
+
c as injectContext
|
|
31
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import p from "../../../node_modules/jsep/dist/jsep.js";
|
|
2
|
+
import { unref as c } from "vue";
|
|
3
|
+
p.addIdentifierChar("$");
|
|
4
|
+
p.addIdentifierChar("@");
|
|
5
|
+
function y(r) {
|
|
6
|
+
try {
|
|
7
|
+
return p(r);
|
|
8
|
+
} catch (e) {
|
|
9
|
+
return console.warn(`Expression parsing failed: ${r}`, e), null;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function m(r, e) {
|
|
13
|
+
const n = y(r);
|
|
14
|
+
if (n)
|
|
15
|
+
return i(n, e);
|
|
16
|
+
}
|
|
17
|
+
function i(r, e) {
|
|
18
|
+
var n, l;
|
|
19
|
+
if (!(!r || typeof r != "object"))
|
|
20
|
+
switch (r.type) {
|
|
21
|
+
case "Literal":
|
|
22
|
+
return r.value;
|
|
23
|
+
case "Identifier":
|
|
24
|
+
return v(e, r.name);
|
|
25
|
+
case "MemberExpression": {
|
|
26
|
+
const t = i(r.object, e);
|
|
27
|
+
if (t == null)
|
|
28
|
+
return;
|
|
29
|
+
const s = r.computed ? i(r.property, e) : (n = r.property) == null ? void 0 : n.name, a = c(t);
|
|
30
|
+
return a == null ? void 0 : a[s];
|
|
31
|
+
}
|
|
32
|
+
case "BinaryExpression": {
|
|
33
|
+
const t = i(r.left, e), s = i(r.right, e), a = {
|
|
34
|
+
"+": () => t + s,
|
|
35
|
+
"-": () => t - s,
|
|
36
|
+
"*": () => t * s,
|
|
37
|
+
"/": () => t / s,
|
|
38
|
+
"%": () => t % s,
|
|
39
|
+
"==": () => t === s,
|
|
40
|
+
"===": () => t === s,
|
|
41
|
+
"!=": () => t !== s,
|
|
42
|
+
"!==": () => t !== s,
|
|
43
|
+
"<": () => t < s,
|
|
44
|
+
">": () => t > s,
|
|
45
|
+
"<=": () => t <= s,
|
|
46
|
+
">=": () => t >= s
|
|
47
|
+
};
|
|
48
|
+
return ((l = a[r.operator]) == null ? void 0 : l.call(a)) ?? void 0;
|
|
49
|
+
}
|
|
50
|
+
case "LogicalExpression": {
|
|
51
|
+
const t = i(r.left, e);
|
|
52
|
+
return r.operator === "&&" ? t && i(r.right, e) : r.operator === "||" ? t || i(r.right, e) : r.operator === "??" ? t ?? i(r.right, e) : void 0;
|
|
53
|
+
}
|
|
54
|
+
case "UnaryExpression": {
|
|
55
|
+
const t = i(r.argument, e);
|
|
56
|
+
return r.operator === "!" ? !t : r.operator === "-" ? -t : r.operator === "+" ? +t : void 0;
|
|
57
|
+
}
|
|
58
|
+
case "ConditionalExpression": {
|
|
59
|
+
const t = i(r.test, e);
|
|
60
|
+
return i(t ? r.consequent : r.alternate, e);
|
|
61
|
+
}
|
|
62
|
+
case "CallExpression": {
|
|
63
|
+
const t = i(r.callee, e), s = c(t);
|
|
64
|
+
if (typeof s != "function") {
|
|
65
|
+
console.warn("Attempting to call non-function value:", s);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const a = Array.isArray(r.arguments) ? r.arguments.map((u) => {
|
|
69
|
+
const o = i(u, e);
|
|
70
|
+
return c(o);
|
|
71
|
+
}) : [];
|
|
72
|
+
try {
|
|
73
|
+
let u;
|
|
74
|
+
if (r.callee.type === "MemberExpression") {
|
|
75
|
+
const o = i(r.callee.object, e);
|
|
76
|
+
u = c(o);
|
|
77
|
+
}
|
|
78
|
+
return s.apply(u, a);
|
|
79
|
+
} catch (u) {
|
|
80
|
+
console.warn("Function call error:", u);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
case "ArrayExpression":
|
|
85
|
+
return Array.isArray(r.elements) ? r.elements.map((t) => {
|
|
86
|
+
if (!t)
|
|
87
|
+
return;
|
|
88
|
+
const s = i(t, e);
|
|
89
|
+
return c(s);
|
|
90
|
+
}) : [];
|
|
91
|
+
default:
|
|
92
|
+
console.warn(`Unsupported expression type: ${r.type}`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function v(r, e) {
|
|
97
|
+
if (!(!e || !r))
|
|
98
|
+
try {
|
|
99
|
+
return e.split(".").reduce((n, l) => {
|
|
100
|
+
if (n == null)
|
|
101
|
+
return;
|
|
102
|
+
const t = c(n);
|
|
103
|
+
return t == null ? void 0 : t[l];
|
|
104
|
+
}, r);
|
|
105
|
+
} catch {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function g(r, e) {
|
|
110
|
+
const n = r.trim(), l = n.match(/^\((\w+),\s*(\w+)\) in (.+)$/);
|
|
111
|
+
if (l) {
|
|
112
|
+
const [, s, a, u] = l, o = m(u, e), f = c(o);
|
|
113
|
+
return {
|
|
114
|
+
items: Array.isArray(f) ? f : [],
|
|
115
|
+
itemName: s,
|
|
116
|
+
indexName: a
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const t = n.match(/^(\w+) in (.+)$/);
|
|
120
|
+
if (t) {
|
|
121
|
+
const [, s, a] = t, u = m(a, e), o = c(u);
|
|
122
|
+
return {
|
|
123
|
+
items: Array.isArray(o) ? o : [],
|
|
124
|
+
itemName: s,
|
|
125
|
+
indexName: "index"
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
throw new Error(`Invalid v-for expression: ${r}`);
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
m as evaluateExpression,
|
|
132
|
+
y as parseExpression,
|
|
133
|
+
g as parseVForExpression
|
|
134
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { extractContext as x, injectContext as u, cleanProps as d } from "./utils/contextManager.js";
|
|
2
|
+
import { parseVForExpression as v } from "./utils/expressionParser.js";
|
|
3
|
+
const A = {
|
|
4
|
+
name: "v-for",
|
|
5
|
+
priority: 90,
|
|
6
|
+
process(r, n) {
|
|
7
|
+
var a, m;
|
|
8
|
+
const e = ((a = r.attrs) == null ? void 0 : a["v-for"]) || ((m = r.attrs) == null ? void 0 : m.vFor);
|
|
9
|
+
if (!e)
|
|
10
|
+
return null;
|
|
11
|
+
const o = { ...r.attrs };
|
|
12
|
+
delete o["v-for"], delete o.vFor;
|
|
13
|
+
const i = x(n);
|
|
14
|
+
let t;
|
|
15
|
+
try {
|
|
16
|
+
if (Array.isArray(e))
|
|
17
|
+
t = {
|
|
18
|
+
items: e,
|
|
19
|
+
itemName: "item",
|
|
20
|
+
indexName: "index"
|
|
21
|
+
};
|
|
22
|
+
else if (typeof e == "object" && e.list)
|
|
23
|
+
t = {
|
|
24
|
+
items: Array.isArray(e.list) ? e.list : [],
|
|
25
|
+
itemName: e.item || "item",
|
|
26
|
+
indexName: e.index || "index"
|
|
27
|
+
};
|
|
28
|
+
else if (typeof e == "string")
|
|
29
|
+
t = v(e, i);
|
|
30
|
+
else
|
|
31
|
+
return console.warn("Unsupported v-for format:", e), null;
|
|
32
|
+
} catch (s) {
|
|
33
|
+
return console.warn("v-for parsing failed:", s), null;
|
|
34
|
+
}
|
|
35
|
+
const p = t.items.map((s, l) => {
|
|
36
|
+
const c = {
|
|
37
|
+
[t.itemName]: s,
|
|
38
|
+
[t.indexName]: l
|
|
39
|
+
}, f = { ...i, ...c };
|
|
40
|
+
return {
|
|
41
|
+
...r,
|
|
42
|
+
attrs: {
|
|
43
|
+
...o,
|
|
44
|
+
key: `${t.itemName}_${l}`,
|
|
45
|
+
...u({}, f)
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
props: d(n),
|
|
51
|
+
nodes: p
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
A as vForAdaptor
|
|
57
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { extractContext as n, evaluateCondition as r, createAdaptorResult as f } from "./utils/contextManager.js";
|
|
2
|
+
import { evaluateExpression as s } from "./utils/expressionParser.js";
|
|
3
|
+
const c = {
|
|
4
|
+
name: "v-if",
|
|
5
|
+
priority: 100,
|
|
6
|
+
process(v, i) {
|
|
7
|
+
const e = v.attrs || {}, o = n(i);
|
|
8
|
+
let t;
|
|
9
|
+
return e["v-if"] !== void 0 ? t = r(e["v-if"], o, s) : e["v-else-if"] !== void 0 ? t = r(e["v-else-if"], o, s) : e["v-else"] !== void 0 && (t = !0), t === void 0 ? null : f(i, {
|
|
10
|
+
skip: !t,
|
|
11
|
+
cleanKeys: ["v-if", "v-else-if", "v-else"]
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
c as vIfAdaptor
|
|
17
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { toRef as p } from "vue";
|
|
2
|
+
const b = {
|
|
3
|
+
name: "v-model",
|
|
4
|
+
priority: 70,
|
|
5
|
+
process(e, s) {
|
|
6
|
+
const t = {}, r = {};
|
|
7
|
+
let o = !1;
|
|
8
|
+
return Object.entries(s).forEach(([n, i]) => {
|
|
9
|
+
if (n.startsWith("v-model") || n.startsWith("vModel")) {
|
|
10
|
+
o = !0;
|
|
11
|
+
const [d, ...u] = n.split(".");
|
|
12
|
+
let l;
|
|
13
|
+
d === "v-model" || d === "vModel" ? l = "modelValue" : d.startsWith("v-model:") ? l = d.slice(8) : d.startsWith("vModel:") ? l = d.slice(7) : l = "modelValue";
|
|
14
|
+
try {
|
|
15
|
+
const { modelValue: a, updateFn: m } = f(i, u);
|
|
16
|
+
t[l] = a, t[`onUpdate:${l}`] = m;
|
|
17
|
+
} catch (a) {
|
|
18
|
+
console.error(`v-model binding error (${l}):`, a);
|
|
19
|
+
}
|
|
20
|
+
} else
|
|
21
|
+
r[n] = i;
|
|
22
|
+
}), o ? { props: { ...r, ...t } } : null;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
function f(e, s) {
|
|
26
|
+
if (Array.isArray(e) && e.length === 2 && typeof e[0] == "function" && typeof e[1] == "function") {
|
|
27
|
+
const [r, o] = e;
|
|
28
|
+
return {
|
|
29
|
+
modelValue: r(),
|
|
30
|
+
updateFn: (n) => {
|
|
31
|
+
o(c(n, s));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(e) && e.length === 2) {
|
|
36
|
+
const [r, o] = e;
|
|
37
|
+
if (!r || typeof o != "string")
|
|
38
|
+
throw new Error("Invalid v-model binding format: [obj, prop] expected");
|
|
39
|
+
const n = p(r, o);
|
|
40
|
+
return {
|
|
41
|
+
modelValue: n.value,
|
|
42
|
+
updateFn: (i) => {
|
|
43
|
+
n.value = c(i, s);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const t = p(e);
|
|
48
|
+
return t === e && typeof e != "object" ? {
|
|
49
|
+
modelValue: e,
|
|
50
|
+
updateFn: () => {
|
|
51
|
+
console.warn("v-model: Cannot update non-reactive value. Please use ref, [obj, prop], or [getter, setter] format.");
|
|
52
|
+
}
|
|
53
|
+
} : {
|
|
54
|
+
modelValue: t.value,
|
|
55
|
+
updateFn: (r) => {
|
|
56
|
+
t.value = c(r, s);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function c(e, s) {
|
|
61
|
+
return s.reduce((t, r) => {
|
|
62
|
+
switch (r) {
|
|
63
|
+
case "trim":
|
|
64
|
+
return typeof t == "string" ? t.trim() : t;
|
|
65
|
+
case "number": {
|
|
66
|
+
const o = Number(t);
|
|
67
|
+
return Number.isNaN(o) ? t : o;
|
|
68
|
+
}
|
|
69
|
+
case "lazy":
|
|
70
|
+
return t;
|
|
71
|
+
default:
|
|
72
|
+
return console.warn(`Unknown v-model modifier: ${r}`), t;
|
|
73
|
+
}
|
|
74
|
+
}, e);
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
b as vModelAdaptor
|
|
78
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const P = {
|
|
2
|
+
name: "v-on",
|
|
3
|
+
priority: 60,
|
|
4
|
+
process($, p) {
|
|
5
|
+
const n = {}, e = {};
|
|
6
|
+
let i = !1;
|
|
7
|
+
return Object.entries(p).forEach(([r, o]) => {
|
|
8
|
+
if (r.startsWith("@") || r.startsWith("v-on:")) {
|
|
9
|
+
i = !0;
|
|
10
|
+
const f = r.startsWith("@") ? r.slice(1) : r.slice(5), [s, ...a] = f.split(".");
|
|
11
|
+
if (!s) {
|
|
12
|
+
console.warn(`Invalid event name: ${r}`);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const d = `on${s.charAt(0).toUpperCase()}${s.slice(1)}`, h = (t, ...u) => {
|
|
16
|
+
var c, l;
|
|
17
|
+
a.includes("prevent") && ((c = t.preventDefault) == null || c.call(t)), a.includes("stop") && ((l = t.stopPropagation) == null || l.call(t));
|
|
18
|
+
try {
|
|
19
|
+
typeof o == "function" ? o(t, ...u) : console.warn(`Invalid event handler type: ${typeof o}`);
|
|
20
|
+
} catch (m) {
|
|
21
|
+
console.error(`Event handler execution error (${s}):`, m);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
n[d] = h;
|
|
25
|
+
} else
|
|
26
|
+
e[r] = o;
|
|
27
|
+
}), i ? { props: { ...e, ...n } } : null;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
P as vOnAdaptor
|
|
32
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { extractContext as a, evaluateCondition as p } from "./utils/contextManager.js";
|
|
2
|
+
import { evaluateExpression as v } from "./utils/expressionParser.js";
|
|
3
|
+
const u = {
|
|
4
|
+
name: "v-show",
|
|
5
|
+
priority: 95,
|
|
6
|
+
process(c, t) {
|
|
7
|
+
var r;
|
|
8
|
+
const e = (r = c.attrs) == null ? void 0 : r["v-show"];
|
|
9
|
+
if (e === void 0)
|
|
10
|
+
return null;
|
|
11
|
+
const i = a(t), n = p(e, i, v), o = { ...t };
|
|
12
|
+
delete o["v-show"];
|
|
13
|
+
const s = o.style || {}, l = typeof s == "object" ? { ...s, display: n ? void 0 : "none" } : { display: n ? void 0 : "none" };
|
|
14
|
+
return {
|
|
15
|
+
props: {
|
|
16
|
+
...o,
|
|
17
|
+
style: l
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
u as vShowAdaptor
|
|
24
|
+
};
|