@@ -9,13 +9,13 @@ const defaultFilter: ShowSearchType['filter'] = (search, options, { label = '' }
9
9
const defaultRender : ShowSearchType [ 'render' ] = ( inputValue , path , prefixCls , fieldNames ) =>
10
10
path . map ( opt => opt [ fieldNames . label as string ] ) . join ( ' / ' ) ;
11
11
12
- export default (
12
+ const useSearchOptions = (
13
13
search : string ,
14
14
options : DefaultOptionType [ ] ,
15
15
fieldNames : InternalFieldNames ,
16
16
prefixCls : string ,
17
17
config : ShowSearchType ,
18
- changeOnSelect ?: boolean ,
18
+ enableHalfPath ?: boolean ,
19
19
) => {
20
20
const { filter = defaultFilter , render = defaultRender , limit = 50 , sort } = config ;
21
21
@@ -46,8 +46,8 @@ export default (
46
46
// If is leaf option
47
47
! children ||
48
48
children . length === 0 ||
49
- // If is changeOnSelect
50
- changeOnSelect
49
+ // If is changeOnSelect or multiple
50
+ enableHalfPath
51
51
) {
52
52
if ( filter ( search , connectedPathOptions , { label : fieldNames . label } ) ) {
53
53
filteredOptions . push ( {
@@ -87,5 +87,7 @@ export default (
87
87
return limit !== false && limit > 0
88
88
? filteredOptions . slice ( 0 , limit as number )
89
89
: filteredOptions ;
90
- } , [ search , options , fieldNames , prefixCls , render , changeOnSelect , filter , sort , limit ] ) ;
90
+ } , [ search , options , fieldNames , prefixCls , render , enableHalfPath , filter , sort , limit ] ) ;
91
91
} ;
92
+
93
+ export default useSearchOptions ;
0 commit comments