react-native-gifted-chat 0.16.3 → 1.0.0-beta-3

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 (73) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.js +21 -0
  3. package/README.md +18 -15
  4. package/jest.config.js +15 -0
  5. package/lib/Actions.d.ts +4 -10
  6. package/lib/Actions.js +27 -41
  7. package/lib/Actions.js.map +1 -1
  8. package/lib/Avatar.d.ts +5 -6
  9. package/lib/Avatar.js +29 -34
  10. package/lib/Avatar.js.map +1 -1
  11. package/lib/Bubble.d.ts +24 -20
  12. package/lib/Bubble.js +26 -19
  13. package/lib/Bubble.js.map +1 -1
  14. package/lib/Composer.d.ts +4 -24
  15. package/lib/Composer.js +22 -44
  16. package/lib/Composer.js.map +1 -1
  17. package/lib/Day.d.ts +5 -19
  18. package/lib/Day.js +14 -29
  19. package/lib/Day.js.map +1 -1
  20. package/lib/GiftedAvatar.js +9 -9
  21. package/lib/GiftedAvatar.js.map +1 -1
  22. package/lib/GiftedChat.d.ts +54 -42
  23. package/lib/GiftedChat.js +69 -42
  24. package/lib/GiftedChat.js.flow +8 -0
  25. package/lib/GiftedChat.js.map +1 -1
  26. package/lib/GiftedChatContext.d.ts +9 -0
  27. package/lib/GiftedChatContext.js +9 -0
  28. package/lib/GiftedChatContext.js.map +1 -0
  29. package/lib/InputToolbar.d.ts +13 -37
  30. package/lib/InputToolbar.js +27 -93
  31. package/lib/InputToolbar.js.map +1 -1
  32. package/lib/LoadEarlier.d.ts +3 -15
  33. package/lib/LoadEarlier.js +11 -36
  34. package/lib/LoadEarlier.js.map +1 -1
  35. package/lib/Message.d.ts +13 -10
  36. package/lib/Message.js +16 -14
  37. package/lib/Message.js.map +1 -1
  38. package/lib/MessageAudio.d.ts +1 -3
  39. package/lib/MessageAudio.js +11 -9
  40. package/lib/MessageAudio.js.map +1 -1
  41. package/lib/MessageContainer.d.ts +10 -13
  42. package/lib/MessageContainer.js +11 -48
  43. package/lib/MessageContainer.js.map +1 -1
  44. package/lib/MessageImage.d.ts +5 -14
  45. package/lib/MessageImage.js +11 -24
  46. package/lib/MessageImage.js.map +1 -1
  47. package/lib/MessageText.d.ts +4 -25
  48. package/lib/MessageText.js +77 -93
  49. package/lib/MessageText.js.map +1 -1
  50. package/lib/MessageVideo.d.ts +1 -3
  51. package/lib/MessageVideo.js +11 -9
  52. package/lib/MessageVideo.js.map +1 -1
  53. package/lib/Models.d.ts +5 -5
  54. package/lib/Models.js +1 -0
  55. package/lib/QuickReplies.d.ts +6 -27
  56. package/lib/QuickReplies.js +65 -97
  57. package/lib/QuickReplies.js.map +1 -1
  58. package/lib/Send.d.ts +5 -17
  59. package/lib/Send.js +15 -31
  60. package/lib/Send.js.map +1 -1
  61. package/lib/SystemMessage.d.ts +3 -12
  62. package/lib/SystemMessage.js +8 -19
  63. package/lib/SystemMessage.js.map +1 -1
  64. package/lib/Time.d.ts +4 -17
  65. package/lib/Time.js +30 -41
  66. package/lib/Time.js.map +1 -1
  67. package/lib/TypingIndicator.d.ts +0 -1
  68. package/lib/TypingIndicator.js +11 -11
  69. package/lib/TypingIndicator.js.map +1 -1
  70. package/lib/hooks/useUpdateLayoutEffect.d.ts +3 -2
  71. package/lib/hooks/useUpdateLayoutEffect.js +1 -1
  72. package/lib/hooks/useUpdateLayoutEffect.js.map +1 -1
  73. package/package.json +41 -67
