UNPKG

6.11 kBTypeScriptView Raw
1import React from 'react';
2import { ActionSheetOptions } from '@expo/react-native-action-sheet';
3import { FlatList, StyleProp, TextInput, TextStyle, ViewStyle } from 'react-native';
4import { LightboxProps } from 'react-native-lightbox-v2';
5import { Actions, ActionsProps } from './Actions';
6import { Avatar, AvatarProps } from './Avatar';
7import Bubble from './Bubble';
8import { Composer, ComposerProps } from './Composer';
9import { Day, DayProps } from './Day';
10import { GiftedAvatar } from './GiftedAvatar';
11import { InputToolbar, InputToolbarProps } from './InputToolbar';
12import { LoadEarlier, LoadEarlierProps } from './LoadEarlier';
13import Message from './Message';
14import MessageContainer from './MessageContainer';
15import { MessageImage, MessageImageProps } from './MessageImage';
16import { MessageText, MessageTextProps } from './MessageText';
17import { IMessage, LeftRightStyle, MessageAudioProps, MessageVideoProps, Reply, User } from './Models';
18import { QuickRepliesProps } from './QuickReplies';
19import { Send, SendProps } from './Send';
20import { SystemMessage, SystemMessageProps } from './SystemMessage';
21import { Time, TimeProps } from './Time';
22import * as utils from './utils';
23export interface GiftedChatProps<TMessage extends IMessage = IMessage> {
24 messageContainerRef?: React.RefObject<FlatList<IMessage>>;
25 textInputRef?: React.RefObject<TextInput>;
26 messages?: TMessage[];
27 isTyping?: boolean;
28 renderUsernameOnMessage?: boolean;
29 messagesContainerStyle?: StyleProp<ViewStyle>;
30 text?: string;
31 alignTop?: boolean;
32 scrollToBottom?: boolean;
33 scrollToBottomStyle?: StyleProp<ViewStyle>;
34 initialText?: string;
35 placeholder?: string;
36 disableComposer?: boolean;
37 user?: User;
38 locale?: string;
39 timeFormat?: string;
40 dateFormat?: string;
41 loadEarlier?: boolean;
42 isLoadingEarlier?: boolean;
43 showUserAvatar?: boolean;
44 showAvatarForEveryMessage?: boolean;
45 renderAvatarOnTop?: boolean;
46 inverted?: boolean;
47 imageProps?: Message<TMessage>['props'];
48 lightboxProps?: LightboxProps;
49 bottomOffset?: number;
50 minInputToolbarHeight?: number;
51 listViewProps?: object;
52 textInputProps?: object;
53 keyboardShouldPersistTaps?: 'always' | 'never' | 'handled';
54 maxInputLength?: number;
55 alwaysShowSend?: boolean;
56 imageStyle?: StyleProp<ViewStyle>;
57 extraData?: object;
58 minComposerHeight?: number;
59 maxComposerHeight?: number;
60 options?: {
61 [key: string]: () => void;
62 };
63 optionTintColor?: string;
64 quickReplyStyle?: StyleProp<ViewStyle>;
65 quickReplyTextStyle?: StyleProp<TextStyle>;
66 quickReplyContainerStyle?: StyleProp<ViewStyle>;
67 isCustomViewBottom?: boolean;
68 infiniteScroll?: boolean;
69 timeTextStyle?: LeftRightStyle<TextStyle>;
70 /** If you use translucent status bar on Android, set this option to true. Ignored on iOS. */
71 isStatusBarTranslucentAndroid?: boolean;
72 actionSheet?(): {
73 showActionSheetWithOptions: (options: ActionSheetOptions, callback: (buttonIndex: number) => void | Promise<void>) => void;
74 };
75 onPressAvatar?(user: User): void;
76 onLongPressAvatar?(user: User): void;
77 messageIdGenerator?(message?: TMessage): string;
78 onSend?(messages: TMessage[]): void;
79 onLoadEarlier?(): void;
80 renderLoading?(): React.ReactNode;
81 renderLoadEarlier?(props: LoadEarlierProps): React.ReactNode;
82 renderAvatar?: null | ((props: AvatarProps<TMessage>) => React.ReactNode);
83 renderBubble?(props: Bubble<TMessage>['props']): React.ReactNode;
84 renderSystemMessage?(props: SystemMessageProps<TMessage>): React.ReactNode;
85 onPress?(context: unknown, message: TMessage): void;
86 onLongPress?(context: unknown, message: TMessage): void;
87 renderUsername?(user: User): React.ReactNode;
88 renderMessage?(message: Message<TMessage>['props']): React.ReactElement;
89 renderMessageText?(messageText: MessageTextProps<TMessage>): React.ReactNode;
90 renderMessageImage?(props: MessageImageProps<TMessage>): React.ReactNode;
91 renderMessageVideo?(props: MessageVideoProps<TMessage>): React.ReactNode;
92 renderMessageAudio?(props: MessageAudioProps<TMessage>): React.ReactNode;
93 renderCustomView?(props: Bubble<TMessage>['props']): React.ReactNode;
94 renderDay?(props: DayProps<TMessage>): React.ReactNode;
95 renderTime?(props: TimeProps<TMessage>): React.ReactNode;
96 renderFooter?(): React.ReactNode;
97 renderChatEmpty?(): React.ReactNode;
98 renderChatFooter?(): React.ReactNode;
99 renderInputToolbar?(props: InputToolbarProps<TMessage>): React.ReactNode;
100 renderComposer?(props: ComposerProps): React.ReactNode;
101 renderActions?(props: ActionsProps): React.ReactNode;
102 renderSend?(props: SendProps<TMessage>): React.ReactNode;
103 renderAccessory?(props: InputToolbarProps<TMessage>): React.ReactNode;
104 onPressActionButton?(): void;
105 onInputTextChanged?(text: string): void;
106 parsePatterns?: (linkStyle?: TextStyle) => {
107 type?: string;
108 pattern?: RegExp;
109 style?: StyleProp<TextStyle> | object;
110 onPress?: unknown;
111 renderText?: unknown;
112 }[];
113 onQuickReply?(replies: Reply[]): void;
114 renderQuickReplies?(quickReplies: QuickRepliesProps<TMessage>): React.ReactNode;
115 renderQuickReplySend?(): React.ReactNode;
116 scrollToBottomComponent?(): React.ReactNode;
117 shouldUpdateMessage?(props: Message<TMessage>['props'], nextProps: Message<TMessage>['props']): boolean;
118}
119declare function GiftedChat<TMessage extends IMessage = IMessage>(props: GiftedChatProps): React.JSX.Element;
120declare namespace GiftedChat {
121 var append: <TMessage extends IMessage>(currentMessages: TMessage[] | undefined, messages: TMessage[], inverted?: boolean) => TMessage[];
122 var prepend: <TMessage extends IMessage>(currentMessages: TMessage[] | undefined, messages: TMessage[], inverted?: boolean) => TMessage[];
123}
124export * from './Models';
125export { GiftedChat, Actions, Avatar, Bubble, SystemMessage, MessageImage, MessageText, Composer, Day, InputToolbar, LoadEarlier, Message, MessageContainer, Send, Time, GiftedAvatar, utils };