@cometchat/chat-uikit-react-native 5.1.2 → 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 (200) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.4/gc.properties +0 -0
  5. package/android/.gradle/vcs-1/gc.properties +0 -0
  6. package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.d.ts +40 -0
  7. package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.js +467 -0
  8. package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.js.map +1 -0
  9. package/lib/CometChatAIAssistantChatHistory/Skeleton.d.ts +24 -0
  10. package/lib/CometChatAIAssistantChatHistory/Skeleton.js +130 -0
  11. package/lib/CometChatAIAssistantChatHistory/Skeleton.js.map +1 -0
  12. package/lib/CometChatAIAssistantChatHistory/index.d.ts +1 -0
  13. package/lib/CometChatAIAssistantChatHistory/index.js +2 -0
  14. package/lib/CometChatAIAssistantChatHistory/index.js.map +1 -0
  15. package/lib/CometChatAIAssistantChatHistory/style.d.ts +30 -0
  16. package/lib/CometChatAIAssistantChatHistory/style.js +122 -0
  17. package/lib/CometChatAIAssistantChatHistory/style.js.map +1 -0
  18. package/lib/CometChatConversations/CometChatConversations.js +26 -5
  19. package/lib/CometChatConversations/CometChatConversations.js.map +1 -1
  20. package/lib/CometChatMessageComposer/CometChatMessageComposer.d.ts +7 -0
  21. package/lib/CometChatMessageComposer/CometChatMessageComposer.js +101 -13
  22. package/lib/CometChatMessageComposer/CometChatMessageComposer.js.map +1 -1
  23. package/lib/CometChatMessageHeader/CometChatMessageHeader.d.ts +16 -0
  24. package/lib/CometChatMessageHeader/CometChatMessageHeader.js +63 -13
  25. package/lib/CometChatMessageHeader/CometChatMessageHeader.js.map +1 -1
  26. package/lib/CometChatMessageList/CometChatMessageList.d.ts +33 -0
  27. package/lib/CometChatMessageList/CometChatMessageList.js +535 -76
  28. package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
  29. package/lib/CometChatMessageList/style.js +74 -2
  30. package/lib/CometChatMessageList/style.js.map +1 -1
  31. package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js +6 -12
  32. package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js.map +1 -1
  33. package/lib/calls/CometChatOutgoingCall/CometChatOutgoingCall.js +4 -3
  34. package/lib/calls/CometChatOutgoingCall/CometChatOutgoingCall.js.map +1 -1
  35. package/lib/extensions/Polls/Polls.js +38 -17
  36. package/lib/extensions/Polls/Polls.js.map +1 -1
  37. package/lib/index.d.ts +5 -1
  38. package/lib/index.js +6 -2
  39. package/lib/index.js.map +1 -1
  40. package/lib/shared/constants/UIKitConstants.d.ts +16 -0
  41. package/lib/shared/constants/UIKitConstants.js +16 -0
  42. package/lib/shared/constants/UIKitConstants.js.map +1 -1
  43. package/lib/shared/events/CometChatMessageEvents/index.d.ts +3 -0
  44. package/lib/shared/events/CometChatMessageEvents/index.js +3 -0
  45. package/lib/shared/events/CometChatMessageEvents/index.js.map +1 -1
  46. package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js +3 -0
  47. package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js.map +1 -1
  48. package/lib/shared/events/CometChatUIEventHandler/Listener.d.ts +3 -1
  49. package/lib/shared/events/CometChatUIEventHandler/Listener.js +4 -1
  50. package/lib/shared/events/CometChatUIEventHandler/Listener.js.map +1 -1
  51. package/lib/shared/events/ListenerInitializer.d.ts +3 -1
  52. package/lib/shared/events/ListenerInitializer.js +5 -1
  53. package/lib/shared/events/ListenerInitializer.js.map +1 -1
  54. package/lib/shared/events/messages.d.ts +2 -1
  55. package/lib/shared/events/messages.js +1 -0
  56. package/lib/shared/events/messages.js.map +1 -1
  57. package/lib/shared/framework/DataSource.d.ts +3 -1
  58. package/lib/shared/framework/DataSourceDecorator.d.ts +3 -1
  59. package/lib/shared/framework/DataSourceDecorator.js +8 -2
  60. package/lib/shared/framework/DataSourceDecorator.js.map +1 -1
  61. package/lib/shared/framework/MessageDataSource.d.ts +6 -0
  62. package/lib/shared/framework/MessageDataSource.js +64 -1
  63. package/lib/shared/framework/MessageDataSource.js.map +1 -1
  64. package/lib/shared/icons/components/ai-chat-history.d.ts +8 -0
  65. package/lib/shared/icons/components/ai-chat-history.js +9 -0
  66. package/lib/shared/icons/components/ai-chat-history.js.map +1 -0
  67. package/lib/shared/icons/components/ai-copy-option.d.ts +8 -0
  68. package/lib/shared/icons/components/ai-copy-option.js +9 -0
  69. package/lib/shared/icons/components/ai-copy-option.js.map +1 -0
  70. package/lib/shared/icons/components/ai-new-chat.d.ts +8 -0
  71. package/lib/shared/icons/components/ai-new-chat.js +9 -0
  72. package/lib/shared/icons/components/ai-new-chat.js.map +1 -0
  73. package/lib/shared/icons/components/ai-send-button.d.ts +8 -0
  74. package/lib/shared/icons/components/ai-send-button.js +9 -0
  75. package/lib/shared/icons/components/ai-send-button.js.map +1 -0
  76. package/lib/shared/icons/components/right-arrow.d.ts +3 -0
  77. package/lib/shared/icons/components/right-arrow.js +6 -0
  78. package/lib/shared/icons/components/right-arrow.js.map +1 -0
  79. package/lib/shared/icons/components/stop-fill.js +8 -7
  80. package/lib/shared/icons/components/stop-fill.js.map +1 -1
  81. package/lib/shared/icons/icon-mapping.d.ts +11 -0
  82. package/lib/shared/icons/icon-mapping.js +11 -0
  83. package/lib/shared/icons/icon-mapping.js.map +1 -1
  84. package/lib/shared/modals/CometChatAIAssistantTools.d.ts +47 -0
  85. package/lib/shared/modals/CometChatAIAssistantTools.js +44 -0
  86. package/lib/shared/modals/CometChatAIAssistantTools.js.map +1 -0
  87. package/lib/shared/modals/StreamMessage.d.ts +4 -0
  88. package/lib/shared/modals/StreamMessage.js +11 -0
  89. package/lib/shared/modals/StreamMessage.js.map +1 -0
  90. package/lib/shared/modals/index.d.ts +3 -1
  91. package/lib/shared/modals/index.js +3 -1
  92. package/lib/shared/modals/index.js.map +1 -1
  93. package/lib/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.d.ts +126 -0
  94. package/lib/shared/resources/CometChatLocalizeNew/resources/de/translation.json +7 -1
  95. package/lib/shared/resources/CometChatLocalizeNew/resources/en/translation.json +7 -1
  96. package/lib/shared/resources/CometChatLocalizeNew/resources/es/translation.json +7 -1
  97. package/lib/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +7 -1
  98. package/lib/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +7 -1
  99. package/lib/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +7 -1
  100. package/lib/shared/resources/CometChatLocalizeNew/resources/it/translation.json +7 -1
  101. package/lib/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +7 -1
  102. package/lib/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +7 -1
  103. package/lib/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +7 -1
  104. package/lib/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +7 -1
  105. package/lib/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +7 -1
  106. package/lib/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +7 -1
  107. package/lib/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +7 -1
  108. package/lib/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +7 -1
  109. package/lib/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +7 -1
  110. package/lib/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +7 -1
  111. package/lib/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +7 -1
  112. package/lib/shared/services/stream-message.service.d.ts +84 -0
  113. package/lib/shared/services/stream-message.service.js +406 -0
  114. package/lib/shared/services/stream-message.service.js.map +1 -0
  115. package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.d.ts +9 -0
  116. package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.js +248 -0
  117. package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.js.map +1 -0
  118. package/lib/shared/views/CometChatAIAssistantMessageBubble/index.d.ts +3 -0
  119. package/lib/shared/views/CometChatAIAssistantMessageBubble/index.js +4 -0
  120. package/lib/shared/views/CometChatAIAssistantMessageBubble/index.js.map +1 -0
  121. package/lib/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.js +5 -2
  122. package/lib/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.js.map +1 -1
  123. package/lib/shared/views/CometChatImageBubble/CometChatImageLoader.js +1 -1
  124. package/lib/shared/views/CometChatImageBubble/CometChatImageLoader.js.map +1 -1
  125. package/lib/shared/views/CometChatImageViewerModal/ImageViewerModal.js +52 -32
  126. package/lib/shared/views/CometChatImageViewerModal/ImageViewerModal.js.map +1 -1
  127. package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.d.ts +10 -0
  128. package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.js +54 -0
  129. package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.js.map +1 -0
  130. package/lib/shared/views/CometChatSendButtonView/index.d.ts +1 -0
  131. package/lib/shared/views/CometChatSendButtonView/index.js +2 -0
  132. package/lib/shared/views/CometChatSendButtonView/index.js.map +1 -0
  133. package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.d.ts +8 -0
  134. package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.js +436 -0
  135. package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.js.map +1 -0
  136. package/lib/shared/views/CometChatStreamMessageBubble/index.d.ts +3 -0
  137. package/lib/shared/views/CometChatStreamMessageBubble/index.js +3 -0
  138. package/lib/shared/views/CometChatStreamMessageBubble/index.js.map +1 -0
  139. package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.d.ts +14 -6
  140. package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.js +82 -57
  141. package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.js.map +1 -1
  142. package/lib/theme/context.d.ts +96 -15
  143. package/lib/theme/type.d.ts +14 -1
  144. package/package.json +5 -2
  145. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +627 -0
  146. package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +228 -0
  147. package/src/CometChatAIAssistantChatHistory/index.ts +2 -0
  148. package/src/CometChatAIAssistantChatHistory/style.ts +160 -0
  149. package/src/CometChatConversations/CometChatConversations.tsx +36 -10
  150. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +137 -19
  151. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +106 -18
  152. package/src/CometChatMessageList/CometChatMessageList.tsx +619 -72
  153. package/src/CometChatMessageList/style.ts +74 -2
  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/CometChatSendButtonView/CometChatSendButtonView.tsx +86 -0
  197. package/src/shared/views/CometChatSendButtonView/index.ts +1 -0
  198. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +493 -0
  199. package/src/shared/views/CometChatStreamMessageBubble/index.ts +9 -0
  200. package/src/theme/type.ts +14 -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;
@@ -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";