@cometchat/chat-uikit-react-native 5.1.1 → 5.2.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 (227) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  3. package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.d.ts +40 -0
  4. package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.js +467 -0
  5. package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.js.map +1 -0
  6. package/lib/CometChatAIAssistantChatHistory/Skeleton.d.ts +24 -0
  7. package/lib/CometChatAIAssistantChatHistory/Skeleton.js +130 -0
  8. package/lib/CometChatAIAssistantChatHistory/Skeleton.js.map +1 -0
  9. package/lib/CometChatAIAssistantChatHistory/index.d.ts +1 -0
  10. package/lib/CometChatAIAssistantChatHistory/index.js +2 -0
  11. package/lib/CometChatAIAssistantChatHistory/index.js.map +1 -0
  12. package/lib/CometChatAIAssistantChatHistory/style.d.ts +30 -0
  13. package/lib/CometChatAIAssistantChatHistory/style.js +122 -0
  14. package/lib/CometChatAIAssistantChatHistory/style.js.map +1 -0
  15. package/lib/CometChatConversations/CometChatConversations.js +26 -5
  16. package/lib/CometChatConversations/CometChatConversations.js.map +1 -1
  17. package/lib/CometChatMessageComposer/CometChatMessageComposer.d.ts +7 -0
  18. package/lib/CometChatMessageComposer/CometChatMessageComposer.js +101 -13
  19. package/lib/CometChatMessageComposer/CometChatMessageComposer.js.map +1 -1
  20. package/lib/CometChatMessageHeader/CometChatMessageHeader.d.ts +16 -0
  21. package/lib/CometChatMessageHeader/CometChatMessageHeader.js +63 -13
  22. package/lib/CometChatMessageHeader/CometChatMessageHeader.js.map +1 -1
  23. package/lib/CometChatMessageList/CometChatMessageList.d.ts +33 -0
  24. package/lib/CometChatMessageList/CometChatMessageList.js +535 -76
  25. package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
  26. package/lib/CometChatMessageList/style.js +74 -2
  27. package/lib/CometChatMessageList/style.js.map +1 -1
  28. package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js +6 -12
  29. package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js.map +1 -1
  30. package/lib/calls/CometChatOutgoingCall/CometChatOutgoingCall.js +4 -3
  31. package/lib/calls/CometChatOutgoingCall/CometChatOutgoingCall.js.map +1 -1
  32. package/lib/extensions/Polls/Polls.js +38 -17
  33. package/lib/extensions/Polls/Polls.js.map +1 -1
  34. package/lib/index.d.ts +5 -1
  35. package/lib/index.js +6 -2
  36. package/lib/index.js.map +1 -1
  37. package/lib/shared/constants/UIKitConstants.d.ts +16 -0
  38. package/lib/shared/constants/UIKitConstants.js +16 -0
  39. package/lib/shared/constants/UIKitConstants.js.map +1 -1
  40. package/lib/shared/events/CometChatMessageEvents/index.d.ts +3 -0
  41. package/lib/shared/events/CometChatMessageEvents/index.js +3 -0
  42. package/lib/shared/events/CometChatMessageEvents/index.js.map +1 -1
  43. package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js +3 -0
  44. package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js.map +1 -1
  45. package/lib/shared/events/CometChatUIEventHandler/Listener.d.ts +3 -1
  46. package/lib/shared/events/CometChatUIEventHandler/Listener.js +4 -1
  47. package/lib/shared/events/CometChatUIEventHandler/Listener.js.map +1 -1
  48. package/lib/shared/events/ListenerInitializer.d.ts +3 -1
  49. package/lib/shared/events/ListenerInitializer.js +5 -1
  50. package/lib/shared/events/ListenerInitializer.js.map +1 -1
  51. package/lib/shared/events/messages.d.ts +2 -1
  52. package/lib/shared/events/messages.js +1 -0
  53. package/lib/shared/events/messages.js.map +1 -1
  54. package/lib/shared/framework/DataSource.d.ts +3 -1
  55. package/lib/shared/framework/DataSourceDecorator.d.ts +3 -1
  56. package/lib/shared/framework/DataSourceDecorator.js +8 -2
  57. package/lib/shared/framework/DataSourceDecorator.js.map +1 -1
  58. package/lib/shared/framework/MessageDataSource.d.ts +6 -0
  59. package/lib/shared/framework/MessageDataSource.js +64 -1
  60. package/lib/shared/framework/MessageDataSource.js.map +1 -1
  61. package/lib/shared/icons/components/ai-chat-history.d.ts +8 -0
  62. package/lib/shared/icons/components/ai-chat-history.js +9 -0
  63. package/lib/shared/icons/components/ai-chat-history.js.map +1 -0
  64. package/lib/shared/icons/components/ai-copy-option.d.ts +8 -0
  65. package/lib/shared/icons/components/ai-copy-option.js +9 -0
  66. package/lib/shared/icons/components/ai-copy-option.js.map +1 -0
  67. package/lib/shared/icons/components/ai-new-chat.d.ts +8 -0
  68. package/lib/shared/icons/components/ai-new-chat.js +9 -0
  69. package/lib/shared/icons/components/ai-new-chat.js.map +1 -0
  70. package/lib/shared/icons/components/ai-send-button.d.ts +8 -0
  71. package/lib/shared/icons/components/ai-send-button.js +9 -0
  72. package/lib/shared/icons/components/ai-send-button.js.map +1 -0
  73. package/lib/shared/icons/components/right-arrow.d.ts +3 -0
  74. package/lib/shared/icons/components/right-arrow.js +6 -0
  75. package/lib/shared/icons/components/right-arrow.js.map +1 -0
  76. package/lib/shared/icons/components/stop-fill.js +8 -7
  77. package/lib/shared/icons/components/stop-fill.js.map +1 -1
  78. package/lib/shared/icons/icon-mapping.d.ts +11 -0
  79. package/lib/shared/icons/icon-mapping.js +11 -0
  80. package/lib/shared/icons/icon-mapping.js.map +1 -1
  81. package/lib/shared/modals/CometChatAIAssistantTools.d.ts +47 -0
  82. package/lib/shared/modals/CometChatAIAssistantTools.js +44 -0
  83. package/lib/shared/modals/CometChatAIAssistantTools.js.map +1 -0
  84. package/lib/shared/modals/StreamMessage.d.ts +4 -0
  85. package/lib/shared/modals/StreamMessage.js +11 -0
  86. package/lib/shared/modals/StreamMessage.js.map +1 -0
  87. package/lib/shared/modals/index.d.ts +3 -1
  88. package/lib/shared/modals/index.js +3 -1
  89. package/lib/shared/modals/index.js.map +1 -1
  90. package/lib/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.d.ts +126 -0
  91. package/lib/shared/resources/CometChatLocalizeNew/resources/de/translation.json +7 -1
  92. package/lib/shared/resources/CometChatLocalizeNew/resources/en/translation.json +7 -1
  93. package/lib/shared/resources/CometChatLocalizeNew/resources/es/translation.json +7 -1
  94. package/lib/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +7 -1
  95. package/lib/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +7 -1
  96. package/lib/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +7 -1
  97. package/lib/shared/resources/CometChatLocalizeNew/resources/it/translation.json +7 -1
  98. package/lib/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +7 -1
  99. package/lib/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +7 -1
  100. package/lib/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +7 -1
  101. package/lib/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +7 -1
  102. package/lib/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +7 -1
  103. package/lib/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +7 -1
  104. package/lib/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +7 -1
  105. package/lib/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +7 -1
  106. package/lib/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +7 -1
  107. package/lib/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +7 -1
  108. package/lib/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +7 -1
  109. package/lib/shared/services/stream-message.service.d.ts +84 -0
  110. package/lib/shared/services/stream-message.service.js +406 -0
  111. package/lib/shared/services/stream-message.service.js.map +1 -0
  112. package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.d.ts +9 -0
  113. package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.js +248 -0
  114. package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.js.map +1 -0
  115. package/lib/shared/views/CometChatAIAssistantMessageBubble/index.d.ts +3 -0
  116. package/lib/shared/views/CometChatAIAssistantMessageBubble/index.js +4 -0
  117. package/lib/shared/views/CometChatAIAssistantMessageBubble/index.js.map +1 -0
  118. package/lib/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.js +5 -2
  119. package/lib/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.js.map +1 -1
  120. package/lib/shared/views/CometChatImageBubble/CometChatImageLoader.js +1 -1
  121. package/lib/shared/views/CometChatImageBubble/CometChatImageLoader.js.map +1 -1
  122. package/lib/shared/views/CometChatImageViewerModal/ImageViewerModal.js +52 -32
  123. package/lib/shared/views/CometChatImageViewerModal/ImageViewerModal.js.map +1 -1
  124. package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.d.ts +10 -0
  125. package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.js +54 -0
  126. package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.js.map +1 -0
  127. package/lib/shared/views/CometChatSendButtonView/index.d.ts +1 -0
  128. package/lib/shared/views/CometChatSendButtonView/index.js +2 -0
  129. package/lib/shared/views/CometChatSendButtonView/index.js.map +1 -0
  130. package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.d.ts +8 -0
  131. package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.js +436 -0
  132. package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.js.map +1 -0
  133. package/lib/shared/views/CometChatStreamMessageBubble/index.d.ts +3 -0
  134. package/lib/shared/views/CometChatStreamMessageBubble/index.js +3 -0
  135. package/lib/shared/views/CometChatStreamMessageBubble/index.js.map +1 -0
  136. package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.d.ts +14 -6
  137. package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.js +82 -57
  138. package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.js.map +1 -1
  139. package/lib/theme/context.d.ts +96 -15
  140. package/lib/theme/type.d.ts +14 -1
  141. package/package.json +6 -3
  142. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +627 -0
  143. package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +228 -0
  144. package/src/CometChatAIAssistantChatHistory/index.ts +2 -0
  145. package/src/CometChatAIAssistantChatHistory/style.ts +160 -0
  146. package/src/CometChatConversations/CometChatConversations.tsx +36 -10
  147. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +137 -19
  148. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +106 -18
  149. package/src/CometChatMessageList/CometChatMessageList.tsx +721 -116
  150. package/src/CometChatMessageList/style.ts +74 -2
  151. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +13 -29
  152. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +8 -5
  153. package/src/extensions/Polls/Polls.tsx +50 -22
  154. package/src/index.ts +31 -1
  155. package/src/shared/constants/UIKitConstants.ts +17 -0
  156. package/src/shared/events/CometChatMessageEvents/index.ts +3 -1
  157. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +3 -0
  158. package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -0
  159. package/src/shared/events/ListenerInitializer.ts +6 -1
  160. package/src/shared/events/messages.ts +1 -0
  161. package/src/shared/framework/DataSource.ts +4 -2
  162. package/src/shared/framework/DataSourceDecorator.tsx +10 -2
  163. package/src/shared/framework/MessageDataSource.tsx +75 -2
  164. package/src/shared/icons/Icon.tsx +1 -1
  165. package/src/shared/icons/components/ai-chat-history.tsx +21 -0
  166. package/src/shared/icons/components/ai-copy-option.tsx +21 -0
  167. package/src/shared/icons/components/ai-new-chat.tsx +21 -0
  168. package/src/shared/icons/components/ai-send-button.tsx +24 -0
  169. package/src/shared/icons/components/right-arrow.tsx +13 -0
  170. package/src/shared/icons/components/stop-fill.tsx +14 -12
  171. package/src/shared/icons/icon-mapping.tsx +14 -0
  172. package/src/shared/modals/CometChatAIAssistantTools.ts +65 -0
  173. package/src/shared/modals/StreamMessage.ts +12 -0
  174. package/src/shared/modals/index.ts +5 -1
  175. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +7 -1
  176. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +7 -1
  177. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +7 -1
  178. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +7 -1
  179. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +7 -2
  180. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +7 -1
  181. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +7 -1
  182. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +7 -1
  183. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +7 -1
  184. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +7 -1
  185. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +7 -1
  186. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +7 -1
  187. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +7 -1
  188. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +7 -1
  189. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +7 -1
  190. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +7 -1
  191. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +7 -1
  192. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +7 -1
  193. package/src/shared/services/stream-message.service.ts +470 -0
  194. package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +262 -0
  195. package/src/shared/views/CometChatAIAssistantMessageBubble/index.ts +4 -0
  196. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +5 -1
  197. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +1 -0
  198. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +57 -45
  199. package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +86 -0
  200. package/src/shared/views/CometChatSendButtonView/index.ts +1 -0
  201. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +493 -0
  202. package/src/shared/views/CometChatStreamMessageBubble/index.ts +9 -0
  203. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +121 -74
  204. package/src/theme/type.ts +14 -1
  205. package/lib/shared/resources/CometChatLocalize/CometChatLocalize.d.ts +0 -79
  206. package/lib/shared/resources/CometChatLocalize/CometChatLocalize.js +0 -152
  207. package/lib/shared/resources/CometChatLocalize/CometChatLocalize.js.map +0 -1
  208. package/lib/shared/resources/CometChatLocalize/index.d.ts +0 -2
  209. package/lib/shared/resources/CometChatLocalize/index.js +0 -3
  210. package/lib/shared/resources/CometChatLocalize/index.js.map +0 -1
  211. package/lib/shared/resources/CometChatLocalize/resources/ar/translation.json +0 -447
  212. package/lib/shared/resources/CometChatLocalize/resources/de/translation.json +0 -447
  213. package/lib/shared/resources/CometChatLocalize/resources/en/translation.json +0 -447
  214. package/lib/shared/resources/CometChatLocalize/resources/es/translation.json +0 -447
  215. package/lib/shared/resources/CometChatLocalize/resources/fr/translation.json +0 -446
  216. package/lib/shared/resources/CometChatLocalize/resources/hi/translation.json +0 -447
  217. package/lib/shared/resources/CometChatLocalize/resources/hu/translation.json +0 -447
  218. package/lib/shared/resources/CometChatLocalize/resources/lt/translation.json +0 -447
  219. package/lib/shared/resources/CometChatLocalize/resources/ms/translation.json +0 -447
  220. package/lib/shared/resources/CometChatLocalize/resources/pt/translation.json +0 -447
  221. package/lib/shared/resources/CometChatLocalize/resources/ru/translation.json +0 -447
  222. package/lib/shared/resources/CometChatLocalize/resources/sv/translation.json +0 -447
  223. package/lib/shared/resources/CometChatLocalize/resources/zh/translation.json +0 -447
  224. package/lib/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +0 -446
  225. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.d.ts +0 -29
  226. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js +0 -29
  227. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js.map +0 -1
