@kesha-antonov/react-native-chat 4.3.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +318 -210
  2. package/lib/Avatar.d.ts.map +1 -1
  3. package/lib/Avatar.js +12 -5
  4. package/lib/Avatar.js.map +1 -1
  5. package/lib/Bubble/index.d.ts.map +1 -1
  6. package/lib/Bubble/index.js +15 -5
  7. package/lib/Bubble/index.js.map +1 -1
  8. package/lib/Chat/index.d.ts +1 -0
  9. package/lib/Chat/index.d.ts.map +1 -1
  10. package/lib/Chat/index.js +81 -34
  11. package/lib/Chat/index.js.map +1 -1
  12. package/lib/Chat/types.d.ts +37 -4
  13. package/lib/Chat/types.d.ts.map +1 -1
  14. package/lib/ChatContext.d.ts +2 -0
  15. package/lib/ChatContext.d.ts.map +1 -1
  16. package/lib/ChatContext.js +1 -0
  17. package/lib/ChatContext.js.map +1 -1
  18. package/lib/Composer.d.ts.map +1 -1
  19. package/lib/Composer.js +5 -0
  20. package/lib/Composer.js.map +1 -1
  21. package/lib/Constant.d.ts +1 -0
  22. package/lib/Constant.d.ts.map +1 -1
  23. package/lib/Constant.js +1 -0
  24. package/lib/Constant.js.map +1 -1
  25. package/lib/InputToolbar.d.ts.map +1 -1
  26. package/lib/InputToolbar.js +36 -10
  27. package/lib/InputToolbar.js.map +1 -1
  28. package/lib/Message/index.d.ts.map +1 -1
  29. package/lib/Message/index.js +11 -3
  30. package/lib/Message/index.js.map +1 -1
  31. package/lib/MessageImage.js +2 -2
  32. package/lib/MessageImage.js.map +1 -1
  33. package/lib/MessagesContainer/components/DayAnimated/debug.d.ts +1 -1
  34. package/lib/MessagesContainer/components/DayAnimated/debug.d.ts.map +1 -1
  35. package/lib/MessagesContainer/components/DayAnimated/debug.js +2 -2
  36. package/lib/MessagesContainer/components/DayAnimated/debug.js.map +1 -1
  37. package/lib/MessagesContainer/components/DayAnimated/index.d.ts.map +1 -1
  38. package/lib/MessagesContainer/components/DayAnimated/index.js +5 -5
  39. package/lib/MessagesContainer/components/DayAnimated/index.js.map +1 -1
  40. package/lib/MessagesContainer/components/DayAnimated/useScrollGatedOpacity.d.ts.map +1 -1
  41. package/lib/MessagesContainer/components/DayAnimated/useScrollGatedOpacity.js +1 -1
  42. package/lib/MessagesContainer/components/DayAnimated/useScrollGatedOpacity.js.map +1 -1
  43. package/lib/MessagesContainer/components/Item/index.d.ts.map +1 -1
  44. package/lib/MessagesContainer/components/Item/index.js +13 -11
  45. package/lib/MessagesContainer/components/Item/index.js.map +1 -1
  46. package/lib/MessagesContainer/index.d.ts.map +1 -1
  47. package/lib/MessagesContainer/index.js +71 -42
  48. package/lib/MessagesContainer/index.js.map +1 -1
  49. package/lib/MessagesContainer/types.d.ts +1 -0
  50. package/lib/MessagesContainer/types.d.ts.map +1 -1
  51. package/lib/Theme.d.ts +13 -2
  52. package/lib/Theme.d.ts.map +1 -1
  53. package/lib/Theme.js +7 -2
  54. package/lib/Theme.js.map +1 -1
  55. package/lib/TypingIndicator/index.d.ts.map +1 -1
  56. package/lib/TypingIndicator/index.js +11 -5
  57. package/lib/TypingIndicator/index.js.map +1 -1
  58. package/lib/components/MediaControls.d.ts +1 -1
  59. package/lib/components/MediaControls.d.ts.map +1 -1
  60. package/lib/components/MediaControls.js +2 -1
  61. package/lib/components/MediaControls.js.map +1 -1
  62. package/lib/components/ReplyPreview.d.ts.map +1 -1
  63. package/lib/components/ReplyPreview.js +2 -1
  64. package/lib/components/ReplyPreview.js.map +1 -1
  65. package/lib/components/TouchableOpacity.d.ts.map +1 -1
  66. package/lib/components/TouchableOpacity.js +10 -3
  67. package/lib/components/TouchableOpacity.js.map +1 -1
  68. package/lib/components/VoiceMessageInput.d.ts.map +1 -1
  69. package/lib/components/VoiceMessageInput.js +11 -4
  70. package/lib/components/VoiceMessageInput.js.map +1 -1
  71. package/lib/dayjsLocales.d.ts +18 -0
  72. package/lib/dayjsLocales.d.ts.map +1 -0
  73. package/lib/dayjsLocales.js +36 -0
  74. package/lib/dayjsLocales.js.map +1 -0
  75. package/lib/hooks/useIsRTL.d.ts +3 -0
  76. package/lib/hooks/useIsRTL.d.ts.map +1 -0
  77. package/lib/hooks/useIsRTL.js +7 -0
  78. package/lib/hooks/useIsRTL.js.map +1 -0
  79. package/lib/hooks/useKeyboardVerticalOffset.d.ts +12 -0
  80. package/lib/hooks/useKeyboardVerticalOffset.d.ts.map +1 -1
  81. package/lib/hooks/useKeyboardVerticalOffset.js +12 -0
  82. package/lib/hooks/useKeyboardVerticalOffset.js.map +1 -1
  83. package/lib/hooks/useUpdateLayoutEffect.d.ts.map +1 -1
  84. package/lib/hooks/useUpdateLayoutEffect.js +3 -0
  85. package/lib/hooks/useUpdateLayoutEffect.js.map +1 -1
  86. package/lib/i18n.d.ts +12 -5
  87. package/lib/i18n.d.ts.map +1 -1
  88. package/lib/i18n.js +20 -89
  89. package/lib/i18n.js.map +1 -1
  90. package/lib/index.d.ts +2 -0
  91. package/lib/index.d.ts.map +1 -1
  92. package/lib/index.js +2 -0
  93. package/lib/index.js.map +1 -1
  94. package/lib/linkParser.d.ts +14 -0
  95. package/lib/linkParser.d.ts.map +1 -1
  96. package/lib/linkParser.js +103 -34
  97. package/lib/linkParser.js.map +1 -1
  98. package/lib/locales/ar.d.ts +3 -0
  99. package/lib/locales/ar.d.ts.map +1 -0
  100. package/lib/locales/ar.js +22 -0
  101. package/lib/locales/ar.js.map +1 -0
  102. package/lib/locales/de.d.ts +3 -0
  103. package/lib/locales/de.d.ts.map +1 -0
  104. package/lib/locales/de.js +22 -0
  105. package/lib/locales/de.js.map +1 -0
  106. package/lib/locales/es.d.ts +3 -0
  107. package/lib/locales/es.d.ts.map +1 -0
  108. package/lib/locales/es.js +22 -0
  109. package/lib/locales/es.js.map +1 -0
  110. package/lib/locales/fr.d.ts +3 -0
  111. package/lib/locales/fr.d.ts.map +1 -0
  112. package/lib/locales/fr.js +22 -0
  113. package/lib/locales/fr.js.map +1 -0
  114. package/lib/locales/hi.d.ts +3 -0
  115. package/lib/locales/hi.d.ts.map +1 -0
  116. package/lib/locales/hi.js +22 -0
  117. package/lib/locales/hi.js.map +1 -0
  118. package/lib/locales/id.d.ts +3 -0
  119. package/lib/locales/id.d.ts.map +1 -0
  120. package/lib/locales/id.js +22 -0
  121. package/lib/locales/id.js.map +1 -0
  122. package/lib/locales/index.d.ts +19 -0
  123. package/lib/locales/index.d.ts.map +1 -0
  124. package/lib/locales/index.js +39 -0
  125. package/lib/locales/index.js.map +1 -0
  126. package/lib/locales/it.d.ts +3 -0
  127. package/lib/locales/it.d.ts.map +1 -0
  128. package/lib/locales/it.js +22 -0
  129. package/lib/locales/it.js.map +1 -0
  130. package/lib/locales/ja.d.ts +3 -0
  131. package/lib/locales/ja.d.ts.map +1 -0
  132. package/lib/locales/ja.js +22 -0
  133. package/lib/locales/ja.js.map +1 -0
  134. package/lib/locales/ko.d.ts +3 -0
  135. package/lib/locales/ko.d.ts.map +1 -0
  136. package/lib/locales/ko.js +22 -0
  137. package/lib/locales/ko.js.map +1 -0
  138. package/lib/locales/nl.d.ts +3 -0
  139. package/lib/locales/nl.d.ts.map +1 -0
  140. package/lib/locales/nl.js +22 -0
  141. package/lib/locales/nl.js.map +1 -0
  142. package/lib/locales/pl.d.ts +3 -0
  143. package/lib/locales/pl.d.ts.map +1 -0
  144. package/lib/locales/pl.js +22 -0
  145. package/lib/locales/pl.js.map +1 -0
  146. package/lib/locales/pt.d.ts +3 -0
  147. package/lib/locales/pt.d.ts.map +1 -0
  148. package/lib/locales/pt.js +22 -0
  149. package/lib/locales/pt.js.map +1 -0
  150. package/lib/locales/ru.d.ts +3 -0
  151. package/lib/locales/ru.d.ts.map +1 -0
  152. package/lib/locales/ru.js +22 -0
  153. package/lib/locales/ru.js.map +1 -0
  154. package/lib/locales/tr.d.ts +3 -0
  155. package/lib/locales/tr.d.ts.map +1 -0
  156. package/lib/locales/tr.js +22 -0
  157. package/lib/locales/tr.js.map +1 -0
  158. package/lib/locales/zh.d.ts +3 -0
  159. package/lib/locales/zh.d.ts.map +1 -0
  160. package/lib/locales/zh.js +22 -0
  161. package/lib/locales/zh.js.map +1 -0
  162. package/lib/rtl.d.ts +18 -0
  163. package/lib/rtl.d.ts.map +1 -0
  164. package/lib/rtl.js +31 -0
  165. package/lib/rtl.js.map +1 -0
  166. package/llms.txt +175 -0
  167. package/package.json +21 -22