package/.eslintignore ADDED
@@ -0,0 +1,2 @@
1
+
2
+ example/*
package/.eslintrc.js ADDED
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ root: true,
3
+ env: {
4
+ node: true,
5
+ },
6
+ parser: '@typescript-eslint/parser',
7
+ plugins: ['@typescript-eslint'],
8
+ // extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
9
+ rules: {
10
+ 'member-access': 0,
11
+ 'interface-name': 0,
12
+ 'ordered-imports': 0,
13
+ 'object-literal-sort-keys': 0,
14
+ 'variable-name': 0,
15
+ 'one-variable-per-declaration': 0,
16
+ 'no-empty': 0,
17
+ 'no-console': 0,
18
+ 'no-shadowed-variable': 0,
19
+ 'no-extra-boolean-cast': 0,
20
+ },
21
+ }
package/README.md CHANGED
@@ -16,7 +16,6 @@
16
16
  <a href="https://www.npmjs.com/package/react-native-gifted-chat">
17
17
  <img alt="npm downloads" src="https://img.shields.io/npm/dm/react-native-gifted-chat.svg"/></a>
18
18
  <a href="https://www.npmjs.com/package/react-native-gifted-chat"><img alt="npm version" src="https://badge.fury.io/js/react-native-gifted-chat.svg"/></a>
19
- <a href="https://greenkeeper.io/"><img src="https://badges.greenkeeper.io/FaridSafi/react-native-gifted-chat.svg" alt="build"></a>
20
19
  <a href="https://reactnative.gallery/FaridSafi/gifted-chat"><img src="https://img.shields.io/badge/reactnative.gallery-%F0%9F%8E%AC-green.svg"/></a>
21
20
 
22
21
  </p>
@@ -57,15 +56,15 @@
57
56
 
58
57
  <p align="center">
59
58
  <br/>
60
- <a href="https://getstream.io/chat/?utm_source=github&utm_medium=react-native-gifted-chat&utm_campaign=sponsorship" target="_blank">
59
+ <a href="https://getstream.io/chat/?utm_source=Github&utm_medium=Github_Repo_Content_Ad&utm_content=Developer&utm_campaign=Github_Jan2022_Chat&utm_term=react-native-gifted-chat" target="_blank">
61
60
  <img src="https://i.imgur.com/oU7XYkk.png">
62
61
  </a>
63
62
  <br>
64
63
  <p align="center">
65
- Scalable <a href="https://getstream.io/chat/?utm_source=github&utm_medium=react-native-gifted-chat&utm_campaign=sponsorship" target="_blank">chat API/Server</a> written in Go
64
+ Scalable <a href="https://getstream.io/chat/?utm_source=Github&utm_medium=Github_Repo_Content_Ad&utm_content=Developer&utm_campaign=Github_Jan2022_Chat&utm_term=react-native-gifted-chat" target="_blank">chat API/Server</a> written in Go
66
65
  </p>
67
66
  <p align="center">
68
- <a href="https://getstream.io/chat/get_started/?utm_source=github&utm_medium=react-native-gifted-chat&utm_campaign=sponsorship" target="_blank">API Tour</a> | <a href="https://dev.to/nickparsons/react-native-chat-with-chuck-norris-3h7m?utm_source=github&utm_medium=react-native-gifted-chat&utm_campaign=sponsorship" target="_blank">React Native Gifted tutorial</a>
67
+ <a href="https://getstream.io/chat/get_started/?utm_source=Github&utm_medium=Github_Repo_Content_Ad&utm_content=Developer&utm_campaign=Github_Jan2022_Chat&utm_term=react-native-gifted-chat" target="_blank">API Tour</a> | <a href="https://dev.to/nickparsons/react-native-chat-with-chuck-norris-3h7m?utm_source=Github&utm_medium=Github_Repo_Content_Ad&utm_content=Developer&utm_campaign=Github_Jan2022_Chat&utm_term=react-native-gifted-chat" target="_blank">React Native Gifted tutorial</a>
69
68
  </p>
70
69
  </p>
71
70
 
@@ -81,11 +80,12 @@
81
80
  </p>
82
81
  </p>
83
82
 
83
+ ## The future of GiftedChat 🎉
84
+ Please give us your advice: [Related PR](https://github.com/FaridSafi/react-native-gifted-chat/pull/1775)
85
+
84
86
  ## Please vote
85
87
 
86
88
  **GiftedChat** depends on other packages and some needs a boost, please vote for PRs will improve it, thanks:
87
-
88
- - https://github.com/taskrabbit/react-native-parsed-text/pull/58
89
89
  - https://github.com/watadarkstar/react-native-typing-animation/issues/18
90
90
 
91
91
  ## Features
@@ -104,7 +104,7 @@
104
104
  - Redux support
105
105
  - System message
106
106
  - Quick Reply messages (bot)
107
- - Typying indicatior [react-native-typing-animation](https://github.com/watadarkstar/react-native-typing-animation)
107
+ - Typing indicator [react-native-typing-animation](https://github.com/watadarkstar/react-native-typing-animation)
108
108
 
109
109
  ## Dependency
110
110
 
@@ -318,8 +318,8 @@ interface QuickReplies {
318
318
  - **`onSend`** _(Function)_ - Callback when sending a message
319
319
  - **`alwaysShowSend`** _(Bool)_ - Always show send button in input text composer; default `false`, show only when text input is not empty
320
320
  - **`locale`** _(String)_ - Locale to localize the dates. You need first to import the locale you need (ie. `require('dayjs/locale/de')` or `import 'dayjs/locale/fr'`)
321
- - **`timeFormat`** _(String)_ - Format to use for rendering times; default is `'LT'`
322
- - **`dateFormat`** _(String)_ - Format to use for rendering dates; default is `'ll'`
321
+ - **`timeFormat`** _(String)_ - Format to use for rendering times; default is `'LT'` (see [Day.js Format](https://day.js.org/docs/en/display/format))
322
+ - **`dateFormat`** _(String)_ - Format to use for rendering dates; default is `'ll'` (see [Day.js Format](https://day.js.org/docs/en/display/format))
323
323
  - **`loadEarlier`** _(Bool)_ - Enables the "load earlier messages" button, required for `infiniteScroll`
324
324
  - **`isKeyboardInternallyHandled`** _(Bool)_ - Determine whether to handle keyboard awareness inside the plugin. If you have your own keyboard handling outside the plugin set this to false; default is `true`
325
325
  - **`onLoadEarlier`** _(Function)_ - Callback when loading earlier messages
@@ -335,6 +335,7 @@ interface QuickReplies {
335
335
  - **`renderBubble`** _(Function)_ - Custom message bubble
336
336
  - **`renderTicks`** _(Function(`message`))_ - Custom ticks indicator to display message status
337
337
  - **`renderSystemMessage`** _(Function)_ - Custom system message
338
+ - **`onPress`** _(Function(`context`, `message`))_ - Callback when a message bubble is pressed
338
339
  - **`onLongPress`** _(Function(`context`, `message`))_ - Callback when a message bubble is long-pressed; default is to show an ActionSheet with "Copy Text" (see [example using `showActionSheetWithOptions()`](https://github.com/FaridSafi/react-native-gifted-chat/blob/master@%7B2017-09-25%7D/src/Bubble.js#L96-L119))
339
340
  - **`inverted`** _(Bool)_ - Reverses display order of `messages`; default is `true`
340
341
  - **`renderUsernameOnMessage`** _(Bool)_ - Indicate whether to show the user's username inside the message bubble; default is `false`
@@ -349,7 +350,7 @@ interface QuickReplies {
349
350
  - **`renderCustomView`** _(Function)_ - Custom view inside the bubble
350
351
  - **`renderDay`** _(Function)_ - Custom day above a message
351
352
  - **`renderTime`** _(Function)_ - Custom time inside a message
352
- - **`renderFooter`** _(Function)_ - Custom footer component on the ListView, e.g. `'User is typing...'`; see [example/App.js](example/App.js) for an example. Overrides default typing indicator that triggers when `isTyping` is true.
353
+ - **`renderFooter`** _(Function)_ - Custom footer component on the ListView, e.g. `'User is typing...'`; see [App.tsx](/App.tsx) for an example. Overrides default typing indicator that triggers when `isTyping` is true.
353
354
  - **`renderChatEmpty`** _(Function)_ - Custom component to render in the ListView when messages are empty
354
355
  - **`renderChatFooter`** _(Function)_ - Custom component to render below the MessageContainer (separate from the ListView)
355
356
  - **`renderInputToolbar`** _(Function)_ - Custom message composer container
@@ -451,15 +452,17 @@ If you use React Navigation, additional handling may be required to account for
451
452
 
452
453
  ### Native
453
454
 
454
- 1. Install `yarn add -g expo-cli`
455
- 2. `expo start`
455
+ 1. Install `yarn global add expo-cli`
456
+ 2. Install dependencies`yarn install`
457
+ 3. `expo start`
456
458
 
457
459
  ### react-native-web
458
460
 
459
461
  #### With expo
460
462
 
461
- 1. Install `yarn add -g expo-cli`
462
- 2. `expo start -w`
463
+ 1. Install `yarn global add expo-cli`
464
+ 2. Install dependencies`yarn install`
465
+ 3. `expo start -w`
463
466
 
464
467
  [Upgrade snack version](https://snackager.expo.io/bundle/react-native-gifted-chat@0.15.0?bypassCache=true)
465
468
 
@@ -525,4 +528,4 @@ Feel free to ask me questions on Twitter [@FaridSafi](https://www.twitter.com/Fa
525
528
 
526
529
  ## Hire an expert!
527
530
 
528
- Looking for a ReactNative freelance expert with more than 12 years of experience? Contact Xavier from his [website](https://xaviercarpentier.com)!
531
+ Looking for a ReactNative freelance expert with more than 14 years of experience? Contact Xavier from his [website](https://xaviercarpentier.com)!
package/jest.config.js ADDED
@@ -0,0 +1,15 @@
1
+ module.exports = {
2
+ preset: 'react-native',
3
+ setupFiles: ['<rootDir>/tests/setup.js'],
4
+ moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'],
5
+ transform: {
6
+ '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
7
+ // '^.+\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
8
+ },
9
+ transformIgnorePatterns: [
10
+ '/node_modules/(?!(@react-native|react-native)).*/',
11
+ ],
12
+ testMatch: ['**/*.test.ts?(x)'],
13
+ modulePathIgnorePatterns: ['<rootDir>/example'],
14
+ coveragePathIgnorePatterns: ['./src/__tests__/'],
15
+ }
package/lib/Actions.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import React, { ReactNode } from 'react';
2
+ import { ReactNode } from 'react';
3
3
  import { StyleProp, ViewStyle, TextStyle } from 'react-native';
