@@ -56,6 +56,7 @@ import type { FlattenOptionData } from './interface';
56
56
import { hasValue , isComboNoValue , toArray } from './utils/commonUtil' ;
57
57
import { fillFieldNames , flattenOptions , injectPropsWithOption } from './utils/valueUtil' ;
58
58
import warningProps , { warningNullOptions } from './utils/warningPropsUtil' ;
59
+ import useSearchConfig from './hooks/useSearchConfig' ;
59
60
60
61
const OMIT_DOM_PROPS = [ 'inputValue' ] ;
61
62
@@ -110,7 +111,7 @@ type ArrayElementType<T> = T extends (infer E)[] ? E : T;
110
111
111
112
export type SemanticName = BaseSelectSemanticName ;
112
113
export type PopupSemantic = 'listItem' | 'list' ;
113
- interface SearchConfig < OptionType > {
114
+ export interface SearchConfig < OptionType > {
114
115
searchValue ?: string ;
115
116
autoClearSearchValue ?: boolean ;
116
117
onSearch ?: ( value : string ) => void ;
@@ -226,21 +227,22 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
226
227
...restProps
227
228
} = props ;
228
229
229
- const legacySearchProps = [
230
- 'filterOption' ,
231
- 'searchValue' ,
232
- 'optionFilterProp' ,
233
- 'optionLabelProp' ,
234
- 'filterSort' ,
235
- 'onSearch' ,
236
- 'autoClearSearchValue' ,
237
- 'tokenSeparators' ,
238
- ] ;
239
- const legacyShowSearch : SearchConfig < DefaultOptionType > = { } ;
240
- legacySearchProps . forEach ( ( propsName ) => {
241
- legacyShowSearch [ propsName ] = props ?. [ propsName ] ;
242
- } ) ;
243
- const mergedShowSearch = typeof showSearch === 'object' ? showSearch : legacyShowSearch ;
230
+ // const legacySearchProps = [
231
+ // 'filterOption',
232
+ // 'searchValue',
233
+ // 'optionFilterProp',
234
+ // 'optionLabelProp',
235
+ // 'filterSort',
236
+ // 'onSearch',
237
+ // 'autoClearSearchValue',
238
+ // 'tokenSeparators',
239
+ // ];
240
+ // const legacyShowSearch: SearchConfig<DefaultOptionType> = {};
241
+ // legacySearchProps.forEach((propsName) => {
242
+ // legacyShowSearch[propsName] = props?.[propsName];
243
+ // });
244
+ const [ mergedShowSearch , searchConfig ] = useSearchConfig ( showSearch , props ) ;
245
+ // const mergedShowSearch = typeof showSearch === 'object' ? showSearch : legacyShowSearch;
244
246
const {
245
247
filterOption,
246
248
searchValue,
@@ -250,7 +252,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
250
252
onSearch,
251
253
autoClearSearchValue = true ,
252
254
tokenSeparators,
253
- } = mergedShowSearch ;
255
+ } = searchConfig ;
254
256
255
257
const mergedId = useId ( id ) ;
256
258
const multiple = isMultiple ( mode ) ;
@@ -734,7 +736,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
734
736
// >>> Trigger
735
737
direction = { direction }
736
738
// >>> Search
737
- showSearch = { showSearch === undefined ? undefined : ! ! showSearch }
739
+ showSearch = { mergedShowSearch }
738
740
searchValue = { mergedSearchValue }
739
741
onSearch = { onInternalSearch }
740
742
autoClearSearchValue = { autoClearSearchValue }
0 commit comments