1- import type { SearchConfig , DefaultOptionType } from '@/Select' ;
1+ import type { SearchConfig , DefaultOptionType , SelectProps } from '@/Select' ;
22import * as React from 'react' ;
33const legacySearchProps = [
44 'filterOption' ,
@@ -11,7 +11,7 @@ const legacySearchProps = [
1111// Convert `showSearch` to unique config
1212export default function useSearchConfig (
1313 showSearch : boolean | SearchConfig < DefaultOptionType > | undefined ,
14- props : any ,
14+ props : SelectProps ,
1515) {
1616 const {
1717 filterOption,
@@ -22,19 +22,25 @@ export default function useSearchConfig(
2222 autoClearSearchValue,
2323 } = props || { } ;
2424 return React . useMemo < [ boolean | undefined , SearchConfig < DefaultOptionType > ] > ( ( ) => {
25- const legacyShowSearch : SearchConfig < DefaultOptionType > = { } ;
26- legacySearchProps . forEach ( ( name ) => {
27- const val = props ?. [ name ] ;
28- if ( val !== undefined ) legacyShowSearch [ name ] = val ;
29- } ) ;
30- const searchConfig : SearchConfig < DefaultOptionType > =
31- typeof showSearch === 'object' ? showSearch : legacyShowSearch ;
32- if ( showSearch === undefined ) {
33- return [ undefined , searchConfig ] ;
25+ const legacyShowSearch : SearchConfig < DefaultOptionType > = {
26+ filterOption,
27+ searchValue,
28+ optionFilterProp,
29+ filterSort,
30+ onSearch,
31+ autoClearSearchValue,
32+ } ;
33+
34+ if ( showSearch === undefined || showSearch === true ) {
35+ return [ showSearch as undefined | boolean , legacyShowSearch ] ;
3436 }
3537 if ( ! showSearch ) {
3638 return [ false , { } ] ;
3739 }
40+ const searchConfig = {
41+ ...legacyShowSearch ,
42+ ...showSearch ,
43+ } ;
3844 return [ true , searchConfig ] ;
3945 } , [
4046 showSearch ,
0 commit comments