@@ -106,17 +106,26 @@ export type SelectHandler<ValueType, OptionType extends BaseOptionType = Default
106106) => void ;
107107
108108type ArrayElementType < T > = T extends ( infer E ) [ ] ? E : T ;
109-
109+ interface ShowSearch < OptionType > {
110+ searchValue ?: string ;
111+ autoClearSearchValue ?: boolean ;
112+ onSearch ?: ( value : string ) => void ;
113+ tokenSeparators ?: string | string [ ] ;
114+ filterOption ?: boolean | FilterFunc < OptionType > ;
115+ filterSort ?: ( optionA : OptionType , optionB : OptionType , info : { searchValue : string } ) => number ;
116+ optionFilterProp ?: string ;
117+ optionLabelProp ?: string ;
118+ }
110119export interface SelectProps < ValueType = any , OptionType extends BaseOptionType = DefaultOptionType >
111- extends BaseSelectPropsWithoutPrivate {
120+ extends Omit < BaseSelectPropsWithoutPrivate , 'showSearch' > {
112121 prefixCls ?: string ;
113122 id ?: string ;
114123
115124 backfill ?: boolean ;
116125
117126 // >>> Field Names
118127 fieldNames ?: FieldNames ;
119-
128+ showSearch ?: boolean | ShowSearch < OptionType > ;
120129 searchValue ?: string ;
121130 onSearch ?: ( value : string ) => void ;
122131 autoClearSearchValue ?: boolean ;
@@ -171,22 +180,12 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
171180 prefixCls = 'rc-select' ,
172181 backfill,
173182 fieldNames,
174-
175183 // Search
176- searchValue,
177- onSearch,
178- autoClearSearchValue = true ,
179-
184+ showSearch,
180185 // Select
181186 onSelect,
182187 onDeselect,
183188 popupMatchSelectWidth = true ,
184-
185- // Options
186- filterOption,
187- filterSort,
188- optionFilterProp,
189- optionLabelProp,
190189 options,
191190 optionRender,
192191 children,
@@ -208,6 +207,31 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
208207 ...restProps
209208 } = props ;
210209
210+ const legacySearchProps = [
211+ 'filterOption' ,
212+ 'searchValue' ,
213+ 'optionFilterProp' ,
214+ 'optionLabelProp' ,
215+ 'filterSort' ,
216+ 'onSearch' ,
217+ 'autoClearSearchValue' ,
218+ 'tokenSeparators' ,
219+ ] ;
220+ const legacyShowSearch : ShowSearch < DefaultOptionType > = { } ;
221+ legacySearchProps . forEach ( ( propsName ) => {
222+ legacyShowSearch [ propsName ] = restProps ?. [ propsName ] ;
223+ } ) ;
224+ const mergedShowSearch = typeof showSearch === 'object' ? showSearch : legacyShowSearch ;
225+ const {
226+ filterOption,
227+ searchValue,
228+ optionFilterProp,
229+ optionLabelProp,
230+ filterSort,
231+ onSearch,
232+ autoClearSearchValue,
233+ } = mergedShowSearch ;
234+
211235 const mergedId = useId ( id ) ;
212236 const multiple = isMultiple ( mode ) ;
213237 const childrenAsData = ! ! ( ! options && children ) ;
@@ -671,6 +695,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
671695 // >>> Trigger
672696 direction = { direction }
673697 // >>> Search
698+ showSearch = { showSearch === undefined ? undefined : ! ! showSearch }
674699 searchValue = { mergedSearchValue }
675700 onSearch = { onInternalSearch }
676701 autoClearSearchValue = { autoClearSearchValue }
0 commit comments