package/llms.txt ADDED
@@ -0,0 +1,175 @@
1
+ # @kesha-antonov/react-native-chat
2
+
3
+ > Chat UI for React Native, Expo and Web. A maintained continuation of
4
+ > `react-native-gifted-chat` with the same `IMessage` model and prop names, plus dark mode
5
+ > and theming, streaming (AI) messages, emoji reactions, swipe-to-reply, and inline
6
+ > video/audio/location messages. TypeScript-first; no native code of its own.
7
+
8
+ This file is a condensed integration guide for AI agents. Full docs: [README](https://github.com/kesha-antonov/react-native-chat#readme).
9
+
10
+ ## Install
11
+
12
+ Required peers - all four must be installed and configured:
13
+
14
+ ```bash
15
+ npx expo install @kesha-antonov/react-native-chat react-native-reanimated react-native-gesture-handler react-native-safe-area-context react-native-keyboard-controller
16
+ ```
17
+
18
+ Bare React Native: use `yarn add` / `npm install --save` with the same list, then
19
+ `npx pod-install`, then add Reanimated's Babel plugin to `babel.config.js`
20
+ (`plugins: ['react-native-worklets/plugin']` for Reanimated 4, `'react-native-reanimated/plugin'` for 3).
21
+
22
+ Requires React Native >= 0.70, iOS >= 13.4, Android API 21+, Expo SDK 50+.
23
+
24
+ ## Minimal working example
25
+
26
+ ```tsx
27
+ import { useCallback, useState } from 'react'
28
+ import { Chat, IMessage } from '@kesha-antonov/react-native-chat'
29
+
30
+ export function ChatScreen () {
31
+ const [messages, setMessages] = useState<IMessage[]>([
32
+ {
33
+ _id: 1,
34
+ text: 'Hello developer',
35
+ createdAt: new Date(),
36
+ user: { _id: 2, name: 'John Doe' },
37
+ },
38
+ ])
39
+
40
+ const onSend = useCallback((newMessages: IMessage[] = []) => {
41
+ setMessages(previous => Chat.append(previous, newMessages))
42
+ }, [])
43
+
44
+ return <Chat messages={messages} onSend={onSend} user={{ _id: 1 }} />
45
+ }
46
+ ```
47
+
48
+ `Chat` fills its parent, so give it a `flex: 1` container. It mounts its own
49
+ `GestureHandlerRootView` and `KeyboardProvider` unless the app already provides them.
50
+
51
+ ## Data model
52
+
53
+ ```ts
54
+ interface IMessage {
55
+ _id: string | number
56
+ text: string
57
+ createdAt: Date | number
58
+ user: { _id: string | number, name?: string, avatar?: string | number | (() => React.ReactNode) }
59
+ image?: string
60
+ video?: string
61
+ audio?: string
62
+ system?: boolean // renders as a centered system notice
63
+ sent?: boolean // ✓
64
+ received?: boolean // ✓✓
65
+ pending?: boolean // 🕓
66
+ streaming?: boolean // shows a typing caret while tokens arrive
67
+ quickReplies?: { type: 'radio' | 'checkbox', values: { title: string, value: string }[], keepIt?: boolean }
68
+ replyMessage?: { _id: string | number, text: string, user: User, image?: string, audio?: string }
69
+ reactions?: { emoji: string, userIds: (string | number)[] }[]
70
+ location?: { latitude: number, longitude: number }
71
+ }
72
+ ```
73
+
74
+ Messages are newest-first by default (`isInverted` defaults to `true`). `Chat.append(previous, newMessages)`
75
+ prepends correctly for that ordering.
76
+
77
+ ## Props you will reach for first
78
+
79
+ - `messages`, `user`, `onSend` - required
80
+ - `text` + `textInputProps.onChangeText` - only if you control the composer text externally
81
+ - `theme` / `darkTheme` - deep-merged token overrides (`colors`, `radii`, `spacing`, `typography`, …)
82
+ - `colorScheme` - `'light' | 'dark'` to force a scheme; omit to follow the system
83
+ - `locale` + `labels` - 15 built-in translations (es, fr, de, ru, zh, ar, pt, ja, ko, it, tr, hi, nl, pl, id; English is the default, `pt-BR` falls back to `pt`) and per-string overrides
84
+ - `renderBubble`, `renderMessageText`, `renderAvatar`, `renderInputToolbar`, … - override any component
85
+ - `isTyping` - typing indicator
86
+ - `loadEarlierMessagesProps` - `{ isAvailable, onPress, isLoading, isInfiniteScrollEnabled }`
87
+ - `isScrollToBottomEnabled`, `listProps`, `isFlashListEnabled`
88
+
89
+ ## Optional features and the peers they need
90
+
91
+ Each is inert until you install its peer and turn it on - nothing is forced on the user.
92
+
93
+ | Feature | Enable with | Extra peer dependency |
94
+ | --- | --- | --- |
95
+ | Inline video playback | `IMessage.video` | `expo-video` |
96
+ | Inline audio playback | `IMessage.audio` | `expo-audio` |
97
+ | Voice notes (hold to record) | `audioRecording={{ isEnabled: true }}` | `expo-audio`, plus `react-native-audio-api` for the waveform |
98
+ | Video messages (camera notes) | `videoRecording={{ isEnabled: true }}` | `react-native-vision-camera`, or `expo-image-picker` |
99
+ | Location messages | `IMessage.location` | none |
100
+ | Emoji reactions | `reactions={{ isEnabled: true, onReactionPress }}` | none |
101
+ | Long-press action menu | `messageActions={[{ label, onPress }]}` | none |
102
+ | Rich markdown for AI replies | `messageTextProps={{ markdown: true }}` | none (built-in), `react-native-streamdown` upgrades it |
103
+ | Recycling list for huge histories | `isFlashListEnabled` | `@shopify/flash-list` |
104
+ | Custom icons | `icons={{ send: … }}` | `react-native-svg` for the built-in Lucide glyphs |
105
+
106
+ ## Streaming (AI) replies
107
+
108
+ ```tsx
109
+ import { Chat, IMessage, useStreamingMessages } from '@kesha-antonov/react-native-chat'
110
+
111
+ const { messages, append, startStream, isStreaming, stop } = useStreamingMessages<IMessage>()
112
+
113
+ const onSend = useCallback((newMessages: IMessage[] = []) => {
114
+ append(newMessages[0])
115
+ const stream = startStream({ user: { _id: 2, name: 'Assistant' } })
116
+
117
+ runModel(newMessages[0].text, {
118
+ signal: stream.signal, // aborts when stop() is called
119
+ onToken: token => stream.push(token), // batched, one render per frame
120
+ onDone: () => stream.done(),
121
+ })
122
+ }, [append, startStream])
123
+ ```
124
+
125
+ Tokens are batched with `requestAnimationFrame`, and only the streaming bubble re-renders.
126
+ The send button becomes a Stop control while `isStreaming`.
127
+
128
+ ## Emoji reactions
129
+
130
+ Reaction state is owned by the app, so it works with any backend. `onReactionPress` fires for
131
+ both the picker and a pill tap; you implement the toggle:
132
+
133
+ ```tsx
134
+ <Chat
135
+ reactions={{
136
+ isEnabled: true,
137
+ onReactionPress: (message, emoji) => toggleReaction(message._id, emoji),
138
+ }}
139
+ {...props}
140
+ />
141
+ ```
142
+
143
+ ## Coming from react-native-gifted-chat
144
+
145
+ Same props, same `IMessage`. Swap the package and rename: `GiftedChat` → `Chat`,
146
+ `GiftedAvatar` → `ChatAvatar`, `GiftedChatContext` → `ChatContext`. Everything else -
147
+ `IMessage`, `User`, `useChatContext` - is unchanged. A codemod is in
148
+ [docs/MIGRATION.md](https://github.com/kesha-antonov/react-native-chat/blob/main/docs/MIGRATION.md).
149
+
150
+ ## Common mistakes
151
+
152
+ - **Unstable render props.** Each row is `React.memo`'d with a comparator that
153
+ reference-compares every prop except the message. An inline `renderBubble={props => …}` or
154
+ `reactions={{ … }}` re-renders every row on every parent render - wrap them in `useCallback` /
155
+ `useMemo`.
156
+ - **Mutating messages in place.** The comparator detects updates by value, so always build new
157
+ arrays and objects.
158
+ - **Setting `keyboardVerticalOffset` by hand.** Chat measures its own position on screen; a
159
+ manual value replaces the measured one and usually leaves the toolbar floating. Pass one only
160
+ to add deliberate extra space.
161
+ - **Nesting a second `GestureHandlerRootView`.** If the app already mounts one (directly or via
162
+ a bottom-sheet library), set `enableGestureHandlerRootView={false}` - it cannot be
163
+ auto-detected. An existing `KeyboardProvider` *is* detected and reused automatically.
164
+ - **Expecting `actionSheet()` to work out of the box.** The bundled
165
+ `@expo/react-native-action-sheet` dependency was removed; prefer `messageActions`, or supply
166
+ your own `actionSheet` implementation.
167
+ - **Forgetting the container.** `<Chat>` needs a parent with `flex: 1`.
168
+
169
+ ## Links
170
+
171
+ - [README](https://github.com/kesha-antonov/react-native-chat#readme) - full props reference and guides
172
+ - [Migration guide](https://github.com/kesha-antonov/react-native-chat/blob/main/docs/MIGRATION.md)
173
+ - [Streaming guide](https://github.com/kesha-antonov/react-native-chat/blob/main/docs/STREAMING.md)
174
+ - [Example app](https://github.com/kesha-antonov/react-native-chat/tree/main/example)
175
+ - [Expo Snack playground](https://snack.expo.dev/@kesha-antonov/react-native-chat-playground)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kesha-antonov/react-native-chat",
3
- "version": "4.3.0",
3
+ "version": "5.0.0",
4
4
  "description": "The most complete chat UI for React Native & Web - streaming AI messages, emoji reactions, replies, quick replies, and full customization. TypeScript-first, Expo-ready. A maintained react-native-gifted-chat successor.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -45,7 +45,8 @@
45
45
  "access": "public"
46
46
  },
47
47
  "files": [
48
- "lib"
48
+ "lib",
49
+ "llms.txt"
49
50
  ],
50
51
  "scripts": {
51
52
  "typecheck": "yarn tsc --noEmit",
@@ -69,9 +70,9 @@
69
70
  },
70
71
  "dependencies": {
71
72
  "@types/lodash.isequal": "^4.5.8",
72
- "dayjs": "^1.11.21",
73
+ "dayjs": "^1.11.23",
73
74
  "lodash.isequal": "^4.5.0",
74
- "react-native-zoom-reanimated": "^1.5.4"
75
+ "react-native-zoom-reanimated": "^1.5.6"
75
76
  },
76
77
  "devDependencies": {
77
78
  "@babel/core": "^7.28.5",
@@ -84,28 +85,26 @@
84
85
  "@react-native-community/cli": "20.2.0",
85
86
  "@react-native-community/cli-platform-android": "20.2.0",
86
87
  "@react-native-community/cli-platform-ios": "20.2.0",
87
- "@react-native/babel-preset": "0.86.2",
88
- "@react-native/eslint-config": "0.86.2",
89
- "@react-native/jest-preset": "0.86.2",
90
- "@react-native/metro-config": "0.86.2",
91
- "@react-native/typescript-config": "0.86.2",
88
+ "@react-native/babel-preset": "0.86.3",
89
+ "@react-native/eslint-config": "0.86.3",
90
+ "@react-native/jest-preset": "0.86.3",
91
+ "@react-native/metro-config": "0.86.3",
92
+ "@react-native/typescript-config": "0.86.3",
92
93
  "@shopify/flash-list": "^2.3.2",
93
94
  "@stylistic/eslint-plugin": "^5.10.0",
94
95
  "@testing-library/dom": "^10.4.1",
95
96
  "@testing-library/react": "^16.3.2",
96
- "@testing-library/react-native": "^13.3.3",
97
+ "@testing-library/react-native": "^14.0.1",
97
98
  "@types/jest": "^29.5.14",
98
99
  "@types/react": "^19.2.18",
99
- "@types/react-dom": "^19.2.4",
100
- "@types/react-native": "^0.73.0",
101
- "@types/react-test-renderer": "^19.1.0",
102
- "@typescript-eslint/eslint-plugin": "^8.66.0",
103
- "@typescript-eslint/parser": "^8.66.0",
100
+ "@types/react-dom": "^19.2.5",
101
+ "@typescript-eslint/eslint-plugin": "^8.68.0",
102
+ "@typescript-eslint/parser": "^8.68.0",
104
103
  "babel-jest": "^29.7.0",
105
- "eslint": "^10.8.0",
104
+ "eslint": "^10.9.1",
106
105
  "eslint-import-resolver-typescript": "^4.4.5",
107
106
  "eslint-plugin-import": "^2.32.0",
108
- "eslint-plugin-jest": "^29.16.0",
107
+ "eslint-plugin-jest": "^29.16.2",
109
108
  "eslint-plugin-perfectionist": "^5.10.1",
110
109
  "eslint-plugin-react": "^7.37.5",
111
110
  "eslint-plugin-react-hooks": "^7.1.1",
@@ -115,13 +114,13 @@
115
114
  "lint-staged": "^17.3.0",
116
115
  "react": "19.2.3",
117
116
  "react-dom": "19.2.3",
118
- "react-native": "0.86.2",
117
+ "react-native": "0.86.3",
119
118
  "react-native-gesture-handler": "~2.32.0",
120
- "react-native-keyboard-controller": "^1.21.14",
121
- "react-native-reanimated": "~4.5.3",
119
+ "react-native-keyboard-controller": "^1.22.4",
120
+ "react-native-reanimated": "~4.6.0",
122
121
  "react-native-safe-area-context": "~5.7.0",
123
- "react-native-worklets": "~0.10.3",
124
- "react-test-renderer": "19.2.3",
122
+ "react-native-worklets": "~0.12.1",
123
+ "test-renderer": "^1.2.0",
125
124
  "typescript": "^6.0.3"
126
125
  },
127
126
  "peerDependencies": {