@@ -18,6 +18,13 @@ import type {
1818 DefaultUserType ,
1919} from '../../types/types' ;
2020
21+ export type ChannelSearchFunctionParams < Us extends DefaultUserType < Us > = DefaultUserType > = {
22+ setQuery : React . Dispatch < React . SetStateAction < string > > ;
23+ setResults : React . Dispatch < React . SetStateAction < Array < UserResponse < Us > > > > ;
24+ setResultsOpen : React . Dispatch < React . SetStateAction < boolean > > ;
25+ setSearching : React . Dispatch < React . SetStateAction < boolean > > ;
26+ } ;
27+
2128export type SearchQueryParams < Us extends DefaultUserType < Us > = DefaultUserType > = {
2229 filters ?: UserFilters < Us > ;
2330 options ?: UserOptions ;
@@ -34,7 +41,10 @@ export type ChannelSearchProps<Us extends DefaultUserType<Us> = DefaultUserType>
3441 /** Custom UI component to display empty search results */
3542 SearchEmpty ?: React . ComponentType ;
3643 /** Custom search function to override default */
37- searchFunction ?: ( event : React . BaseSyntheticEvent ) => Promise < void > | void ;
44+ searchFunction ?: (
45+ params : ChannelSearchFunctionParams < Us > ,
46+ event : React . BaseSyntheticEvent ,
47+ ) => Promise < void > | void ;
3848 /** Custom UI component to display the search loading state */
3949 SearchLoading ?: React . ComponentType ;
4050 /** Object containing filters/sort/options overrides for user search */
@@ -144,10 +154,19 @@ const UnMemoizedChannelSearch = <
144154 getChannelsThrottled ( event . target . value ) ;
145155 } ;
146156
157+ const channelSearchParams = {
158+ setQuery,
159+ setResults,
160+ setResultsOpen,
161+ setSearching,
162+ } ;
163+
147164 return (
148165 < div className = 'str-chat__channel-search' >
149166 < input
150- onChange = { searchFunction || onSearch }
167+ onChange = { ( event ) =>
168+ searchFunction ? searchFunction ( channelSearchParams , event ) : onSearch ( event )
169+ }
151170 placeholder = { t ( 'Search' ) }
152171 ref = { inputRef }
153172 type = 'text'
0 commit comments