@@ -4,11 +4,17 @@ import BottomSheet, {
4
4
BottomSheetModal as BSModal ,
5
5
BottomSheetModalProvider ,
6
6
BottomSheetScrollView as BSScrollView ,
7
+ BottomSheetTextInput as BSTextInput ,
7
8
BottomSheetView as BSView ,
8
9
} from '@gorhom/bottom-sheet'
10
+ import { BottomSheetTextInputProps } from '@gorhom/bottom-sheet/lib/typescript/components/bottomSheetTextInput'
9
11
import { cssInterop } from 'nativewind'
10
12
import React , { forwardRef , Fragment } from 'react'
13
+ import { View } from 'react-native'
11
14
15
+ import { cn } from '~/lib/utils'
16
+
17
+ import { Text } from '../text'
12
18
import { BottomSheetProps , BSHandleProps } from './types'
13
19
14
20
const BottomSheetTrigger = Fragment
@@ -38,13 +44,46 @@ const BottomSheetScrollView = cssInterop(BSScrollView, {
38
44
39
45
const BottomSheetHandle : React . FC < BSHandleProps > = BSHandle
40
46
47
+ const BottomSheetTextInput = forwardRef <
48
+ React . ComponentRef < typeof BSTextInput > ,
49
+ BottomSheetTextInputProps & { label ?: string ; errorMessage ?: string }
50
+ > ( ( { label, errorMessage, ...rest } , ref ) => {
51
+ const InputComponent = cssInterop ( BSTextInput , {
52
+ className : 'style' ,
53
+ } )
54
+
55
+ return (
56
+ < View className = "w-full gap-1.5" >
57
+ { label && < Text className = "text-base font-medium text-foreground-muted" > { label } </ Text > }
58
+ < InputComponent
59
+ ref = { ref }
60
+ { ...rest }
61
+ className = { cn (
62
+ 'native:h-12 native:text-lg native:leading-[1.25] h-10 rounded-lg border border-edge bg-background px-3 text-base text-foreground file:border-0 file:bg-transparent file:font-medium lg:text-sm' ,
63
+ rest . editable === false && 'opacity-50' ,
64
+ { 'border-edge-danger' : ! ! errorMessage } ,
65
+ rest . className ,
66
+ ) }
67
+ placeholderClassName = { cn (
68
+ 'text-foreground-muted' ,
69
+ { 'text-fill-danger' : ! ! errorMessage } ,
70
+ rest . placeholderClassName ,
71
+ ) }
72
+ />
73
+ { errorMessage && < Text className = "text-sm text-fill-danger" > { errorMessage } </ Text > }
74
+ </ View >
75
+ )
76
+ } )
77
+ BottomSheetTextInput . displayName = 'BottomSheetTextInput'
78
+
41
79
type TypedBottomSheet = typeof BottomSheet & {
42
80
Provider : typeof BottomSheetModalProvider
43
81
Modal : typeof BottomSheetModal
44
82
Handle : typeof BottomSheetHandle
45
83
ScrollView : typeof BottomSheetScrollView
46
84
View : typeof BottomSheetView
47
85
Trigger : typeof BottomSheetTrigger
86
+ Input : typeof BottomSheetTextInput
48
87
}
49
88
50
89
const TypedBottomSheet = BottomSheet as TypedBottomSheet
@@ -54,5 +93,6 @@ TypedBottomSheet.Handle = BottomSheetHandle
54
93
TypedBottomSheet . ScrollView = BottomSheetScrollView
55
94
TypedBottomSheet . View = BottomSheetView
56
95
TypedBottomSheet . Trigger = BottomSheetTrigger
96
+ TypedBottomSheet . Input = BottomSheetTextInput
57
97
58
98
export { TypedBottomSheet as BottomSheet }
0 commit comments