@@ -12,8 +12,9 @@ import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined';
12
12
import CaretDownOutlined from '@ant-design/icons-vue/CaretDownOutlined' ;
13
13
import DownOutlined from '@ant-design/icons-vue/DownOutlined' ;
14
14
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined' ;
15
- import CloseCircleOutlined from '@ant-design/icons-vue/CloseCircleOutlined ' ;
15
+ import CloseCircleFilled from '@ant-design/icons-vue/CloseCircleFilled ' ;
16
16
import omit from 'omit.js' ;
17
+ import { convertChildrenToData } from './utils' ;
17
18
18
19
const TreeSelect = defineComponent ( {
19
20
TreeNode,
@@ -41,7 +42,7 @@ const TreeSelect = defineComponent({
41
42
) ;
42
43
} ,
43
44
methods : {
44
- saveTreeSelect ( node ) {
45
+ saveTreeSelect ( node : any ) {
45
46
this . vcTreeSelect = node ;
46
47
} ,
47
48
focus ( ) {
@@ -51,7 +52,7 @@ const TreeSelect = defineComponent({
51
52
blur ( ) {
52
53
this . vcTreeSelect . blur ( ) ;
53
54
} ,
54
- renderSwitcherIcon ( prefixCls , { isLeaf, loading } ) {
55
+ renderSwitcherIcon ( prefixCls : string , { isLeaf, loading } ) {
55
56
if ( loading ) {
56
57
return < LoadingOutlined class = { `${ prefixCls } -switcher-loading-icon` } /> ;
57
58
}
@@ -60,19 +61,19 @@ const TreeSelect = defineComponent({
60
61
}
61
62
return < CaretDownOutlined class = { `${ prefixCls } -switcher-icon` } /> ;
62
63
} ,
63
- handleChange ( ...args ) {
64
+ handleChange ( ...args : any [ ] ) {
64
65
this . $emit ( 'update:value' , args [ 0 ] ) ;
65
66
this . $emit ( 'change' , ...args ) ;
66
67
} ,
67
- handleTreeExpand ( ...args ) {
68
+ handleTreeExpand ( ...args : any [ ] ) {
68
69
this . $emit ( 'update:treeExpandedKeys' , args [ 0 ] ) ;
69
70
this . $emit ( 'treeExpand' , ...args ) ;
70
71
} ,
71
- handleSearch ( ...args ) {
72
+ handleSearch ( ...args : any [ ] ) {
72
73
this . $emit ( 'update:searchValue' , args [ 0 ] ) ;
73
74
this . $emit ( 'search' , ...args ) ;
74
75
} ,
75
- updateTreeData ( treeData ) {
76
+ updateTreeData ( treeData : any [ ] ) {
76
77
const { $slots } = this ;
77
78
const defaultFields = {
78
79
children : 'children' ,
@@ -164,9 +165,7 @@ const TreeSelect = defineComponent({
164
165
165
166
const finalRemoveIcon = removeIcon || < CloseOutlined class = { `${ prefixCls } -remove-icon` } /> ;
166
167
167
- const finalClearIcon = clearIcon || (
168
- < CloseCircleOutlined class = { `${ prefixCls } -clear-icon` } theme = "filled" />
169
- ) ;
168
+ const finalClearIcon = clearIcon || < CloseCircleFilled class = { `${ prefixCls } -clear-icon` } /> ;
170
169
const VcTreeSelectProps = {
171
170
...this . $attrs ,
172
171
switcherIcon : nodeProps => this . renderSwitcherIcon ( prefixCls , nodeProps ) ,
@@ -181,13 +180,12 @@ const TreeSelect = defineComponent({
181
180
dropdownStyle : { maxHeight : '100vh' , overflow : 'auto' , ...dropdownStyle } ,
182
181
treeCheckable : checkable ,
183
182
notFoundContent : notFoundContent || renderEmpty ( 'Select' ) ,
184
- ...( treeData ? { treeData } : { } ) ,
185
183
class : cls ,
186
184
onChange : this . handleChange ,
187
185
onSearch : this . handleSearch ,
188
186
onTreeExpand : this . handleTreeExpand ,
189
187
ref : this . saveTreeSelect ,
190
- children : getSlot ( this ) ,
188
+ treeData : treeData ? treeData : convertChildrenToData ( getSlot ( this ) ) ,
191
189
} ;
192
190
return (
193
191
< VcTreeSelect
@@ -206,4 +204,12 @@ TreeSelect.install = function(app: App) {
206
204
return app ;
207
205
} ;
208
206
209
- export default TreeSelect ;
207
+ export default TreeSelect as typeof TreeSelect & {
208
+ readonly TreeNode : typeof TreeNode ;
209
+
210
+ readonly SHOW_ALL : typeof SHOW_ALL ;
211
+
212
+ readonly SHOW_PARENT : typeof SHOW_PARENT ;
213
+
214
+ readonly SHOW_CHILD : typeof SHOW_CHILD ;
215
+ } ;
0 commit comments