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,7 @@ type AutoCompleteInputPropsWithContext = TextInputProps &
3736 * that would happen if we put this in the MessageInputContext
3837 */
3938 cooldownActive ?: boolean ;
39+ TextInputComponent ?: React . ComponentType < TextInputProps > ;
4040 } ;
4141
4242type AutoCompleteInputProps = Partial < AutoCompleteInputPropsWithContext > ;
@@ -53,7 +53,7 @@ const configStateSelector = (state: MessageComposerConfig) => ({
5353const MAX_NUMBER_OF_LINES = 5 ;
5454
5555const AutoCompleteInputWithContext = ( props : AutoCompleteInputPropsWithContext ) => {
56- const { channel, cooldownActive = false , setInputBoxRef, t, ...rest } = props ;
56+ const { channel, cooldownActive = false , setInputBoxRef, t, TextInputComponent , ...rest } = props ;
5757 const [ localText , setLocalText ] = useState ( '' ) ;
5858 const [ textHeight , setTextHeight ] = useState ( 0 ) ;
5959 const messageComposer = useMessageComposer ( ) ;
@@ -74,7 +74,7 @@ const AutoCompleteInputWithContext = (props: AutoCompleteInputPropsWithContext)
7474 } , [ text ] ) ;
7575
7676 const handleSelectionChange = useCallback (
77- ( e : NativeSyntheticEvent < TextInputSelectionChangeEventData > ) => {
77+ ( e : TextInputSelectionChangeEvent ) => {
7878 const { selection } = e . nativeEvent ;
7979 textComposer . setSelection ( selection ) ;
8080 } ,
@@ -108,16 +108,18 @@ const AutoCompleteInputWithContext = (props: AutoCompleteInputPropsWithContext)
108108 } , [ command , cooldownActive , t ] ) ;
109109
110110 const handleContentSizeChange = useCallback (
111- ( {
112- nativeEvent : { contentSize } ,
113- } : NativeSyntheticEvent < TextInputContentSizeChangeEventData > ) => {
111+ ( { nativeEvent : { contentSize } } : TextInputContentSizeChangeEvent ) => {
114112 setTextHeight ( contentSize . height ) ;
115113 } ,
116114 [ ] ,
117115 ) ;
118116
117+ if ( TextInputComponent ) {
118+ return < TextInputComponent { ...rest } /> ;
119+ }
120+
119121 return (
120- < TextInput
122+ < RNTextInput
121123 autoFocus = { ! ! command }
122124 editable = { enabled }
123125 maxLength = { maxMessageLength }
0 commit comments