@duxweb/dvha-pro 1.0.42 → 1.0.44

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("@duxweb/dvha-core"),f=require("naive-ui"),s=require("vue"),S=require("vue-router"),M=require("./dialog.cjs"),$=require("./drawer.cjs"),D=require("./modal.cjs");function I(o){const h=D.useModal(),i=$.useDrawer(),u=M.useDialog(),{t:n}=r.useI18n(),d=f.useMessage(),y=r.useManage(),k=S.useRouter(),v=r.useCustomMutation({onSuccess:t=>{d.success(t.message||n("common.success"))},onError:t=>{d.error(t.message||n("common.error"))}}),q=r.useDelete({onSuccess:t=>{d.success(t.message||n("common.success"))},onError:t=>{d.error(t.message||n("common.error"))}}),m=o?.path||y.getPath(),g=t=>{const c=n(t.item.title||"",{},t.item.title),l=n(t.item.label||"",{},t.item.label);if(t.item.type==="modal"){const e=t.item,a=typeof e.componentProps=="function"?e.componentProps(t.data):e.componentProps;h.show({title:c||l,component:e.component,componentProps:{id:t.id,...a},width:e.width,draggable:e.draggable!==void 0?e.draggable:!0})}if(t.item.type==="drawer"){const e=t.item,a=typeof e.componentProps=="function"?e.componentProps(t.data):e.componentProps;i.show({title:c||l,component:e.component,componentProps:{id:t.id,...a},width:e.width,maxWidth:e.maxWidth})}if(t.item.type==="confirm"){const e=t.item;u.confirm({title:c||l,content:e.content}).then(a=>{a&&e.callback?.(t.id,t.data)})}if(t.item.type==="request"){const e=t.item;u.confirm({title:c||l,content:e.content}).then(()=>{const a=typeof e.data=="function"?e.data(t.id,t.data):e.data,A=(e.method||"post").toLowerCase(),j=typeof e.path=="function"?e.path(t.id,t.data):e.path||m;v.mutate({path:j,method:A,payload:a})})}if(t.item.type==="delete"){const e=t.item;u.confirm({title:c||l,content:e.content}).then(()=>{q.mutate({id:t.id,path:typeof e.path=="function"?e.path(t.id,t.data):e.path||m})})}if(t.item.type==="link"){const e=t.item;let a=typeof e.path=="function"?e.path?.(t.id,t.data):t.id?`${e.path||m}${t.data===void 0?"":`/${t.id}`}`:e.path||m;a.startsWith("/")||(a=y.getRoutePath(a)),k.push(a)}t.item.type==="callback"&&t.item.callback?.(t.id,t.data)},b=w(),x=P();return{target:g,renderTable:t=>(c,l)=>{const e={id:c[t.key||o?.key||"id"],data:c,index:l,target:g,text:t.text!==void 0?t.text:o?.text||!1,align:t.align!==void 0?t.align:o?.align||"left"};return(t.type||o?.type)==="button"?b.render({...e,action:t||o}):x.render({...e,action:t||o})},renderAction:t=>{const c={target:g,text:t.text!==void 0?t.text:o?.text||!1,align:t.align!==void 0?t.align:o?.align||"left"};return(t.type||o?.type)==="button"?b.render({...c,action:t||o}):x.render({...c,action:t||o})}}}function w(){const{t:o}=r.useI18n();return{render:i=>{const u=i.action.items?.filter(n=>!n.show||n.show?.(i.data,i.index)).map((n,d)=>s.h(f.NButton,{key:d,type:n.color||(n.type==="delete"?"error":"primary"),text:i.text,secondary:!i.text,onClick:()=>{i?.target?.({id:i.id,data:i.data,item:n})},renderIcon:n.icon?()=>s.h("div",{class:["n-icon",n.icon]}):void 0},()=>o(n.label||"",{},n.label)));return s.h("div",{class:["flex gap-2 flex-wrap items-center",i.align==="right"?"justify-end":i.align==="center"?"justify-center":"justify-start"]},u)}}}function P(){const{t:o}=r.useI18n();return{render:i=>{const u=i.action.items?.filter(n=>!n.show||n.show?.(i.data,i.index)).map((n,d)=>({label:o(n.label||"",{},n.label),key:d,icon:n.icon?()=>s.h("div",{class:["n-icon",n.icon]}):void 0,onSelect:()=>{i?.target?.({id:i.id,data:i.data,item:n})}}));return s.h(f.NDropdown,{trigger:"click",options:u,onSelect:(n,d)=>{d?.onSelect?.()}},()=>[s.h("div",{class:["flex items-center",i.align==="right"?"justify-end":i.align==="center"?"justify-center":"justify-start"]},s.h(f.NButton,{type:"default",text:i.text,secondary:!i.text,renderIcon:()=>s.h("div",{class:["n-icon","i-tabler:dots-vertical"]})}))])}}}exports.useAction=I;exports.useActionButton=w;exports.useActionDropdown=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@duxweb/dvha-core"),f=require("naive-ui"),s=require("vue"),w=require("vue-router"),$=require("./dialog.cjs"),D=require("./drawer.cjs"),B=require("./modal.cjs");function C(a){const h=B.useModal(),i=D.useDrawer(),u=$.useDialog(),{t:n}=r.useI18n(),d=f.useMessage(),y=r.useManage(),k=w.useRouter(),q=w.useRoute(),{invalidate:A}=r.useInvalidate(),j=r.useCustomMutation({onSuccess:t=>{d.success(t.message||n("common.success")),A(a?.invalidate||q.path)},onError:t=>{d.error(t.message||n("common.error"))}}),S=r.useDelete({onSuccess:t=>{d.success(t.message||n("common.success"))},onError:t=>{d.error(t.message||n("common.error"))}}),m=a?.path||y.getPath(),g=t=>{const c=n(t.item.title||"",{},t.item.title),l=n(t.item.label||"",{},t.item.label);if(t.item.type==="modal"){const e=t.item,o=typeof e.componentProps=="function"?e.componentProps(t.data):e.componentProps;h.show({title:c||l,component:e.component,componentProps:{id:t.id,...o},width:e.width,draggable:e.draggable!==void 0?e.draggable:!0})}if(t.item.type==="drawer"){const e=t.item,o=typeof e.componentProps=="function"?e.componentProps(t.data):e.componentProps;i.show({title:c||l,component:e.component,componentProps:{id:t.id,...o},width:e.width,maxWidth:e.maxWidth})}if(t.item.type==="confirm"){const e=t.item;u.confirm({title:c||l,content:e.content}).then(o=>{o&&e.callback?.(t.id,t.data)})}if(t.item.type==="request"){const e=t.item;u.confirm({title:c||l,content:e.content}).then(()=>{const o=typeof e.data=="function"?e.data(t.id,t.data):e.data,I=(e.method||"post").toLowerCase(),M=typeof e.path=="function"?e.path(t.id,t.data):e.path||m;j.mutate({path:M,method:I,payload:o})})}if(t.item.type==="delete"){const e=t.item;u.confirm({title:c||l,content:e.content}).then(()=>{S.mutate({id:t.id,path:typeof e.path=="function"?e.path(t.id,t.data):e.path||m})})}if(t.item.type==="link"){const e=t.item;let o=typeof e.path=="function"?e.path?.(t.id,t.data):t.id?`${e.path||m}${t.data===void 0?"":`/${t.id}`}`:e.path||m;o.startsWith("/")||(o=y.getRoutePath(o)),k.push(o)}t.item.type==="callback"&&t.item.callback?.(t.id,t.data)},b=v(),x=P();return{target:g,renderTable:t=>(c,l)=>{const e={id:c[t.key||a?.key||"id"],data:c,index:l,target:g,text:t.text!==void 0?t.text:a?.text||!1,align:t.align!==void 0?t.align:a?.align||"left"};return(t.type||a?.type)==="button"?b.render({...e,action:t||a}):x.render({...e,action:t||a})},renderAction:t=>{const c={target:g,text:t.text!==void 0?t.text:a?.text||!1,align:t.align!==void 0?t.align:a?.align||"left"};return(t.type||a?.type)==="button"?b.render({...c,action:t||a}):x.render({...c,action:t||a})}}}function v(){const{t:a}=r.useI18n();return{render:i=>{const u=i.action.items?.filter(n=>!n.show||n.show?.(i.data,i.index)).map((n,d)=>s.h(f.NButton,{key:d,type:n.color||(n.type==="delete"?"error":"primary"),text:i.text,secondary:!i.text,onClick:()=>{i?.target?.({id:i.id,data:i.data,item:n})},renderIcon:n.icon?()=>s.h("div",{class:["n-icon",n.icon]}):void 0},()=>a(n.label||"",{},n.label)));return s.h("div",{class:["flex gap-2 flex-wrap items-center",i.align==="right"?"justify-end":i.align==="center"?"justify-center":"justify-start"]},u)}}}function P(){const{t:a}=r.useI18n();return{render:i=>{const u=i.action.items?.filter(n=>!n.show||n.show?.(i.data,i.index)).map((n,d)=>({label:a(n.label||"",{},n.label),key:d,icon:n.icon?()=>s.h("div",{class:["n-icon",n.icon]}):void 0,onSelect:()=>{i?.target?.({id:i.id,data:i.data,item:n})}}));return s.h(f.NDropdown,{trigger:"click",options:u,onSelect:(n,d)=>{d?.onSelect?.()}},()=>[s.h("div",{class:["flex items-center",i.align==="right"?"justify-end":i.align==="center"?"justify-center":"justify-start"]},s.h(f.NButton,{type:"default",text:i.text,secondary:!i.text,renderIcon:()=>s.h("div",{class:["n-icon","i-tabler:dots-vertical"]})}))])}}}exports.useAction=C;exports.useActionButton=v;exports.useActionDropdown=P;
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=`/* layer: properties */
2
- @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*, ::before, ::after, ::backdrop{--un-text-opacity:100%;--un-bg-opacity:100%;--un-from-opacity:100%;--un-divide-y-reverse:initial;--un-border-style:solid;--un-divide-x-reverse:initial;--un-divide-opacity:100%;--un-shadow-opacity:100%;--un-border-opacity:100%;--un-ease:initial;--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-to-opacity:100%;--un-outline-style:solid;--un-fill-opacity:100%;}}
2
+ @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*, ::before, ::after, ::backdrop{--un-from-opacity:100%;--un-text-opacity:100%;--un-bg-opacity:100%;--un-divide-y-reverse:initial;--un-border-style:solid;--un-divide-x-reverse:initial;--un-divide-opacity:100%;--un-shadow-opacity:100%;--un-ease:initial;--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-border-opacity:100%;--un-to-opacity:100%;--un-outline-style:solid;--un-fill-opacity:100%;}}
3
3
  @property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
4
4
  @property --un-outline-style{syntax:"*";inherits:false;initial-value:solid;}
5
5
  @property --un-border-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
@@ -1,50 +1,52 @@
1
- import { useI18n as h, useManage as A, useCustomMutation as M, useDelete as S } from "@duxweb/dvha-core";
2
- import { useMessage as D, NButton as b, NDropdown as C } from "naive-ui";
1
+ import { useI18n as h, useManage as S, useInvalidate as D, useCustomMutation as I, useDelete as C } from "@duxweb/dvha-core";
2
+ import { useMessage as N, NButton as b, NDropdown as W } from "naive-ui";
3
3
  import { h as l } from "vue";
4
- import { useRouter as I } from "vue-router";
5
- import { useDialog as N } from "./dialog.js";
6
- import { useDrawer as W } from "./drawer.js";
7
- import { useModal as $ } from "./modal.js";
8
- function K(o) {
9
- const u = $(), i = W(), m = N(), {
4
+ import { useRouter as $, useRoute as B } from "vue-router";
5
+ import { useDialog as E } from "./dialog.js";
6
+ import { useDrawer as T } from "./drawer.js";
7
+ import { useModal as q } from "./modal.js";
8
+ function V(a) {
9
+ const u = q(), i = T(), m = E(), {
10
10
  t: n
11
- } = h(), d = D(), g = A(), w = I(), P = M({
11
+ } = h(), d = N(), g = S(), w = $(), P = B(), {
12
+ invalidate: k
13
+ } = D(), v = I({
12
14
  onSuccess: (t) => {
13
- d.success(t.message || n("common.success"));
15
+ d.success(t.message || n("common.success")), k(a?.invalidate || P.path);
14
16
  },
15
17
  onError: (t) => {
16
18
  d.error(t.message || n("common.error"));
17
19
  }
18
- }), k = S({
20
+ }), j = C({
19
21
  onSuccess: (t) => {
20
22
  d.success(t.message || n("common.success"));
21
23
  },
22
24
  onError: (t) => {
23
25
  d.error(t.message || n("common.error"));
24
26
  }
25
- }), r = o?.path || g.getPath(), f = (t) => {
27
+ }), r = a?.path || g.getPath(), f = (t) => {
26
28
  const c = n(t.item.title || "", {}, t.item.title), s = n(t.item.label || "", {}, t.item.label);
27
29
  if (t.item.type === "modal") {
28
- const e = t.item, a = typeof e.componentProps == "function" ? e.componentProps(t.data) : e.componentProps;
30
+ const e = t.item, o = typeof e.componentProps == "function" ? e.componentProps(t.data) : e.componentProps;
29
31
  u.show({
30
32
  title: c || s,
31
33
  component: e.component,
32
34
  componentProps: {
33
35
  id: t.id,
34
- ...a
36
+ ...o
35
37
  },
36
38
  width: e.width,
37
39
  draggable: e.draggable !== void 0 ? e.draggable : !0
38
40
  });
39
41
  }
40
42
  if (t.item.type === "drawer") {
41
- const e = t.item, a = typeof e.componentProps == "function" ? e.componentProps(t.data) : e.componentProps;
43
+ const e = t.item, o = typeof e.componentProps == "function" ? e.componentProps(t.data) : e.componentProps;
42
44
  i.show({
43
45
  title: c || s,
44
46
  component: e.component,
45
47
  componentProps: {
46
48
  id: t.id,
47
- ...a
49
+ ...o
48
50
  },
49
51
  width: e.width,
50
52
  maxWidth: e.maxWidth
@@ -55,8 +57,8 @@ function K(o) {
55
57
  m.confirm({
56
58
  title: c || s,
57
59
  content: e.content
58
- }).then((a) => {
59
- a && e.callback?.(t.id, t.data);
60
+ }).then((o) => {
61
+ o && e.callback?.(t.id, t.data);
60
62
  });
61
63
  }
62
64
  if (t.item.type === "request") {
@@ -65,11 +67,11 @@ function K(o) {
65
67
  title: c || s,
66
68
  content: e.content
67
69
  }).then(() => {
68
- const a = typeof e.data == "function" ? e.data(t.id, t.data) : e.data, j = (e.method || "post").toLowerCase(), v = typeof e.path == "function" ? e.path(t.id, t.data) : e.path || r;
69
- P.mutate({
70
- path: v,
71
- method: j,
72
- payload: a
70
+ const o = typeof e.data == "function" ? e.data(t.id, t.data) : e.data, A = (e.method || "post").toLowerCase(), M = typeof e.path == "function" ? e.path(t.id, t.data) : e.path || r;
71
+ v.mutate({
72
+ path: M,
73
+ method: A,
74
+ payload: o
73
75
  });
74
76
  });
75
77
  }
@@ -79,7 +81,7 @@ function K(o) {
79
81
  title: c || s,
80
82
  content: e.content
81
83
  }).then(() => {
82
- k.mutate({
84
+ j.mutate({
83
85
  id: t.id,
84
86
  path: typeof e.path == "function" ? e.path(t.id, t.data) : e.path || r
85
87
  });
@@ -87,49 +89,49 @@ function K(o) {
87
89
  }
88
90
  if (t.item.type === "link") {
89
91
  const e = t.item;
90
- let a = typeof e.path == "function" ? e.path?.(t.id, t.data) : t.id ? `${e.path || r}${t.data === void 0 ? "" : `/${t.id}`}` : e.path || r;
91
- a.startsWith("/") || (a = g.getRoutePath(a)), w.push(a);
92
+ let o = typeof e.path == "function" ? e.path?.(t.id, t.data) : t.id ? `${e.path || r}${t.data === void 0 ? "" : `/${t.id}`}` : e.path || r;
93
+ o.startsWith("/") || (o = g.getRoutePath(o)), w.push(o);
92
94
  }
93
95
  t.item.type === "callback" && t.item.callback?.(t.id, t.data);
94
- }, y = B(), x = E();
96
+ }, y = L(), x = _();
95
97
  return {
96
98
  target: f,
97
99
  renderTable: (t) => (c, s) => {
98
100
  const e = {
99
- id: c[t.key || o?.key || "id"],
101
+ id: c[t.key || a?.key || "id"],
100
102
  data: c,
101
103
  index: s,
102
104
  target: f,
103
- text: t.text !== void 0 ? t.text : o?.text || !1,
104
- align: t.align !== void 0 ? t.align : o?.align || "left"
105
+ text: t.text !== void 0 ? t.text : a?.text || !1,
106
+ align: t.align !== void 0 ? t.align : a?.align || "left"
105
107
  };
106
- return (t.type || o?.type) === "button" ? y.render({
108
+ return (t.type || a?.type) === "button" ? y.render({
107
109
  ...e,
108
- action: t || o
110
+ action: t || a
109
111
  }) : x.render({
110
112
  ...e,
111
- action: t || o
113
+ action: t || a
112
114
  });
113
115
  },
114
116
  renderAction: (t) => {
115
117
  const c = {
116
118
  target: f,
117
- text: t.text !== void 0 ? t.text : o?.text || !1,
118
- align: t.align !== void 0 ? t.align : o?.align || "left"
119
+ text: t.text !== void 0 ? t.text : a?.text || !1,
120
+ align: t.align !== void 0 ? t.align : a?.align || "left"
119
121
  };
120
- return (t.type || o?.type) === "button" ? y.render({
122
+ return (t.type || a?.type) === "button" ? y.render({
121
123
  ...c,
122
- action: t || o
124
+ action: t || a
123
125
  }) : x.render({
124
126
  ...c,
125
- action: t || o
127
+ action: t || a
126
128
  });
127
129
  }
128
130
  };
129
131
  }
130
- function B() {
132
+ function L() {
131
133
  const {
132
- t: o
134
+ t: a
133
135
  } = h();
134
136
  return {
135
137
  render: (i) => {
@@ -148,21 +150,21 @@ function B() {
148
150
  renderIcon: n.icon ? () => l("div", {
149
151
  class: ["n-icon", n.icon]
150
152
  }) : void 0
151
- }, () => o(n.label || "", {}, n.label)));
153
+ }, () => a(n.label || "", {}, n.label)));
152
154
  return l("div", {
153
155
  class: ["flex gap-2 flex-wrap items-center", i.align === "right" ? "justify-end" : i.align === "center" ? "justify-center" : "justify-start"]
154
156
  }, m);
155
157
  }
156
158
  };
157
159
  }
158
- function E() {
160
+ function _() {
159
161
  const {
160
- t: o
162
+ t: a
161
163
  } = h();
162
164
  return {
163
165
  render: (i) => {
164
166
  const m = i.action.items?.filter((n) => !n.show || n.show?.(i.data, i.index)).map((n, d) => ({
165
- label: o(n.label || "", {}, n.label),
167
+ label: a(n.label || "", {}, n.label),
166
168
  key: d,
167
169
  icon: n.icon ? () => l("div", {
168
170
  class: ["n-icon", n.icon]
@@ -175,7 +177,7 @@ function E() {
175
177
  });
176
178
  }
177
179
  }));
178
- return l(C, {
180
+ return l(W, {
179
181
  trigger: "click",
180
182
  options: m,
181
183
  onSelect: (n, d) => {
@@ -195,7 +197,7 @@ function E() {
195
197
  };
196
198
  }
197
199
  export {
198
- K as useAction,
199
- B as useActionButton,
200
- E as useActionDropdown
200
+ V as useAction,
201
+ L as useActionButton,
202
+ _ as useActionDropdown
201
203
  };
@@ -1,5 +1,5 @@
1
1
  const r = `/* layer: properties */
