react-native-gifted-chat 2.8.1 → 2.8.2-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.
Files changed (39) hide show
  1. package/README.md +10 -5
  2. package/lib/Bubble/index.d.ts +2 -2
  3. package/lib/Bubble/index.js +8 -23
  4. package/lib/Bubble/index.js.map +1 -1
  5. package/lib/Bubble/types.d.ts +3 -3
  6. package/lib/GiftedChat/index.js +19 -4
  7. package/lib/GiftedChat/index.js.map +1 -1
  8. package/lib/GiftedChat/types.d.ts +2 -7
  9. package/lib/MessageContainer/index.js +50 -39
  10. package/lib/MessageContainer/index.js.map +1 -1
  11. package/lib/MessageContainer/styles.d.ts +3 -2
  12. package/lib/MessageContainer/styles.js +3 -2
  13. package/lib/MessageContainer/styles.js.map +1 -1
  14. package/lib/MessageContainer/types.d.ts +6 -9
  15. package/lib/MessageText.d.ts +11 -7
  16. package/lib/MessageText.js +57 -96
  17. package/lib/MessageText.js.map +1 -1
  18. package/lib/SystemMessage.d.ts +2 -1
  19. package/lib/SystemMessage.js +3 -2
  20. package/lib/SystemMessage.js.map +1 -1
  21. package/lib/utils.d.ts +2 -0
  22. package/lib/utils.js +66 -0
  23. package/lib/utils.js.map +1 -1
  24. package/package.json +33 -26
  25. package/src/Bubble/index.tsx +10 -35
  26. package/src/Bubble/types.ts +3 -3
  27. package/src/GiftedChat/index.tsx +23 -3
  28. package/src/GiftedChat/types.ts +3 -1
  29. package/src/MessageContainer/index.tsx +61 -40
  30. package/src/MessageContainer/styles.ts +3 -2
  31. package/src/MessageContainer/types.ts +6 -9
  32. package/src/MessageText.tsx +86 -121
  33. package/src/SystemMessage.tsx +4 -1
  34. package/src/__tests__/DayAnimated.test.tsx +54 -0
  35. package/src/__tests__/GiftedChat.test.tsx +25 -0
  36. package/src/__tests__/__snapshots__/DayAnimated.test.tsx.snap +5 -0
  37. package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +25 -0
  38. package/src/__tests__/__snapshots__/MessageContainer.test.tsx.snap +10 -3
  39. package/src/utils.ts +77 -1
