react-native-gifted-chat 3.0.0-alpha.1 → 3.0.1

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 (31) hide show
  1. package/CHANGELOG.md +295 -0
  2. package/README.md +12 -30
  3. package/package.json +1 -1
  4. package/src/Actions.tsx +27 -18
  5. package/src/Composer.tsx +60 -80
  6. package/src/Constant.ts +0 -9
  7. package/src/GiftedChat/index.tsx +13 -38
  8. package/src/GiftedChat/types.ts +8 -6
  9. package/src/InputToolbar.tsx +6 -11
  10. package/src/MessageImage.tsx +94 -57
  11. package/src/{MessageContainer → MessagesContainer}/components/Item/index.tsx +21 -17
  12. package/src/{MessageContainer → MessagesContainer}/components/Item/types.ts +3 -2
  13. package/src/{MessageContainer → MessagesContainer}/index.tsx +16 -14
  14. package/src/{MessageContainer → MessagesContainer}/types.ts +4 -2
  15. package/src/Send.tsx +40 -22
  16. package/src/__tests__/DayAnimated.test.tsx +1 -1
  17. package/src/__tests__/{MessageContainer.test.tsx → MessagesContainer.test.tsx} +7 -7
  18. package/src/__tests__/__snapshots__/Actions.test.tsx.snap +31 -23
  19. package/src/__tests__/__snapshots__/Composer.test.tsx.snap +39 -30
  20. package/src/__tests__/__snapshots__/Constant.test.tsx.snap +0 -2
  21. package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +112 -31
  22. package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +251 -0
  23. package/src/__tests__/__snapshots__/Send.test.tsx.snap +189 -49
  24. package/src/index.ts +1 -1
  25. package/src/styles.ts +5 -0
  26. package/src/types.ts +1 -1
  27. package/CHANGELOG_2.8.1_to_2.8.2-alpha.5.md +0 -374
  28. /package/src/{MessageContainer → MessagesContainer}/components/DayAnimated/index.tsx +0 -0
  29. /package/src/{MessageContainer → MessagesContainer}/components/DayAnimated/styles.ts +0 -0
  30. /package/src/{MessageContainer → MessagesContainer}/components/DayAnimated/types.ts +0 -0
  31. /package/src/{MessageContainer → MessagesContainer}/styles.ts +0 -0
@@ -1,374 +0,0 @@
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