about summary refs log tree commit diff
path: root/src/view/com/composer/text-input/TextInput.web.tsx
blob: 395f8e5a2a3015c5e4e596ad1a642f07c7bfe98c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react'
import {
  StyleProp,
  StyleSheet,
  TextInput as RNTextInput,
  TextStyle,
} from 'react-native'
import {usePalette} from '../../../lib/hooks/usePalette'
import {addStyle} from '../../../lib/addStyle'

export type TextInputRef = RNTextInput

interface TextInputProps {
  testID: string
  innerRef: React.Ref<TextInputRef>
  placeholder: string
  style: StyleProp<TextStyle>
  onChangeText: (str: string) => void
  onPaste: (err: string | undefined, uris: string[]) => void
}

export function TextInput({
  testID,
  innerRef,
  placeholder,
  style,
  onChangeText,
  children,
}: React.PropsWithChildren<TextInputProps>) {
  const pal = usePalette('default')
  style = addStyle(style, styles.input)
  return (
    <RNTextInput
      testID={testID}
      ref={innerRef}
      multiline
      scrollEnabled
      onChangeText={(str: string) => onChangeText(str)}
      placeholder={placeholder}
      placeholderTextColor={pal.colors.textLight}
      style={style}>
      {children}
    </RNTextInput>
  )
}

const styles = StyleSheet.create({
  input: {
    minHeight: 140,
  },
})