11import React from 'react' ;
2- import { View , Text , Pressable , ScrollView , TextInput } from 'react-native' ;
2+ import { View , Text , Pressable , ScrollView , TextInput , Image as NativeImage } from 'react-native' ;
33import { RuntimeProvider } from '@creatorem/ai-chat/runtime' ;
44import type { RuntimeHooks } from '@creatorem/ai-chat/hook-types' ;
55import type { RuntimeComponents } from "@creatorem/ai-chat/component-types" ;
@@ -10,6 +10,7 @@ import { useNativeHover } from './hooks/use-native-hover';
1010const NativeComponents : RuntimeComponents = {
1111 Box : ( { className, ...props } ) => < View { ...props } /> ,
1212 Text : ( { className, ...props } ) => < Text { ...props } /> ,
13+ Form : ( { className, onSubmit, ...props } ) => < View { ...props } /> ,
1314 Button : ( { className, onClick, ...props } ) => (
1415 < Pressable onPress = { onClick } { ...props } >
1516 { props . children }
@@ -18,17 +19,85 @@ const NativeComponents: RuntimeComponents = {
1819 ScrollArea : ( { className, ...props } ) => < ScrollView { ...props } /> ,
1920 Input : ( { className, onChange, ...props } ) => (
2021 < TextInput
21- onChangeText = { ( t ) => onChange ?.( { target : { value : t } } ) }
22+ onChangeText = { ( t ) => onChange ?.( { target : { value : t } } as any ) }
2223 { ...props }
2324 />
2425 ) ,
25- Textarea : ( { className, onChange, ...props } ) => (
26+ Textarea : ( { className, onChange, minRows , maxRows , onHeightChange , cacheMeasurements , rowHeight , ...props } ) => (
2627 < TextInput
2728 multiline
28- onChangeText = { ( t ) => onChange ?.( { target : { value : t } } ) }
29+ onChangeText = { ( t ) => onChange ?.( { target : { value : t } } as any ) }
2930 { ...props }
3031 />
31- )
32+ ) ,
33+
34+ // Action bar
35+ ActionBarRoot : ( { children, ...props } ) => < View { ...props } style = { [ { flexDirection : 'row' } , props . style ] } > { children } </ View > ,
36+ ActionBarPortal : ( { children } ) => < > { children } </ > ,
37+ ActionBarContent : ( { children, sideOffset, ...props } ) => < View { ...props } > { children } </ View > ,
38+ ActionBarItem : ( { children, ...props } ) => < View { ...props } > { children } </ View > ,
39+ ActionBarSeparator : ( { ...props } ) => < View { ...props } style = { [ { width : 1 , backgroundColor : '#ccc' , marginHorizontal : 4 } , props . style ] } /> ,
40+ ActionBarTrigger : ( { children, ...props } ) => < Pressable { ...props } > { children } </ Pressable > ,
41+
42+ // Thread List Item More
43+ ThreadListItemMoreRoot : ( { children, ...props } ) => < View { ...props } > { children } </ View > ,
44+ ThreadListItemMorePortal : ( { children } ) => < > { children } </ > ,
45+ ThreadListItemMoreContent : ( { children, sideOffset, ...props } ) => < View { ...props } > { children } </ View > ,
46+ ThreadListItemMoreItem : ( { children, ...props } ) => < Pressable { ...props } > { children } </ Pressable > ,
47+ ThreadListItemMoreSeparator : ( { ...props } ) => < View { ...props } style = { [ { height : 1 , backgroundColor : '#ccc' , marginVertical : 4 } , props . style ] } /> ,
48+ ThreadListItemMoreTrigger : ( { children, ...props } ) => < Pressable { ...props } > { children } </ Pressable > ,
49+
50+ // Content Components
51+ Markdown : ( { content, className, ...props } ) => < Text { ...props } > { content } </ Text > ,
52+ CodeBlock : ( { value, language, className, ...props } ) => (
53+ < View { ...props } style = { [ { backgroundColor : '#f0f0f0' , padding : 8 , borderRadius : 4 } , props . style ] } >
54+ < Text style = { { fontFamily : 'monospace' } } > { value } </ Text >
55+ </ View >
56+ ) ,
57+ Pre : ( { children, ...props } ) => < View { ...props } > { children } </ View > ,
58+
59+ // Media Components
60+ Image : ( { src, alt, className, ...props } ) => (
61+ < NativeImage source = { { uri : src } } accessibilityLabel = { alt } { ...props } style = { [ { width : 200 , height : 200 } , props . style ] } />
62+ ) ,
63+ Avatar : ( { src, fallback, className } ) => (
64+ < View style = { { width : 40 , height : 40 , borderRadius : 20 , overflow : 'hidden' , backgroundColor : '#e0e0e0' } } >
65+ { src ? < NativeImage source = { { uri : src } } style = { { width : '100%' , height : '100%' } } /> : < Text > { fallback } </ Text > }
66+ </ View >
67+ ) ,
68+
69+ // Attachments
70+ ComposerPrimitiveAddAttachment : ( { onClick, children, ...props } ) => (
71+ < Pressable onPress = { onClick } { ...props } >
72+ { children }
73+ </ Pressable >
74+ ) ,
75+
76+ Attachment : ( { name, contentType, url, size, onRemove, className } ) => (
77+ < View style = { { flexDirection : 'row' , alignItems : 'center' , padding : 8 , backgroundColor : '#f5f5f5' , borderRadius : 4 } } >
78+ < Text > { name } </ Text >
79+ { onRemove && (
80+ < Pressable onPress = { onRemove } style = { { marginLeft : 8 } } >
81+ < Text > X</ Text >
82+ </ Pressable >
83+ ) }
84+ </ View >
85+ ) ,
86+
87+ // Layout
88+ Separator : ( { orientation = 'horizontal' , className, ...props } ) => (
89+ < View
90+ { ...props }
91+ style = { [
92+ orientation === 'horizontal' ? { height : 1 , width : '100%' } : { width : 1 , height : '100%' } ,
93+ { backgroundColor : '#e0e0e0' } ,
94+ props . style
95+ ] }
96+ />
97+ ) ,
98+
99+ // Logic/Wrappers
100+ MessageSpacer : ( { children, ...props } ) => < View { ...props } > { children } </ View > ,
32101} ;
33102
34103const NativeHooks : RuntimeHooks = {
0 commit comments