import React from 'react' import { NativeSyntheticEvent, StyleProp, TextInputSelectionChangeEventData, TextStyle, } from 'react-native' import PasteInput, { PastedFile, PasteInputRef, } from '@mattermost/react-native-paste-input' import {usePalette} from 'lib/hooks/usePalette' export type TextInputRef = PasteInputRef interface TextInputProps { testID: string innerRef: React.Ref placeholder: string style: StyleProp onChangeText: (str: string) => void onSelectionChange?: | ((e: NativeSyntheticEvent) => void) | undefined onPaste: (err: string | undefined, uris: string[]) => void } export function TextInput({ testID, innerRef, placeholder, style, onChangeText, onSelectionChange, onPaste, children, }: React.PropsWithChildren) { const pal = usePalette('default') const onPasteInner = (err: string | undefined, files: PastedFile[]) => { if (err) { onPaste(err, []) } else { onPaste( undefined, files.map(f => f.uri), ) } } return ( onChangeText(str)} onSelectionChange={onSelectionChange} onPaste={onPasteInner} placeholder={placeholder} placeholderTextColor={pal.colors.textLight} style={style}> {children} ) }