11import React , { useCallback , useEffect , useMemo , useState } from 'react' ;
22import {
33 I18nManager ,
4- NativeSyntheticEvent ,
4+ TextInput as RNTextInput ,
55 StyleSheet ,
6- TextInput ,
7- TextInputContentSizeChangeEventData ,
6+ TextInputContentSizeChangeEvent ,
87 TextInputProps ,
9- TextInputSelectionChangeEventData ,
8+ TextInputSelectionChangeEvent ,
109} from 'react-native' ;
1110
1211import { MessageComposerConfig , TextComposerState } from 'stream-chat' ;
@@ -37,6 +36,11 @@ type AutoCompleteInputPropsWithContext = TextInputProps &
3736 * that would happen if we put this in the MessageInputContext
3837 */
3938 cooldownActive ?: boolean ;
39+ TextInputComponent ?: React . ComponentType <
40+ TextInputProps & {
41+ ref : React . Ref < RNTextInput > | undefined ;
42+ }
43+ > ;
4044 } ;
4145
4246type AutoCompleteInputProps = Partial < AutoCompleteInputPropsWithContext > ;
@@ -53,7 +57,14 @@ const configStateSelector = (state: MessageComposerConfig) => ({
5357const MAX_NUMBER_OF_LINES = 5 ;
5458
5559const AutoCompleteInputWithContext = ( props : AutoCompleteInputPropsWithContext ) => {
56- const { channel, cooldownActive = false , setInputBoxRef, t, ...rest } = props ;
60+ const {
61+ channel,
62+ cooldownActive = false ,
63+ setInputBoxRef,
64+ t,
65+ TextInputComponent = RNTextInput ,
66+ ...rest
67+ } = props ;
5768 const [ localText , setLocalText ] = useState ( '' ) ;
5869 const [ textHeight , setTextHeight ] = useState ( 0 ) ;
5970 const messageComposer = useMessageComposer ( ) ;
@@ -74,7 +85,7 @@ const AutoCompleteInputWithContext = (props: AutoCompleteInputPropsWithContext)
7485 } , [ text ] ) ;
7586
7687 const handleSelectionChange = useCallback (
77- ( e : NativeSyntheticEvent < TextInputSelectionChangeEventData > ) => {
88+ ( e : TextInputSelectionChangeEvent ) => {
7889 const { selection } = e . nativeEvent ;
7990 textComposer . setSelection ( selection ) ;
8091 } ,
@@ -108,16 +119,14 @@ const AutoCompleteInputWithContext = (props: AutoCompleteInputPropsWithContext)
108119 } , [ command , cooldownActive , t ] ) ;
109120
110121 const handleContentSizeChange = useCallback (
111- ( {
112- nativeEvent : { contentSize } ,
113- } : NativeSyntheticEvent < TextInputContentSizeChangeEventData > ) => {
122+ ( { nativeEvent : { contentSize } } : TextInputContentSizeChangeEvent ) => {
114123 setTextHeight ( contentSize . height ) ;
115124 } ,
116125 [ ] ,
117126 ) ;
118127
119128 return (
120- < TextInput
129+ < TextInputComponent
121130 autoFocus = { ! ! command }
122131 editable = { enabled }
123132 maxLength = { maxMessageLength }
0 commit comments