2
- @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*, ::before, ::after, ::backdrop{--un-text-opacity:100%;--un-bg-opacity:100%;--un-from-opacity:100%;--un-divide-y-reverse:initial;--un-border-style:solid;--un-divide-x-reverse:initial;--un-divide-opacity:100%;--un-shadow-opacity:100%;--un-border-opacity:100%;--un-ease:initial;--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-to-opacity:100%;--un-outline-style:solid;--un-fill-opacity:100%;}}
2
+ @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*, ::before, ::after, ::backdrop{--un-from-opacity:100%;--un-text-opacity:100%;--un-bg-opacity:100%;--un-divide-y-reverse:initial;--un-border-style:solid;--un-divide-x-reverse:initial;--un-divide-opacity:100%;--un-shadow-opacity:100%;--un-ease:initial;--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-border-opacity:100%;--un-to-opacity:100%;--un-outline-style:solid;--un-fill-opacity:100%;}}
3
3
  @property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
4
4
  @property --un-outline-style{syntax:"*";inherits:false;initial-value:solid;}
5
5
  @property --un-border-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
@@ -54,6 +54,7 @@ export interface UseActionProps {
54
54
  text?: boolean;
55
55
  path?: string;
56
56
  key?: string;
57
+ invalidate?: string;
57
58
  }
58
59
  export interface UseActionTarget {
59
60
  id?: unknown;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@duxweb/dvha-pro",
3
3
  "type": "module",
4
- "version": "1.0.42",
4
+ "version": "1.0.44",
5
5
  "author": "DuxWeb",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -33,8 +33,8 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@ant-design/colors": "^7.2.1",
36
- "@duxweb/dvha-core": "^1.0.42",
37
- "@duxweb/dvha-naiveui": "^1.0.42",
36
+ "@duxweb/dvha-core": "^1.0.44",
37
+ "@duxweb/dvha-naiveui": "^1.0.44",
38
38
  "@iconify-json/tabler": "^1.2.18",
39
39
  "@overlastic/vue": "^0.8.1",
40
40
  "@tanstack/vue-query": "^5.80.7",