4
4
  export interface ActionsProps {
5
5
  options?: {
@@ -12,9 +12,9 @@ export interface ActionsProps {
12
12
  containerStyle?: StyleProp<ViewStyle>;
13
13
  onPressActionButton?(): void;
14
14
  }
15
- export default class Actions extends React.Component<ActionsProps> {
16
- static defaultProps: ActionsProps;
17
- static propTypes: {
15
+ export declare function Actions({ options, optionTintColor, icon, wrapperStyle, iconTextStyle, onPressActionButton, containerStyle, }: ActionsProps): JSX.Element;
16
+ export declare namespace Actions {
17
+ var propTypes: {
18
18
  onSend: PropTypes.Requireable<(...args: any[]) => any>;
19
19
  options: PropTypes.Requireable<object>;
20
20
  optionTintColor: PropTypes.Requireable<string>;
@@ -23,10 +23,4 @@ export default class Actions extends React.Component<ActionsProps> {
23
23
  wrapperStyle: PropTypes.Requireable<number | boolean | object>;
24
24
  containerStyle: PropTypes.Requireable<number | boolean | object>;
25
25
  };
26
- static contextTypes: {
27
- actionSheet: PropTypes.Requireable<(...args: any[]) => any>;
28
- };
29
- onActionsPress: () => void;
30
- renderIcon(): {} | null | undefined;
31
- render(): JSX.Element;
32
26
  }
package/lib/Actions.js CHANGED
@@ -3,47 +3,36 @@ import React from 'react';
3
3
  import { StyleSheet, Text, TouchableOpacity, View, } from 'react-native';
4
4
  import Color from './Color';
5
5
  import { StylePropType } from './utils';
6
- export default class Actions extends React.Component {
7
- constructor() {
8
- super(...arguments);
9
- this.onActionsPress = () => {
10
- const { options } = this.props;
11
- const optionKeys = Object.keys(options);
12
- const cancelButtonIndex = optionKeys.indexOf('Cancel');
13
- this.context.actionSheet().showActionSheetWithOptions({
14
- options: optionKeys,
15
- cancelButtonIndex,
16
- tintColor: this.props.optionTintColor,
17
- }, (buttonIndex) => {
18
- const key = optionKeys[buttonIndex];
19
- if (key) {
20
- options[key](this.props);
21
- }
22
- });
23
- };
24
- }
25
- renderIcon() {
26
- if (this.props.icon) {
27
- return this.props.icon();
6
+ import { useChatContext } from './GiftedChatContext';
7
+ import { useCallbackOne } from 'use-memo-one';
8
+ export function Actions({ options = {}, optionTintColor = Color.optionTintColor, icon, wrapperStyle, iconTextStyle, onPressActionButton, containerStyle, }) {
9
+ const { actionSheet } = useChatContext();
10
+ const onActionsPress = useCallbackOne(() => {
11
+ const optionKeys = Object.keys(options);
12
+ const cancelButtonIndex = optionKeys.indexOf('Cancel');
13
+ actionSheet().showActionSheetWithOptions({
14
+ options: optionKeys,
15
+ cancelButtonIndex,
16
+ tintColor: optionTintColor,
17
+ }, (buttonIndex) => {
18
+ const key = optionKeys[buttonIndex];
19
+ if (key) {
20
+ options[key]();
21
+ }
22
+ });
23
+ }, []);
24
+ const renderIcon = useCallbackOne(() => {
25
+ if (icon) {
26
+ return icon();
28
27
  }
29
- return (<View style={[styles.wrapper, this.props.wrapperStyle]}>
30
- <Text style={[styles.iconText, this.props.iconTextStyle]}>+</Text>
28
+ return (<View style={[styles.wrapper, wrapperStyle]}>
29
+ <Text style={[styles.iconText, iconTextStyle]}>+</Text>
31
30
  </View>);
32
- }
33
- render() {
34
- return (<TouchableOpacity style={[styles.container, this.props.containerStyle]} onPress={this.props.onPressActionButton || this.onActionsPress}>
35
- {this.renderIcon()}
36
- </TouchableOpacity>);
37
- }
31
+ }, []);
32
+ return (<TouchableOpacity style={[styles.container, containerStyle]} onPress={onPressActionButton || onActionsPress}>
33
+ {renderIcon()}
34
+ </TouchableOpacity>);
38
35
  }
39
- Actions.defaultProps = {
40
- options: {},
41
- optionTintColor: Color.optionTintColor,
42
- icon: undefined,
43
- containerStyle: {},
44
- iconTextStyle: {},
45
- wrapperStyle: {},
46
- };
47
36
  Actions.propTypes = {
48
37
  onSend: PropTypes.func,
49
38
  options: PropTypes.object,
@@ -53,9 +42,6 @@ Actions.propTypes = {
53
42
  wrapperStyle: StylePropType,
54
43
  containerStyle: StylePropType,
55
44
  };
56
- Actions.contextTypes = {
57
- actionSheet: PropTypes.func,
58
- };
59
45
  const styles = StyleSheet.create({
60
46
  container: {
61
47
  width: 26,
@@ -1 +1 @@
1
- {"version":3,"file":"Actions.js","sourceRoot":"","sources":["../src/Actions.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,EACL,UAAU,EACV,IAAI,EACJ,gBAAgB,EAChB,IAAI,GAIL,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAYvC,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,KAAK,CAAC,SAAuB;IAAlE;;QAwBE,mBAAc,GAAG,GAAG,EAAE;YACpB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;YAC9B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAQ,CAAC,CAAA;YACxC,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;YACtD,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,0BAA0B,CACnD;gBACE,OAAO,EAAE,UAAU;gBACnB,iBAAiB;gBACjB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe;aACtC,EACD,CAAC,WAAmB,EAAE,EAAE;gBACtB,MAAM,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;gBACnC,IAAI,GAAG,EAAE;oBACP,OAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;iBAC1B;YACH,CAAC,CACF,CAAA;QACH,CAAC,CAAA;IAuBH,CAAC;IArBC,UAAU;QACR,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,E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IACnC,YAAY,EAAE,aAAa;IAC3B,cAAc,EAAE,aAAa;CAC9B,CAAA;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,EAAE;KACjB;IACD,OAAO,EAAE;QACP,YAAY,EAAE,EAAE;QAChB,WAAW,EAAE,KAAK,CAAC,YAAY;QAC/B,WAAW,EAAE,CAAC;QACd,IAAI,EAAE,CAAC;KACR;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,KAAK,CAAC,YAAY;QACzB,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,EAAE;QACZ,eAAe,EAAE,KAAK,CAAC,qBAAqB;QAC5C,SAAS,EAAE,QAAQ;KACpB;CACF,CAAC,CAAA"}
package/lib/Avatar.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import React, { ReactNode } from 'react';
2
+ import { ReactNode } from 'react';
3
3
  import { ImageStyle, TextStyle, ViewStyle } from 'react-native';
4
4
  import { Omit, IMessage, User, LeftRightStyle } from './Models';
5
5
  export interface AvatarProps<TMessage extends IMessage> {
@@ -16,8 +16,9 @@ export interface AvatarProps<TMessage extends IMessage> {
16
16
  onPressAvatar?(user: User): void;
17
17
  onLongPressAvatar?(user: User): void;
18
18
  }
19
- export default class Avatar<TMessage extends IMessage = IMessage> extends React.Component<AvatarProps<TMessage>> {
20
- static defaultProps: {
19
+ export declare function Avatar<TMessage extends IMessage = IMessage>(props: AvatarProps<TMessage>): JSX.Element | null;
20
+ export declare namespace Avatar {
21
+ var defaultProps: {
21
22
  renderAvatarOnTop: boolean;
22
23
  showAvatarForEveryMessage: boolean;
23
24
  position: string;
@@ -31,7 +32,7 @@ export default class Avatar<TMessage extends IMessage = IMessage> extends React.
31
32
  onPressAvatar: () => void;
32
33
  onLongPressAvatar: () => void;
33
34
  };
34
- static propTypes: {
35
+ var propTypes: {
35
36
  renderAvatarOnTop: PropTypes.Requireable<boolean>;
36
37
  showAvatarForEveryMessage: PropTypes.Requireable<boolean>;
37
38
  position: PropTypes.Requireable<string>;
@@ -50,6 +51,4 @@ export default class Avatar<TMessage extends IMessage = IMessage> extends React.
50
51
  right: PropTypes.Requireable<number | boolean | object>;
51
52
  }>>;
52
53
  };
53
- renderAvatar(): {} | null | undefined;
54
- render(): JSX.Element | null;
55
54
  }
package/lib/Avatar.js CHANGED
@@ -33,53 +33,48 @@ const styles = {
33
33
  },
34
34
  }),
35
35
  };
36
- export default class Avatar extends React.Component {
37
- renderAvatar() {
38
- if (this.props.renderAvatar) {
39
- const { renderAvatar, ...avatarProps } = this.props;
40
- return this.props.renderAvatar(avatarProps);
41
- }
42
- if (this.props.currentMessage) {
43
- return (<GiftedAvatar avatarStyle={[
44
- styles[this.props.position].image,
45
- this.props.imageStyle &&
46
- this.props.imageStyle[this.props.position],
47
- ]} textStyle={this.props.textStyle ? this.props.textStyle : {}} user={this.props.currentMessage.user} onPress={() => this.props.onPressAvatar &&
48
- this.props.onPressAvatar(this.props.currentMessage.user)} onLongPress={() => this.props.onLongPressAvatar &&
49
- this.props.onLongPressAvatar(this.props.currentMessage.user)}/>);
50
- }
36
+ export function Avatar(props) {
37
+ const { renderAvatarOnTop, showAvatarForEveryMessage, containerStyle, position, currentMessage, renderAvatar, previousMessage, nextMessage, imageStyle, } = props;
38
+ const messageToCompare = renderAvatarOnTop ? previousMessage : nextMessage;
39
+ const computedStyle = renderAvatarOnTop ? 'onTop' : 'onBottom';
40
+ if (renderAvatar === null) {
51
41
  return null;
52
42
  }
53
- render() {
54
- const { renderAvatarOnTop, showAvatarForEveryMessage, containerStyle, position, currentMessage, renderAvatar, previousMessage, nextMessage, imageStyle, } = this.props;
55
- const messageToCompare = renderAvatarOnTop ? previousMessage : nextMessage;
56
- const computedStyle = renderAvatarOnTop ? 'onTop' : 'onBottom';
57
- if (renderAvatar === null) {
58
- return null;
59
- }
60
- if (!showAvatarForEveryMessage &&
61
- currentMessage &&
62
- messageToCompare &&
63
- isSameUser(currentMessage, messageToCompare) &&
64
- isSameDay(currentMessage, messageToCompare)) {
65
- return (<View style={[
43
+ if (!showAvatarForEveryMessage &&
44
+ currentMessage &&
45
+ messageToCompare &&
46
+ isSameUser(currentMessage, messageToCompare) &&
47
+ isSameDay(currentMessage, messageToCompare)) {
48
+ return (<View style={[
66
49
  styles[position].container,
67
50
  containerStyle && containerStyle[position],
68
51
  ]}>
69
- <GiftedAvatar avatarStyle={[
52
+ <GiftedAvatar avatarStyle={[
70
53
  styles[position].image,
71
54
  imageStyle && imageStyle[position],
72
55
  ]}/>
73
- </View>);
56
+ </View>);
57
+ }
58
+ const renderAvatarComponent = () => {
59
+ if (props.renderAvatar) {
60
+ const { renderAvatar, ...avatarProps } = props;
61
+ return props.renderAvatar(avatarProps);
74
62
  }
75
- return (<View style={[
63
+ if (props.currentMessage) {
64
+ return (<GiftedAvatar avatarStyle={[
65
+ styles[props.position].image,
66
+ props.imageStyle && props.imageStyle[props.position],
67
+ ]} user={props.currentMessage.user} onPress={() => { var _a; return (_a = props.onPressAvatar) === null || _a === void 0 ? void 0 : _a.call(props, props.currentMessage.user); }} onLongPress={() => { var _a; return (_a = props.onLongPressAvatar) === null || _a === void 0 ? void 0 : _a.call(props, props.currentMessage.user); }}/>);
68
+ }
69
+ return null;
70
+ };
71
+ return (<View style={[
76
72
  styles[position].container,
77
73
  styles[position][computedStyle],
78
74
  containerStyle && containerStyle[position],
79
75
  ]}>
80
- {this.renderAvatar()}
81
- </View>);
82
- }
76
+ {renderAvatarComponent()}
77
+ </View>);
83
78
  }
84
79
  Avatar.defaultProps = {
85
80
  renderAvatarOnTop: false,
package/lib/Avatar.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../src/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,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,IAAI;IACjC,yBAAyB,EAAE,SAAS,CAAC,IAAI;IACzC,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,cAAc,EAAE,SAAS,CAAC,MAAM;IAChC,eAAe,EAAE,SAAS,CAAC,MAAM;IACjC,WAAW,EAAE,SAAS,CAAC,MAAM;IAC7B,aAAa,EAAE,SAAS,CAAC,IAAI;IAC7B,iBAAiB,EAAE,SAAS,CAAC,IAAI;IACjC,YAAY,EAAE,SAAS,CAAC,IAAI;IAC5B,cAAc,EAAE,SAAS,CAAC,KAAK,CAAC;QAC9B,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,aAAa;KACrB,CAAC;IACF,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC;QAC1B,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,aAAa;KACrB,CAAC;CACH,CAAA"}
package/lib/Bubble.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { StyleProp, ViewStyle, TextStyle } from 'react-native';
4
- import QuickReplies from './QuickReplies';
5
- import MessageText from './MessageText';
6
- import MessageImage from './MessageImage';
7
- import Time from './Time';
4
+ import { QuickRepliesProps } from './QuickReplies';
5
+ import { MessageTextProps } from './MessageText';
6
+ import { MessageImageProps } from './MessageImage';
7
+ import { TimeProps } from './Time';
8
8
  import { User, IMessage, LeftRightStyle, Reply, Omit, MessageVideoProps, MessageAudioProps } from './Models';
9
- export declare type RenderMessageImageProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageImage['props'];
9
+ export declare type RenderMessageImageProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageImageProps<TMessage>;
10
10
  export declare type RenderMessageVideoProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageVideoProps<TMessage>;
11
11
  export declare type RenderMessageAudioProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageAudioProps<TMessage>;
12
- export declare type RenderMessageTextProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageText['props'];
12
+ export declare type RenderMessageTextProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageTextProps<TMessage>;
13
13
  export interface BubbleProps<TMessage extends IMessage> {
14
14
  user?: User;
15
15
  touchableProps?: object;
@@ -30,6 +30,8 @@ export interface BubbleProps<TMessage extends IMessage> {
30
30
  containerToPreviousStyle?: LeftRightStyle<ViewStyle>;
31
31
  usernameStyle?: TextStyle;
32
32
  quickReplyStyle?: StyleProp<ViewStyle>;
33
+ quickReplyTextStyle?: StyleProp<TextStyle>;
34
+ onPress?(context?: any, message?: any): void;
33
35
  onLongPress?(context?: any, message?: any): void;
34
36
  onQuickReply?(replies: Reply[]): void;
35
37
  renderMessageImage?(props: RenderMessageImageProps<TMessage>): React.ReactNode;
@@ -37,11 +39,11 @@ export interface BubbleProps<TMessage extends IMessage> {
37
39
  renderMessageAudio?(props: RenderMessageAudioProps<TMessage>): React.ReactNode;
38
40
  renderMessageText?(props: RenderMessageTextProps<TMessage>): React.ReactNode;
39
41
  renderCustomView?(bubbleProps: BubbleProps<TMessage>): React.ReactNode;
40
- renderTime?(timeProps: Time['props']): React.ReactNode;
42
+ renderTime?(timeProps: TimeProps<TMessage>): React.ReactNode;
41
43
  renderTicks?(currentMessage: TMessage): React.ReactNode;
42
44
  renderUsername?(): React.ReactNode;
43
45
  renderQuickReplySend?(): React.ReactNode;
44
- renderQuickReplies?(quickReplies: QuickReplies['props']): React.ReactNode;
46
+ renderQuickReplies?(quickReplies: QuickRepliesProps): React.ReactNode;
45
47
  }
46
48
  export default class Bubble<TMessage extends IMessage = IMessage> extends React.Component<BubbleProps<TMessage>> {
47
49
  static contextTypes: {
@@ -49,6 +51,7 @@ export default class Bubble<TMessage extends IMessage = IMessage> extends React.
49
51
  };
50
52
  static defaultProps: {
51
53
  touchableProps: {};
54
+ onPress: null;
52
55
  onLongPress: null;
53
56
  renderMessageImage: null;
54
57
  renderMessageVideo: null;
@@ -121,26 +124,27 @@ export default class Bubble<TMessage extends IMessage = IMessage> extends React.
121
124
  right: PropTypes.Requireable<number | boolean | object>;
122
125
  }>>;
123
126
  };
127
+ onPress: () => void;
124
128
  onLongPress: () => void;
125
- styledBubbleToNext(): (false | ViewStyle | import("react-native").RegisteredStyle<ViewStyle> | import("react-native").RecursiveArray<false | ViewStyle | import("react-native").RegisteredStyle<ViewStyle> | null | undefined> | {
129
+ styledBubbleToNext(): (StyleProp<ViewStyle> | {
126
130
  borderBottomLeftRadius: number;
127
131
  } | {
128
132
  borderBottomRightRadius: number;
129
- } | null | undefined)[] | null;
130
- styledBubbleToPrevious(): (false | ViewStyle | import("react-native").RegisteredStyle<ViewStyle> | import("react-native").RecursiveArray<false | ViewStyle | import("react-native").RegisteredStyle<ViewStyle> | null | undefined> | {
133
+ })[] | null;
134
+ styledBubbleToPrevious(): (StyleProp<ViewStyle> | {
131
135
  borderTopLeftRadius: number;
132
136
  } | {
133
137
  borderTopRightRadius: number;
134
- } | null | undefined)[] | null;
135
- renderQuickReplies(): {} | null | undefined;
136
- renderMessageText(): {} | null | undefined;
137
- renderMessageImage(): {} | null | undefined;
138
- renderMessageVideo(): {} | null | undefined;
139
- renderMessageAudio(): {} | null | undefined;
140
- renderTicks(): {} | null | undefined;
141
- renderTime(): {} | null | undefined;
138
+ })[] | null;
139
+ renderQuickReplies(): React.ReactNode;
140
+ renderMessageText(): React.ReactNode;
141
+ renderMessageImage(): React.ReactNode;
142
+ renderMessageVideo(): React.ReactNode;
143
+ renderMessageAudio(): React.ReactNode;
144
+ renderTicks(): React.ReactNode;
145
+ renderTime(): React.ReactNode;
142
146
  renderUsername(): JSX.Element | null;
143
- renderCustomView(): {} | null | undefined;
147
+ renderCustomView(): React.ReactNode;
144
148
  renderBubbleContent(): JSX.Element;
145
149
  render(): JSX.Element;
146
150
  }
package/lib/Bubble.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { Text, Clipboard, StyleSheet, TouchableWithoutFeedback, View, } from 'react-native';
4
- import QuickReplies from './QuickReplies';
5
- import MessageText from './MessageText';
6
- import MessageImage from './MessageImage';
7
- import MessageVideo from './MessageVideo';
8
- import MessageAudio from './MessageAudio';
9
- import Time from './Time';
4
+ import { QuickReplies } from './QuickReplies';
5
+ import { MessageText } from './MessageText';
6
+ import { MessageImage } from './MessageImage';
7
+ import { MessageVideo } from './MessageVideo';
8
+ import { MessageAudio } from './MessageAudio';
9
+ import { Time } from './Time';
10
10
  import Color from './Color';
11
11
  import { StylePropType, isSameUser, isSameDay } from './utils';
12
12
  const styles = {
@@ -83,6 +83,11 @@ const DEFAULT_OPTION_TITLES = ['Copy Text', 'Cancel'];
83
83
  export default class Bubble extends React.Component {
84
84
  constructor() {
85
85
  super(...arguments);
86
+ this.onPress = () => {
87
+ if (this.props.onPress) {
88
+ this.props.onPress(this.context, this.props.currentMessage);
89
+ }
90
+ };
86
91
  this.onLongPress = () => {
87
92
  const { currentMessage } = this.props;
88
93
  if (this.props.onLongPress) {
@@ -138,7 +143,7 @@ export default class Bubble extends React.Component {
138
143
  return null;
139
144
  }
140
145
  renderQuickReplies() {
141
- const { currentMessage, onQuickReply, nextMessage, renderQuickReplySend, quickReplyStyle, } = this.props;
146
+ const { currentMessage, onQuickReply, nextMessage, renderQuickReplySend, quickReplyStyle, quickReplyTextStyle, } = this.props;
142
147
  if (currentMessage && currentMessage.quickReplies) {
143
148
  const { containerStyle, wrapperStyle, ...quickReplyProps } = this.props;
144
149
  if (this.props.renderQuickReplies) {
@@ -150,6 +155,7 @@ export default class Bubble extends React.Component {
150
155
  nextMessage,
151
156
  renderQuickReplySend,
152
157
  quickReplyStyle,
158
+ quickReplyTextStyle,
153
159
  }}/>);
154
160
  }
155
161
  return null;
@@ -263,22 +269,22 @@ export default class Bubble extends React.Component {
263
269
  render() {
264
270
  const { position, containerStyle, wrapperStyle, bottomContainerStyle, } = this.props;
265
271
  return (<View style={[
266
- styles[position].container,
267
- containerStyle && containerStyle[position],
268
- ]}>
272
+ styles[position].container,
273
+ containerStyle && containerStyle[position],
274
+ ]}>
269
275
  <View style={[
270
- styles[position].wrapper,
271
- this.styledBubbleToNext(),
272
- this.styledBubbleToPrevious(),
273
- wrapperStyle && wrapperStyle[position],
274
- ]}>
275
- <TouchableWithoutFeedback onLongPress={this.onLongPress} accessibilityTraits='text' {...this.props.touchableProps}>
276
+ styles[position].wrapper,
277
+ this.styledBubbleToNext(),
278
+ this.styledBubbleToPrevious(),
279
+ wrapperStyle && wrapperStyle[position],
280
+ ]}>
281
+ <TouchableWithoutFeedback onPress={this.onPress} onLongPress={this.onLongPress} accessibilityRole='text' {...this.props.touchableProps}>
276
282
  <View>
277
283
  {this.renderBubbleContent()}
278
284
  <View style={[
279
- styles[position].bottom,
280
- bottomContainerStyle && bottomContainerStyle[position],
281
- ]}>
285
+ styles[position].bottom,
286
+ bottomContainerStyle && bottomContainerStyle[position],
287
+ ]}>
282
288
  {this.renderUsername()}
283
289
  {this.renderTime()}
284
290
  {this.renderTicks()}
@@ -295,6 +301,7 @@ Bubble.contextTypes = {
295
301
  };
296
302
  Bubble.defaultProps = {
297
303
  touchableProps: {},
304
+ onPress: null,
298
305
  onLongPress: null,
299
306
  renderMessageImage: null,
300
307
  renderMessageVideo: null,