@duxweb/dvha-core 0.1.23 → 1.0.14

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 (39) hide show
  1. package/dist/cjs/components/auth/can.cjs +1 -1
  2. package/dist/cjs/components/loader/loader.cjs +1 -1
  3. package/dist/cjs/components/loader/remote/loader.cjs +1 -1
  4. package/dist/cjs/directive/permission.cjs +1 -1
  5. package/dist/cjs/hooks/data.cjs +1 -1
  6. package/dist/cjs/hooks/json/vModel.cjs +1 -1
  7. package/dist/cjs/hooks/json.cjs +1 -1
  8. package/dist/cjs/hooks/menu.cjs +1 -1
  9. package/dist/cjs/hooks/overlay.cjs +1 -1
  10. package/dist/cjs/hooks/tree.cjs +1 -1
  11. package/dist/cjs/hooks/upload/local.cjs +1 -1
  12. package/dist/cjs/hooks/upload.cjs +1 -1
  13. package/dist/cjs/index.cjs +1 -1
  14. package/dist/cjs/main.cjs +1 -1
  15. package/dist/cjs/provider/app.cjs +1 -1
  16. package/dist/cjs/utils/bus.cjs +1 -0
  17. package/dist/esm/components/auth/can.js +3 -2
  18. package/dist/esm/components/loader/loader.js +3 -2
  19. package/dist/esm/components/loader/remote/loader.js +3 -2
  20. package/dist/esm/directive/permission.js +3 -2
  21. package/dist/esm/hooks/data.js +166 -158
  22. package/dist/esm/hooks/json/vModel.js +67 -36
  23. package/dist/esm/hooks/json.js +62 -47
  24. package/dist/esm/hooks/menu.js +14 -13
  25. package/dist/esm/hooks/overlay.js +3 -2
  26. package/dist/esm/hooks/tree.js +8 -7
  27. package/dist/esm/hooks/upload/local.js +8 -8
  28. package/dist/esm/hooks/upload.js +123 -116
  29. package/dist/esm/index.js +24 -22
  30. package/dist/esm/main.js +7 -6
  31. package/dist/esm/provider/app.js +3 -2
  32. package/dist/esm/utils/bus.js +5 -0
  33. package/dist/types/hooks/data.d.ts +6 -66
  34. package/dist/types/hooks/json.d.ts +5 -1
  35. package/dist/types/hooks/upload/local.d.ts +1 -1
  36. package/dist/types/hooks/upload.d.ts +1 -1
  37. package/dist/types/utils/bus.d.ts +1 -0
  38. package/dist/types/utils/index.d.ts +1 -0
  39. package/package.json +2 -2
