react-native-gifted-chat 2.8.2-alpha.4 → 2.9.0-alpha.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.
- package/CHANGELOG_2.8.1_to_2.8.2-alpha.5.md +374 -0
- package/README.md +26 -26
- package/package.json +2 -1
- package/src/Actions.tsx +1 -1
- package/src/Bubble/index.tsx +12 -14
- package/src/Bubble/styles.ts +1 -1
- package/src/Bubble/types.ts +4 -5
- package/src/Color.ts +1 -1
- package/src/Composer.tsx +1 -1
- package/src/Day/styles.ts +1 -1
- package/src/GiftedAvatar.tsx +1 -1
- package/src/GiftedChat/index.tsx +12 -49
- package/src/GiftedChat/types.ts +2 -2
- package/src/InputToolbar.tsx +22 -13
- package/src/LoadEarlierMessages.tsx +48 -51
- package/src/Message/index.tsx +6 -8
- package/src/MessageAudio.tsx +1 -1
- package/src/MessageContainer/components/DayAnimated/index.tsx +2 -3
- package/src/MessageContainer/components/Item/index.tsx +8 -10
- package/src/MessageContainer/index.tsx +9 -11
- package/src/MessageContainer/styles.ts +1 -1
- package/src/MessageText.tsx +2 -1
- package/src/MessageVideo.tsx +1 -1
- package/src/QuickReplies.tsx +1 -1
- package/src/Send.tsx +1 -1
- package/src/SystemMessage.tsx +30 -24
- package/src/Time.tsx +5 -5
- package/src/TypingIndicator/index.tsx +1 -3
- package/src/TypingIndicator/styles.ts +1 -1
- package/src/__tests__/Actions.test.tsx +1 -1
- package/src/__tests__/Avatar.test.tsx +7 -2
- package/src/__tests__/Bubble.test.tsx +3 -7
- package/src/__tests__/Color.test.tsx +1 -1
- package/src/__tests__/Composer.test.tsx +1 -1
- package/src/__tests__/Day.test.tsx +3 -3
- package/src/__tests__/DayAnimated.test.tsx +5 -11
- package/src/__tests__/GiftedAvatar.test.tsx +1 -1
- package/src/__tests__/GiftedChat.test.tsx +1 -1
- package/src/__tests__/InputToolbar.test.tsx +1 -1
- package/src/__tests__/LoadEarlier.test.tsx +2 -2
- package/src/__tests__/Message.test.tsx +5 -11
- package/src/__tests__/MessageContainer.test.tsx +4 -4
- package/src/__tests__/MessageImage.test.tsx +2 -2
- package/src/__tests__/MessageText.test.tsx +3 -2
- package/src/__tests__/Send.test.tsx +1 -1
- package/src/__tests__/SystemMessage.test.tsx +1 -1
- package/src/__tests__/Time.test.tsx +1 -1
- package/src/__tests__/__snapshots__/Actions.test.tsx.snap +61 -57
- package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +1 -2
- package/src/__tests__/__snapshots__/Day.test.tsx.snap +96 -2
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +56 -36
- package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +64 -52
- package/src/__tests__/__snapshots__/Message.test.tsx.snap +41 -5
- package/src/__tests__/__snapshots__/MessageText.test.tsx.snap +1 -2
- package/src/__tests__/__snapshots__/Send.test.tsx.snap +120 -108
- package/src/__tests__/__snapshots__/SystemMessage.test.tsx.snap +38 -8
- package/src/__tests__/data.ts +1 -1
- package/src/components/TouchableOpacity.tsx +26 -15
- package/src/index.ts +19 -1
- package/src/utils.ts +22 -1
- package/src/LoadEarlier.tsx +0 -95
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
# Changelog: v2.8.1 to v2.8.2-alpha.5
|
|
2
|
+
|
|
3
|
+
## 🚨 BREAKING CHANGES
|
|
4
|
+
|
|
5
|
+
### Removed Dependencies
|
|
6
|
+
- **Removed `react-native-lightbox-v2`**: The library now uses a custom Modal implementation for viewing images
|
|
7
|
+
- ❌ Removed prop: `lightboxProps` from `MessageImageProps`
|
|
8
|
+
- ❌ Removed prop: `lightboxProps` from `GiftedChatProps`
|
|
9
|
+
- The image viewer now uses `react-native-zoom-reanimated` for zoom functionality
|
|
10
|
+
|
|
11
|
+
### New Required Peer Dependencies
|
|
12
|
+
- ✅ **`react-native-gesture-handler`** (>=2.0.0) - now required
|
|
13
|
+
- ✅ **`react-native-safe-area-context`** (>=5.0.0) - now required
|
|
14
|
+
- Updated **`react-native-reanimated`** peer dependency to support both v3 and v4 (>=3.0.0 || ^4.0.0)
|
|
15
|
+
|
|
16
|
+
### Renamed Props (GiftedChatProps)
|
|
17
|
+
|
|
18
|
+
#### Action Sheet Props
|
|
19
|
+
- ❌ `options` → ✅ `actions` (type changed from `{ [key: string]: () => void }` to `Array<{ title: string, action: () => void }>`)
|
|
20
|
+
- ❌ `optionTintColor` → ✅ `actionSheetOptionTintColor`
|
|
21
|
+
|
|
22
|
+
#### Keyboard Props
|
|
23
|
+
- ❌ `bottomOffset` → ✅ `keyboardBottomOffset`
|
|
24
|
+
|
|
25
|
+
#### Message Event Handlers
|
|
26
|
+
- ❌ `onPress` → ✅ `onPressMessage`
|
|
27
|
+
- ❌ `onLongPress` → ✅ `onLongPressMessage`
|
|
28
|
+
|
|
29
|
+
#### LoadEarlier Component
|
|
30
|
+
- ❌ `LoadEarlier` → ✅ `LoadEarlierMessages` (component renamed)
|
|
31
|
+
- ❌ `LoadEarlierProps` → ✅ `LoadEarlierMessagesProps` (type renamed)
|
|
32
|
+
|
|
33
|
+
### Removed Props (GiftedChatProps)
|
|
34
|
+
|
|
35
|
+
#### Keyboard & Input Props
|
|
36
|
+
- ❌ `keyboardShouldPersistTaps` - removed (keyboard handling is now managed internally)
|
|
37
|
+
- ❌ `maxInputLength` - removed (use `textInputProps.maxLength` instead)
|
|
38
|
+
- ❌ `placeholder` - removed (use `textInputProps.placeholder` instead)
|
|
39
|
+
- ❌ `disableComposer` - removed (use `textInputProps.editable={false}` instead)
|
|
40
|
+
|
|
41
|
+
#### Load Earlier Props
|
|
42
|
+
- ❌ `loadEarlier` - removed from GiftedChatProps (use `loadEarlierMessagesProps.isAvailable` instead)
|
|
43
|
+
- ❌ `isLoadingEarlier` - removed from GiftedChatProps (use `loadEarlierMessagesProps.isLoading` instead)
|
|
44
|
+
- ❌ `onLoadEarlier` - removed from GiftedChatProps (use `loadEarlierMessagesProps.onPress` instead)
|
|
45
|
+
- ❌ `infiniteScroll` - removed (use `loadEarlierMessagesProps.isInfiniteScrollEnabled` instead)
|
|
46
|
+
|
|
47
|
+
#### ListView Props
|
|
48
|
+
- ❌ `listViewProps` - removed (use `listProps` via MessageContainerProps instead)
|
|
49
|
+
|
|
50
|
+
#### Parse Patterns
|
|
51
|
+
- ❌ `parsePatterns` - removed (replaced with `matchers`)
|
|
52
|
+
|
|
53
|
+
#### Explicit Props Moved to Parent Interface
|
|
54
|
+
The following props were explicitly listed in GiftedChatProps in v2.8.1 but are now only available through the extended `MessageContainerProps`:
|
|
55
|
+
- ❌ `messages` - removed as explicit prop (still available via MessageContainerProps)
|
|
56
|
+
- ❌ `isTyping` - removed as explicit prop (still available via MessageContainerProps)
|
|
57
|
+
- ❌ `inverted` - removed as explicit prop (still available via MessageContainerProps)
|
|
58
|
+
- ❌ `alignTop` - removed as explicit prop (still available via MessageContainerProps)
|
|
59
|
+
- ❌ `isScrollToBottomEnabled` - removed as explicit prop (still available via MessageContainerProps)
|
|
60
|
+
- ❌ `scrollToBottomStyle` - removed as explicit prop (still available via MessageContainerProps)
|
|
61
|
+
- ❌ `extraData` - removed as explicit prop (still available via MessageContainerProps)
|
|
62
|
+
- ❌ `renderMessage` - removed as explicit prop (still available via MessageContainerProps)
|
|
63
|
+
- ❌ `renderFooter` - removed as explicit prop (still available via MessageContainerProps)
|
|
64
|
+
- ❌ `renderChatEmpty` - removed as explicit prop (still available via MessageContainerProps)
|
|
65
|
+
- ❌ `renderDay` - removed as explicit prop (still available via MessageContainerProps)
|
|
66
|
+
- ❌ `renderLoadEarlier` - removed as explicit prop (still available via MessageContainerProps)
|
|
67
|
+
- ❌ `onQuickReply` - removed as explicit prop (still available via MessageContainerProps)
|
|
68
|
+
|
|
69
|
+
**Important:** Since `GiftedChatProps` extends `Partial<MessageContainerProps<TMessage>>` in both versions, all MessageContainerProps are still available on GiftedChat. The difference is they're no longer explicitly redefined in the GiftedChatProps interface.
|
|
70
|
+
|
|
71
|
+
### Removed Props (ComposerProps)
|
|
72
|
+
- ❌ `placeholder` - removed (use `textInputProps.placeholder` instead)
|
|
73
|
+
- ❌ `placeholderTextColor` - removed (use `textInputProps.placeholderTextColor` instead)
|
|
74
|
+
|
|
75
|
+
### Removed Props (InputToolbarProps)
|
|
76
|
+
- ❌ `options` → ✅ `actions` (renamed)
|
|
77
|
+
- ❌ `optionTintColor` → ✅ `actionSheetOptionTintColor` (renamed)
|
|
78
|
+
|
|
79
|
+
### Changed Props (GiftedChatProps)
|
|
80
|
+
|
|
81
|
+
#### Type Changes
|
|
82
|
+
- `textInputProps`: Changed from `object` to `Partial<React.ComponentProps<typeof TextInput>>`
|
|
83
|
+
- Now properly typed with all TextInput props available
|
|
84
|
+
- Use this for `placeholder`, `placeholderTextColor`, `maxLength`, `editable`, etc.
|
|
85
|
+
|
|
86
|
+
#### MessageContainer Props
|
|
87
|
+
- `invertibleScrollViewProps` removed - use individual props instead:
|
|
88
|
+
- `inverted` prop now passed directly
|
|
89
|
+
- Removed `keyboardShouldPersistTaps` (handled internally)
|
|
90
|
+
|
|
91
|
+
#### Link Parsing
|
|
92
|
+
- ❌ `parsePatterns` → ✅ `matchers`
|
|
93
|
+
- Now uses `react-native-autolink` instead of `react-native-parsed-text`
|
|
94
|
+
- See [react-native-autolink documentation](https://github.com/joshswan/react-native-autolink) for matcher configuration
|
|
95
|
+
|
|
96
|
+
### New Props
|
|
97
|
+
|
|
98
|
+
#### GiftedChatProps
|
|
99
|
+
- ✅ `messageTextProps` - Extra props to be passed to the MessageText component
|
|
100
|
+
- ✅ `matchers` - Custom parse patterns for react-native-autolink (replaces `parsePatterns`)
|
|
101
|
+
- ✅ `keyboardBottomOffset` - Distance of the chat from the bottom of the screen (replaces `bottomOffset`)
|
|
102
|
+
- ✅ `actions` - Array of action sheet options (replaces `options`)
|
|
103
|
+
- ✅ `actionSheetOptionTintColor` - Tint color for action sheet (replaces `optionTintColor`)
|
|
104
|
+
|
|
105
|
+
#### IMessage Interface
|
|
106
|
+
- ✅ `location` - Optional location data with latitude and longitude:
|
|
107
|
+
```typescript
|
|
108
|
+
location?: {
|
|
109
|
+
latitude: number
|
|
110
|
+
longitude: number
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 📦 Migration Guide
|
|
115
|
+
|
|
116
|
+
### 1. Install New Dependencies
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Yarn
|
|
120
|
+
yarn add react-native-gesture-handler react-native-safe-area-context
|
|
121
|
+
|
|
122
|
+
# npm
|
|
123
|
+
npm install react-native-gesture-handler react-native-safe-area-context
|
|
124
|
+
|
|
125
|
+
# Expo
|
|
126
|
+
npx expo install react-native-gesture-handler react-native-safe-area-context
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 2. Update Imports
|
|
130
|
+
|
|
131
|
+
If you were importing `LoadEarlier`:
|
|
132
|
+
```typescript
|
|
133
|
+
// Before
|
|
134
|
+
import { LoadEarlier, LoadEarlierProps } from 'react-native-gifted-chat'
|
|
135
|
+
|
|
136
|
+
// After
|
|
137
|
+
import { LoadEarlierMessages, LoadEarlierMessagesProps } from 'react-native-gifted-chat'
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 3. Update Props
|
|
141
|
+
|
|
142
|
+
#### Action Sheet Props
|
|
143
|
+
```typescript
|
|
144
|
+
// Before
|
|
145
|
+
<GiftedChat
|
|
146
|
+
options={{
|
|
147
|
+
'Action 1': () => console.log('Action 1'),
|
|
148
|
+
'Action 2': () => console.log('Action 2'),
|
|
149
|
+
}}
|
|
150
|
+
optionTintColor="#007AFF"
|
|
151
|
+
/>
|
|
152
|
+
|
|
153
|
+
// After
|
|
154
|
+
<GiftedChat
|
|
155
|
+
actions={[
|
|
156
|
+
{ title: 'Action 1', action: () => console.log('Action 1') },
|
|
157
|
+
{ title: 'Action 2', action: () => console.log('Action 2') },
|
|
158
|
+
]}
|
|
159
|
+
actionSheetOptionTintColor="#007AFF"
|
|
160
|
+
/>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### Keyboard Offset
|
|
164
|
+
```typescript
|
|
165
|
+
// Before
|
|
166
|
+
<GiftedChat bottomOffset={50} />
|
|
167
|
+
|
|
168
|
+
// After
|
|
169
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
170
|
+
|
|
171
|
+
function MyChat() {
|
|
172
|
+
const insets = useSafeAreaInsets()
|
|
173
|
+
const tabbarHeight = 50
|
|
174
|
+
const keyboardBottomOffset = insets.bottom + tabbarHeight
|
|
175
|
+
|
|
176
|
+
return <GiftedChat keyboardBottomOffset={keyboardBottomOffset} />
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### Message Press Handlers
|
|
181
|
+
```typescript
|
|
182
|
+
// Before
|
|
183
|
+
<GiftedChat
|
|
184
|
+
onPress={(context, message) => console.log('Pressed')}
|
|
185
|
+
onLongPress={(context, message) => console.log('Long pressed')}
|
|
186
|
+
/>
|
|
187
|
+
|
|
188
|
+
// After
|
|
189
|
+
<GiftedChat
|
|
190
|
+
onPressMessage={(context, message) => console.log('Pressed')}
|
|
191
|
+
onLongPressMessage={(context, message) => console.log('Long pressed')}
|
|
192
|
+
/>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Text Input Props
|
|
196
|
+
```typescript
|
|
197
|
+
// Before
|
|
198
|
+
<GiftedChat
|
|
199
|
+
placeholder="Type a message..."
|
|
200
|
+
maxInputLength={1000}
|
|
201
|
+
disableComposer={false}
|
|
202
|
+
/>
|
|
203
|
+
|
|
204
|
+
// After
|
|
205
|
+
<GiftedChat
|
|
206
|
+
textInputProps={{
|
|
207
|
+
placeholder: "Type a message...",
|
|
208
|
+
maxLength: 1000,
|
|
209
|
+
editable: true,
|
|
210
|
+
}}
|
|
211
|
+
/>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### Load Earlier Messages
|
|
215
|
+
```typescript
|
|
216
|
+
// Before
|
|
217
|
+
<GiftedChat
|
|
218
|
+
loadEarlier={true}
|
|
219
|
+
isLoadingEarlier={isLoading}
|
|
220
|
+
onLoadEarlier={handleLoadEarlier}
|
|
221
|
+
renderLoadEarlier={(props) => <CustomLoadEarlier {...props} />}
|
|
222
|
+
/>
|
|
223
|
+
|
|
224
|
+
// After
|
|
225
|
+
<GiftedChat
|
|
226
|
+
loadEarlierMessagesProps={{
|
|
227
|
+
loadEarlier: true,
|
|
228
|
+
isLoadingEarlier: isLoading,
|
|
229
|
+
onLoadEarlier: handleLoadEarlier,
|
|
230
|
+
renderLoadEarlier: (props) => <CustomLoadEarlier {...props} />,
|
|
231
|
+
}}
|
|
232
|
+
/>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### Link Parsing
|
|
236
|
+
```typescript
|
|
237
|
+
// Before
|
|
238
|
+
<GiftedChat
|
|
239
|
+
parsePatterns={(linkStyle) => [
|
|
240
|
+
{ pattern: /#(\w+)/, style: linkStyle, onPress: (tag) => console.log(tag) },
|
|
241
|
+
]}
|
|
242
|
+
/>
|
|
243
|
+
|
|
244
|
+
// After
|
|
245
|
+
<GiftedChat
|
|
246
|
+
matchers={[
|
|
247
|
+
{
|
|
248
|
+
pattern: /#(\w+)/,
|
|
249
|
+
style: { color: 'blue' },
|
|
250
|
+
onPress: (url, match) => console.log(match),
|
|
251
|
+
},
|
|
252
|
+
]}
|
|
253
|
+
/>
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
#### Lightbox Props (Image Viewer)
|
|
257
|
+
```typescript
|
|
258
|
+
// Before
|
|
259
|
+
<GiftedChat
|
|
260
|
+
lightboxProps={{
|
|
261
|
+
backgroundColor: 'black',
|
|
262
|
+
// other lightbox props
|
|
263
|
+
}}
|
|
264
|
+
/>
|
|
265
|
+
|
|
266
|
+
// After
|
|
267
|
+
// Custom image viewer is now built-in with react-native-zoom-reanimated
|
|
268
|
+
// No props needed - just works out of the box
|
|
269
|
+
<GiftedChat />
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## ✨ New Features
|
|
273
|
+
|
|
274
|
+
### TypeScript Improvements
|
|
275
|
+
- Complete TypeScript conversion of the library
|
|
276
|
+
- Better type safety for all props
|
|
277
|
+
- Properly typed `textInputProps` with TextInput component types
|
|
278
|
+
|
|
279
|
+
### Keyboard Handling
|
|
280
|
+
- Improved keyboard handling with `react-native-keyboard-controller`
|
|
281
|
+
- Better support for safe areas
|
|
282
|
+
- More predictable keyboard offset behavior
|
|
283
|
+
|
|
284
|
+
### Image Viewer
|
|
285
|
+
- Custom built-in image viewer using `react-native-zoom-reanimated`
|
|
286
|
+
- No external lightbox dependency needed
|
|
287
|
+
- Better cross-platform support (including web)
|
|
288
|
+
|
|
289
|
+
### SafeArea Integration
|
|
290
|
+
- Built-in SafeAreaProvider integration
|
|
291
|
+
- Better handling of notches and device-specific layouts
|
|
292
|
+
|
|
293
|
+
### Link Parsing
|
|
294
|
+
- Upgraded from `react-native-parsed-text` to `react-native-autolink`
|
|
295
|
+
- Better URL, email, and phone number detection
|
|
296
|
+
- More customizable matchers
|
|
297
|
+
|
|
298
|
+
### Load Earlier Messages
|
|
299
|
+
- Improved load earlier messages logic
|
|
300
|
+
- Better UX with proper safe area handling
|
|
301
|
+
- Consolidated props under `loadEarlierMessagesProps`
|
|
302
|
+
|
|
303
|
+
## 🐛 Bug Fixes
|
|
304
|
+
|
|
305
|
+
- Fixed scroll to bottom behavior on Android
|
|
306
|
+
- Fixed load earlier messages display
|
|
307
|
+
- Fixed keyboard offset calculations
|
|
308
|
+
- Fixed TypeScript type inconsistencies
|
|
309
|
+
- Fixed ESLint errors throughout the codebase
|
|
310
|
+
- Fixed snapshot tests
|
|
311
|
+
- Fixed message container reanimated issues
|
|
312
|
+
- Fixed DayAnimated component and proper test coverage for renderDay prop
|
|
313
|
+
- Fixed automatic scroll to bottom when `isScrollToBottomEnabled=false`
|
|
314
|
+
- Fixed MessageText container styles
|
|
315
|
+
- Fixed construct messages on send in examples
|
|
316
|
+
|
|
317
|
+
## 🔧 Internal Improvements
|
|
318
|
+
|
|
319
|
+
- Converted JavaScript to TypeScript throughout the library
|
|
320
|
+
- Improved ESLint configuration with import sorting
|
|
321
|
+
- Added support for Reanimated v3 and v4
|
|
322
|
+
- Memoized values and functions for better performance
|
|
323
|
+
- Better themed styles refactoring
|
|
324
|
+
- Improved example app with tabs and different examples
|
|
325
|
+
- Updated to latest React Native, Expo, and dependency versions
|
|
326
|
+
- Removed unused dependencies (`react-native-iphone-x-helper`, `react-native-lightbox-v2`)
|
|
327
|
+
- Replaced deprecated `TouchableWithoutFeedback` with `Pressable`
|
|
328
|
+
- Added useCallbackThrottled for better scroll to bottom visibility
|
|
329
|
+
- Removed redundant TextInput configs
|
|
330
|
+
|
|
331
|
+
## 📚 Documentation Updates
|
|
332
|
+
|
|
333
|
+
- Updated README with new installation instructions
|
|
334
|
+
- Added working Expo Snack link
|
|
335
|
+
- Better structure for props documentation
|
|
336
|
+
- Added missing props to README
|
|
337
|
+
- Fixed broken links
|
|
338
|
+
- Added dark theme support in examples
|
|
339
|
+
- Better keyboard offset documentation
|
|
340
|
+
- Improved example readmes
|
|
341
|
+
|
|
342
|
+
## 🧪 Testing
|
|
343
|
+
|
|
344
|
+
- Fixed tests to run in correct timezone (Europe/Paris)
|
|
345
|
+
- Updated snapshots for new components
|
|
346
|
+
- Added proper test coverage for DayAnimated
|
|
347
|
+
- Fixed test setup and configuration
|
|
348
|
+
|
|
349
|
+
## 📋 Repository Changes
|
|
350
|
+
|
|
351
|
+
- Added GitHub stale workflow
|
|
352
|
+
- Removed package-lock.json (yarn-only repository)
|
|
353
|
+
- Updated Node.js engine requirement to >=20
|
|
354
|
+
- Various CI/CD improvements
|
|
355
|
+
|
|
356
|
+
## ⚠️ Important Notes
|
|
357
|
+
|
|
358
|
+
1. **This is an alpha release** - Test thoroughly before using in production
|
|
359
|
+
2. **Backup your code** before upgrading
|
|
360
|
+
3. **Review all prop changes** - Many props have been renamed or removed
|
|
361
|
+
4. **New peer dependencies** - Make sure to install `react-native-gesture-handler` and `react-native-safe-area-context`
|
|
362
|
+
5. **TypeScript users** - You may need to update type imports and usages
|
|
363
|
+
6. **Keyboard behavior** - The keyboard is now handled internally by default. Set `isKeyboardInternallyHandled={false}` if you have custom keyboard handling
|
|
364
|
+
7. **Safe areas** - The library now includes SafeAreaProvider internally, but you should still wrap your app with it for best results
|
|
365
|
+
|
|
366
|
+
## 📊 Version History
|
|
367
|
+
|
|
368
|
+
- **2.8.1** - Last stable release
|
|
369
|
+
- **2.8.2-alpha.0** - Initial alpha release
|
|
370
|
+
- **2.8.2-alpha.5** - Current alpha release (this changelog)
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
For issues or questions, please visit: https://github.com/FaridSafi/react-native-gifted-chat/issues
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<p align="center"
|
|
2
|
-
<p align="center"
|
|
1
|
+
<p align="center">
|
|
2
|
+
<p align="center">
|
|
3
3
|
<a href="https://reactnative.gallery/FaridSafi/gifted-chat">
|
|
4
4
|
<img alt="react-native-gifted-chat" src="https://thumbs.gfycat.com/AbsoluteSadDobermanpinscher-size_restricted.gif" width="260" height="510" />
|
|
5
5
|
</a>
|
|
@@ -382,44 +382,44 @@ interface QuickReplies {
|
|
|
382
382
|
- `activityIndicatorStyle` - Custom style for the loading indicator
|
|
383
383
|
- `activityIndicatorColor` - Color of the loading indicator (default: 'white')
|
|
384
384
|
- `activityIndicatorSize` - Size of the loading indicator (default: 'small')
|
|
385
|
-
- **`renderLoading`** _(Function)_ - Render a loading view when initializing
|
|
386
|
-
- **`renderLoadEarlier`** _(Function)_ - Custom "Load earlier messages" button
|
|
387
|
-
- **`renderAvatar`** _(Function)_ - Custom message avatar; set to `null` to not render any avatar for the message
|
|
385
|
+
- **`renderLoading`** _(Component | Function)_ - Render a loading view when initializing
|
|
386
|
+
- **`renderLoadEarlier`** _(Component | Function)_ - Custom "Load earlier messages" button
|
|
387
|
+
- **`renderAvatar`** _(Component | Function)_ - Custom message avatar; set to `null` to not render any avatar for the message
|
|
388
388
|
- **`showUserAvatar`** _(Bool)_ - Whether to render an avatar for the current user; default is `false`, only show avatars for other users
|
|
389
389
|
- **`showAvatarForEveryMessage`** _(Bool)_ - When false, avatars will only be displayed when a consecutive message is from the same user on the same day; default is `false`
|
|
390
390
|
- **`onPressAvatar`** _(Function(`user`))_ - Callback when a message avatar is tapped
|
|
391
391
|
- **`onLongPressAvatar`** _(Function(`user`))_ - Callback when a message avatar is long-pressed
|
|
392
392
|
- **`renderAvatarOnTop`** _(Bool)_ - Render the message avatar at the top of consecutive messages, rather than the bottom; default is `false`
|
|
393
|
-
- **`renderBubble`** _(Function)_ - Custom message bubble
|
|
394
|
-
- **`renderTicks`** _(Function(`message`))_ - Custom ticks indicator to display message status
|
|
395
|
-
- **`renderSystemMessage`** _(Function)_ - Custom system message
|
|
393
|
+
- **`renderBubble`** _(Component | Function)_ - Custom message bubble
|
|
394
|
+
- **`renderTicks`** _(Component | Function(`message`))_ - Custom ticks indicator to display message status
|
|
395
|
+
- **`renderSystemMessage`** _(Component | Function)_ - Custom system message
|
|
396
396
|
- **`onPressMessage`** _(Function(`context`, `message`))_ - Callback when a message bubble is pressed
|
|
397
397
|
- **`onLongPressMessage`** _(Function(`context`, `message`))_ - Callback when a message bubble is long-pressed (see [example using `showActionSheetWithOptions()`](https://github.com/FaridSafi/react-native-gifted-chat/blob/master@%7B2017-09-25%7D/src/Bubble.js#L96-L119))
|
|
398
398
|
- **`inverted`** _(Bool)_ - Reverses display order of `messages`; default is `true`
|
|
399
399
|
- **`renderUsernameOnMessage`** _(Bool)_ - Indicate whether to show the user's username inside the message bubble; default is `false`
|
|
400
|
-
- **`renderUsername`** _(Function)_ - Custom Username container
|
|
401
|
-
- **`renderMessage`** _(Function)_ - Custom message container
|
|
402
|
-
- **`renderMessageText`** _(Function)_ - Custom message text
|
|
403
|
-
- **`renderMessageImage`** _(Function)_ - Custom message image
|
|
404
|
-
- **`renderMessageVideo`** _(Function)_ - Custom message video
|
|
405
|
-
- **`renderMessageAudio`** _(Function)_ - Custom message audio
|
|
400
|
+
- **`renderUsername`** _(Component | Function)_ - Custom Username container
|
|
401
|
+
- **`renderMessage`** _(Component | Function)_ - Custom message container
|
|
402
|
+
- **`renderMessageText`** _(Component | Function)_ - Custom message text
|
|
403
|
+
- **`renderMessageImage`** _(Component | Function)_ - Custom message image
|
|
404
|
+
- **`renderMessageVideo`** _(Component | Function)_ - Custom message video
|
|
405
|
+
- **`renderMessageAudio`** _(Component | Function)_ - Custom message audio
|
|
406
406
|
- **`imageProps`** _(Object)_ - Extra props to be passed to the [`<Image>`](https://reactnative.dev/docs/image.html) component created by the default `renderMessageImage`
|
|
407
407
|
- **`imageStyle`** _(Object)_ - Custom style for message images
|
|
408
408
|
- **`videoProps`** _(Object)_ - Extra props to be passed to the video component created by the required `renderMessageVideo`
|
|
409
409
|
- **`isCustomViewBottom`** _(Bool)_ - Determine whether renderCustomView is displayed before or after the text, image and video views; default is `false`
|
|
410
|
-
- **`renderCustomView`** _(Function)_ - Custom view inside the bubble
|
|
411
|
-
- **`renderDay`** _(Function)_ - Custom day above a message
|
|
412
|
-
- **`renderTime`** _(Function)_ - Custom time inside a message
|
|
410
|
+
- **`renderCustomView`** _(Component | Function)_ - Custom view inside the bubble
|
|
411
|
+
- **`renderDay`** _(Component | Function)_ - Custom day above a message
|
|
412
|
+
- **`renderTime`** _(Component | Function)_ - Custom time inside a message
|
|
413
413
|
- **`timeTextStyle`** _(Object)_ - Custom text style for time inside messages (supports left/right styles)
|
|
414
|
-
- **`renderFooter`** _(Function)_ - Custom footer component on the ListView, e.g. `'User is typing...'`; see [App.tsx](/example/App.tsx) for an example. Overrides default typing indicator that triggers when `isTyping` is true.
|
|
415
|
-
- **`renderTypingIndicator`** _(Function)_ - Custom typing indicator component
|
|
416
|
-
- **`renderChatEmpty`** _(Function)_ - Custom component to render in the ListView when messages are empty
|
|
417
|
-
- **`renderChatFooter`** _(Function)_ - Custom component to render below the MessageContainer (separate from the ListView)
|
|
418
|
-
- **`renderInputToolbar`** _(Function)_ - Custom message composer container
|
|
419
|
-
- **`renderComposer`** _(Function)_ - Custom text input message composer
|
|
420
|
-
- **`renderActions`** _(Function)_ - Custom action button on the left of the message composer
|
|
421
|
-
- **`renderSend`** _(Function)_ - Custom send button; you can pass children to the original `Send` component quite easily, for example, to use a custom icon ([example](https://github.com/FaridSafi/react-native-gifted-chat/pull/487))
|
|
422
|
-
- **`renderAccessory`** _(Function)_ - Custom second line of actions below the message composer
|
|
414
|
+
- **`renderFooter`** _(Component | Function)_ - Custom footer component on the ListView, e.g. `'User is typing...'`; see [App.tsx](/example/App.tsx) for an example. Overrides default typing indicator that triggers when `isTyping` is true.
|
|
415
|
+
- **`renderTypingIndicator`** _(Component | Function)_ - Custom typing indicator component
|
|
416
|
+
- **`renderChatEmpty`** _(Component | Function)_ - Custom component to render in the ListView when messages are empty
|
|
417
|
+
- **`renderChatFooter`** _(Component | Function)_ - Custom component to render below the MessageContainer (separate from the ListView)
|
|
418
|
+
- **`renderInputToolbar`** _(Component | Function)_ - Custom message composer container
|
|
419
|
+
- **`renderComposer`** _(Component | Function)_ - Custom text input message composer
|
|
420
|
+
- **`renderActions`** _(Component | Function)_ - Custom action button on the left of the message composer
|
|
421
|
+
- **`renderSend`** _(Component | Function)_ - Custom send button; you can pass children to the original `Send` component quite easily, for example, to use a custom icon ([example](https://github.com/FaridSafi/react-native-gifted-chat/pull/487))
|
|
422
|
+
- **`renderAccessory`** _(Component | Function)_ - Custom second line of actions below the message composer
|
|
423
423
|
- **`onPressActionButton`** _(Function)_ - Callback when the Action button is pressed (if set, the default `actionSheet` will not be used)
|
|
424
424
|
- **`actionSheet`** _(Function)_ - Custom action sheet interface for showing action options
|
|
425
425
|
- **`actions`** _(Array)_ - Custom action options for the input toolbar action button; array of objects with `title` (string) and `action` (function) properties
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-chat",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0-alpha.0",
|
|
4
4
|
"description": "The most complete chat UI for React Native",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"android",
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"@typescript-eslint/parser": "^8.46.4",
|
|
81
81
|
"babel-jest": "^29.7.0",
|
|
82
82
|
"eslint": "^9.18.0",
|
|
83
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
83
84
|
"eslint-plugin-import": "^2.32.0",
|
|
84
85
|
"eslint-plugin-jest": "^28.11.0",
|
|
85
86
|
"eslint-plugin-perfectionist": "^4.15.1",
|
package/src/Actions.tsx
CHANGED
package/src/Bubble/index.tsx
CHANGED
|
@@ -15,14 +15,14 @@ import stylesCommon from '../styles'
|
|
|
15
15
|
|
|
16
16
|
import { Time } from '../Time'
|
|
17
17
|
import { IMessage } from '../types'
|
|
18
|
-
import { isSameUser, isSameDay } from '../utils'
|
|
18
|
+
import { isSameUser, isSameDay, renderComponentOrElement } from '../utils'
|
|
19
19
|
|
|
20
20
|
import styles from './styles'
|
|
21
21
|
import { BubbleProps, RenderMessageTextProps } from './types'
|
|
22
22
|
|
|
23
23
|
export * from './types'
|
|
24
24
|
|
|
25
|
-
const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessage>): JSX.Element => {
|
|
25
|
+
export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessage>): JSX.Element => {
|
|
26
26
|
const {
|
|
27
27
|
currentMessage,
|
|
28
28
|
nextMessage,
|
|
@@ -109,7 +109,7 @@ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessag
|
|
|
109
109
|
} = props
|
|
110
110
|
|
|
111
111
|
if (props.renderQuickReplies)
|
|
112
|
-
return props.renderQuickReplies
|
|
112
|
+
return renderComponentOrElement(props.renderQuickReplies, quickReplyProps)
|
|
113
113
|
|
|
114
114
|
return (
|
|
115
115
|
<QuickReplies
|
|
@@ -150,9 +150,9 @@ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessag
|
|
|
150
150
|
const combinedProps = { ...messageTextPropsRest, ...messageTextProps } as RenderMessageTextProps<TMessage>
|
|
151
151
|
|
|
152
152
|
if (props.renderMessageText)
|
|
153
|
-
return props.renderMessageText
|
|
153
|
+
return renderComponentOrElement(props.renderMessageText, combinedProps)
|
|
154
154
|
|
|
155
|
-
return <MessageText {...combinedProps} />
|
|
155
|
+
return <MessageText {...combinedProps as any} />
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
return null
|
|
@@ -169,7 +169,7 @@ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessag
|
|
|
169
169
|
} = props
|
|
170
170
|
|
|
171
171
|
if (props.renderMessageImage)
|
|
172
|
-
return props.renderMessageImage
|
|
172
|
+
return renderComponentOrElement(props.renderMessageImage, messageImageProps)
|
|
173
173
|
|
|
174
174
|
return <MessageImage {...messageImageProps} />
|
|
175
175
|
}
|
|
@@ -190,7 +190,7 @@ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessag
|
|
|
190
190
|
} = props
|
|
191
191
|
|
|
192
192
|
if (props.renderMessageVideo)
|
|
193
|
-
return props.renderMessageVideo
|
|
193
|
+
return renderComponentOrElement(props.renderMessageVideo, messageVideoProps)
|
|
194
194
|
|
|
195
195
|
return <MessageVideo />
|
|
196
196
|
}, [props, currentMessage])
|
|
@@ -208,7 +208,7 @@ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessag
|
|
|
208
208
|
} = props
|
|
209
209
|
|
|
210
210
|
if (props.renderMessageAudio)
|
|
211
|
-
return props.renderMessageAudio
|
|
211
|
+
return renderComponentOrElement(props.renderMessageAudio, messageAudioProps)
|
|
212
212
|
|
|
213
213
|
return <MessageAudio />
|
|
214
214
|
}, [props, currentMessage])
|
|
@@ -220,7 +220,7 @@ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessag
|
|
|
220
220
|
} = props
|
|
221
221
|
|
|
222
222
|
if (renderTicks && currentMessage)
|
|
223
|
-
return renderTicks
|
|
223
|
+
return renderComponentOrElement(renderTicks, currentMessage)
|
|
224
224
|
|
|
225
225
|
if (
|
|
226
226
|
user &&
|
|
@@ -271,7 +271,7 @@ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessag
|
|
|
271
271
|
} = props
|
|
272
272
|
|
|
273
273
|
if (props.renderTime)
|
|
274
|
-
return props.renderTime
|
|
274
|
+
return renderComponentOrElement(props.renderTime, timeProps)
|
|
275
275
|
|
|
276
276
|
return <Time {...timeProps} />
|
|
277
277
|
}
|
|
@@ -289,7 +289,7 @@ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessag
|
|
|
289
289
|
return null
|
|
290
290
|
|
|
291
291
|
if (renderUsername)
|
|
292
|
-
return renderUsername
|
|
292
|
+
return renderComponentOrElement(renderUsername, currentMessage.user)
|
|
293
293
|
|
|
294
294
|
return (
|
|
295
295
|
<View style={styles.content.usernameView}>
|
|
@@ -313,7 +313,7 @@ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessag
|
|
|
313
313
|
|
|
314
314
|
const renderCustomView = useCallback(() => {
|
|
315
315
|
if (props.renderCustomView)
|
|
316
|
-
return props.renderCustomView
|
|
316
|
+
return renderComponentOrElement(props.renderCustomView, props)
|
|
317
317
|
|
|
318
318
|
return null
|
|
319
319
|
}, [props])
|
|
@@ -378,5 +378,3 @@ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessag
|
|
|
378
378
|
</View>
|
|
379
379
|
)
|
|
380
380
|
}
|
|
381
|
-
|
|
382
|
-
export default Bubble
|
package/src/Bubble/styles.ts
CHANGED
package/src/Bubble/types.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
TextStyle,
|
|
6
6
|
} from 'react-native'
|
|
7
7
|
import { MessageImageProps } from '../MessageImage'
|
|
8
|
-
import { MessageTextProps
|
|
8
|
+
import { MessageTextProps } from '../MessageText'
|
|
9
9
|
import { QuickRepliesProps } from '../QuickReplies'
|
|
10
10
|
import { TimeProps } from '../Time'
|
|
11
11
|
import {
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
MessageAudioProps,
|
|
19
19
|
} from '../types'
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
export type RenderMessageImageProps<TMessage extends IMessage> = Omit<
|
|
23
23
|
BubbleProps<TMessage>,
|
|
24
24
|
'containerStyle' | 'wrapperStyle'
|
|
@@ -39,10 +39,10 @@ export type RenderMessageAudioProps<TMessage extends IMessage> = Omit<
|
|
|
39
39
|
|
|
40
40
|
export type RenderMessageTextProps<TMessage extends IMessage> = Omit<
|
|
41
41
|
BubbleProps<TMessage>,
|
|
42
|
-
'containerStyle' | 'wrapperStyle'
|
|
42
|
+
'containerStyle' | 'wrapperStyle'
|
|
43
43
|
> &
|
|
44
44
|
MessageTextProps<TMessage>
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
|
|
47
47
|
export interface BubbleProps<TMessage extends IMessage> {
|
|
48
48
|
user?: User
|
|
@@ -54,7 +54,6 @@ export interface BubbleProps<TMessage extends IMessage> {
|
|
|
54
54
|
currentMessage: TMessage
|
|
55
55
|
nextMessage?: TMessage
|
|
56
56
|
previousMessage?: TMessage
|
|
57
|
-
options?: MessageOption[]
|
|
58
57
|
containerStyle?: LeftRightStyle<ViewStyle>
|
|
59
58
|
wrapperStyle?: LeftRightStyle<ViewStyle>
|
|
60
59
|
textStyle?: LeftRightStyle<TextStyle>
|
package/src/Color.ts
CHANGED
package/src/Composer.tsx
CHANGED
package/src/Day/styles.ts
CHANGED
package/src/GiftedAvatar.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
ImageStyle,
|
|
9
9
|
TextStyle,
|
|
10
10
|
} from 'react-native'
|
|
11
|
-
import Color from './Color'
|
|
11
|
+
import { Color } from './Color'
|
|
12
12
|
import { TouchableOpacity } from './components/TouchableOpacity'
|
|
13
13
|
import stylesCommon from './styles'
|
|
14
14
|
import { User } from './types'
|