@duxweb/dvha-naiveui 1.1.19 → 1.1.20
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 a=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),x=require("@duxweb/dvha-core"),F=require("@vueuse/core"),C=require("lodash-es"),l=require("naive-ui");function O(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!a.isVNode(e)}const I=a.defineComponent({name:"DuxSelect",props:{path:String,params:Object,pagination:{type:Boolean,default:!0},avatarField:{type:String},imageField:{type:String},descField:{type:String},multiple:Boolean,option:{type:[Object,Array],default:void 0}},extends:l.NSelect,setup(e,{emit:u,slots:i}){const o=a.toRef(e,"params",{}),N=a.toRef(e,"path"),s=F.useVModel(e,"value",u,{passive:!0,defaultValue:e.defaultValue}),g=F.useVModel(e,"option",u,{passive:!0,defaultValue:e.multiple?[]:null}),n=a.toRef(e,"labelField","name"),j=a.toRef(e,"valueField","id"),f=a.toRef(e,"avatarField",""),c=a.toRef(e,"imageField",""),d=a.toRef(e,"descField",""),{onSearch:w,loading:A,pagination:m,options:V,pageCount:R}=x.useSelect({path:N,params:o,defaultValue:s,pagination:e.pagination,optionLabel:n.value,optionValue:j.value}),q=a.computed(()=>{const{labelField:t,valueField:v,avatarField:r,imageField:S,descField:b,option:p,...y}=e;return y}),h=t=>{if(e.multiple){C.isEqual(g.value,t)||(g.value=t||[]);return}g.value!==t&&(g.value=t||null)};return a.watch([s,V],([t,v])=>{if(e.multiple){const b=(Array.isArray(t)?t:[]).map(p=>v.find(y=>y.value===p)?.raw).filter(p=>!!p);h(b);return}const r=v.find(S=>S.value===t)?.raw||null;h(r)},{immediate:!0}),()=>a.createVNode(l.NSelect,a.mergeProps(q.value,{onSearch:w,loading:A.value,filterable:!!e.pagination,clearable:!0,remote:!0,options:V.value,value:s.value,"onUpdate:value":t=>s.value=t,multiple:e.multiple,onClear:()=>{w("")},renderLabel:t=>c.value||d.value?a.createVNode(l.NSpace,{align:"center",size:"small",wrapItem:!1,style:{padding:"6px 0"}},{default:()=>[c.value&&a.createVNode(l.NImage,{src:t?.raw?.[c.value],objectFit:"cover",width:32,height:32},null),f.value&&a.createVNode(l.NAvatar,{round:!0,src:t?.raw?.[f.value],size:32},{default:()=>[t?.raw?.[n.value]?.charAt?.(0)]}),a.createVNode(l.NSpace,{vertical:!0,size:0,wrapItem:!1},{default:()=>[a.createVNode("div",null,[t?.raw?.[n.value]]),d.value&&a.createVNode("div",{style:{opacity:.6}},[t?.raw?.[d.value]])]})]}):t?.raw?.[n.value],renderTag:({option:t,handleClose:v})=>{let r;return e.multiple?a.createVNode(l.NTag,{type:"primary",size:e.size,closable:!0,round:!0,onClose:()=>{v()},style:{"--n-padding":"0"}},O(r=z(t,n.value,c.value,f.value,d.value))?r:{default:()=>[r]}):z(t,n.value,c.value,f.value,d.value)}}),{action:()=>e.pagination?a.createVNode(l.NPagination,{size:"small",page:m.value.page,"onUpdate:page":t=>m.value.page=t,pageSlot:3,pageCount:R.value,pageSize:m.value.pageSize},null):null,...i})}});function z(e,u,i,o,N){return i||N||o?a.createVNode(l.NSpace,{align:"center",size:"small",style:{padding:"6px 0"},wrapItem:!1},{default:()=>[i&&a.createVNode(l.NImage,{src:e?.raw?.[i],objectFit:"cover",width:22,height:22},null),o&&a.createVNode(l.NAvatar,{round:!0,src:e?.raw?.[o]||"",size:22},{default:()=>[e?.raw?.[u]?.charAt?.(0)]}),a.createVNode("div",null,[e?.raw?.[u]])]}):e?.raw?.[u]||""}exports.DuxSelect=I;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useSelect as
|
|
3
|
-
import { useVModel as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { defineComponent as P, toRef as t, computed as T, watch as D, createVNode as l, mergeProps as U, isVNode as _ } from "vue";
|
|
2
|
+
import { useSelect as q } from "@duxweb/dvha-core";
|
|
3
|
+
import { useVModel as j } from "@vueuse/core";
|
|
4
|
+
import { isEqual as E } from "lodash-es";
|
|
5
|
+
import { NSelect as x, NTag as L, NSpace as h, NImage as V, NAvatar as C, NPagination as R } from "naive-ui";
|
|
6
|
+
function k(e) {
|
|
7
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !_(e);
|
|
7
8
|
}
|
|
8
|
-
const
|
|
9
|
+
const W = /* @__PURE__ */ P({
|
|
9
10
|
name: "DuxSelect",
|
|
10
11
|
props: {
|
|
11
12
|
path: String,
|
|
@@ -23,54 +24,78 @@ const E = /* @__PURE__ */ C({
|
|
|
23
24
|
descField: {
|
|
24
25
|
type: String
|
|
25
26
|
},
|
|
26
|
-
multiple: Boolean
|
|
27
|
+
multiple: Boolean,
|
|
28
|
+
option: {
|
|
29
|
+
type: [Object, Array],
|
|
30
|
+
default: void 0
|
|
31
|
+
}
|
|
27
32
|
},
|
|
28
|
-
extends:
|
|
33
|
+
extends: x,
|
|
29
34
|
setup(e, {
|
|
30
|
-
emit:
|
|
35
|
+
emit: u,
|
|
31
36
|
slots: r
|
|
32
37
|
}) {
|
|
33
|
-
const
|
|
38
|
+
const o = t(e, "params", {}), p = t(e, "path"), s = j(e, "value", u, {
|
|
34
39
|
passive: !0,
|
|
35
40
|
defaultValue: e.defaultValue
|
|
36
|
-
}),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
}), f = j(e, "option", u, {
|
|
42
|
+
passive: !0,
|
|
43
|
+
defaultValue: e.multiple ? [] : null
|
|
44
|
+
}), n = t(e, "labelField", "name"), O = t(e, "valueField", "id"), g = t(e, "avatarField", ""), d = t(e, "imageField", ""), c = t(e, "descField", ""), {
|
|
45
|
+
onSearch: F,
|
|
46
|
+
loading: I,
|
|
47
|
+
pagination: w,
|
|
48
|
+
options: b,
|
|
49
|
+
pageCount: B
|
|
50
|
+
} = q({
|
|
51
|
+
path: p,
|
|
52
|
+
params: o,
|
|
53
|
+
defaultValue: s,
|
|
46
54
|
pagination: e.pagination,
|
|
47
|
-
optionLabel:
|
|
48
|
-
optionValue:
|
|
49
|
-
}),
|
|
55
|
+
optionLabel: n.value,
|
|
56
|
+
optionValue: O.value
|
|
57
|
+
}), M = T(() => {
|
|
50
58
|
const {
|
|
51
59
|
labelField: a,
|
|
52
|
-
valueField:
|
|
53
|
-
avatarField:
|
|
54
|
-
imageField:
|
|
55
|
-
descField:
|
|
56
|
-
|
|
60
|
+
valueField: v,
|
|
61
|
+
avatarField: i,
|
|
62
|
+
imageField: y,
|
|
63
|
+
descField: N,
|
|
64
|
+
option: m,
|
|
65
|
+
...S
|
|
57
66
|
} = e;
|
|
58
|
-
return
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
return S;
|
|
68
|
+
}), z = (a) => {
|
|
69
|
+
if (e.multiple) {
|
|
70
|
+
E(f.value, a) || (f.value = a || []);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
f.value !== a && (f.value = a || null);
|
|
74
|
+
};
|
|
75
|
+
return D([s, b], ([a, v]) => {
|
|
76
|
+
if (e.multiple) {
|
|
77
|
+
const N = (Array.isArray(a) ? a : []).map((m) => v.find((S) => S.value === m)?.raw).filter((m) => !!m);
|
|
78
|
+
z(N);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const i = v.find((y) => y.value === a)?.raw || null;
|
|
82
|
+
z(i);
|
|
83
|
+
}, {
|
|
84
|
+
immediate: !0
|
|
85
|
+
}), () => l(x, U(M.value, {
|
|
86
|
+
onSearch: F,
|
|
87
|
+
loading: I.value,
|
|
63
88
|
filterable: !!e.pagination,
|
|
64
89
|
clearable: !0,
|
|
65
90
|
remote: !0,
|
|
66
|
-
options:
|
|
67
|
-
value:
|
|
68
|
-
"onUpdate:value": (a) =>
|
|
91
|
+
options: b.value,
|
|
92
|
+
value: s.value,
|
|
93
|
+
"onUpdate:value": (a) => s.value = a,
|
|
69
94
|
multiple: e.multiple,
|
|
70
95
|
onClear: () => {
|
|
71
|
-
|
|
96
|
+
F("");
|
|
72
97
|
},
|
|
73
|
-
renderLabel: (a) =>
|
|
98
|
+
renderLabel: (a) => d.value || c.value ? l(h, {
|
|
74
99
|
align: "center",
|
|
75
100
|
size: "small",
|
|
76
101
|
wrapItem: !1,
|
|
@@ -78,64 +103,64 @@ const E = /* @__PURE__ */ C({
|
|
|
78
103
|
padding: "6px 0"
|
|
79
104
|
}
|
|
80
105
|
}, {
|
|
81
|
-
default: () => [
|
|
82
|
-
src: a?.raw?.[
|
|
106
|
+
default: () => [d.value && l(V, {
|
|
107
|
+
src: a?.raw?.[d.value],
|
|
83
108
|
objectFit: "cover",
|
|
84
109
|
width: 32,
|
|
85
110
|
height: 32
|
|
86
|
-
}, null),
|
|
111
|
+
}, null), g.value && l(C, {
|
|
87
112
|
round: !0,
|
|
88
|
-
src: a?.raw?.[
|
|
113
|
+
src: a?.raw?.[g.value],
|
|
89
114
|
size: 32
|
|
90
115
|
}, {
|
|
91
|
-
default: () => [a?.raw?.[
|
|
92
|
-
}), l(
|
|
116
|
+
default: () => [a?.raw?.[n.value]?.charAt?.(0)]
|
|
117
|
+
}), l(h, {
|
|
93
118
|
vertical: !0,
|
|
94
119
|
size: 0,
|
|
95
120
|
wrapItem: !1
|
|
96
121
|
}, {
|
|
97
|
-
default: () => [l("div", null, [a?.raw?.[
|
|
122
|
+
default: () => [l("div", null, [a?.raw?.[n.value]]), c.value && l("div", {
|
|
98
123
|
style: {
|
|
99
124
|
opacity: 0.6
|
|
100
125
|
}
|
|
101
|
-
}, [a?.raw?.[
|
|
126
|
+
}, [a?.raw?.[c.value]])]
|
|
102
127
|
})]
|
|
103
|
-
}) : a?.raw?.[
|
|
128
|
+
}) : a?.raw?.[n.value],
|
|
104
129
|
renderTag: ({
|
|
105
130
|
option: a,
|
|
106
|
-
handleClose:
|
|
131
|
+
handleClose: v
|
|
107
132
|
}) => {
|
|
108
|
-
let
|
|
109
|
-
return e.multiple ? l(
|
|
133
|
+
let i;
|
|
134
|
+
return e.multiple ? l(L, {
|
|
110
135
|
type: "primary",
|
|
111
136
|
size: e.size,
|
|
112
137
|
closable: !0,
|
|
113
138
|
round: !0,
|
|
114
139
|
onClose: () => {
|
|
115
|
-
|
|
140
|
+
v();
|
|
116
141
|
},
|
|
117
142
|
style: {
|
|
118
143
|
"--n-padding": "0"
|
|
119
144
|
}
|
|
120
|
-
},
|
|
121
|
-
default: () => [
|
|
122
|
-
}) :
|
|
145
|
+
}, k(i = A(a, n.value, d.value, g.value, c.value)) ? i : {
|
|
146
|
+
default: () => [i]
|
|
147
|
+
}) : A(a, n.value, d.value, g.value, c.value);
|
|
123
148
|
}
|
|
124
149
|
}), {
|
|
125
|
-
action: () => e.pagination ? l(
|
|
150
|
+
action: () => e.pagination ? l(R, {
|
|
126
151
|
size: "small",
|
|
127
|
-
page:
|
|
128
|
-
"onUpdate:page": (a) =>
|
|
152
|
+
page: w.value.page,
|
|
153
|
+
"onUpdate:page": (a) => w.value.page = a,
|
|
129
154
|
pageSlot: 3,
|
|
130
|
-
pageCount:
|
|
131
|
-
pageSize:
|
|
155
|
+
pageCount: B.value,
|
|
156
|
+
pageSize: w.value.pageSize
|
|
132
157
|
}, null) : null,
|
|
133
158
|
...r
|
|
134
159
|
});
|
|
135
160
|
}
|
|
136
161
|
});
|
|
137
|
-
function
|
|
138
|
-
return r ||
|
|
162
|
+
function A(e, u, r, o, p) {
|
|
163
|
+
return r || p || o ? l(h, {
|
|
139
164
|
align: "center",
|
|
140
165
|
size: "small",
|
|
141
166
|
style: {
|
|
@@ -143,20 +168,20 @@ function F(e, n, r, i, s) {
|
|
|
143
168
|
},
|
|
144
169
|
wrapItem: !1
|
|
145
170
|
}, {
|
|
146
|
-
default: () => [r && l(
|
|
171
|
+
default: () => [r && l(V, {
|
|
147
172
|
src: e?.raw?.[r],
|
|
148
173
|
objectFit: "cover",
|
|
149
174
|
width: 22,
|
|
150
175
|
height: 22
|
|
151
|
-
}, null),
|
|
176
|
+
}, null), o && l(C, {
|
|
152
177
|
round: !0,
|
|
153
|
-
src: e?.raw?.[
|
|
178
|
+
src: e?.raw?.[o] || "",
|
|
154
179
|
size: 22
|
|
155
180
|
}, {
|
|
156
|
-
default: () => [e?.raw?.[
|
|
157
|
-
}), l("div", null, [e?.raw?.[
|
|
158
|
-
}) : e?.raw?.[
|
|
181
|
+
default: () => [e?.raw?.[u]?.charAt?.(0)]
|
|
182
|
+
}), l("div", null, [e?.raw?.[u]])]
|
|
183
|
+
}) : e?.raw?.[u] || "";
|
|
159
184
|
}
|
|
160
185
|
export {
|
|
161
|
-
|
|
186
|
+
W as DuxSelect
|
|
162
187
|
};
|
|
@@ -7,6 +7,7 @@ interface DuxSelectProps extends SelectProps {
|
|
|
7
7
|
imageField?: string;
|
|
8
8
|
descField?: string;
|
|
9
9
|
multiple?: boolean;
|
|
10
|
+
option?: Record<string, any> | Record<string, any>[] | null;
|
|
10
11
|
}
|
|
11
12
|
export declare const DuxSelect: import("vue").DefineComponent<DuxSelectProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DuxSelectProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
13
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duxweb/dvha-naiveui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.20",
|
|
5
5
|
"author": "DuxWeb",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"pinia": "^3.0.4",
|
|
34
34
|
"vue": "^3.5.24",
|
|
35
35
|
"vue-router": "^4.6.3",
|
|
36
|
-
"@duxweb/dvha-core": "1.1.
|
|
36
|
+
"@duxweb/dvha-core": "1.1.20"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"clean": "rimraf dist",
|