@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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("lodash-es"),u=require("vue"),l=require("./data.cjs");function b(a){const t=u.toRef(a,"form",{}),o=u.toRef(a,"id",void 0),i=u.ref(r.cloneDeep(t.value||{})),s=u.ref(r.cloneDeep(t.value||{})),n=u.computed(()=>a.action==="edit"||!!o.value),{data:m,isLoading:g,refetch:f}=l.useOne({get path(){return a.path||""},get id(){return o.value},options:{enabled:n.value},providerName:a.providerName}),c=()=>{let e={};n.value?e=r.cloneDeep(i.value):e=r.cloneDeep(s.value),Object.assign(t.value,e)};u.watch([o,n],async()=>{if(!n.value){c();return}await f();const e=r.cloneDeep(m.value?.data||{});Object.assign(t.value,e),Object.assign(i.value,e)},{immediate:!0});const d=l.useCreate({path:a.path??"",data:t.value,onSuccess:e=>{c(),a.onSuccess?.(e)},onError:e=>{a.onError?.(e)},providerName:a.providerName}),v=l.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=>{n.value?v.mutate({id:o.value,data:e||t.value}):d.mutate({data:e||t.value})},h=u.computed(()=>g.value||d.isLoading.value||v.isLoading.value);return{form:t,initData:n.value?i.value:s.value,isLoading:h,isEdit:n,onSubmit:D,onReset:c}}exports.useForm=b;
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"?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;
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;
@@ -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"),P=require("./json/index.cjs"),V=require("./json/utils/contextManager.cjs");function $(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 z(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=[...P.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 o={};return Object.entries(e).forEach(([t,a])=>{if(t==="_context")return;const j=t==="modelValue"||t.startsWith("modelValue")||t!=="value"&&(t.includes("model")||t.includes("Model"));o[t]=j&&s.isRef(a)?s.unref(a):a}),o}function y(e,o,t){return typeof e=="string"?e:typeof e=="function"?y(e(o),o,t):Array.isArray(e)?e.flatMap(a=>y(a,o,t)).filter(Boolean):e?.tag?p(e,!0,t):e}function M(e,o,t){if(e)return typeof e=="string"?e:Array.isArray(e)?e.flatMap(a=>typeof a=="string"?a:p(a,o,t)).filter(Boolean):p(e,o,t)}function p(e,o=!1,t={}){const{tag:a,attrs:j={},children:O,slots:B}=e,h={...A(),...t};let g={...j};Object.keys(h).length>0&&(g={...g,...V.injectContext({},h)});for(const f of i){const r=f.process(e,g);if(r){if(g=r.props,r.skip)return null;if(r.nodes)return r.nodes.map(l=>{const S=l.attrs?._context||{};return p(l,o,{...h,...S})}).filter(Boolean)}}let u=typeof a=="string"&&(f=>{let r=c.getComponentByName(f);if(r)return r;const l=$(f);if(r=c.getComponentByName(l),r)return r;const S=f.replace(/-([a-z])/g,(R,w)=>w.toUpperCase()).replace(/^[a-z]/,R=>R.toUpperCase());return r=c.getComponentByName(S),r||null})(a)||a;typeof u!="string"&&typeof u=="object"&&(u=s.markRaw(u));const J=typeof u!="string",C=_(g);if(B&&J&&!o){const f={};return Object.entries(B).forEach(([r,l])=>{f[r]=(S={})=>y(l,S,h)}),s.h(u,C,f)}const x=M(O,o,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 o={...A(),...e.context};return e.data?.map(t=>p(t,!1,o)).filter(Boolean)}})}return{render:q,renderAsync:E}}exports.initJsonSchemaComponents=z;exports.useJsonSchema=T;
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;
@@ -1,8 +1,8 @@
1
1
  import { cloneDeep as i } from "lodash-es";
