react-native-gifted-chat 2.9.0-alpha.0 → 3.0.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/README.md +183 -262
- package/package.json +1 -1
- package/src/Avatar.tsx +12 -12
- package/src/Bubble/index.tsx +2 -2
- package/src/Bubble/types.ts +22 -22
- package/src/Composer.tsx +0 -3
- package/src/GiftedAvatar.tsx +1 -1
- package/src/GiftedChat/index.tsx +20 -23
- package/src/GiftedChat/types.ts +38 -47
- package/src/InputToolbar.tsx +6 -6
- package/src/Message/index.tsx +5 -6
- package/src/Message/types.ts +8 -12
- package/src/MessageContainer/components/DayAnimated/types.ts +1 -1
- package/src/MessageContainer/components/Item/index.tsx +2 -2
- package/src/MessageContainer/components/Item/types.ts +1 -1
- package/src/MessageContainer/index.tsx +28 -30
- package/src/MessageContainer/types.ts +12 -16
- package/src/MessageImage.tsx +1 -1
- package/src/MessageText.tsx +1 -1
- package/src/Models.ts +63 -0
- package/src/QuickReplies.tsx +1 -1
- package/src/Send.tsx +30 -31
- package/src/SystemMessage.tsx +1 -1
- package/src/Time.tsx +1 -1
- package/src/__tests__/Message.test.tsx +2 -2
- package/src/__tests__/Send.test.tsx +1 -1
- package/src/__tests__/__snapshots__/Actions.test.tsx.snap +2 -86
- package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +3 -89
- package/src/__tests__/__snapshots__/Message.test.tsx.snap +2 -2
- package/src/__tests__/__snapshots__/Send.test.tsx.snap +10 -142
- package/src/__tests__/data.ts +1 -1
- package/src/components/TouchableOpacity.tsx +19 -8
- package/src/types.ts +1 -63
- package/src/utils.ts +1 -1
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`should render <LoadEarlierMessages /> and compare with snapshot 1`] = `
|
|
4
4
|
<View
|
|
5
|
+
accessibilityRole="button"
|
|
5
6
|
accessibilityState={
|
|
6
7
|
{
|
|
7
8
|
"busy": undefined,
|
|
8
9
|
"checked": undefined,
|
|
9
|
-
"disabled":
|
|
10
|
+
"disabled": false,
|
|
10
11
|
"expanded": undefined,
|
|
11
12
|
"selected": undefined,
|
|
12
13
|
}
|
|
@@ -20,100 +21,13 @@ exports[`should render <LoadEarlierMessages /> and compare with snapshot 1`] = `
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
accessible={true}
|
|
23
|
-
collapsable={false}
|
|
24
24
|
focusable={true}
|
|
25
|
-
onBlur={[Function]}
|
|
26
25
|
onClick={[Function]}
|
|
27
|
-
onFocus={[Function]}
|
|
28
26
|
onResponderGrant={[Function]}
|
|
29
27
|
onResponderMove={[Function]}
|
|
30
28
|
onResponderRelease={[Function]}
|
|
31
29
|
onResponderTerminate={[Function]}
|
|
32
30
|
onResponderTerminationRequest={[Function]}
|
|
33
31
|
onStartShouldSetResponder={[Function]}
|
|
34
|
-
|
|
35
|
-
<View
|
|
36
|
-
accessibilityRole="button"
|
|
37
|
-
collapsable={false}
|
|
38
|
-
disabled={false}
|
|
39
|
-
jestAnimatedProps={
|
|
40
|
-
{
|
|
41
|
-
"value": {},
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
jestAnimatedStyle={
|
|
45
|
-
{
|
|
46
|
-
"value": {
|
|
47
|
-
"opacity": 1,
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
jestInlineStyle={
|
|
52
|
-
[
|
|
53
|
-
[
|
|
54
|
-
{
|
|
55
|
-
"alignItems": "center",
|
|
56
|
-
"marginVertical": 10,
|
|
57
|
-
},
|
|
58
|
-
undefined,
|
|
59
|
-
],
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
style={
|
|
63
|
-
[
|
|
64
|
-
{
|
|
65
|
-
"alignItems": "center",
|
|
66
|
-
"marginVertical": 10,
|
|
67
|
-
},
|
|
68
|
-
undefined,
|
|
69
|
-
{
|
|
70
|
-
"opacity": 1,
|
|
71
|
-
},
|
|
72
|
-
]
|
|
73
|
-
}
|
|
74
|
-
>
|
|
75
|
-
<View
|
|
76
|
-
style={
|
|
77
|
-
[
|
|
78
|
-
{
|
|
79
|
-
"alignItems": "center",
|
|
80
|
-
"justifyContent": "center",
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"backgroundColor": "#b2b2b2",
|
|
84
|
-
"borderRadius": 15,
|
|
85
|
-
"paddingHorizontal": 10,
|
|
86
|
-
"paddingVertical": 5,
|
|
87
|
-
},
|
|
88
|
-
undefined,
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
>
|
|
92
|
-
<View
|
|
93
|
-
style={
|
|
94
|
-
{
|
|
95
|
-
"paddingBottom": 4,
|
|
96
|
-
"paddingTop": 3,
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
>
|
|
100
|
-
<Text
|
|
101
|
-
style={
|
|
102
|
-
[
|
|
103
|
-
{
|
|
104
|
-
"backgroundColor": "transparent",
|
|
105
|
-
"color": "#fff",
|
|
106
|
-
"fontSize": 12,
|
|
107
|
-
"lineHeight": 13,
|
|
108
|
-
},
|
|
109
|
-
undefined,
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
>
|
|
113
|
-
Load earlier messages
|
|
114
|
-
</Text>
|
|
115
|
-
</View>
|
|
116
|
-
</View>
|
|
117
|
-
</View>
|
|
118
|
-
</View>
|
|
32
|
+
/>
|
|
119
33
|
`;
|
|
@@ -305,7 +305,7 @@ exports[`Message component should render <Message /> with Avatar 1`] = `
|
|
|
305
305
|
}
|
|
306
306
|
>
|
|
307
307
|
<Text
|
|
308
|
-
|
|
308
|
+
isUserAvatarVisible={true}
|
|
309
309
|
style={
|
|
310
310
|
[
|
|
311
311
|
{
|
|
@@ -511,7 +511,7 @@ exports[`Message component should render null if user has no Avatar 1`] = `
|
|
|
511
511
|
}
|
|
512
512
|
>
|
|
513
513
|
<Text
|
|
514
|
-
|
|
514
|
+
isUserAvatarVisible={true}
|
|
515
515
|
style={
|
|
516
516
|
[
|
|
517
517
|
{
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Send should always render <Send /> and compare with snapshot 1`] = `
|
|
4
4
|
<View
|
|
5
|
+
accessibilityLabel="send"
|
|
6
|
+
accessibilityRole="button"
|
|
5
7
|
accessibilityState={
|
|
6
8
|
{
|
|
7
9
|
"busy": undefined,
|
|
8
10
|
"checked": undefined,
|
|
9
|
-
"disabled":
|
|
11
|
+
"disabled": false,
|
|
10
12
|
"expanded": undefined,
|
|
11
13
|
"selected": undefined,
|
|
12
14
|
}
|
|
@@ -20,95 +22,29 @@ exports[`Send should always render <Send /> and compare with snapshot 1`] = `
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
accessible={true}
|
|
23
|
-
collapsable={false}
|
|
24
25
|
focusable={true}
|
|
25
|
-
onBlur={[Function]}
|
|
26
26
|
onClick={[Function]}
|
|
27
|
-
onFocus={[Function]}
|
|
28
27
|
onResponderGrant={[Function]}
|
|
29
28
|
onResponderMove={[Function]}
|
|
30
29
|
onResponderRelease={[Function]}
|
|
31
30
|
onResponderTerminate={[Function]}
|
|
32
31
|
onResponderTerminationRequest={[Function]}
|
|
33
32
|
onStartShouldSetResponder={[Function]}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
accessibilityLabel="send"
|
|
37
|
-
accessibilityRole="button"
|
|
38
|
-
accessible={true}
|
|
39
|
-
collapsable={false}
|
|
40
|
-
disabled={false}
|
|
41
|
-
jestAnimatedProps={
|
|
42
|
-
{
|
|
43
|
-
"value": {},
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
jestAnimatedStyle={
|
|
47
|
-
{
|
|
48
|
-
"value": {
|
|
49
|
-
"opacity": 1,
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
jestInlineStyle={
|
|
54
|
-
[
|
|
55
|
-
[
|
|
56
|
-
{
|
|
57
|
-
"height": 44,
|
|
58
|
-
"justifyContent": "flex-end",
|
|
59
|
-
},
|
|
60
|
-
undefined,
|
|
61
|
-
],
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
style={
|
|
65
|
-
[
|
|
66
|
-
{
|
|
67
|
-
"height": 44,
|
|
68
|
-
"justifyContent": "flex-end",
|
|
69
|
-
},
|
|
70
|
-
undefined,
|
|
71
|
-
{
|
|
72
|
-
"opacity": 1,
|
|
73
|
-
},
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
testID="GC_SEND_TOUCHABLE"
|
|
77
|
-
>
|
|
78
|
-
<View>
|
|
79
|
-
<Text
|
|
80
|
-
style={
|
|
81
|
-
[
|
|
82
|
-
{
|
|
83
|
-
"backgroundColor": "transparent",
|
|
84
|
-
"color": "#0084ff",
|
|
85
|
-
"fontSize": 17,
|
|
86
|
-
"fontWeight": "600",
|
|
87
|
-
"marginBottom": 12,
|
|
88
|
-
"marginLeft": 10,
|
|
89
|
-
"marginRight": 10,
|
|
90
|
-
},
|
|
91
|
-
undefined,
|
|
92
|
-
undefined,
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
>
|
|
96
|
-
Send
|
|
97
|
-
</Text>
|
|
98
|
-
</View>
|
|
99
|
-
</View>
|
|
100
|
-
</View>
|
|
33
|
+
testID="GC_SEND_TOUCHABLE"
|
|
34
|
+
/>
|
|
101
35
|
`;
|
|
102
36
|
|
|
103
37
|
exports[`Send should not render <Send /> and compare with snapshot 1`] = `null`;
|
|
104
38
|
|
|
105
39
|
exports[`Send should render <Send /> where there is input and compare with snapshot 1`] = `
|
|
106
40
|
<View
|
|
41
|
+
accessibilityLabel="send"
|
|
42
|
+
accessibilityRole="button"
|
|
107
43
|
accessibilityState={
|
|
108
44
|
{
|
|
109
45
|
"busy": undefined,
|
|
110
46
|
"checked": undefined,
|
|
111
|
-
"disabled":
|
|
47
|
+
"disabled": false,
|
|
112
48
|
"expanded": undefined,
|
|
113
49
|
"selected": undefined,
|
|
114
50
|
}
|
|
@@ -122,82 +58,14 @@ exports[`Send should render <Send /> where there is input and compare with snaps
|
|
|
122
58
|
}
|
|
123
59
|
}
|
|
124
60
|
accessible={true}
|
|
125
|
-
collapsable={false}
|
|
126
61
|
focusable={true}
|
|
127
|
-
onBlur={[Function]}
|
|
128
62
|
onClick={[Function]}
|
|
129
|
-
onFocus={[Function]}
|
|
130
63
|
onResponderGrant={[Function]}
|
|
131
64
|
onResponderMove={[Function]}
|
|
132
65
|
onResponderRelease={[Function]}
|
|
133
66
|
onResponderTerminate={[Function]}
|
|
134
67
|
onResponderTerminationRequest={[Function]}
|
|
135
68
|
onStartShouldSetResponder={[Function]}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
accessibilityLabel="send"
|
|
139
|
-
accessibilityRole="button"
|
|
140
|
-
accessible={true}
|
|
141
|
-
collapsable={false}
|
|
142
|
-
disabled={false}
|
|
143
|
-
jestAnimatedProps={
|
|
144
|
-
{
|
|
145
|
-
"value": {},
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
jestAnimatedStyle={
|
|
149
|
-
{
|
|
150
|
-
"value": {
|
|
151
|
-
"opacity": 1,
|
|
152
|
-
},
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
jestInlineStyle={
|
|
156
|
-
[
|
|
157
|
-
[
|
|
158
|
-
{
|
|
159
|
-
"height": 44,
|
|
160
|
-
"justifyContent": "flex-end",
|
|
161
|
-
},
|
|
162
|
-
undefined,
|
|
163
|
-
],
|
|
164
|
-
]
|
|
165
|
-
}
|
|
166
|
-
style={
|
|
167
|
-
[
|
|
168
|
-
{
|
|
169
|
-
"height": 44,
|
|
170
|
-
"justifyContent": "flex-end",
|
|
171
|
-
},
|
|
172
|
-
undefined,
|
|
173
|
-
{
|
|
174
|
-
"opacity": 1,
|
|
175
|
-
},
|
|
176
|
-
]
|
|
177
|
-
}
|
|
178
|
-
testID="GC_SEND_TOUCHABLE"
|
|
179
|
-
>
|
|
180
|
-
<View>
|
|
181
|
-
<Text
|
|
182
|
-
style={
|
|
183
|
-
[
|
|
184
|
-
{
|
|
185
|
-
"backgroundColor": "transparent",
|
|
186
|
-
"color": "#0084ff",
|
|
187
|
-
"fontSize": 17,
|
|
188
|
-
"fontWeight": "600",
|
|
189
|
-
"marginBottom": 12,
|
|
190
|
-
"marginLeft": 10,
|
|
191
|
-
"marginRight": 10,
|
|
192
|
-
},
|
|
193
|
-
undefined,
|
|
194
|
-
undefined,
|
|
195
|
-
]
|
|
196
|
-
}
|
|
197
|
-
>
|
|
198
|
-
Send
|
|
199
|
-
</Text>
|
|
200
|
-
</View>
|
|
201
|
-
</View>
|
|
202
|
-
</View>
|
|
69
|
+
testID="GC_SEND_TOUCHABLE"
|
|
70
|
+
/>
|
|
203
71
|
`;
|
package/src/__tests__/data.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React, { useCallback } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { BaseButton } from 'react-native-gesture-handler'
|
|
3
3
|
import Animated, {
|
|
4
4
|
useAnimatedStyle,
|
|
5
5
|
useSharedValue,
|
|
6
6
|
withTiming,
|
|
7
7
|
} from 'react-native-reanimated'
|
|
8
8
|
|
|
9
|
-
export type TouchableOpacityProps = React.ComponentProps<typeof
|
|
9
|
+
export type TouchableOpacityProps = Omit<React.ComponentProps<typeof BaseButton>, 'onPress'> & {
|
|
10
10
|
activeOpacity?: number
|
|
11
|
+
onPress?: () => void
|
|
11
12
|
} & React.ComponentProps<typeof Animated.View>
|
|
12
13
|
|
|
13
14
|
export const TouchableOpacity: React.FC<TouchableOpacityProps> = ({
|
|
@@ -35,22 +36,32 @@ export const TouchableOpacity: React.FC<TouchableOpacityProps> = ({
|
|
|
35
36
|
}, isAnimationInFinished.value ? 0 : 150)
|
|
36
37
|
}, [opacity, isAnimationInFinished])
|
|
37
38
|
|
|
39
|
+
const handleActiveStateChange = useCallback((isActive: boolean) => {
|
|
40
|
+
if (isActive)
|
|
41
|
+
handlePressIn()
|
|
42
|
+
else
|
|
43
|
+
handlePressOut()
|
|
44
|
+
}, [handlePressIn, handlePressOut])
|
|
45
|
+
|
|
38
46
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
39
47
|
opacity: opacity.value,
|
|
40
48
|
}))
|
|
41
49
|
|
|
50
|
+
const handlePress = useCallback(() => {
|
|
51
|
+
onPress?.()
|
|
52
|
+
}, [onPress])
|
|
53
|
+
|
|
42
54
|
return (
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
<BaseButton
|
|
56
|
+
{...rest}
|
|
57
|
+
onPress={handlePress}
|
|
58
|
+
onActiveStateChange={handleActiveStateChange}
|
|
47
59
|
>
|
|
48
60
|
<Animated.View
|
|
49
|
-
{...rest}
|
|
50
61
|
style={[style, animatedStyle]}
|
|
51
62
|
>
|
|
52
63
|
{children}
|
|
53
64
|
</Animated.View>
|
|
54
|
-
</
|
|
65
|
+
</BaseButton>
|
|
55
66
|
)
|
|
56
67
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './Models'
|
|
2
2
|
|
|
3
3
|
export { ActionsProps } from './Actions'
|
|
4
4
|
export { AvatarProps } from './Avatar'
|
|
@@ -22,65 +22,3 @@ export { QuickRepliesProps } from './QuickReplies'
|
|
|
22
22
|
export { SendProps } from './Send'
|
|
23
23
|
export { SystemMessageProps } from './SystemMessage'
|
|
24
24
|
export { TimeProps } from './Time'
|
|
25
|
-
|
|
26
|
-
export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>
|
|
27
|
-
|
|
28
|
-
export interface LeftRightStyle<T> {
|
|
29
|
-
left?: StyleProp<T>
|
|
30
|
-
right?: StyleProp<T>
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type renderFunction = (x: unknown) => React.ReactNode
|
|
34
|
-
|
|
35
|
-
export interface User {
|
|
36
|
-
_id: string | number
|
|
37
|
-
name?: string
|
|
38
|
-
avatar?: string | number | renderFunction
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface Reply {
|
|
42
|
-
title: string
|
|
43
|
-
value: string
|
|
44
|
-
messageId?: number | string
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface QuickReplies {
|
|
48
|
-
type: 'radio' | 'checkbox'
|
|
49
|
-
values: Reply[]
|
|
50
|
-
keepIt?: boolean
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface IMessage {
|
|
54
|
-
_id: string | number
|
|
55
|
-
text: string
|
|
56
|
-
createdAt: Date | number
|
|
57
|
-
user: User
|
|
58
|
-
image?: string
|
|
59
|
-
video?: string
|
|
60
|
-
audio?: string
|
|
61
|
-
system?: boolean
|
|
62
|
-
sent?: boolean
|
|
63
|
-
received?: boolean
|
|
64
|
-
pending?: boolean
|
|
65
|
-
quickReplies?: QuickReplies
|
|
66
|
-
location?: {
|
|
67
|
-
latitude: number
|
|
68
|
-
longitude: number
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export type IChatMessage = IMessage
|
|
73
|
-
|
|
74
|
-
export interface MessageVideoProps<TMessage extends IMessage> {
|
|
75
|
-
currentMessage: TMessage
|
|
76
|
-
containerStyle?: StyleProp<ViewStyle>
|
|
77
|
-
videoStyle?: StyleProp<ViewStyle>
|
|
78
|
-
videoProps?: object
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface MessageAudioProps<TMessage extends IMessage> {
|
|
82
|
-
currentMessage: TMessage
|
|
83
|
-
containerStyle?: StyleProp<ViewStyle>
|
|
84
|
-
audioStyle?: StyleProp<ViewStyle>
|
|
85
|
-
audioProps?: object
|
|
86
|
-
}
|
package/src/utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef } from 'react'
|
|
2
2
|
import dayjs from 'dayjs'
|
|
3
|
-
import { IMessage } from './
|
|
3
|
+
import { IMessage } from './Models'
|
|
4
4
|
|
|
5
5
|
export function renderComponentOrElement<TProps extends Record<string, any>>(
|
|
6
6
|
component: React.ComponentType<TProps> | React.ReactElement | ((props: TProps) => React.ReactNode) | null | undefined,
|