@@ -1,15 +1,11 @@
1
- import React, { Component, RefObject } from 'react';
2
- import { FlatListProps, LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';
1
+ import React, { RefObject } from 'react';
2
+ import { FlatListProps, StyleProp, ViewStyle, FlatList } from 'react-native';
3
3
  import { LoadEarlierProps } from '../LoadEarlier';
4
4
  import { MessageProps } from '../Message';
5
- import { User, IMessage, Reply } from '../types';
5
+ import { User, IMessage, Reply, DayProps } from '../types';
6
6
  import { ReanimatedScrollEvent } from 'react-native-reanimated/lib/typescript/hook/commonTypes';
7
- import { FlatList } from 'react-native-reanimated/lib/typescript/Animated';
8
- import { AnimateProps } from 'react-native-reanimated';
9
- export type ListViewProps = {
10
- onLayout?: (event: LayoutChangeEvent) => void;
11
- } & object;
12
- export type AnimatedList<TMessage> = Component<AnimateProps<FlatListProps<TMessage>>, unknown, unknown> & FlatList<FlatListProps<TMessage>>;
7
+ export type ListViewProps<TMessage extends IMessage = IMessage> = Partial<FlatListProps<TMessage>>;
8
+ export type AnimatedList<TMessage> = FlatList<TMessage>;
13
9
  export interface MessageContainerProps<TMessage extends IMessage = IMessage> {
14
10
  forwardRef?: RefObject<AnimatedList<TMessage>>;
15
11
  messages?: TMessage[];
@@ -27,6 +23,7 @@ export interface MessageContainerProps<TMessage extends IMessage = IMessage> {
27
23
  renderChatEmpty?(): React.ReactNode;
28
24
  renderFooter?(props: MessageContainerProps<TMessage>): React.ReactNode;
29
25
  renderMessage?(props: MessageProps<TMessage>): React.ReactElement;
26
+ renderDay?(props: DayProps): React.ReactNode;
30
27
  renderLoadEarlier?(props: LoadEarlierProps): React.ReactNode;
31
28
  renderTypingIndicator?(): React.ReactNode;
32
29
  scrollToBottomComponent?(): React.ReactNode;
@@ -1,15 +1,19 @@
1
1
  import React from 'react';
2
- import { TextProps, StyleProp, ViewStyle, TextStyle } from 'react-native';
2
+ import { StyleProp, ViewStyle, TextStyle } from 'react-native';
3
+ import { AutolinkProps } from 'react-native-autolink';
4
+ import { Match } from 'autolinker/dist/es2015';
3
5
  import { LeftRightStyle, IMessage } from './types';
4
- export interface MessageTextProps<TMessage extends IMessage> {
6
+ export interface MessageOption {
7
+ title: string;
8
+ action: (phone: string) => void;
9
+ }
10
+ export type MessageTextProps<TMessage extends IMessage> = {
5
11
  position?: 'left' | 'right';
6
- optionTitles?: string[];
7
12
  currentMessage: TMessage;
8
13
  containerStyle?: LeftRightStyle<ViewStyle>;
9
14
  textStyle?: LeftRightStyle<TextStyle>;
10
15
  linkStyle?: LeftRightStyle<TextStyle>;
11
- textProps?: TextProps;
12
16
  customTextStyle?: StyleProp<TextStyle>;
13
- parsePatterns?: (linkStyle: TextStyle) => [];
14
- }
15
- export declare function MessageText<TMessage extends IMessage = IMessage>({ currentMessage, optionTitles, position, containerStyle, textStyle, linkStyle: linkStyleProp, customTextStyle, parsePatterns, textProps, }: MessageTextProps<TMessage>): React.JSX.Element;
17
+ onPress?: (message: TMessage, url: string, match: Match) => void;
18
+ } & Omit<AutolinkProps, 'text' | 'onPress'>;
19
+ export declare const MessageText: React.FC<MessageTextProps<IMessage>>;
@@ -1,46 +1,8 @@
1
- import React from 'react';
2
- import { Linking, StyleSheet, View, } from 'react-native';
3
- import ParsedText from 'react-native-parsed-text';
4
- import { useChatContext } from './GiftedChatContext';
1
+ import React, { useMemo, useCallback } from 'react';
2
+ import { Linking, StyleSheet, } from 'react-native';
3
+ import Autolink from 'react-native-autolink';
5
4
  import { error } from './logging';
6
- const WWW_URL_PATTERN = /^www\./i;
7
- const { textStyle } = StyleSheet.create({
8
- textStyle: {
9
- fontSize: 16,
10
- lineHeight: 20,
11
- marginTop: 5,
12
- marginBottom: 5,
13
- marginLeft: 10,
14
- marginRight: 10,
15
- },
16
- });
17
- const styles = {
18
- left: StyleSheet.create({
19
- container: {},
20
- text: {
21
- color: 'black',
22
- ...textStyle,
23
- },
24
- link: {
25
- color: 'black',
26
- textDecorationLine: 'underline',
27
- },
28
- }),
29
- right: StyleSheet.create({
30
- container: {},
31
- text: {
32
- color: 'white',
33
- ...textStyle,
34
- },
35
- link: {
36
- color: 'white',
37
- textDecorationLine: 'underline',
38
- },
39
- }),
40
- };
41
- const DEFAULT_OPTION_TITLES = ['Call', 'Text', 'Cancel'];
42
- export function MessageText({ currentMessage = {}, optionTitles = DEFAULT_OPTION_TITLES, position = 'left', containerStyle, textStyle, linkStyle: linkStyleProp, customTextStyle, parsePatterns, textProps, }) {
43
- const { actionSheet } = useChatContext();
5
+ export const MessageText = ({ currentMessage = {}, position = 'left', containerStyle, textStyle, linkStyle: linkStyleProp, customTextStyle, onPress: onPressProp, ...rest }) => {
44
6
  // TODO: React.memo
45
7
  // const shouldComponentUpdate = (nextProps: MessageTextProps<TMessage>) => {
46
8
  // return (
@@ -49,60 +11,59 @@ export function MessageText({ currentMessage = {}, optionTitles = DEFAULT_OPTION
49
11
  // currentMessage.text !== nextProps.currentMessage.text
50
12
  // )
51
13
  // }
52
- const onUrlPress = (url) => {
53
- // When someone sends a message that includes a website address beginning with "www." (omitting the scheme),
54
- // react-native-parsed-text recognizes it as a valid url, but Linking fails to open due to the missing scheme.
55
- if (WWW_URL_PATTERN.test(url))
56
- onUrlPress(`https://${url}`);
57
- else
58
- Linking.openURL(url).catch(e => {
59
- error(e, 'No handler for URL:', url);
60
- });
61
- };
62
- const onPhonePress = (phone) => {
63
- const options = optionTitles && optionTitles.length > 0
64
- ? optionTitles.slice(0, 3)
65
- : DEFAULT_OPTION_TITLES;
66
- const cancelButtonIndex = options.length - 1;
67
- actionSheet().showActionSheetWithOptions({
68
- options,
69
- cancelButtonIndex,
70
- }, (buttonIndex) => {
71
- switch (buttonIndex) {
72
- case 0:
73
- Linking.openURL(`tel:${phone}`).catch(e => {
74
- error(e, 'No handler for telephone');
75
- });
76
- break;
77
- case 1:
78
- Linking.openURL(`sms:${phone}`).catch(e => {
79
- error(e, 'No handler for text');
80
- });
81
- break;
82
- }
14
+ const onUrlPress = useCallback((url) => {
15
+ if (/^www\./i.test(url))
16
+ url = `https://${url}`;
17
+ Linking.openURL(url).catch(e => {
18
+ error(e, 'No handler for URL:', url);
83
19
  });
84
- };
85
- const onEmailPress = (email) => Linking.openURL(`mailto:${email}`).catch(e => error(e, 'No handler for mailto'));
86
- const linkStyle = [
87
- styles[position].link,
20
+ }, []);
21
+ const onPhonePress = useCallback((phone) => {
22
+ Linking.openURL(`tel:${phone}`).catch(e => {
23
+ error(e, 'No handler for telephone');
24
+ });
25
+ }, []);
26
+ const onEmailPress = useCallback((email) => Linking.openURL(`mailto:${email}`).catch(e => error(e, 'No handler for mailto')), []);
27
+ const linkStyle = useMemo(() => StyleSheet.flatten([
28
+ styles.link,
88
29
  linkStyleProp?.[position],
89
- ];
90
- return (<View style={[
91
- styles[position].container,
92
- containerStyle?.[position],
93
- ]}>
94
- <ParsedText style={[
95
- styles[position].text,
96
- textStyle?.[position],
97
- customTextStyle,
98
- ]} parse={[
99
- ...(parsePatterns ? parsePatterns(linkStyle) : []),
100
- { type: 'url', style: linkStyle, onPress: onUrlPress },
101
- { type: 'phone', style: linkStyle, onPress: onPhonePress },
102
- { type: 'email', style: linkStyle, onPress: onEmailPress },
103
- ]} childrenProps={{ ...textProps }}>
104
- {currentMessage.text}
105
- </ParsedText>
106
- </View>);
107
- }
30
+ ]), [position, linkStyleProp]);
31
+ const handlePress = useCallback((url, match) => {
32
+ const type = match.getType();
33
+ if (onPressProp)
34
+ onPressProp(currentMessage, url, match);
35
+ else if (type === 'url')
36
+ onUrlPress(url);
37
+ else if (type === 'phone')
38
+ onPhonePress(url);
39
+ else if (type === 'email')
40
+ onEmailPress(url);
41
+ }, [onUrlPress, onPhonePress, onEmailPress, onPressProp, currentMessage]);
42
+ const style = useMemo(() => [
43
+ containerStyle?.[position],
44
+ styles[`text_${position}`],
45
+ textStyle?.[position],
46
+ customTextStyle,
47
+ ], [containerStyle, position, textStyle, customTextStyle]);
48
+ return (<Autolink style={style} {...rest} text={currentMessage.text} email link linkStyle={linkStyle} onPress={handlePress}/>);
49
+ };
50
+ const styles = StyleSheet.create({
51
+ text: {
52
+ fontSize: 16,
53
+ lineHeight: 20,
54
+ marginTop: 5,
55
+ marginBottom: 5,
56
+ marginLeft: 10,
57
+ marginRight: 10,
58
+ },
59
+ text_left: {
60
+ color: 'black',
61
+ },
62
+ text_right: {
63
+ color: 'white',
64
+ },
65
+ link: {
66
+ textDecorationLine: 'underline',
67
+ },
68
+ });
108
69
  //# sourceMappingURL=MessageText.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MessageText.js","sourceRoot":"","sources":["../src/MessageText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EACL,OAAO,EACP,UAAU,EACV,IAAI,GAKL,MAAM,cAAc,CAAA;AAErB,OAAO,UAAU,MAAM,0BAA0B,CAAA;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEjC,MAAM,eAAe,GAAG,SAAS,CAAA;AAEjC,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC;IACtC,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,SAAS,EAAE,CAAC;QACZ,YAAY,EAAE,CAAC;QACf,UAAU,EAAE,EAAE;QACd,WAAW,EAAE,EAAE;KAChB;CACF,CAAC,CAAA;AAEF,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC;QACtB,SAAS,EAAE,EAAE;QACb,IAAI,EAAE;YACJ,KAAK,EAAE,OAAO;YACd,GAAG,SAAS;SACb;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,OAAO;YACd,kBAAkB,EAAE,WAAW;SAChC;KACF,CAAC;IACF,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC;QACvB,SAAS,EA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
  textStyle?: StyleProp<TextStyle>;
9
+ children?: React.ReactNode;
9
10
  }
10
- export declare function SystemMessage<TMessage extends IMessage = IMessage>({ currentMessage, containerStyle, wrapperStyle, textStyle, }: SystemMessageProps<TMessage>): React.JSX.Element | null;
11
+ export declare function SystemMessage<TMessage extends IMessage = IMessage>({ currentMessage, containerStyle, wrapperStyle, textStyle, children, }: SystemMessageProps<TMessage>): React.JSX.Element | null;
@@ -14,12 +14,13 @@ const styles = StyleSheet.create({
14
14
  fontWeight: '300',
15
15
  },
16
16
  });
17
- export function SystemMessage({ currentMessage, containerStyle, wrapperStyle, textStyle, }) {
17
+ export function SystemMessage({ currentMessage, containerStyle, wrapperStyle, textStyle, children, }) {
18
18
  if (currentMessage == null || currentMessage.system === false)
19
19
  return null;
20
20
  return (<View style={[stylesCommon.fill, stylesCommon.centerItems, styles.container, containerStyle]}>
21
21
  <View style={wrapperStyle}>
22
- <Text style={[styles.text, textStyle]}>{currentMessage.text}</Text>
22
+ {!!currentMessage.text && <Text style={[styles.text, textStyle]}>{currentMessage.text}</Text>}
23
+ {children}
23
24
  </View>
24
25
  </View>);
25
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SystemMessage.js","sourceRoot":"","sources":["../src/SystemMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EACL,UAAU,EACV,IAAI,EACJ,IAAI,GAIL,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,MAAM,SAAS,CAAA;AAE3B,OAAO,YAAY,MAAM,UAAU,CAAA;AAEnC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,SAAS,EAAE,CAAC;QACZ,YAAY,EAAE,EAAE;KACjB;IACD,IAAI,EAAE;QACJ,eAAe,EAAE,KAAK,CAAC,qBAAqB;QAC5C,KAAK,EAAE,KAAK,CAAC,YAAY;QACzB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,KAA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AAY,EACZ,SAAS,EACT,QAAQ,GACqB;IAC7B,IAAI,cAAc,IAAI,IAAI,IAAI,cAAc,CAAC,MAAM,KAAK,KAAK;QAC3D,OAAO,IAAI,CAAA;IAEb,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAC3F;MAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CACxB;QAAA,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAC7F;QAAA,CAAC,QAAQ,CACX;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC"}
package/lib/utils.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import { IMessage } from './types';
2
2
  export declare function isSameDay(currentMessage: IMessage, diffMessage: IMessage | null | undefined): boolean;
3
3
  export declare function isSameUser(currentMessage: IMessage, diffMessage: IMessage | null | undefined): boolean;
4
+ export declare function useCallbackDebounced<T extends (...args: any[]) => any>(callbackFunc: T, deps: React.DependencyList | undefined, time: number): (...args: Parameters<T>) => void;
5
+ export declare function useCallbackThrottled<T extends (...args: any[]) => any>(callbackFunc: T, deps: React.DependencyList | undefined, time: number): (...args: Parameters<T>) => void;
package/lib/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { useCallback, useEffect, useRef } from 'react';
1
2
  import dayjs from 'dayjs';
2
3
  export function isSameDay(currentMessage, diffMessage) {
3
4
  if (!diffMessage || !diffMessage.createdAt)
@@ -14,4 +15,69 @@ export function isSameUser(currentMessage, diffMessage) {
14
15
  currentMessage.user &&
15
16
  diffMessage.user._id === currentMessage.user._id);
16
17
  }
18
+ function processCallbackArguments(args) {
19
+ const [e, ...rest] = args;
20
+ const { nativeEvent } = e || {};
21
+ let params = [];
22
+ if (e) {
23
+ if (nativeEvent)
24
+ params.push({ nativeEvent });
25
+ else
26
+ params.push(e);
27
+ if (rest)
28
+ params = params.concat(rest);
29
+ }
30
+ return params;
31
+ }
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ export function useCallbackDebounced(callbackFunc, deps = [], time) {
34
+ const timeoutId = useRef(undefined);
35
+ const savedFunc = useCallback((...args) => {
36
+ const params = processCallbackArguments(args);
37
+ if (timeoutId.current)
38
+ clearTimeout(timeoutId.current);
39
+ timeoutId.current = setTimeout(() => {
40
+ callbackFunc(...params);
41
+ }, time);
42
+ // eslint-disable-next-line react-hooks/exhaustive-deps
43
+ }, [callbackFunc, time, ...deps]);
44
+ useEffect(() => {
45
+ return () => {
46
+ if (timeoutId.current)
47
+ clearTimeout(timeoutId.current);
48
+ };
49
+ }, []);
50
+ return savedFunc;
51
+ }
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ export function useCallbackThrottled(callbackFunc, deps = [], time) {
54
+ const lastExecution = useRef(0);
55
+ const timeoutId = useRef(undefined);
56
+ // we use function instead of arrow to access arguments object
57
+ const savedFunc = useCallback((...args) => {
58
+ const params = processCallbackArguments(args);
59
+ const now = Date.now();
60
+ const timeSinceLastExecution = now - lastExecution.current;
61
+ if (timeSinceLastExecution >= time) {
62
+ // Execute immediately if enough time has passed
63
+ lastExecution.current = now;
64
+ callbackFunc(...params);
65
+ }
66
+ else {
67
+ // Schedule execution for the remaining time
68
+ clearTimeout(timeoutId.current);
69
+ timeoutId.current = setTimeout(() => {
70
+ lastExecution.current = Date.now();
71
+ callbackFunc(...params);
72
+ }, time - timeSinceLastExecution);
73
+ }
74
+ // eslint-disable-next-line react-hooks/exhaustive-deps
75
+ }, [callbackFunc, time, ...deps]);
76
+ useEffect(() => {
77
+ return () => {
78
+ clearTimeout(timeoutId.current);
79
+ };
80
+ }, []);
81
+ return savedFunc;
82
+ }
17
83
  //# sourceMappingURL=utils.js.map
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,MAAM,UAAU,SAAS,CACvB,cAAwB,EACxB,WAAwC;IAExC,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,SAAS;QACxC,OAAO,KAAK,CAAA;IAEd,MAAM,gBAAgB,GAAG,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAA;IACxD,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;IAElD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;QACzD,OAAO,KAAK,CAAA;IAEd,OAAO,gBAAgB,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,cAAwB,EACxB,WAAwC;IAExC,OAAO,CAAC,CAAC,CACP,WAAW;QACX,WAAW,CAAC,IAAI;QAChB,cAAc,CAAC,IAAI;QACnB,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,cAAc,CAAC,IAAI,CAAC,GAAG,CACjD,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,MAAM,UAAU,SAAS,CACvB,cAAwB,EACxB,WAAwC;IAExC,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,SAAS;QACxC,OAAO,KAAK,CAAA;IAEd,MAAM,gBAAgB,GAAG,KAAK,CA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A;YAC/B,SAAS,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBAClC,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;gBAClC,YAAY,CAAC,GAAG,MAAuB,CAAC,CAAA;YAC1C,CAAC,EAAE,IAAI,GAAG,sBAAsB,CAAC,CAAA;QACnC,CAAC;QACH,uDAAuD;IACvD,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAA;IAEjC,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QACjC,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,SAAS,CAAA;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gifted-chat",
3
- "version": "2.8.1",
3
+ "version": "2.8.2-alpha.0",
4
4
  "description": "The most complete chat UI for React Native",
5
5
  "keywords": [
6
6
  "android",
@@ -33,7 +33,7 @@
33
33
  "build": "rm -rf lib/ && yarn tsc",
34
34
  "lint": "yarn eslint src",
35
35
  "lint:fix": "yarn eslint --cache --fix",
36
- "prepublishOnly": "yarn lint && yarn build && yarn test",
36
+ "prepublishOnly": "yarn lint && yarn build",
37
37
  "start": "cd example && expo start",
38
38
  "start:web": "cd example && expo start -w --dev",
39
39
  "test": "TZ=Europe/Paris jest --no-watchman",
@@ -53,48 +53,55 @@
53
53
  "dependencies": {
54
54
  "@expo/react-native-action-sheet": "^4.1.1",
55
55
  "@types/lodash.isequal": "^4.5.8",
56
- "dayjs": "^1.11.13",
56
+ "dayjs": "^1.11.18",
57
57
  "lodash.isequal": "^4.5.0",
58
+ "react-native-autolink": "^4.2.0",
58
59
  "react-native-communications": "^2.2.1",
59
60
  "react-native-iphone-x-helper": "^1.3.1",
60
- "react-native-lightbox-v2": "^0.9.2",
61
- "react-native-parsed-text": "^0.0.22"
61
+ "react-native-lightbox-v2": "^0.9.2"
62
62
  },
63
63
  "devDependencies": {
64
- "@babel/core": "^7.26.10",
65
- "@babel/plugin-transform-react-jsx": "^7.25.9",
66
- "@babel/plugin-transform-unicode-property-regex": "^7.25.9",
67
- "@babel/preset-env": "^7.26.9",
68
- "@react-native/eslint-config": "^0.76.6",
64
+ "@babel/core": "^7.28.4",
65
+ "@babel/plugin-transform-react-jsx": "^7.27.1",
66
+ "@babel/plugin-transform-unicode-property-regex": "^7.27.1",
67
+ "@babel/preset-env": "^7.28.3",
69
68
  "@stylistic/eslint-plugin": "^3.1.0",
70
- "@types/jest": "^29.5.14",
71
- "@types/react": "^19.0.10",
72
- "@types/react-dom": "^19.0.4",
69
+ "@react-native-community/cli": "20.0.0",
70
+ "@react-native-community/cli-platform-android": "20.0.0",
71
+ "@react-native-community/cli-platform-ios": "20.0.0",
72
+ "@react-native/babel-preset": "0.81.5",
73
+ "@react-native/eslint-config": "0.81.5",
74
+ "@react-native/metro-config": "0.81.5",
75
+ "@react-native/typescript-config": "0.81.5",
76
+ "@types/jest": "^29.5.13",
77
+ "@types/react": "^19.1.0",
78
+ "@types/react-test-renderer": "^19.1.0",
79
+ "@types/react-dom": "^19.1.9",
73
80
  "@types/react-native": "^0.72.8",
74
- "@typescript-eslint/eslint-plugin": "^8.28.0",
75
- "@typescript-eslint/parser": "^8.28.0",
81
+ "@typescript-eslint/eslint-plugin": "^8.44.1",
82
+ "@typescript-eslint/parser": "^8.44.1",
76
83
  "babel-jest": "^29.7.0",
77
84
  "eslint": "^8.57.0",
78
85
  "eslint-config-standard": "^17.1.0",
79
86
  "eslint-config-standard-jsx": "^11.0.0",
80
- "eslint-plugin-import": "^2.31.0",
87
+ "eslint-plugin-import": "^2.32.0",
81
88
  "eslint-plugin-jest": "^28.11.0",
82
89
  "eslint-plugin-json": "^4.0.1",
83
- "eslint-plugin-n": "^17.17.0",
90
+ "eslint-plugin-n": "^17.23.1",
84
91
  "eslint-plugin-node": "^11.1.0",
85
92
  "eslint-plugin-promise": "^7.2.1",
86
- "eslint-plugin-react": "^7.37.4",
93
+ "eslint-plugin-react": "^7.37.5",
87
94
  "husky": "^9.1.7",
88
95
  "jest": "^29.7.0",
89
96
  "json": "^11.0.0",
90
97
  "lint-staged": "^15.5.0",
91
- "react": "^18.3.1",
92
- "react-dom": "^18.3.1",
93
- "react-native": "^0.76.6",
94
- "react-native-keyboard-controller": "^1.16.8",
95
- "react-native-reanimated": "^3.17.1",
96
- "react-test-renderer": "^18.3.1",
97
- "typescript": "^5.8.2"
98
+ "react": "19.1.0",
99
+ "react-dom": "19.1.0",
100
+ "react-native": "0.81.5",
101
+ "react-native-keyboard-controller": "^1.19.5",
102
+ "react-native-reanimated": "^3.19.4",
103
+ "react-test-renderer": "19.1.0",
104
+ "typescript": "^5.9.2"
98
105
  },
99
106
  "peerDependencies": {
100
107
  "react": ">=18.0.0",
@@ -104,6 +111,6 @@
104
111
  },
105
112
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
106
113
  "engines": {
107
- "node": ">=18"
114
+ "node": ">=20"
108
115
  }
109
116
  }
@@ -1,4 +1,4 @@
1
- import React, { useCallback } from 'react'
1
+ import React, { JSX, useCallback } from 'react'
2
2
  import {
3
3
  Text,
4
4
  TouchableWithoutFeedback,
@@ -22,7 +22,7 @@ import styles from './styles'
22
22
 
23
23
  export * from './types'
24
24
 
25
- const Bubble: React.FC<BubbleProps<IMessage>> = (props: BubbleProps<IMessage>) => {
25
+ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessage>): JSX.Element => {
26
26
  const {
27
27
  currentMessage,
28
28
  nextMessage,
@@ -38,46 +38,22 @@ const Bubble: React.FC<BubbleProps<IMessage>> = (props: BubbleProps<IMessage>) =
38
38
  containerStyle,
39
39
  wrapperStyle,
40
40
  bottomContainerStyle,
41
+ onPress: onPressProp,
42
+ onLongPress: onLongPressProp,
41
43
  } = props
42
44
 
43
45
  const context = useChatContext()
44
46
 
45
47
  const onPress = useCallback(() => {
46
- if (props.onPress)
47
- props.onPress(context, currentMessage)
48
- }, [context, props, currentMessage])
48
+ onPressProp?.(context, currentMessage)
49
+ }, [onPressProp, context, currentMessage])
49
50
 
50
51
  const onLongPress = useCallback(() => {
51
- const {
52
- onLongPress,
53
- optionTitles,
54
- } = props
55
-
56
- if (onLongPress) {
57
- onLongPress(context, currentMessage)
58
- return
59
- }
60
-
61
- if (!optionTitles?.length)
62
- return
63
-
64
- const options = optionTitles
65
- const cancelButtonIndex = options.length - 1
66
-
67
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
- ;(context as any).actionSheet().showActionSheetWithOptions(
69
- {
70
- options,
71
- cancelButtonIndex,
72
- },
73
- (buttonIndex: number) => {
74
- console.log('onLongPress', { buttonIndex })
75
- }
76
- )
52
+ onLongPressProp?.(context, currentMessage)
77
53
  }, [
78
54
  currentMessage,
79
55
  context,
80
- props,
56
+ onLongPressProp,
81
57
  ])
82
58
 
83
59
  const styledBubbleToNext = useCallback(() => {
@@ -111,7 +87,7 @@ const Bubble: React.FC<BubbleProps<IMessage>> = (props: BubbleProps<IMessage>) =
111
87
  )
112
88
  return [
113
89
  styles[position].containerToPrevious,
114
- containerToPreviousStyle && containerToPreviousStyle[position],
90
+ containerToPreviousStyle?.[position],
115
91
  ]
116
92
 
117
93
  return null
@@ -166,7 +142,6 @@ const Bubble: React.FC<BubbleProps<IMessage>> = (props: BubbleProps<IMessage>) =
166
142
  /* eslint-disable @typescript-eslint/no-unused-vars */
167
143
  containerStyle,
168
144
  wrapperStyle,
169
- optionTitles,
170
145
  /* eslint-enable @typescript-eslint/no-unused-vars */
171
146
  ...messageTextProps
172
147
  } = props
@@ -385,7 +360,7 @@ const Bubble: React.FC<BubbleProps<IMessage>> = (props: BubbleProps<IMessage>) =
385
360
  <View
386
361
  style={[
387
362
  styles[position].bottom,
388
- bottomContainerStyle && bottomContainerStyle[position],
363
+ bottomContainerStyle?.[position],
389
364
  ]}
390
365
  >
391
366
  {renderUsername()}
@@ -5,7 +5,7 @@ import {
5
5
  TextStyle,
6
6
  } from 'react-native'
7
7
  import { QuickRepliesProps } from '../QuickReplies'
8
- import { MessageTextProps } from '../MessageText'
8
+ import { MessageTextProps, MessageOption } from '../MessageText'
9
9
  import { MessageImageProps } from '../MessageImage'
10
10
  import { TimeProps } from '../Time'
11
11
  import {
@@ -39,7 +39,7 @@ 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' | 'options'
43
43
  > &
44
44
  MessageTextProps<TMessage>
45
45
  /* eslint-enable no-use-before-define */
@@ -54,7 +54,7 @@ export interface BubbleProps<TMessage extends IMessage> {
54
54
  currentMessage: TMessage
55
55
  nextMessage?: TMessage
56
56
  previousMessage?: TMessage
57
- optionTitles?: string[]
57
+ options?: MessageOption[]
58
58
  containerStyle?: LeftRightStyle<ViewStyle>
59
59
  wrapperStyle?: LeftRightStyle<ViewStyle>
60
60
  textStyle?: LeftRightStyle<TextStyle>