@@ -1,65 +1,96 @@
1
- import { toRef as p } from "vue";
2
- const b = {
1
+ import { toRef as m } from "vue";
2
+ import { extractContext as b } from "./utils/contextManager.js";
3
+ import { evaluateExpression as f } from "./utils/expressionParser.js";
4
+ const w = {
3
5
  name: "v-model",
4
6
  priority: 70,
5
- process(e, s) {
6
- const t = {}, r = {};
7
+ process(e, l) {
8
+ const t = {}, i = {};
7
9
  let o = !1;
8
- return Object.entries(s).forEach(([n, i]) => {
9
- if (n.startsWith("v-model") || n.startsWith("vModel")) {
10
+ const a = b(l);
11
+ return Object.entries(l).forEach(([r, n]) => {
12
+ if (r.startsWith("v-model") || r.startsWith("vModel")) {
10
13
  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
+ const [c, ...p] = r.split(".");
15
+ let s;
16
+ c === "v-model" || c === "vModel" ? s = "modelValue" : c.startsWith("v-model:") ? s = c.slice(8) : c.startsWith("vModel:") ? s = c.slice(7) : s = "modelValue";
14
17
  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);
18
+ const { modelValue: u, updateFn: h } = g(n, p, a);
19
+ t[s] = u, t[`onUpdate:${s}`] = h;
20
+ } catch (u) {
21
+ console.error(`v-model binding error (${s}):`, u);
19
22
  }
20
23
  } else
21
- r[n] = i;
22
- }), o ? { props: { ...r, ...t } } : null;
24
+ i[r] = n;
25
+ }), o ? { props: { ...i, ...t } } : null;
23
26
  }
24
27
  };
25
- function f(e, s) {
28
+ function g(e, l, t) {
29
+ if (typeof e == "string") {
30
+ const o = () => {
31
+ try {
32
+ return f(e, t);
33
+ } catch (r) {
34
+ console.warn(`v-model: Failed to evaluate expression "${e}"`, r);
35
+ return;
36
+ }
37
+ }, a = (r) => {
38
+ try {
39
+ const n = e.split(".");
40
+ if (n.length >= 2) {
41
+ const c = n.slice(0, -1).join("."), p = n[n.length - 1], s = f(c, t);
42
+ if (s && typeof s == "object") {
43
+ s[p] = d(r, l);
44
+ return;
45
+ }
46
+ }
47
+ console.warn(`v-model: Cannot update expression "${e}". Target object not found.`);
48
+ } catch (n) {
49
+ console.warn(`v-model: Failed to update expression "${e}"`, n);
50
+ }
51
+ };
52
+ return {
53
+ modelValue: o(),
54
+ updateFn: a
55
+ };
56
+ }
26
57
  if (Array.isArray(e) && e.length === 2 && typeof e[0] == "function" && typeof e[1] == "function") {
27
- const [r, o] = e;
58
+ const [o, a] = e;
28
59
  return {
29
- modelValue: r(),
30
- updateFn: (n) => {
31
- o(c(n, s));
60
+ modelValue: o(),
61
+ updateFn: (r) => {
62
+ a(d(r, l));
32
63
  }
33
64
  };
34
65
  }
35
66
  if (Array.isArray(e) && e.length === 2) {
36
- const [r, o] = e;
37
- if (!r || typeof o != "string")
67
+ const [o, a] = e;
68
+ if (!o || typeof a != "string")
38
69
  throw new Error("Invalid v-model binding format: [obj, prop] expected");
39
- const n = p(r, o);
70
+ const r = m(o, a);
40
71
  return {
41
- modelValue: n.value,
42
- updateFn: (i) => {
43
- n.value = c(i, s);
72
+ modelValue: r.value,
73
+ updateFn: (n) => {
74
+ r.value = d(n, l);
44
75
  }
45
76
  };
46
77
  }
47
- const t = p(e);
48
- return t === e && typeof e != "object" ? {
78
+ const i = m(e);
79
+ return i === e && typeof e != "object" ? {
49
80
  modelValue: e,
50
81
  updateFn: () => {
51
82
  console.warn("v-model: Cannot update non-reactive value. Please use ref, [obj, prop], or [getter, setter] format.");
52
83
  }
53
84
  } : {
54
- modelValue: t.value,
55
- updateFn: (r) => {
56
- t.value = c(r, s);
85
+ modelValue: i.value,
86
+ updateFn: (o) => {
87
+ i.value = d(o, l);
57
88
  }
58
89
  };
59
90
  }
60
- function c(e, s) {
61
- return s.reduce((t, r) => {
62
- switch (r) {
91
+ function d(e, l) {
92
+ return l.reduce((t, i) => {
93
+ switch (i) {
63
94
  case "trim":
64
95
  return typeof t == "string" ? t.trim() : t;
65
96
  case "number": {
@@ -69,10 +100,10 @@ function c(e, s) {
69
100
  case "lazy":
70
101
  return t;
71
102
  default:
72
- return console.warn(`Unknown v-model modifier: ${r}`), t;
103
+ return console.warn(`Unknown v-model modifier: ${i}`), t;
73
104
  }
74
105
  }, e);
75
106
  }
76
107
  export {
77
- b as vModelAdaptor
108
+ w as vModelAdaptor
78
109
  };
@@ -1,80 +1,95 @@
1
- import { computed as R, isRef as A, defineComponent as _, h as b, unref as F } from "vue";
2
- import { defaultAdaptors as G } from "./json/index.js";
3
- import { injectContext as N } from "./json/utils/contextManager.js";
4
- function z(t) {
5
- const O = (t == null ? void 0 : t.adaptors) || G, j = (t == null ? void 0 : t.components) || {}, P = R(() => A(t == null ? void 0 : t.data) ? t == null ? void 0 : t.data.value : t == null ? void 0 : t.data);
6
- function V() {
7
- return (A(t == null ? void 0 : t.context) ? t == null ? void 0 : t.context.value : t == null ? void 0 : t.context) || {};
1
+ import { computed as F, isRef as A, defineComponent as J, h as B, unref as G } from "vue";
2
+ import { defaultAdaptors as N } from "./json/index.js";
3
+ import { injectContext as S } from "./json/utils/contextManager.js";
4
+ function w(n) {
5
+ const O = (n == null ? void 0 : n.adaptors) || N, b = (n == null ? void 0 : n.components) || {}, P = F(() => A(n == null ? void 0 : n.data) ? n == null ? void 0 : n.data.value : n == null ? void 0 : n.data);
6
+ function j() {
7
+ return (A(n == null ? void 0 : n.context) ? n == null ? void 0 : n.context.value : n == null ? void 0 : n.context) || {};
8
8
  }
9
- function h(e) {
9
+ function R(e) {
10
10
  const r = {};
11
- return Object.entries(e).forEach(([n, f]) => {
12
- if (n === "_context") return;
13
- const l = n === "modelValue" || n.startsWith("modelValue") || n !== "value" && (n.includes("model") || n.includes("Model"));
14
- r[n] = l && A(f) ? F(f) : f;
11
+ return Object.entries(e).forEach(([t, a]) => {
12
+ if (t === "_context") return;
13
+ const l = t === "modelValue" || t.startsWith("modelValue") || t !== "value" && (t.includes("model") || t.includes("Model"));
14
+ r[t] = l && A(a) ? G(a) : a;
15
15
  }), r;
16
16
  }
17
- function s(e, r, n) {
18
- return typeof e == "string" ? e : typeof e == "function" ? s(e(r), r, n) : Array.isArray(e) ? e.flatMap((f) => s(f, r, n)).filter(Boolean) : e != null && e.tag ? a(e, !0, n) : e;
17
+ function s(e, r, t) {
18
+ return typeof e == "string" ? e : typeof e == "function" ? s(e(r), r, t) : Array.isArray(e) ? e.flatMap((a) => s(a, r, t)).filter(Boolean) : e != null && e.tag ? c(e, !0, t) : e;
19
19
  }
20
- function E(e, r, n) {
20
+ function V(e, r, t) {
21
21
  if (e)
22
- return typeof e == "string" ? e : Array.isArray(e) ? e.flatMap((f) => typeof f == "string" ? f : a(f, r, n)).filter(Boolean) : a(e, r, n);
22
+ return typeof e == "string" ? e : Array.isArray(e) ? e.flatMap((a) => typeof a == "string" ? a : c(a, r, t)).filter(Boolean) : c(e, r, t);
23
23
  }
24
- function a(e, r = !1, n = {}) {
24
+ function c(e, r = !1, t = {}) {
25
25
  const {
26
- tag: f,
26
+ tag: a,
27
27
  attrs: l = {},
28
- children: J,
29
- slots: B
30
- } = e, c = {
31
- ...V(),
32
- ...n
28
+ children: D,
29
+ slots: M
30
+ } = e, u = {
31
+ ...j(),
32
+ ...t
33
33
  };
34
34
  let i = {
35
35
  ...l
36
36
  };
37
- Object.keys(c).length > 0 && (i = {
37
+ Object.keys(u).length > 0 && (i = {
38
38
  ...i,
39
- ...N({}, c)
39
+ ...S({}, u)
40
40
  });
41
41
  for (const o of O) {
42
- const u = o.process(e, i);
43
- if (u) {
44
- if (i = u.props, u.skip) return null;
45
- if (u.nodes)
46
- return u.nodes.map((m) => {
42
+ const f = o.process(e, i);
43
+ if (f) {
44
+ if (i = f.props, f.skip) return null;
45
+ if (f.nodes)
46
+ return f.nodes.map((m) => {
47
47
  var v;
48
48
  const y = ((v = m.attrs) == null ? void 0 : v._context) || {};
49
- return a(m, r, {
50
- ...c,
49
+ return c(m, r, {
50
+ ...u,
51
51
  ...y
52
52
  });
53
53
  }).filter(Boolean);
54
54
  }
55
55
  }
56
- const d = typeof f == "string" && j[f] ? j[f] : f, M = typeof d != "string", g = h(i);
57
- if (B && M && !r) {
56
+ const d = typeof a == "string" && b[a] ? b[a] : a, h = typeof d != "string", g = R(i);
57
+ if (M && h && !r) {
58
58
  const o = {};
59
- return Object.entries(B).forEach(([u, m]) => {
60
- o[u] = (y = {}) => s(m, y, c);
61
- }), b(d, g, o);
59
+ return Object.entries(M).forEach(([f, m]) => {
60
+ o[f] = (y = {}) => s(m, y, u);
61
+ }), B(d, g, o);
62
62
  }
63
- const x = E(J, r, c);
64
- return M && x !== void 0 ? b(d, g, {
63
+ const x = V(D, r, u);
64
+ return h && x !== void 0 ? B(d, g, {
65
65
  default: () => x
66
- }) : b(d, g, x);
66
+ }) : B(d, g, x);
67
67
  }
68
- return {
69
- render: /* @__PURE__ */ _({
70
- name: "JsonSchemaRenderer",
68
+ const E = /* @__PURE__ */ J({
69
+ name: "JsonSchemaRenderer",
70
+ render() {
71
+ var e;
72
+ return ((e = P.value) == null ? void 0 : e.map((r) => c(r)).filter(Boolean)) || [];
73
+ }
74
+ });
75
+ function _(e) {
76
+ return /* @__PURE__ */ J({
77
+ name: "DynamicJsonSchemaRenderer",
71
78
  render() {
72
- var e;
73
- return (e = P.value) == null ? void 0 : e.map((r) => a(r)).filter(Boolean);
79
+ var t;
80
+ const r = {
81
+ ...j(),
82
+ ...e.context
83
+ };
84
+ return (t = e.data) == null ? void 0 : t.map((a) => c(a, !1, r)).filter(Boolean);
74
85
  }
75
- })
86
+ });
87
+ }
88
+ return {
89
+ render: E,
90
+ renderAsync: _
76
91
  };
77
92
  }
78
93
  export {
79
- z as useJsonSchema
94
+ w as useJsonSchema
80
95
  };
@@ -3,11 +3,12 @@ import { storeToRefs as q } from "pinia";
3
3
  import { computed as v, ref as K, watch as h } from "vue";
4
4
  import { useRoute as z } from "vue-router";
5
5
  import { useRouteStore as B } from "../stores/route.js";
6
+ import "../utils/bus.js";
6
7
  import { arrayToTree as A, searchTree as M } from "../utils/tree.js";
7
- function N(n) {
8
+ function O(n) {
8
9
  const D = B(), { routes: L } = q(D), y = (e = !0) => {
9
- var a;
10
- return (a = S(L.value)) == null ? void 0 : a.filter((t) => !!(t != null && t.name)).filter((t) => !e || t.hidden === void 0 || t.hidden === !1);
10
+ var t;
11
+ return (t = S(L.value)) == null ? void 0 : t.filter((a) => !!(a != null && a.name)).filter((a) => !e || a.hidden === void 0 || a.hidden === !1);
11
12
  }, b = v(() => {
12
13
  const e = y(!1);
13
14
  return A(e, {
@@ -28,25 +29,25 @@ function N(n) {
28
29
  if (n != null && n.doubleMenu)
29
30
  return c.value;
30
31
  const e = S(c.value);
31
- return e == null ? void 0 : e.map((a) => (delete a.children, a));
32
+ return e == null ? void 0 : e.map((t) => (delete t.children, t));
32
33
  }), x = v(() => {
33
- var a, t;
34
- return n != null && n.doubleMenu ? [] : ((t = (a = c.value) == null ? void 0 : a.find((d) => d.name === r.value)) == null ? void 0 : t.children) || [];
35
- }), w = v(() => M(b.value, (a) => (a == null ? void 0 : a.name) === i.name));
34
+ var t, a;
35
+ return n != null && n.doubleMenu ? [] : ((a = (t = c.value) == null ? void 0 : t.find((d) => d.name === r.value)) == null ? void 0 : a.children) || [];
36
+ }), w = v(() => M(b.value, (t) => (t == null ? void 0 : t.name) === i.name));
36
37
  h(() => n == null ? void 0 : n.doubleMenu, () => {
37
- var e, a, t, d;
38
+ var e, t, a, d;
38
39
  if (n != null && n.doubleMenu) {
39
40
  const u = M(c.value, (l) => (l == null ? void 0 : l.name) === r.value);
40
- r.value = (t = u == null ? void 0 : u[0]) == null ? void 0 : t.name, o.value = (d = u == null ? void 0 : u[u.length - 1]) == null ? void 0 : d.name;
41
+ r.value = (a = u == null ? void 0 : u[0]) == null ? void 0 : a.name, o.value = (d = u == null ? void 0 : u[u.length - 1]) == null ? void 0 : d.name;
41
42
  } else {
42
43
  const u = M(c.value, (l) => (l == null ? void 0 : l.name) === o.value);
43
- r.value = (e = u == null ? void 0 : u[u.length - 1]) == null ? void 0 : e.name, o.value = (a = u == null ? void 0 : u[u.length - 1]) == null ? void 0 : a.name;
44
+ r.value = (e = u == null ? void 0 : u[u.length - 1]) == null ? void 0 : e.name, o.value = (t = u == null ? void 0 : u[u.length - 1]) == null ? void 0 : t.name;
44
45
  }
45
46
  }, { immediate: !0 });
46
47
  const j = v(() => n != null && n.doubleMenu ? (n == null ? void 0 : n.doubleMenu) || x.value.length > 0 : !0);
47
48
  return h([i, b, () => n == null ? void 0 : n.doubleMenu], () => {
48
49
  var d, u, l, T, I;
49
- const e = M(b.value, (m) => m.name === i.name), t = ((m) => {
50
+ const e = M(b.value, (m) => m.name === i.name), a = ((m) => {
50
51
  let R = -1;
51
52
  for (let f = m.length - 1; f >= 0; f--)
52
53
  if (m[f].hidden === !1 || m[f].hidden === void 0) {
@@ -55,7 +56,7 @@ function N(n) {
55
56
  }
56
57
  return R;
57
58
  })(e);
58
- g.value = (d = e == null ? void 0 : e[t]) == null ? void 0 : d.name, n != null && n.doubleMenu ? (r.value = (u = e == null ? void 0 : e[t]) == null ? void 0 : u.name, o.value = (l = e == null ? void 0 : e[t]) == null ? void 0 : l.name) : (r.value = (T = e == null ? void 0 : e[0]) == null ? void 0 : T.name, o.value = (I = e == null ? void 0 : e[t]) == null ? void 0 : I.name);
59
+ g.value = (d = e == null ? void 0 : e[a]) == null ? void 0 : d.name, n != null && n.doubleMenu ? (r.value = (u = e == null ? void 0 : e[a]) == null ? void 0 : u.name, o.value = (l = e == null ? void 0 : e[a]) == null ? void 0 : l.name) : (r.value = (T = e == null ? void 0 : e[0]) == null ? void 0 : T.name, o.value = (I = e == null ? void 0 : e[a]) == null ? void 0 : I.name);
59
60
  }, { immediate: !0 }), {
60
61
  data: c,
61
62
  originalData: b,
@@ -70,5 +71,5 @@ function N(n) {
70
71
  };
71
72
  }
72
73
  export {
73
- N as useMenu
74
+ O as useMenu
74
75
  };
@@ -9,16 +9,17 @@ import "@vee-validate/rules";
9
9
  import "vee-validate";
10
10
  import "@vueuse/core";
11
11
  import "./json/index.js";
12
+ import "../utils/bus.js";
12
13
  import "colorizr";
13
14
  import "axios";
14
15
  import "clsx";
15
16
  import { DuxOverlay as m } from "../components/overlay/overlay.js";
16
- function j() {
17
+ function D() {
17
18
  const r = t(m);
18
19
  return {
19
20
  show: (o) => r(o)
20
21
  };
21
22
  }
22
23
  export {
23
- j as useOverlay
24
+ D as useOverlay
24
25
  };
@@ -1,8 +1,9 @@
1
1
  import { computed as a } from "vue";
2
- import { arrayToTree as y, treeToArr as m } from "../utils/tree.js";
3
- import { useList as v } from "./data.js";
4
- function g(e) {
5
- const { data: o, isLoading: c } = v({
2
+ import "../utils/bus.js";
3
+ import { arrayToTree as m, treeToArr as y } from "../utils/tree.js";
4
+ import { useList as p } from "./data.js";
5
+ function T(e) {
6
+ const { data: o, isLoading: c } = p({
6
7
  get path() {
7
8
  return e.path || "";
8
9
  },
@@ -14,7 +15,7 @@ function g(e) {
14
15
  }
15
16
  }), d = a(() => {
16
17
  var r, n, i, t, l, s;
17
- return e.converTree ? y(((n = o.value) == null ? void 0 : n.data) || [], {
18
+ return e.converTree ? m(((n = o.value) == null ? void 0 : n.data) || [], {
18
19
  idKey: ((i = e.treeOptions) == null ? void 0 : i.valueKey) || "id",
19
20
  parentKey: ((t = e.treeOptions) == null ? void 0 : t.parentKey) || "parentId",
20
21
  sortKey: ((l = e.treeOptions) == null ? void 0 : l.sortKey) || "sort",
@@ -22,7 +23,7 @@ function g(e) {
22
23
  }) : ((r = o.value) == null ? void 0 : r.data) || [];
23
24
  }), u = a(() => {
24
25
  var r, n;
25
- return m(d.value, ((r = e.treeOptions) == null ? void 0 : r.valueKey) || "id", ((n = e.treeOptions) == null ? void 0 : n.childrenKey) || "children");
26
+ return y(d.value, ((r = e.treeOptions) == null ? void 0 : r.valueKey) || "id", ((n = e.treeOptions) == null ? void 0 : n.childrenKey) || "children");
26
27
  }), h = a(() => c.value);
27
28
  return {
28
29
  options: a(() => {
@@ -37,5 +38,5 @@ function g(e) {
37
38
  };
38
39
  }
39
40
  export {
40
- g as useTree
41
+ T as useTree
41
42
  };
@@ -1,13 +1,13 @@
1
1
  import { useClient as o } from "../data.js";
2
- const m = () => {
3
- const n = o();
2
+ function s() {
3
+ const c = o();
4
4
  return {
5
5
  upload(l, e) {
6
- const c = e.query || {};
6
+ const n = e.query || {};
7
7
  let a = null;
8
8
  if (e.method === "PUT")
9
9
  Object.entries(e.params || {}).forEach(([r, t]) => {
10
- c[r] = t;
10
+ n[r] = t;
11
11
  }), a = l;
12
12
  else {
13
13
  const r = new FormData();
@@ -15,9 +15,9 @@ const m = () => {
15
15
  r.append(t, d);
16
16
  }), a = r;
17
17
  }
18
- return n.request({
18
+ return c.request({
19
19
  ...e,
20
- query: c,
20
+ query: n,
21
21
  method: e.method || "POST",
22
22
  payload: a,
23
23
  signal: e.signal,
@@ -25,7 +25,7 @@ const m = () => {
25
25
  });
26
26
  }
27
27
  };
28
- };
28
+ }
29
29
  export {
30
- m as createLocalUploadDriver
30
+ s as createLocalUploadDriver
31
31
  };