@@ -0,0 +1,262 @@
1
+ import React, { useRef, useEffect, useMemo } from 'react';
2
+ import { View, Text, StyleSheet, Animated } from 'react-native';
3
+ import Markdown from 'react-native-markdown-display';
4
+ import { CometChat } from '@cometchat/chat-sdk-react-native';
5
+ import { useTheme } from '../../../theme';
6
+ import { CometChatTheme } from '../../../theme/type';
7
+
8
+ export interface CometChatAIAssistantMessageBubbleProps {
9
+ message: any;
10
+ theme?: CometChatTheme;
11
+ style?: any;
12
+ }
13
+
14
+ const getMessageText = (message: any) => {
15
+ if (!message) return '';
16
+ if (message instanceof CometChat.CustomMessage) {
17
+ const customData = message.getData();
18
+ if (customData?.text) return customData.text;
19
+ if (customData?.assistantMessageData?.getText) return customData.assistantMessageData.getText();
20
+ }
21
+ if (typeof message.getAssistantMessageData === 'function') {
22
+ const assistantData = message.getAssistantMessageData();
23
+ if (assistantData?.getText) return assistantData.getText();
24
+ }
25
+ if (typeof message.getText === 'function') return message.getText();
26
+ if (typeof message.text === 'string') return message.text;
27
+ return '';
28
+ };
29
+
30
+ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBubbleProps> = ({
31
+ message,
32
+ style: bubbleStyle
33
+ }) => {
34
+ const theme = useTheme();
35
+ const text = getMessageText(message);
36
+
37
+ // Use the bubbleStyle passed from parent, with theme fallbacks
38
+ const styles = StyleSheet.create({
39
+ container: {
40
+ backgroundColor: bubbleStyle?.containerStyle?.backgroundColor || 'transparent',
41
+ borderRadius: bubbleStyle?.containerStyle?.borderRadius || theme.spacing.radius.r3,
42
+ minWidth: bubbleStyle?.containerStyle?.minWidth || 90,
43
+ alignSelf: bubbleStyle?.containerStyle?.alignSelf || 'flex-start',
44
+ maxWidth: '100%',
45
+ ...bubbleStyle?.containerStyle,
46
+ },
47
+ textContainer: {
48
+ ...bubbleStyle?.textContainerStyle,
49
+ },
50
+ text: {
51
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
52
+ fontFamily: bubbleStyle?.textStyle?.fontFamily || theme.typography.body.regular.fontFamily,
53
+ fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
54
+ ...bubbleStyle?.textStyle,
55
+ },
56
+ placeholderText: {
57
+ color: bubbleStyle?.placeholderTextStyle?.color || theme.color.receiveBubbleText,
58
+ fontFamily: bubbleStyle?.placeholderTextStyle?.fontFamily || theme.typography.body.regular.fontFamily,
59
+ fontSize: bubbleStyle?.placeholderTextStyle?.fontSize || theme.typography.body.regular.fontSize,
60
+ opacity: bubbleStyle?.placeholderTextStyle?.opacity || 0.6,
61
+ fontStyle: 'italic',
62
+ ...bubbleStyle?.placeholderTextStyle,
63
+ },
64
+ copyButton: {
65
+ backgroundColor: bubbleStyle?.copyButtonStyle?.backgroundColor || theme.color.primary,
66
+ padding: bubbleStyle?.copyButtonStyle?.padding || theme.spacing.padding.p1,
67
+ borderRadius: bubbleStyle?.copyButtonStyle?.borderRadius || theme.spacing.radius.r1,
68
+ ...bubbleStyle?.copyButtonStyle,
69
+ },
70
+ errorContainer: {
71
+ backgroundColor: bubbleStyle?.errorContainerStyle?.backgroundColor || theme.color.error,
72
+ padding: bubbleStyle?.errorContainerStyle?.padding || theme.spacing.padding.p2,
73
+ borderRadius: bubbleStyle?.errorContainerStyle?.borderRadius || theme.spacing.radius.r2,
74
+ marginTop: bubbleStyle?.errorContainerStyle?.marginTop || theme.spacing.margin.m1,
75
+ ...bubbleStyle?.errorContainerStyle,
76
+ },
77
+ errorText: {
78
+ color: bubbleStyle?.errorTextStyle?.color || theme.color.background1,
79
+ fontFamily: bubbleStyle?.errorTextStyle?.fontFamily || theme.typography.caption1.regular.fontFamily,
80
+ fontSize: bubbleStyle?.errorTextStyle?.fontSize || theme.typography.caption1.regular.fontSize,
81
+ ...bubbleStyle?.errorTextStyle,
82
+ },
83
+ });
84
+
85
+ // Create markdown styles based on theme
86
+ const markdownStyles = useMemo(() => ({
87
+ body: {
88
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
89
+ fontFamily: bubbleStyle?.textStyle?.fontFamily || theme.typography.body.regular.fontFamily,
90
+ fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
91
+ ...bubbleStyle?.textStyle,
92
+ margin: 0,
93
+ padding: 0,
94
+ textAlignVertical: 'top',
95
+ },
96
+ text: {
97
+ fontFamily: bubbleStyle?.textStyle?.fontFamily || theme.typography.body.regular.fontFamily,
98
+ fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
99
+ ...(bubbleStyle?.textStyle && Object.fromEntries(
100
+ Object.entries(bubbleStyle.textStyle).filter(([key]) => key !== 'color')
101
+ )),
102
+ },
103
+ paragraph: {
104
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
105
+ margin: 0,
106
+ padding: 0,
107
+ },
108
+ code_inline: {
109
+ backgroundColor: theme.color.background3,
110
+ color: theme.color.textHighlight,
111
+ borderRadius: theme.spacing.radius.r1,
112
+ padding: theme.spacing.padding.p0_5,
113
+ },
114
+ code_block: {
115
+ backgroundColor: theme.color.background3,
116
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
117
+ borderRadius: theme.spacing.radius.r2,
118
+ padding: theme.spacing.padding.p2,
119
+ fontFamily: 'monospace',
120
+ },
121
+ fence: {
122
+ backgroundColor: theme.color.background3,
123
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
124
+ borderRadius: theme.spacing.radius.r2,
125
+ borderWidth: 1,
126
+ borderColor: theme.color.borderDefault,
127
+ padding: theme.spacing.padding.p2,
128
+ marginVertical: theme.spacing.margin.m4,
129
+ fontFamily: 'monospace',
130
+ },
131
+ table: {
132
+ borderWidth: 1,
133
+ borderColor: theme.color.borderDefault,
134
+ borderRadius: theme.spacing.radius.r2,
135
+ backgroundColor: theme.color.background2,
136
+ marginVertical: theme.spacing.margin.m2,
137
+ overflow: 'hidden' as 'hidden',
138
+ borderCollapse: 'separate' as 'separate',
139
+ borderSpacing: 0,
140
+ },
141
+ thead: {
142
+ backgroundColor: theme.color.background3,
143
+ margin: 0,
144
+ padding: 0,
145
+ },
146
+ tbody: {
147
+ backgroundColor: theme.color.background1,
148
+ margin: 0,
149
+ padding: 0,
150
+ },
151
+ th: {
152
+ borderRightWidth: 1,
153
+ borderBottomWidth: 1,
154
+ borderColor: theme.color.borderDefault,
155
+ backgroundColor: theme.color.background3,
156
+ padding: theme.spacing.padding.p2,
157
+ fontWeight: 'bold',
158
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
159
+ fontFamily: bubbleStyle?.textStyle?.fontFamily || theme.typography.body.regular.fontFamily,
160
+ fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
161
+ margin: 0,
162
+ borderTopWidth: 0,
163
+ borderLeftWidth: 0,
164
+ },
165
+ td: {
166
+ borderRightWidth: 1,
167
+ borderBottomWidth: 1,
168
+ borderColor: theme.color.borderDefault,
169
+ backgroundColor: theme.color.background1,
170
+ padding: theme.spacing.padding.p2,
171
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
172
+ fontFamily: bubbleStyle?.textStyle?.fontFamily || theme.typography.body.regular.fontFamily,
173
+ fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
174
+ margin: 0,
175
+ borderTopWidth: 0,
176
+ borderLeftWidth: 0,
177
+ },
178
+ tr: {
179
+ borderBottomWidth: 0,
180
+ margin: 0,
181
+ padding: 0,
182
+ },
183
+ heading1: {
184
+ fontWeight: '700' as '700',
185
+ fontSize: (bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize) * 1.6,
186
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
187
+ fontFamily: bubbleStyle?.textStyle?.fontFamily || theme.typography.body.regular.fontFamily,
188
+ marginVertical: theme.spacing.margin.m2,
189
+ },
190
+ heading2: {
191
+ fontWeight: '700' as '700',
192
+ fontSize: (bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize) * 1.4,
193
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
194
+ fontFamily: bubbleStyle?.textStyle?.fontFamily || theme.typography.body.regular.fontFamily,
195
+ marginVertical: theme.spacing.margin.m2,
196
+ },
197
+ heading3: {
198
+ fontWeight: '700' as '700',
199
+ fontSize: (bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize) * 1.2,
200
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
201
+ fontFamily: bubbleStyle?.textStyle?.fontFamily || theme.typography.body.regular.fontFamily,
202
+ marginVertical: theme.spacing.margin.m1,
203
+ },
204
+ heading4: {
205
+ fontWeight: '700' as '700',
206
+ fontSize: (bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize) * 1.1,
207
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
208
+ fontFamily: bubbleStyle?.textStyle?.fontFamily || theme.typography.body.regular.fontFamily,
209
+ marginVertical: theme.spacing.margin.m1,
210
+ },
211
+ heading5: {
212
+ fontWeight: '700' as '700',
213
+ fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
214
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
215
+ fontFamily: bubbleStyle?.textStyle?.fontFamily || theme.typography.body.regular.fontFamily,
216
+ marginVertical: theme.spacing.margin.m1,
217
+ },
218
+ heading6: {
219
+ fontWeight: '700' as '700',
220
+ fontSize: (bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize) * 0.9,
221
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
222
+ fontFamily: bubbleStyle?.textStyle?.fontFamily || theme.typography.body.regular.fontFamily,
223
+ marginVertical: theme.spacing.margin.m1,
224
+ },
225
+ strong: {
226
+ fontWeight: '700' as '700',
227
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
228
+ },
229
+ em: {
230
+ fontStyle: 'italic' as 'italic',
231
+ color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
232
+ },
233
+ blockquote: {
234
+ borderLeftWidth: 3,
235
+ borderLeftColor: theme.color.borderDefault,
236
+ paddingLeft: theme.spacing.padding.p2,
237
+ color: theme.color.textSecondary,
238
+ },
239
+ link: {
240
+ underlineColor: theme.color.textHighlight,
241
+ color: theme.color.textHighlight,
242
+ borderRadius: theme.spacing.radius.r1,
243
+ paddingHorizontal: theme.spacing.padding.p0_5,
244
+ paddingVertical: theme.spacing.padding.p0_5,
245
+ textDecorationLine: 'underline' as 'underline',
246
+ },
247
+ }), [bubbleStyle?.textStyle, theme]);
248
+
249
+ const MemoMarkdown = useMemo(() => {
250
+ return (
251
+ <View style={styles.container}>
252
+ <Markdown style={markdownStyles} mergeStyle={true}>
253
+ {text.trim()}
254
+ </Markdown>
255
+ </View>
256
+ )
257
+ }, [text, markdownStyles, styles]);
258
+
259
+ return MemoMarkdown;
260
+ };
261
+
262
+ export default CometChatAIAssistantMessageBubble;
@@ -0,0 +1,4 @@
1
+ import CometChatAIAssistantMessageBubble from "./CometChatAIAssistantMessageBubble";
2
+
3
+ export { CometChatAIAssistantMessageBubble };
4
+ export default CometChatAIAssistantMessageBubble;
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
2
  import {
3
3
  FlatList,
4
- SafeAreaView,
4
+ Platform,
5
5
  StyleProp,
6
6
  Text,
7
7
  TextStyle,
@@ -12,6 +12,7 @@ import { useTheme } from "../../../theme";
12
12
  import { Icon } from "../../icons/Icon";
13
13
  import { Emojis } from "./emojis";
14
14
  import Styles from "./style";
15
+ import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
15
16
 
16
17
  /**
17
18
  * Type definitions for the emoji items and categories.
@@ -149,6 +150,7 @@ const CometChatEmojiKeyboard: React.FC<CometChatEmojiKeyboardProps> = ({
149
150
  }) => {
150
151
  const theme = useTheme();
151
152
  const styles = Styles(theme);
153
+ const insets = useSafeAreaInsets();
152
154
 
153
155
  /**
154
156
  * ITEM_HEIGHT is assumed to be the height of one row or the uniform height per row.
@@ -284,6 +286,7 @@ const CometChatEmojiKeyboard: React.FC<CometChatEmojiKeyboardProps> = ({
284
286
 
285
287
  return (
286
288
  <SafeAreaView
289
+ edges={["top"]}
287
290
  style={[
288
291
  styles.emojiKeyboardContainer,
289
292
  {
@@ -315,6 +318,7 @@ const CometChatEmojiKeyboard: React.FC<CometChatEmojiKeyboardProps> = ({
315
318
  styles.categoryContainer,
316
319
  {
317
320
  backgroundColor: categoryBackground || theme.color.background1,
321
+ paddingBottom: Platform.OS === "ios" ? insets.bottom : 0,
318
322
  },
319
323
  ]}
320
324
  >
@@ -139,6 +139,7 @@ export const CometChatImageLoader = (props: CometChatImageLoaderPropType) => {
139
139
  onTouchStart={handleTouchStart}
140
140
  onTouchEnd={handleTouchEnd}
141
141
  onTouchMove={onTouchMove}
142
+ hitSlop={{top: 10, bottom: 10, left: 10, right: 10}}
142
143
  style={{
143
144
  position: "relative",
144
145
  justifyContent: "center",
@@ -1,43 +1,50 @@
1
1
  import React, { useLayoutEffect, useState } from "react";
2
- import {
3
- ActivityIndicator,
4
- Image,
5
- Modal,
6
- SafeAreaView,
7
- StyleSheet,
8
- TouchableOpacity,
9
- View,
10
- } from "react-native";
2
+ import { ActivityIndicator, Image, Modal, StyleSheet, TouchableOpacity, View } from "react-native";
3
+ import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
11
4
  import { ReactNativeZoomableViewWithGestures } from "../../libs/ImageZoom";
12
- import { ICONS } from "./resources";
5
+ import { Icon } from "../../icons/Icon";
13
6
 
14
7
  export const ImageViewerModal = ({ imageUrl, isVisible, onClose }: any) => {
15
8
  const [downloaded, setDownloaded] = useState(false);
9
+ const insets = useSafeAreaInsets();
10
+
16
11
  useLayoutEffect(() => {
17
- Image.prefetch(imageUrl.uri).then((res) => {
12
+ // include imageUrl as dep so it re-runs when URL changes
13
+ if (!imageUrl) return;
14
+ Image.prefetch(typeof imageUrl === "string" ? imageUrl : imageUrl.uri).then((res) => {
18
15
  setDownloaded(res);
19
16
  });
20
-
21
- Image.getSize(
22
- imageUrl.uri,
23
- (res) => {
24
- console.log("success : ", res);
25
- },
26
- (res) => {
27
- console.log("error : ", res);
28
- }
29
- );
30
- }, []);
17
+ }, [imageUrl]);
31
18
 
32
19
  return (
33
20
  <Modal animationType='slide' transparent={false} visible={isVisible} onRequestClose={onClose}>
34
- <SafeAreaView style={styles.centeredView}>
21
+ {/* keep SafeAreaView so bottom inset is handled too */}
22
+ <SafeAreaView style={styles.centeredView} edges={["bottom"]}>
23
+ <View
24
+ style={[
25
+ styles.header,
26
+ {
27
+ // push header below the notch/status bar
28
+ paddingTop: insets.top,
29
+ height: 60 + insets.top,
30
+ },
31
+ ]}
32
+ >
33
+ <TouchableOpacity
34
+ style={[
35
+ styles.closeButton,
36
+ {
37
+ // respect left inset (very useful on iPhone with rounded corners)
38
+ marginLeft: Math.max(10, insets.left + 6),
39
+ },
40
+ ]}
41
+ onPress={onClose}
42
+ >
43
+ <Icon name='arrow-back-fill' color={"#fff"} height={22} width={22} />
44
+ </TouchableOpacity>
45
+ </View>
46
+
35
47
  <View style={styles.container}>
