@duxweb/dvha-core 1.0.25 → 1.0.27
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/hooks/form.cjs +1 -1
- package/dist/cjs/hooks/json/vOn.cjs +1 -1
- package/dist/cjs/hooks/json.cjs +1 -1
- package/dist/esm/hooks/form.js +10 -9
- package/dist/esm/hooks/json/vOn.js +8 -6
- package/dist/esm/hooks/json.js +46 -36
- package/dist/types/types/data.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/hooks/form.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("lodash-es"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("lodash-es"),n=require("vue"),s=require("./data.cjs");function b(a){const t=n.toRef(a,"form",{}),o=n.toRef(a,"id",void 0),i=n.ref(r.cloneDeep(t.value||{})),l=n.ref(r.cloneDeep(t.value||{})),u=n.computed(()=>a.action==="edit"||!!o.value),{data:m,isLoading:g,refetch:f}=s.useOne({get path(){return a.path||""},get id(){return o.value},options:{enabled:!1},providerName:a.providerName}),c=()=>{let e={};u.value?e=r.cloneDeep(i.value):e=r.cloneDeep(l.value),Object.assign(t.value,e)};n.watch([o,u],async()=>{if(!u.value){c();return}await f();const e=r.cloneDeep(m.value?.data||{});Object.assign(t.value,e),Object.assign(i.value,e)},{immediate:!0,deep:!0});const d=s.useCreate({path:a.path??"",data:t.value,onSuccess:e=>{c(),a.onSuccess?.(e)},onError:e=>{a.onError?.(e)},providerName:a.providerName}),v=s.useUpdate({get path(){return a.path??""},get id(){return o.value},data:t.value,onSuccess:e=>{a.onSuccess?.(e)},onError:e=>{a.onError?.(e)},providerName:a.providerName}),D=e=>{u.value?v.mutate({id:o.value,data:e||t.value}):d.mutate({data:e||t.value})},h=n.computed(()=>g.value||d.isLoading.value||v.isLoading.value);return{form:t,initData:u.value?i.value:l.value,isLoading:h,isEdit:u,onSubmit:D,onReset:c}}exports.useForm=b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v={name:"v-on",priority:60,process(u,c){const o={},s={};let i=!1;return Object.entries(c).forEach(([t,e])=>{if(t.startsWith("@")||t.startsWith("v-on:")){i=!0;const l=t.startsWith("@")?t.slice(1):t.slice(5),[r,...a]=l.split(".");if(!r){console.warn(`Invalid event name: ${t}`);return}const p=`on${r.charAt(0).toUpperCase()}${r.slice(1)}`,d=(n,...f)=>{a.includes("prevent")&&n.preventDefault?.(),a.includes("stop")&&n.stopPropagation?.();try{typeof e=="function"
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v={name:"v-on",priority:60,process(u,c){const o={},s={};let i=!1;return Object.entries(c).forEach(([t,e])=>{if(t.startsWith("@")||t.startsWith("v-on:")){i=!0;const l=t.startsWith("@")?t.slice(1):t.slice(5),[r,...a]=l.split(".");if(!r){console.warn(`Invalid event name: ${t}`);return}const p=`on${r.charAt(0).toUpperCase()}${r.slice(1)}`,d=(n,...f)=>{a.includes("prevent")&&n.preventDefault?.(),a.includes("stop")&&n.stopPropagation?.();try{if(typeof e=="function")return e(n,...f);console.warn(`Invalid event handler type: ${typeof e}`)}catch(h){console.error(`Event handler execution error (${r}):`,h)}};o[p]=d}else s[t]=e}),i?{props:{...s,...o}}:null}};exports.vOnAdaptor=v;
|
package/dist/cjs/hooks/json.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),v=require("../stores/jsonSchema.cjs"),N=require("./config.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),v=require("../stores/jsonSchema.cjs"),N=require("./config.cjs"),V=require("./json/index.cjs"),$=require("./json/utils/contextManager.cjs");function z(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function b(n,m){Array.isArray(n)?n.forEach(c=>{const i=c;let d=i.name;!d&&i.__name&&(d=i.__name.replace(/\.(vue|ts|tsx|js|jsx)$/,"").split("/").pop()),d&&m.addComponent(s.markRaw(c),d)}):typeof n=="object"&&n!==null&&Object.entries(n).forEach(([c,i])=>{m.addComponent(s.markRaw(i),c)})}function P(n,m){const c=v.useJsonSchemaStore(m);n.jsonSchema?.components&&b(n.jsonSchema.components,c),n.manages?.forEach(i=>{i.jsonSchema?.components&&b(i.jsonSchema.components,c)})}function T(n){const m=N.useConfig(),c=v.useJsonSchemaStore(),i=[...V.defaultAdaptors,...m.jsonSchema?.adaptors||[],...n?.adaptors||[]];n?.components&&b(n.components,c);const d=s.computed(()=>s.isRef(n?.data)?n?.data.value:n?.data);function A(){return(s.isRef(n?.context)?n?.context.value:n?.context)||{}}function _(e){const r={};return Object.entries(e).forEach(([t,o])=>{if(t==="_context")return;const j=t==="modelValue"||t.startsWith("modelValue")||t!=="value"&&(t.includes("model")||t.includes("Model"));r[t]=j&&s.isRef(o)?s.unref(o):o}),r}function y(e,r,t){if(typeof e=="string")return e;if(typeof e=="function")return y(e(r),r,t);if(Array.isArray(e))return e.flatMap(o=>y(o,r,t)).filter(Boolean);if(e?.tag){const o={...t,...r};return p(e,!0,o)}return e}function M(e,r,t){if(e)return typeof e=="string"?e:Array.isArray(e)?e.flatMap(o=>typeof o=="string"?o:p(o,r,t)).filter(Boolean):p(e,r,t)}function p(e,r=!1,t={}){const{tag:o,attrs:j={},children:O,slots:B}=e,h={...A(),...t};let g={...j};Object.keys(h).length>0&&(g={...g,...$.injectContext({},h)});for(const f of i){const a=f.process(e,g);if(a){if(g=a.props,a.skip)return null;if(a.nodes)return a.nodes.map(l=>{const S=l.attrs?._context||{};return p(l,r,{...h,...S})}).filter(Boolean)}}let u=typeof o=="string"&&(f=>{let a=c.getComponentByName(f);if(a)return a;const l=z(f);if(a=c.getComponentByName(l),a)return a;const S=f.replace(/-([a-z])/g,(R,w)=>w.toUpperCase()).replace(/^[a-z]/,R=>R.toUpperCase());return a=c.getComponentByName(S),a||null})(o)||o;typeof u!="string"&&typeof u=="object"&&(u=s.markRaw(u));const J=typeof u!="string",C=_(g);if(B&&J&&!r){const f={};return Object.entries(B).forEach(([a,l])=>{f[a]=(S={})=>y(l,S,h)}),s.h(u,C,f)}const x=M(O,r,h);return J&&x!==void 0?s.h(u,C,{default:()=>x}):s.h(u,C,x)}const q=s.defineComponent({name:"JsonSchemaRenderer",render(){return d.value?.map(e=>p(e)).filter(Boolean)||[]}});function E(e){return s.defineComponent({name:"DynamicJsonSchemaRenderer",render(){const r={...A(),...e.context};return e.data?.map(t=>p(t,!1,r)).filter(Boolean)}})}return{render:q,renderAsync:E}}exports.initJsonSchemaComponents=P;exports.useJsonSchema=T;
|
package/dist/esm/hooks/form.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { cloneDeep as i } from "lodash-es";
|
|
2
|
-
import { toRef as
|
|
2
|
+
import { toRef as v, ref as l, computed as m, watch as b } from "vue";
|
|
3
3
|
import { useOne as E, useCreate as L, useUpdate as O } from "./data.js";
|
|
4
4
|
function w(a) {
|
|
5
|
-
const t =
|
|
5
|
+
const t = v(a, "form", {}), u = v(a, "id", void 0), o = l(i(t.value || {})), s = l(i(t.value || {})), n = m(() => a.action === "edit" || !!u.value), { data: f, isLoading: g, refetch: h } = E({
|
|
6
6
|
get path() {
|
|
7
7
|
return a.path || "";
|
|
8
8
|
},
|
|
@@ -10,12 +10,12 @@ function w(a) {
|
|
|
10
10
|
return u.value;
|
|
11
11
|
},
|
|
12
12
|
options: {
|
|
13
|
-
enabled:
|
|
13
|
+
enabled: !1
|
|
14
14
|
},
|
|
15
15
|
providerName: a.providerName
|
|
16
16
|
}), r = () => {
|
|
17
17
|
let e = {};
|
|
18
|
-
n.value ? e = i(o.value) : e = i(
|
|
18
|
+
n.value ? e = i(o.value) : e = i(s.value), Object.assign(t.value, e);
|
|
19
19
|
};
|
|
20
20
|
b([u, n], async () => {
|
|
21
21
|
if (!n.value) {
|
|
@@ -26,7 +26,8 @@ function w(a) {
|
|
|
26
26
|
const e = i(f.value?.data || {});
|
|
27
27
|
Object.assign(t.value, e), Object.assign(o.value, e);
|
|
28
28
|
}, {
|
|
29
|
-
immediate: !0
|
|
29
|
+
immediate: !0,
|
|
30
|
+
deep: !0
|
|
30
31
|
});
|
|
31
32
|
const c = L({
|
|
32
33
|
path: a.path ?? "",
|
|
@@ -38,7 +39,7 @@ function w(a) {
|
|
|
38
39
|
a.onError?.(e);
|
|
39
40
|
},
|
|
40
41
|
providerName: a.providerName
|
|
41
|
-
}),
|
|
42
|
+
}), d = O({
|
|
42
43
|
get path() {
|
|
43
44
|
return a.path ?? "";
|
|
44
45
|
},
|
|
@@ -54,16 +55,16 @@ function w(a) {
|
|
|
54
55
|
},
|
|
55
56
|
providerName: a.providerName
|
|
56
57
|
}), D = (e) => {
|
|
57
|
-
n.value ?
|
|
58
|
+
n.value ? d.mutate({
|
|
58
59
|
id: u.value,
|
|
59
60
|
data: e || t.value
|
|
60
61
|
}) : c.mutate({
|
|
61
62
|
data: e || t.value
|
|
62
63
|
});
|
|
63
|
-
}, N = m(() => g.value || c.isLoading.value ||
|
|
64
|
+
}, N = m(() => g.value || c.isLoading.value || d.isLoading.value);
|
|
64
65
|
return {
|
|
65
66
|
form: t,
|
|
66
|
-
initData: n.value ? o.value :
|
|
67
|
+
initData: n.value ? o.value : s.value,
|
|
67
68
|
isLoading: N,
|
|
68
69
|
isEdit: n,
|
|
69
70
|
onSubmit: D,
|
|
@@ -7,17 +7,19 @@ const u = {
|
|
|
7
7
|
return Object.entries(c).forEach(([t, e]) => {
|
|
8
8
|
if (t.startsWith("@") || t.startsWith("v-on:")) {
|
|
9
9
|
i = !0;
|
|
10
|
-
const l = t.startsWith("@") ? t.slice(1) : t.slice(5), [
|
|
11
|
-
if (!
|
|
10
|
+
const l = t.startsWith("@") ? t.slice(1) : t.slice(5), [r, ...a] = l.split(".");
|
|
11
|
+
if (!r) {
|
|
12
12
|
console.warn(`Invalid event name: ${t}`);
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
const p = `on${
|
|
16
|
-
a.includes("prevent") &&
|
|
15
|
+
const p = `on${r.charAt(0).toUpperCase()}${r.slice(1)}`, f = (n, ...d) => {
|
|
16
|
+
a.includes("prevent") && n.preventDefault?.(), a.includes("stop") && n.stopPropagation?.();
|
|
17
17
|
try {
|
|
18
|
-
typeof e == "function"
|
|
18
|
+
if (typeof e == "function")
|
|
19
|
+
return e(n, ...d);
|
|
20
|
+
console.warn(`Invalid event handler type: ${typeof e}`);
|
|
19
21
|
} catch (h) {
|
|
20
|
-
console.error(`Event handler execution error (${
|
|
22
|
+
console.error(`Event handler execution error (${r}):`, h);
|
|
21
23
|
}
|
|
22
24
|
};
|
|
23
25
|
o[p] = f;
|
package/dist/esm/hooks/json.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed as
|
|
1
|
+
import { computed as P, isRef as S, defineComponent as M, markRaw as A, h as b, unref as T } from "vue";
|
|
2
2
|
import { useJsonSchemaStore as N } from "../stores/jsonSchema.js";
|
|
3
3
|
import { useConfig as U } from "./config.js";
|
|
4
4
|
import { defaultAdaptors as D } from "./json/index.js";
|
|
@@ -24,30 +24,40 @@ function K(n, u) {
|
|
|
24
24
|
function Q(n) {
|
|
25
25
|
const u = U(), s = N(), c = [...D, ...u.jsonSchema?.adaptors || [], ...n?.adaptors || []];
|
|
26
26
|
n?.components && B(n.components, s);
|
|
27
|
-
const m =
|
|
27
|
+
const m = P(() => S(n?.data) ? n?.data.value : n?.data);
|
|
28
28
|
function _() {
|
|
29
29
|
return (S(n?.context) ? n?.context.value : n?.context) || {};
|
|
30
30
|
}
|
|
31
31
|
function O(e) {
|
|
32
|
-
const
|
|
33
|
-
return Object.entries(e).forEach(([t,
|
|
32
|
+
const r = {};
|
|
33
|
+
return Object.entries(e).forEach(([t, o]) => {
|
|
34
34
|
if (t === "_context") return;
|
|
35
35
|
const h = t === "modelValue" || t.startsWith("modelValue") || t !== "value" && (t.includes("model") || t.includes("Model"));
|
|
36
|
-
|
|
37
|
-
}),
|
|
36
|
+
r[t] = h && S(o) ? T(o) : o;
|
|
37
|
+
}), r;
|
|
38
38
|
}
|
|
39
|
-
function j(e,
|
|
40
|
-
|
|
39
|
+
function j(e, r, t) {
|
|
40
|
+
if (typeof e == "string") return e;
|
|
41
|
+
if (typeof e == "function") return j(e(r), r, t);
|
|
42
|
+
if (Array.isArray(e)) return e.flatMap((o) => j(o, r, t)).filter(Boolean);
|
|
43
|
+
if (e?.tag) {
|
|
44
|
+
const o = {
|
|
45
|
+
...t,
|
|
46
|
+
...r
|
|
47
|
+
};
|
|
48
|
+
return p(e, !0, o);
|
|
49
|
+
}
|
|
50
|
+
return e;
|
|
41
51
|
}
|
|
42
|
-
function R(e,
|
|
52
|
+
function R(e, r, t) {
|
|
43
53
|
if (e)
|
|
44
|
-
return typeof e == "string" ? e : Array.isArray(e) ? e.flatMap((
|
|
54
|
+
return typeof e == "string" ? e : Array.isArray(e) ? e.flatMap((o) => typeof o == "string" ? o : p(o, r, t)).filter(Boolean) : p(e, r, t);
|
|
45
55
|
}
|
|
46
|
-
function p(e,
|
|
56
|
+
function p(e, r = !1, t = {}) {
|
|
47
57
|
const {
|
|
48
|
-
tag:
|
|
58
|
+
tag: o,
|
|
49
59
|
attrs: h = {},
|
|
50
|
-
children:
|
|
60
|
+
children: $,
|
|
51
61
|
slots: v
|
|
52
62
|
} = e, l = {
|
|
53
63
|
..._(),
|
|
@@ -61,38 +71,38 @@ function Q(n) {
|
|
|
61
71
|
...F({}, l)
|
|
62
72
|
});
|
|
63
73
|
for (const i of c) {
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
if (y =
|
|
67
|
-
if (
|
|
68
|
-
return
|
|
74
|
+
const a = i.process(e, y);
|
|
75
|
+
if (a) {
|
|
76
|
+
if (y = a.props, a.skip) return null;
|
|
77
|
+
if (a.nodes)
|
|
78
|
+
return a.nodes.map((d) => {
|
|
69
79
|
const g = d.attrs?._context || {};
|
|
70
|
-
return p(d,
|
|
80
|
+
return p(d, r, {
|
|
71
81
|
...l,
|
|
72
82
|
...g
|
|
73
83
|
});
|
|
74
84
|
}).filter(Boolean);
|
|
75
85
|
}
|
|
76
86
|
}
|
|
77
|
-
let f = typeof
|
|
78
|
-
let
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
87
|
+
let f = typeof o == "string" && ((i) => {
|
|
88
|
+
let a = s.getComponentByName(i);
|
|
89
|
+
if (a)
|
|
90
|
+
return a;
|
|
81
91
|
const d = G(i);
|
|
82
|
-
if (
|
|
83
|
-
return
|
|
84
|
-
const g = i.replace(/-([a-z])/g, (J,
|
|
85
|
-
return
|
|
86
|
-
})(
|
|
92
|
+
if (a = s.getComponentByName(d), a)
|
|
93
|
+
return a;
|
|
94
|
+
const g = i.replace(/-([a-z])/g, (J, w) => w.toUpperCase()).replace(/^[a-z]/, (J) => J.toUpperCase());
|
|
95
|
+
return a = s.getComponentByName(g), a || null;
|
|
96
|
+
})(o) || o;
|
|
87
97
|
typeof f != "string" && typeof f == "object" && (f = A(f));
|
|
88
98
|
const E = typeof f != "string", x = O(y);
|
|
89
|
-
if (v && E && !
|
|
99
|
+
if (v && E && !r) {
|
|
90
100
|
const i = {};
|
|
91
|
-
return Object.entries(v).forEach(([
|
|
92
|
-
i[
|
|
101
|
+
return Object.entries(v).forEach(([a, d]) => {
|
|
102
|
+
i[a] = (g = {}) => j(d, g, l);
|
|
93
103
|
}), b(f, x, i);
|
|
94
104
|
}
|
|
95
|
-
const C = R(
|
|
105
|
+
const C = R($, r, l);
|
|
96
106
|
return E && C !== void 0 ? b(f, x, {
|
|
97
107
|
default: () => C
|
|
98
108
|
}) : b(f, x, C);
|
|
@@ -103,21 +113,21 @@ function Q(n) {
|
|
|
103
113
|
return m.value?.map((e) => p(e)).filter(Boolean) || [];
|
|
104
114
|
}
|
|
105
115
|
});
|
|
106
|
-
function
|
|
116
|
+
function V(e) {
|
|
107
117
|
return /* @__PURE__ */ M({
|
|
108
118
|
name: "DynamicJsonSchemaRenderer",
|
|
109
119
|
render() {
|
|
110
|
-
const
|
|
120
|
+
const r = {
|
|
111
121
|
..._(),
|
|
112
122
|
...e.context
|
|
113
123
|
};
|
|
114
|
-
return e.data?.map((t) => p(t, !1,
|
|
124
|
+
return e.data?.map((t) => p(t, !1, r)).filter(Boolean);
|
|
115
125
|
}
|
|
116
126
|
});
|
|
117
127
|
}
|
|
118
128
|
return {
|
|
119
129
|
render: z,
|
|
120
|
-
renderAsync:
|
|
130
|
+
renderAsync: V
|
|
121
131
|
};
|
|
122
132
|
}
|
|
123
133
|
export {
|
|
@@ -48,7 +48,7 @@ export interface IDataProviderListOptions {
|
|
|
48
48
|
}
|
|
49
49
|
export interface IDataProviderCreateOptions {
|
|
50
50
|
path?: string;
|
|
51
|
-
data
|
|
51
|
+
data?: any;
|
|
52
52
|
meta?: Record<string, any>;
|
|
53
53
|
}
|
|
54
54
|
export interface IDataProviderUpdateOptions extends IDataProviderCreateOptions {
|