2
- import { toRef as d, ref as l, computed as m, watch as b } from "vue";
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 = d(a, "form", {}), u = d(a, "id", void 0), o = l(i(t.value || {})), v = l(i(t.value || {})), n = m(() => a.action === "edit" || !!u.value), { data: f, isLoading: g, refetch: h } = E({
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: n.value
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(v.value), Object.assign(t.value, e);
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
- }), s = O({
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 ? s.mutate({
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 || s.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 : v.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), [n, ...a] = l.split(".");
11
- if (!n) {
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${n.charAt(0).toUpperCase()}${n.slice(1)}`, f = (r, ...d) => {
16
- a.includes("prevent") && r.preventDefault?.(), a.includes("stop") && r.stopPropagation?.();
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" ? e(r, ...d) : console.warn(`Invalid event handler type: ${typeof e}`);
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 (${n}):`, h);
22
+ console.error(`Event handler execution error (${r}):`, h);
21
23
  }
22
24
  };
23
25
  o[p] = f;
@@ -1,4 +1,4 @@
1
- import { computed as w, isRef as S, defineComponent as M, markRaw as A, h as b, unref as T } from "vue";
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 = w(() => S(n?.data) ? n?.data.value : n?.data);
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 o = {};
33
- return Object.entries(e).forEach(([t, a]) => {
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
- o[t] = h && S(a) ? T(a) : a;
37
- }), o;
36
+ r[t] = h && S(o) ? T(o) : o;
37
+ }), r;
38
38
  }
39
- function j(e, o, t) {
40
- return typeof e == "string" ? e : typeof e == "function" ? j(e(o), o, t) : Array.isArray(e) ? e.flatMap((a) => j(a, o, t)).filter(Boolean) : e?.tag ? p(e, !0, t) : e;
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, o, t) {
52
+ function R(e, r, t) {
43
53
  if (e)
44
- return typeof e == "string" ? e : Array.isArray(e) ? e.flatMap((a) => typeof a == "string" ? a : p(a, o, t)).filter(Boolean) : p(e, o, t);
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, o = !1, t = {}) {
56
+ function p(e, r = !1, t = {}) {
47
57
  const {
48
- tag: a,
58
+ tag: o,
49
59
  attrs: h = {},
50
- children: V,
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 r = i.process(e, y);
65
- if (r) {
66
- if (y = r.props, r.skip) return null;
67
- if (r.nodes)
68
- return r.nodes.map((d) => {
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, o, {
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 a == "string" && ((i) => {
78
- let r = s.getComponentByName(i);
79
- if (r)
80
- return r;
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 (r = s.getComponentByName(d), r)
83
- return r;
84
- const g = i.replace(/-([a-z])/g, (J, $) => $.toUpperCase()).replace(/^[a-z]/, (J) => J.toUpperCase());
85
- return r = s.getComponentByName(g), r || null;
86
- })(a) || a;
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 && !o) {
99
+ if (v && E && !r) {
90
100
  const i = {};
91
- return Object.entries(v).forEach(([r, d]) => {
92
- i[r] = (g = {}) => j(d, g, l);
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(V, o, l);
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 P(e) {
116
+ function V(e) {
107
117
  return /* @__PURE__ */ M({
108
118
  name: "DynamicJsonSchemaRenderer",
109
119
  render() {
110
- const o = {
120
+ const r = {
111
121
  ..._(),
112
122
  ...e.context
113
123
  };
114
- return e.data?.map((t) => p(t, !1, o)).filter(Boolean);
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: P
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: any;
51
+ data?: any;
52
52
  meta?: Record<string, any>;
53
53
  }
54
54
  export interface IDataProviderUpdateOptions extends IDataProviderCreateOptions {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@duxweb/dvha-core",
3
3
  "type": "module",
4
- "version": "1.0.25",
4
+ "version": "1.0.27",
5
5
  "author": "DuxWeb",
6
6
  "license": "MIT",
7
7
  "repository": {