36
- <View style={styles.header}>
37
- <TouchableOpacity style={styles.closeButton} onPress={onClose}>
38
- <Image source={ICONS.backIcon} style={{ tintColor: "#fff", height: 20, width: 20 }} />
39
- </TouchableOpacity>
40
- </View>
41
48
  {downloaded ? (
42
49
  <View style={styles.imageContainer}>
43
50
  <ReactNativeZoomableViewWithGestures onSwipeDown={onClose}>
@@ -45,7 +52,9 @@ export const ImageViewerModal = ({ imageUrl, isVisible, onClose }: any) => {
45
52
  </ReactNativeZoomableViewWithGestures>
46
53
  </View>
47
54
  ) : (
48
- <ActivityIndicator color={"#fff"} />
55
+ <View style={styles.loaderContainer}>
56
+ <ActivityIndicator color={"#fff"} size='large' />
57
+ </View>
49
58
  )}
50
59
  </View>
51
60
  </SafeAreaView>
@@ -56,38 +65,41 @@ export const ImageViewerModal = ({ imageUrl, isVisible, onClose }: any) => {
56
65
  const styles = StyleSheet.create({
57
66
  centeredView: {
58
67
  flex: 1,
59
- zIndex: 1,
60
- elevation: 1,
68
+ backgroundColor: "#000",
61
69
  },
62
70
  container: {
71
+ flex: 1,
72
+ backgroundColor: "#000",
73
+ },
74
+ loaderContainer: {
63
75
  flex: 1,
64
76
  justifyContent: "center",
65
77
  alignItems: "center",
66
- backgroundColor: "#000",
67
78
  },
68
79
  header: {
69
80
  position: "absolute",
70
81
  top: 0,
82
+ left: 0,
83
+ right: 0,
71
84
  backgroundColor: "transparent",
72
- justifyContent: "flex-start",
73
- width: "100%",
74
- zIndex: 100,
85
+ zIndex: 1000,
86
+ elevation: 50,
87
+ justifyContent: "center",
75
88
  },
76
89
  imageContainer: {
77
90
  flex: 1,
78
- height: "100%",
79
- width: "100%",
80
- },
81
- imageStyle: {
82
- width: "100%",
83
- height: "100%",
91
+ marginVertical: 60,
84
92
  },
85
93
  closeButton: {
86
- zIndex: 10,
87
- height: 60,
88
- width: 60,
94
+ height: 44,
95
+ width: 44,
89
96
  justifyContent: "center",
90
97
  alignItems: "center",
91
- elevation: 10,
98
+ backgroundColor: "rgba(0,0,0,0.3)",
99
+ borderRadius: 22,
100
+ },
101
+ imageStyle: {
102
+ width: "100%",
103
+ height: "100%",
92
104
  },
93
105
  });
@@ -0,0 +1,86 @@
1
+ import React from "react";
2
+ import { TouchableOpacity } from "react-native";
3
+ import { stopStreamingForRunId } from "../../services/stream-message.service";
4
+ import { useTheme } from "../../../theme";
5
+ import { Icon } from "../../../shared/icons/Icon";
6
+
7
+ type CometChatSendButtonViewProps = {
8
+ isButtonDisabled: boolean;
9
+ composerRef: any;
10
+ isStreaming: boolean;
11
+ showStopButton: boolean;
12
+ setShowStopButton: (show: boolean) => void;
13
+ };
14
+
15
+ const CometChatSendButtonView = ({
16
+ isButtonDisabled,
17
+ composerRef,
18
+ isStreaming,
19
+ showStopButton,
20
+ setShowStopButton,
21
+ }: CometChatSendButtonViewProps) => {
22
+ const theme = useTheme();
23
+
24
+ const handlePress = () => {
25
+ if (isButtonDisabled) {
26
+ return;
27
+ }
28
+
29
+ if (isStreaming || showStopButton) {
30
+ setShowStopButton(false);
31
+ stopStreamingForRunId();
32
+ } else {
33
+ setShowStopButton(true);
34
+ setTimeout(() => {
35
+ composerRef.current?.sendTextMessage?.();
36
+ }, 0);
37
+ }
38
+ };
39
+
40
+ const shouldShowStop = isStreaming || showStopButton;
41
+ const isActive = shouldShowStop || !isButtonDisabled;
42
+ const backgroundColor =
43
+ theme.mode === "light"
44
+ ? isActive
45
+ ? theme.color.secondaryButtonBackground
46
+ : theme.color.background4
47
+ : isActive
48
+ ? theme.color.staticWhite
49
+ : theme.color.background4;
50
+ const iconColor =
51
+ theme.mode === "light"
52
+ ? isActive
53
+ ? theme.color.staticWhite
54
+ : theme.color.staticWhite
55
+ : isActive
56
+ ? theme.color.staticBlack
57
+ : theme.color.staticBlack
58
+
59
+
60
+ return (
61
+ <TouchableOpacity
62
+ onPress={handlePress}
63
+ disabled={isButtonDisabled && shouldShowStop}
64
+ style={{
65
+ display: "flex",
66
+ width: 40,
67
+ height: 40,
68
+ paddingVertical: theme.spacing.padding.p4,
69
+ paddingHorizontal: theme.spacing.padding.p3,
70
+ justifyContent: "center",
71
+ alignItems: "center",
72
+ borderRadius: 9999,
73
+ backgroundColor,
74
+ }}
75
+ >
76
+ <Icon
77
+ name={shouldShowStop ? "stop-fill" : "ai-send-button"}
78
+ width={20}
79
+ height={20}
80
+ color={iconColor}
81
+ />
82
+ </TouchableOpacity>
83
+ );
84
+ };
85
+
86
+ export { CometChatSendButtonView };
@@ -0,0 +1 @@
1
+ export { CometChatSendButtonView } from "./CometChatSendButtonView";