@@ -110,16 +110,26 @@ type ArrayElementType<T> = T extends (infer E)[] ? E : T;
110110
111111export type SemanticName = BaseSelectSemanticName ;
112112export type PopupSemantic = 'listItem' | 'list' ;
113+ interface ShowSearch < OptionType > {
114+ searchValue ?: string ;
115+ autoClearSearchValue ?: boolean ;
116+ onSearch ?: ( value : string ) => void ;
117+ tokenSeparators ?: string | string [ ] ;
118+ filterOption ?: boolean | FilterFunc < OptionType > ;
119+ filterSort ?: ( optionA : OptionType , optionB : OptionType , info : { searchValue : string } ) => number ;
120+ optionFilterProp ?: string ;
121+ optionLabelProp ?: string ;
122+ }
113123export interface SelectProps < ValueType = any , OptionType extends BaseOptionType = DefaultOptionType >
114- extends BaseSelectPropsWithoutPrivate {
124+ extends Omit < BaseSelectPropsWithoutPrivate , 'showSearch' > {
115125 prefixCls ?: string ;
116126 id ?: string ;
117127
118128 backfill ?: boolean ;
119129
120130 // >>> Field Names
121131 fieldNames ?: FieldNames ;
122-
132+ showSearch ?: boolean | ShowSearch < OptionType > ;
123133 searchValue ?: string ;
124134 onSearch ?: ( value : string ) => void ;
125135 autoClearSearchValue ?: boolean ;
@@ -176,22 +186,12 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
176186 prefixCls = 'rc-select' ,
177187 backfill,
178188 fieldNames,
179-
180189 // Search
181- searchValue,
182- onSearch,
183- autoClearSearchValue = true ,
184-
190+ showSearch,
185191 // Select
186192 onSelect,
187193 onDeselect,
188194 popupMatchSelectWidth = true ,
189-
190- // Options
191- filterOption,
192- filterSort,
193- optionFilterProp,
194- optionLabelProp,
195195 options,
196196 optionRender,
197197 children,
@@ -214,6 +214,31 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
214214 ...restProps
215215 } = props ;
216216
217+ const legacySearchProps = [
218+ 'filterOption' ,
219+ 'searchValue' ,
220+ 'optionFilterProp' ,
221+ 'optionLabelProp' ,
222+ 'filterSort' ,
223+ 'onSearch' ,
224+ 'autoClearSearchValue' ,
225+ 'tokenSeparators' ,
226+ ] ;
227+ const legacyShowSearch : ShowSearch < DefaultOptionType > = { } ;
228+ legacySearchProps . forEach ( ( propsName ) => {
229+ legacyShowSearch [ propsName ] = restProps ?. [ propsName ] ;
230+ } ) ;
231+ const mergedShowSearch = typeof showSearch === 'object' ? showSearch : legacyShowSearch ;
232+ const {
233+ filterOption,
234+ searchValue,
235+ optionFilterProp,
236+ optionLabelProp,
237+ filterSort,
238+ onSearch,
239+ autoClearSearchValue,
240+ } = mergedShowSearch ;
241+
217242 const mergedId = useId ( id ) ;
218243 const multiple = isMultiple ( mode ) ;
219244 const childrenAsData = ! ! ( ! options && children ) ;
@@ -685,6 +710,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
685710 // >>> Trigger
686711 direction = { direction }
687712 // >>> Search
713+ showSearch = { showSearch === undefined ? undefined : ! ! showSearch }
688714 searchValue = { mergedSearchValue }
689715 onSearch = { onInternalSearch }
690716 autoClearSearchValue = { autoClearSearchValue }
0 commit comments