react-native-chatbot-ai 0.1.19 → 0.1.22

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 (263) hide show
  1. package/lib/module/components/Drawer/DeleteSessionPopup.js +113 -0
  2. package/lib/module/components/Drawer/DeleteSessionPopup.js.map +1 -0
  3. package/lib/module/components/Drawer/DrawerContent.js +21 -8
  4. package/lib/module/components/Drawer/DrawerContent.js.map +1 -1
  5. package/lib/module/components/Drawer/RenameSessionPopup.js +121 -0
  6. package/lib/module/components/Drawer/RenameSessionPopup.js.map +1 -0
  7. package/lib/module/components/Drawer/SearchInput.js +10 -3
  8. package/lib/module/components/Drawer/SearchInput.js.map +1 -1
  9. package/lib/module/components/Drawer/SessionItem.js +36 -20
  10. package/lib/module/components/Drawer/SessionItem.js.map +1 -1
  11. package/lib/module/components/Drawer/SessionList.js +2 -5
  12. package/lib/module/components/Drawer/SessionList.js.map +1 -1
  13. package/lib/module/components/Drawer/SessionOptionsBottomSheet.js +129 -0
  14. package/lib/module/components/Drawer/SessionOptionsBottomSheet.js.map +1 -0
  15. package/lib/module/components/Drawer/ShareSessionPopup.js +132 -0
  16. package/lib/module/components/Drawer/ShareSessionPopup.js.map +1 -0
  17. package/lib/module/components/chat/ChatEmpty.js +15 -4
  18. package/lib/module/components/chat/ChatEmpty.js.map +1 -1
  19. package/lib/module/components/chat/ChatHeader.js +10 -4
  20. package/lib/module/components/chat/ChatHeader.js.map +1 -1
  21. package/lib/module/components/chat/ChatMessageList.js +75 -24
  22. package/lib/module/components/chat/ChatMessageList.js.map +1 -1
  23. package/lib/module/components/chat/SuggestionItem.js +2 -1
  24. package/lib/module/components/chat/SuggestionItem.js.map +1 -1
  25. package/lib/module/components/chat/footer/index.js +77 -15
  26. package/lib/module/components/chat/footer/index.js.map +1 -1
  27. package/lib/module/components/chat/footer/item/UploadImageItem.js +21 -1
  28. package/lib/module/components/chat/footer/item/UploadImageItem.js.map +1 -1
  29. package/lib/module/components/chat/index.js +7 -6
  30. package/lib/module/components/chat/index.js.map +1 -1
  31. package/lib/module/components/chat/item/ChatAIAnswerMessageItem.js +36 -5
  32. package/lib/module/components/chat/item/ChatAIAnswerMessageItem.js.map +1 -1
  33. package/lib/module/components/chat/item/DeeplinkItem.js +30 -2
  34. package/lib/module/components/chat/item/DeeplinkItem.js.map +1 -1
  35. package/lib/module/components/chat/item/MessageActionsBar.js +243 -0
  36. package/lib/module/components/chat/item/MessageActionsBar.js.map +1 -0
  37. package/lib/module/components/chat/item/actions/ActionButton.js +56 -0
  38. package/lib/module/components/chat/item/actions/ActionButton.js.map +1 -0
  39. package/lib/module/components/portal/BottomSheet.js +245 -0
  40. package/lib/module/components/portal/BottomSheet.js.map +1 -0
  41. package/lib/module/components/portal/Popup.js +278 -0
  42. package/lib/module/components/portal/Popup.js.map +1 -0
  43. package/lib/module/components/portal/index.js +11 -5
  44. package/lib/module/components/portal/index.js.map +1 -1
  45. package/lib/module/components/product/CardHorizontal.js +44 -7
  46. package/lib/module/components/product/CardHorizontal.js.map +1 -1
  47. package/lib/module/constants/events.js +33 -0
  48. package/lib/module/constants/events.js.map +1 -1
  49. package/lib/module/constants/index.js +5 -1
  50. package/lib/module/constants/index.js.map +1 -1
  51. package/lib/module/constants/query.js +5 -1
  52. package/lib/module/constants/query.js.map +1 -1
  53. package/lib/module/context/ChatContext.js +9 -3
  54. package/lib/module/context/ChatContext.js.map +1 -1
  55. package/lib/module/hooks/message/useSendMessage.js +21 -3
  56. package/lib/module/hooks/message/useSendMessage.js.map +1 -1
  57. package/lib/module/hooks/message/useStreamMessage.js +10 -3
  58. package/lib/module/hooks/message/useStreamMessage.js.map +1 -1
  59. package/lib/module/hooks/messageActions/index.js +13 -0
  60. package/lib/module/hooks/messageActions/index.js.map +1 -0
  61. package/lib/module/hooks/messageActions/useAudioPlayer.js +269 -0
  62. package/lib/module/hooks/messageActions/useAudioPlayer.js.map +1 -0
  63. package/lib/module/hooks/messageActions/useCopyToClipboard.js +38 -0
  64. package/lib/module/hooks/messageActions/useCopyToClipboard.js.map +1 -0
  65. package/lib/module/hooks/messageActions/useFeedback.js +93 -0
  66. package/lib/module/hooks/messageActions/useFeedback.js.map +1 -0
  67. package/lib/module/hooks/messageActions/useSendFeedback.js +24 -0
  68. package/lib/module/hooks/messageActions/useSendFeedback.js.map +1 -0
  69. package/lib/module/hooks/messageActions/useShareMessage.js +128 -0
  70. package/lib/module/hooks/messageActions/useShareMessage.js.map +1 -0
  71. package/lib/module/hooks/session/useDeleteSession.js +23 -0
  72. package/lib/module/hooks/session/useDeleteSession.js.map +1 -0
  73. package/lib/module/hooks/session/useRenameSession.js +28 -0
  74. package/lib/module/hooks/session/useRenameSession.js.map +1 -0
  75. package/lib/module/hooks/session/useSearchSessions.js +5 -1
  76. package/lib/module/hooks/session/useSearchSessions.js.map +1 -1
  77. package/lib/module/hooks/session/useShareSession.js +16 -0
  78. package/lib/module/hooks/session/useShareSession.js.map +1 -0
  79. package/lib/module/hooks/upload/useImageUpload.js +2 -1
  80. package/lib/module/hooks/upload/useImageUpload.js.map +1 -1
  81. package/lib/module/services/endpoints.js +6 -1
  82. package/lib/module/services/endpoints.js.map +1 -1
  83. package/lib/module/services/index.js +1 -0
  84. package/lib/module/services/index.js.map +1 -1
  85. package/lib/module/services/playbackService.js +22 -0
  86. package/lib/module/services/playbackService.js.map +1 -0
  87. package/lib/module/store/audioPlayer.js +75 -0
  88. package/lib/module/store/audioPlayer.js.map +1 -0
  89. package/lib/module/store/messageActions.js +160 -0
  90. package/lib/module/store/messageActions.js.map +1 -0
  91. package/lib/module/store/session.js +6 -3
  92. package/lib/module/store/session.js.map +1 -1
  93. package/lib/module/translation/index.js +21 -25
  94. package/lib/module/translation/index.js.map +1 -1
  95. package/lib/module/translation/resources/i18n.js +39 -0
  96. package/lib/module/translation/resources/i18n.js.map +1 -0
  97. package/lib/module/types/chat.js +12 -1
  98. package/lib/module/types/chat.js.map +1 -1
  99. package/lib/module/types/index.js +1 -0
  100. package/lib/module/types/index.js.map +1 -1
  101. package/lib/module/types/messageActions.js +56 -0
  102. package/lib/module/types/messageActions.js.map +1 -0
  103. package/lib/module/utils/textCleaner.js +67 -0
  104. package/lib/module/utils/textCleaner.js.map +1 -0
  105. package/lib/module/utils/ui.js +27 -1
  106. package/lib/module/utils/ui.js.map +1 -1
  107. package/lib/typescript/src/components/Drawer/DeleteSessionPopup.d.ts +3 -0
  108. package/lib/typescript/src/components/Drawer/DeleteSessionPopup.d.ts.map +1 -0
  109. package/lib/typescript/src/components/Drawer/DrawerContent.d.ts.map +1 -1
  110. package/lib/typescript/src/components/Drawer/RenameSessionPopup.d.ts +3 -0
  111. package/lib/typescript/src/components/Drawer/RenameSessionPopup.d.ts.map +1 -0
  112. package/lib/typescript/src/components/Drawer/SearchInput.d.ts.map +1 -1
  113. package/lib/typescript/src/components/Drawer/SessionItem.d.ts.map +1 -1
  114. package/lib/typescript/src/components/Drawer/SessionList.d.ts.map +1 -1
  115. package/lib/typescript/src/components/Drawer/SessionOptionsBottomSheet.d.ts +3 -0
  116. package/lib/typescript/src/components/Drawer/SessionOptionsBottomSheet.d.ts.map +1 -0
  117. package/lib/typescript/src/components/Drawer/ShareSessionPopup.d.ts +3 -0
  118. package/lib/typescript/src/components/Drawer/ShareSessionPopup.d.ts.map +1 -0
  119. package/lib/typescript/src/components/chat/ChatEmpty.d.ts.map +1 -1
  120. package/lib/typescript/src/components/chat/ChatHeader.d.ts.map +1 -1
  121. package/lib/typescript/src/components/chat/ChatMessageList.d.ts.map +1 -1
  122. package/lib/typescript/src/components/chat/SuggestionItem.d.ts +3 -2
  123. package/lib/typescript/src/components/chat/SuggestionItem.d.ts.map +1 -1
  124. package/lib/typescript/src/components/chat/footer/index.d.ts.map +1 -1
  125. package/lib/typescript/src/components/chat/footer/item/UploadImageItem.d.ts.map +1 -1
  126. package/lib/typescript/src/components/chat/index.d.ts.map +1 -1
  127. package/lib/typescript/src/components/chat/item/ChatAIAnswerMessageItem.d.ts.map +1 -1
  128. package/lib/typescript/src/components/chat/item/DeeplinkItem.d.ts +2 -1
  129. package/lib/typescript/src/components/chat/item/DeeplinkItem.d.ts.map +1 -1
  130. package/lib/typescript/src/components/chat/item/MessageActionsBar.d.ts +16 -0
  131. package/lib/typescript/src/components/chat/item/MessageActionsBar.d.ts.map +1 -0
  132. package/lib/typescript/src/components/chat/item/actions/ActionButton.d.ts +19 -0
  133. package/lib/typescript/src/components/chat/item/actions/ActionButton.d.ts.map +1 -0
  134. package/lib/typescript/src/components/portal/BottomSheet.d.ts +8 -0
  135. package/lib/typescript/src/components/portal/BottomSheet.d.ts.map +1 -0
  136. package/lib/typescript/src/components/portal/Popup.d.ts +4 -0
  137. package/lib/typescript/src/components/portal/Popup.d.ts.map +1 -0
  138. package/lib/typescript/src/components/portal/index.d.ts.map +1 -1
  139. package/lib/typescript/src/components/product/CardHorizontal.d.ts +3 -2
  140. package/lib/typescript/src/components/product/CardHorizontal.d.ts.map +1 -1
  141. package/lib/typescript/src/constants/events.d.ts +33 -0
  142. package/lib/typescript/src/constants/events.d.ts.map +1 -1
  143. package/lib/typescript/src/constants/index.d.ts +5 -1
  144. package/lib/typescript/src/constants/index.d.ts.map +1 -1
  145. package/lib/typescript/src/constants/query.d.ts +4 -0
  146. package/lib/typescript/src/constants/query.d.ts.map +1 -1
  147. package/lib/typescript/src/context/ChatContext.d.ts.map +1 -1
  148. package/lib/typescript/src/hooks/message/useSendMessage.d.ts +2 -2
  149. package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
  150. package/lib/typescript/src/hooks/message/useStreamMessage.d.ts.map +1 -1
  151. package/lib/typescript/src/hooks/messageActions/index.d.ts +10 -0
  152. package/lib/typescript/src/hooks/messageActions/index.d.ts.map +1 -0
  153. package/lib/typescript/src/hooks/messageActions/useAudioPlayer.d.ts +14 -0
  154. package/lib/typescript/src/hooks/messageActions/useAudioPlayer.d.ts.map +1 -0
  155. package/lib/typescript/src/hooks/messageActions/useCopyToClipboard.d.ts +9 -0
  156. package/lib/typescript/src/hooks/messageActions/useCopyToClipboard.d.ts.map +1 -0
  157. package/lib/typescript/src/hooks/messageActions/useFeedback.d.ts +18 -0
  158. package/lib/typescript/src/hooks/messageActions/useFeedback.d.ts.map +1 -0
  159. package/lib/typescript/src/hooks/messageActions/useSendFeedback.d.ts +6 -0
  160. package/lib/typescript/src/hooks/messageActions/useSendFeedback.d.ts.map +1 -0
  161. package/lib/typescript/src/hooks/messageActions/useShareMessage.d.ts +12 -0
  162. package/lib/typescript/src/hooks/messageActions/useShareMessage.d.ts.map +1 -0
  163. package/lib/typescript/src/hooks/session/useDeleteSession.d.ts +2 -0
  164. package/lib/typescript/src/hooks/session/useDeleteSession.d.ts.map +1 -0
  165. package/lib/typescript/src/hooks/session/useRenameSession.d.ts +2 -0
  166. package/lib/typescript/src/hooks/session/useRenameSession.d.ts.map +1 -0
  167. package/lib/typescript/src/hooks/session/useSearchSessions.d.ts +1 -1
  168. package/lib/typescript/src/hooks/session/useSearchSessions.d.ts.map +1 -1
  169. package/lib/typescript/src/hooks/session/useShareSession.d.ts +2 -0
  170. package/lib/typescript/src/hooks/session/useShareSession.d.ts.map +1 -0
  171. package/lib/typescript/src/hooks/upload/useImageUpload.d.ts +1 -1
  172. package/lib/typescript/src/hooks/upload/useImageUpload.d.ts.map +1 -1
  173. package/lib/typescript/src/services/endpoints.d.ts +5 -0
  174. package/lib/typescript/src/services/endpoints.d.ts.map +1 -1
  175. package/lib/typescript/src/services/index.d.ts +1 -0
  176. package/lib/typescript/src/services/index.d.ts.map +1 -1
  177. package/lib/typescript/src/services/playbackService.d.ts +2 -0
  178. package/lib/typescript/src/services/playbackService.d.ts.map +1 -0
  179. package/lib/typescript/src/store/audioPlayer.d.ts +27 -0
  180. package/lib/typescript/src/store/audioPlayer.d.ts.map +1 -0
  181. package/lib/typescript/src/store/messageActions.d.ts +9 -0
  182. package/lib/typescript/src/store/messageActions.d.ts.map +1 -0
  183. package/lib/typescript/src/store/session.d.ts.map +1 -1
  184. package/lib/typescript/src/translation/index.d.ts +3 -4
  185. package/lib/typescript/src/translation/index.d.ts.map +1 -1
  186. package/lib/typescript/src/translation/resources/i18n.d.ts +5 -0
  187. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -0
  188. package/lib/typescript/src/types/chat.d.ts +16 -1
  189. package/lib/typescript/src/types/chat.d.ts.map +1 -1
  190. package/lib/typescript/src/types/dto.d.ts +11 -0
  191. package/lib/typescript/src/types/dto.d.ts.map +1 -1
  192. package/lib/typescript/src/types/index.d.ts +1 -0
  193. package/lib/typescript/src/types/index.d.ts.map +1 -1
  194. package/lib/typescript/src/types/messageActions.d.ts +85 -0
  195. package/lib/typescript/src/types/messageActions.d.ts.map +1 -0
  196. package/lib/typescript/src/types/ui.d.ts +16 -1
  197. package/lib/typescript/src/types/ui.d.ts.map +1 -1
  198. package/lib/typescript/src/utils/textCleaner.d.ts +30 -0
  199. package/lib/typescript/src/utils/textCleaner.d.ts.map +1 -0
  200. package/lib/typescript/src/utils/ui.d.ts +12 -1
  201. package/lib/typescript/src/utils/ui.d.ts.map +1 -1
  202. package/package.json +6 -6
  203. package/src/components/Drawer/DeleteSessionPopup.tsx +121 -0
  204. package/src/components/Drawer/DrawerContent.tsx +23 -7
  205. package/src/components/Drawer/RenameSessionPopup.tsx +145 -0
  206. package/src/components/Drawer/SearchInput.tsx +11 -2
  207. package/src/components/Drawer/SessionItem.tsx +22 -8
  208. package/src/components/Drawer/SessionList.tsx +0 -2
  209. package/src/components/Drawer/SessionOptionsBottomSheet.tsx +138 -0
  210. package/src/components/Drawer/ShareSessionPopup.tsx +145 -0
  211. package/src/components/chat/ChatEmpty.tsx +15 -5
  212. package/src/components/chat/ChatHeader.tsx +9 -4
  213. package/src/components/chat/ChatMessageList.tsx +78 -18
  214. package/src/components/chat/SuggestionItem.tsx +4 -3
  215. package/src/components/chat/footer/index.tsx +95 -14
  216. package/src/components/chat/footer/item/UploadImageItem.tsx +21 -1
  217. package/src/components/chat/index.tsx +8 -11
  218. package/src/components/chat/item/ChatAIAnswerMessageItem.tsx +55 -6
  219. package/src/components/chat/item/DeeplinkItem.tsx +30 -2
  220. package/src/components/chat/item/MessageActionsBar.tsx +326 -0
  221. package/src/components/chat/item/actions/ActionButton.tsx +65 -0
  222. package/src/components/portal/BottomSheet.tsx +307 -0
  223. package/src/components/portal/Popup.tsx +345 -0
  224. package/src/components/portal/index.tsx +5 -1
  225. package/src/components/product/CardHorizontal.tsx +45 -10
  226. package/src/constants/events.ts +34 -0
  227. package/src/constants/index.ts +6 -1
  228. package/src/constants/query.ts +4 -0
  229. package/src/context/ChatContext.tsx +6 -0
  230. package/src/hooks/message/useSendMessage.ts +47 -4
  231. package/src/hooks/message/useStreamMessage.ts +15 -4
  232. package/src/hooks/messageActions/index.ts +10 -0
  233. package/src/hooks/messageActions/useAudioPlayer.ts +346 -0
  234. package/src/hooks/messageActions/useCopyToClipboard.ts +38 -0
  235. package/src/hooks/messageActions/useFeedback.ts +114 -0
  236. package/src/hooks/messageActions/useSendFeedback.ts +31 -0
  237. package/src/hooks/messageActions/useShareMessage.ts +146 -0
  238. package/src/hooks/session/useDeleteSession.ts +25 -0
  239. package/src/hooks/session/useRenameSession.ts +37 -0
  240. package/src/hooks/session/useSearchSessions.ts +6 -1
  241. package/src/hooks/session/useShareSession.ts +22 -0
  242. package/src/hooks/upload/useImageUpload.ts +6 -2
  243. package/src/ignore.d.ts +20 -1
  244. package/src/services/endpoints.ts +10 -0
  245. package/src/services/index.ts +1 -0
  246. package/src/services/playbackService.ts +22 -0
  247. package/src/store/audioPlayer.ts +112 -0
  248. package/src/store/messageActions.ts +161 -0
  249. package/src/store/session.ts +4 -2
  250. package/src/translation/index.ts +27 -19
  251. package/src/translation/resources/i18n.ts +45 -0
  252. package/src/types/chat.ts +21 -1
  253. package/src/types/dto.ts +14 -0
  254. package/src/types/index.ts +1 -0
  255. package/src/types/messageActions.ts +131 -0
  256. package/src/types/ui.ts +19 -1
  257. package/src/utils/textCleaner.ts +65 -0
  258. package/src/utils/ui.tsx +29 -2
  259. package/lib/module/translation/resources/vi.js +0 -12
  260. package/lib/module/translation/resources/vi.js.map +0 -1
  261. package/lib/typescript/src/translation/resources/vi.d.ts +0 -11
  262. package/lib/typescript/src/translation/resources/vi.d.ts.map +0 -1
  263. package/src/translation/resources/vi.ts +0 -10
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Message Actions Store
3
+ * Zustand store for managing message action states (feedback, audio, export, share)
4
+ */
5
+
6
+ import { create } from 'zustand';
7
+ import {
8
+ MessageActionsState,
9
+ MessageActionsActions,
10
+ AudioState,
11
+ } from '../types/messageActions';
12
+
13
+ type MessageActionsStore = MessageActionsState & MessageActionsActions;
14
+
15
+ const useMessageActionsStore = create<MessageActionsStore>((set, get) => ({
16
+ // Initial State
17
+ feedbacks: {},
18
+ activeFeedbackList: null,
19
+ audioPlaybacks: {},
20
+ activeAudioMessageId: null,
21
+ pdfExports: {},
22
+ shareStates: {},
23
+
24
+ // Feedback Actions
25
+ setFeedback: (messageId, feedbackType, reason) => {
26
+ set((state) => ({
27
+ feedbacks: {
28
+ ...state.feedbacks,
29
+ [messageId]: {
30
+ messageId,
31
+ feedbackType,
32
+ reason,
33
+ timestamp: new Date().toISOString(),
34
+ },
35
+ },
36
+ activeFeedbackList: null, // Close list after selection
37
+ }));
38
+ },
39
+
40
+ setActiveFeedbackList: (messageId) => {
41
+ set({ activeFeedbackList: messageId });
42
+ },
43
+
44
+ getFeedback: (messageId) => {
45
+ return get().feedbacks[messageId];
46
+ },
47
+
48
+ // Audio Actions
49
+ setAudioState: (messageId, state, audioUrl) => {
50
+ set((prevState) => ({
51
+ audioPlaybacks: {
52
+ ...prevState.audioPlaybacks,
53
+ [messageId]: {
54
+ messageId,
55
+ state,
56
+ audioUrl,
57
+ },
58
+ },
59
+ }));
60
+ },
61
+
62
+ setActiveAudio: (messageId) => {
63
+ const currentActive = get().activeAudioMessageId;
64
+
65
+ // Stop previous audio if different message
66
+ if (currentActive && currentActive !== messageId) {
67
+ get().setAudioState(currentActive, AudioState.idle);
68
+ }
69
+
70
+ set({ activeAudioMessageId: messageId });
71
+ },
72
+
73
+ getAudioState: (messageId) => {
74
+ return get().audioPlaybacks[messageId];
75
+ },
76
+
77
+ stopAllAudio: () => {
78
+ const { audioPlaybacks } = get();
79
+ const updated = { ...audioPlaybacks };
80
+
81
+ Object.keys(updated).forEach((id) => {
82
+ if (updated[id]?.state === AudioState.playing) {
83
+ updated[id] = { ...updated[id]!, state: AudioState.idle };
84
+ }
85
+ });
86
+
87
+ set({ audioPlaybacks: updated, activeAudioMessageId: null });
88
+ },
89
+
90
+ // Export Actions
91
+ setPdfExportState: (messageId, state, pdfUrl, error) => {
92
+ set((prevState) => ({
93
+ pdfExports: {
94
+ ...prevState.pdfExports,
95
+ [messageId]: {
96
+ messageId,
97
+ state,
98
+ pdfUrl,
99
+ error,
100
+ },
101
+ },
102
+ }));
103
+ },
104
+
105
+ getPdfExport: (messageId) => {
106
+ return get().pdfExports[messageId];
107
+ },
108
+
109
+ // Share Actions
110
+ setShareState: (messageId, state) => {
111
+ set((prevState) => ({
112
+ shareStates: {
113
+ ...prevState.shareStates,
114
+ [messageId]: {
115
+ messageId,
116
+ text: '',
117
+ state,
118
+ },
119
+ },
120
+ }));
121
+ },
122
+
123
+ getShareState: (messageId) => {
124
+ return get().shareStates[messageId];
125
+ },
126
+
127
+ // Reset Actions
128
+ resetMessageActions: (messageId) => {
129
+ set((state) => {
130
+ const feedbacks = { ...state.feedbacks };
131
+ const audioPlaybacks = { ...state.audioPlaybacks };
132
+ const pdfExports = { ...state.pdfExports };
133
+ const shareStates = { ...state.shareStates };
134
+
135
+ delete feedbacks[messageId];
136
+ delete audioPlaybacks[messageId];
137
+ delete pdfExports[messageId];
138
+ delete shareStates[messageId];
139
+
140
+ return {
141
+ feedbacks,
142
+ audioPlaybacks,
143
+ pdfExports,
144
+ shareStates,
145
+ };
146
+ });
147
+ },
148
+
149
+ clearAllActions: () => {
150
+ set({
151
+ feedbacks: {},
152
+ activeFeedbackList: null,
153
+ audioPlaybacks: {},
154
+ activeAudioMessageId: null,
155
+ pdfExports: {},
156
+ shareStates: {},
157
+ });
158
+ },
159
+ }));
160
+
161
+ export default useMessageActionsStore;
@@ -1,9 +1,11 @@
1
1
  import { create } from 'zustand';
2
- import { SessionStore } from '../types/chat';
2
+ import { SessionLogType, SessionStore } from '../types/chat';
3
3
 
4
4
  const useSessionStore = create<SessionStore>((set) => ({
5
5
  sessionId: undefined,
6
- setSessionId: (sessionId) => set({ sessionId }),
6
+ setSessionId: (sessionId, sessionLogType = SessionLogType.accessed) =>
7
+ set({ sessionId, sessionLogType }),
8
+ sessionLogType: SessionLogType.accessed,
7
9
  }));
8
10
 
9
11
  export default useSessionStore;
@@ -1,22 +1,30 @@
1
- import i18n from 'i18next';
2
- import { initReactI18next } from 'react-i18next';
3
- import vi from './resources/vi';
1
+ import i18n from './resources/i18n';
4
2
 
5
- if (!i18n.isInitialized) {
6
- i18n.use(initReactI18next).init({
7
- resources: {
8
- vi: { chatbot: vi },
9
- },
10
- lng: 'vi', // default
11
- fallbackLng: 'vi',
12
- interpolation: { escapeValue: false },
13
- ns: ['chatbot'],
14
- defaultNS: 'chatbot',
15
- });
16
- }
3
+ export const replaceAll = (
4
+ target: string | undefined,
5
+ oldStr: string,
6
+ newStr: string
7
+ ) => {
8
+ return typeof target === 'string'
9
+ ? target?.replace(new RegExp(oldStr, 'g'), newStr) || newStr
10
+ : '';
11
+ };
17
12
 
18
- //@ts-ignore
19
- const trans = (...args) => i18n.t(...args) as any;
13
+ export const replaceMulti = (target: string | undefined, param: any) => {
14
+ if (typeof target !== 'string') {
15
+ return '';
16
+ }
17
+ let out = target;
18
+ for (const key in param) {
19
+ if (key) {
20
+ const textReplace = '{{' + key + '}}';
21
+ out = replaceAll(out, textReplace, String(param[key]));
22
+ }
23
+ }
24
+ return out;
25
+ };
20
26
 
21
- export { i18n };
22
- export default trans;
27
+ export const trans = (key: string, params?: Record<string, any>) => {
28
+ const text = i18n?.vi?.[key] || '';
29
+ return params ? replaceMulti(text, params) : text;
30
+ };
@@ -0,0 +1,45 @@
1
+ const i18nKey: Record<string, string> = {
2
+ input_placeholder: 'Bạn muốn hỏi gì hôm nay?',
3
+ ai_answer_note:
4
+ 'Lưu ý: Thông tin từ AI chỉ mang tính tham khảo, cần xác minh với chuyên gia hoặc nguồn uy tín.',
5
+ chat_empty_title: 'Bạn cần hỗ trợ gì hôm nay?',
6
+ chat_empty_description_1: 'Hãy đặt câu hỏi hoặc chia sẻ vấn đề của bạn!',
7
+ chat_empty_description_2: 'Những gợi ý dành cho bạn:',
8
+ photo_library: 'Thư viện ảnh',
9
+ camera: 'Chụp ảnh',
10
+
11
+ // Session options
12
+ session_options_title: 'Tuỳ chọn phiên chat',
13
+ session_rename: 'Đổi tên',
14
+ session_share: 'Chia sẻ',
15
+ session_delete: 'Xoá',
16
+
17
+ // Rename session
18
+ rename_session_title: 'Đổi tên phiên chat',
19
+ rename_session_placeholder: 'Nhập tên phiên chat',
20
+ rename_session_success: 'Đổi tên phiên chat thành công',
21
+ rename_session_cancel: 'Huỷ',
22
+ rename_session_confirm: 'Đổi tên',
23
+
24
+ // Share session
25
+ share_session_title: 'Chia sẻ phiên chat',
26
+ share_session_description:
27
+ 'Để chia sẻ phiên chat "{sessionName}", vui lòng sao chép liên kết bên dưới và gửi đến người bạn muốn chia sẻ.',
28
+ share_session_link_label: 'Liên kết chia sẻ',
29
+ share_session_cancel: 'Huỷ',
30
+ share_session_confirm: 'Sao chép',
31
+ share_session_success:
32
+ 'Đã sao chép liên kết của phiên chat. Vui lòng chia sẻ liên kết',
33
+
34
+ // Delete session
35
+ delete_session_title: 'Xoá phiên chat',
36
+ delete_session_description:
37
+ 'Bạn có chắc chắn muốn xóa tất cả đoạn chat của phiên chat "{sessionName}"?',
38
+ delete_session_cancel: 'Không',
39
+ delete_session_confirm: 'Xoá',
40
+ delete_session_success: 'Đã xoá phiên chat thành công',
41
+ };
42
+
43
+ export default {
44
+ vi: i18nKey,
45
+ };
package/src/types/chat.ts CHANGED
@@ -13,6 +13,8 @@ export interface ChatContextType {
13
13
  pushLinkTo?: (url: string, resParams?: any) => void;
14
14
  openDrawer: () => void;
15
15
  closeDrawer: () => void;
16
+ chatbotUrl: string;
17
+ logGA: (event: string, params?: any) => void;
16
18
  }
17
19
 
18
20
  export interface ChatProviderProps {
@@ -25,11 +27,29 @@ export interface ChatProviderProps {
25
27
  onNavigateToProduct?: (product: any) => void;
26
28
  csTeamId?: string;
27
29
  pushLinkTo?: (url: string, resParams?: any) => void;
30
+ chatbotUrl: string;
31
+ logGA: (event: string, params?: any) => void;
32
+ }
33
+
34
+ export enum SessionLogType {
35
+ accessed = 'accessed',
36
+ newChatBtn = 'new_chat_btn',
37
+ oldChat = 'oldchat',
38
+ }
39
+
40
+ export enum SendActionLogType {
41
+ sendBtn = 'send_btn',
42
+ promptSuggestion = 'prompt_suggestion',
43
+ retry = 'retry',
28
44
  }
29
45
 
30
46
  export interface SessionStore {
31
47
  sessionId?: string;
32
- setSessionId: (sessionId: string | undefined) => void;
48
+ setSessionId: (
49
+ sessionId: string | undefined,
50
+ sessionLogType?: SessionLogType
51
+ ) => void;
52
+ sessionLogType: SessionLogType;
33
53
  }
34
54
 
35
55
  export interface StreamMessageStore {
package/src/types/dto.ts CHANGED
@@ -41,6 +41,8 @@ export interface IMessageItem {
41
41
  suggestions?: ISuggestionItem[];
42
42
  manual_retry_attempts: number | null;
43
43
  group_suggestion_id: string | null;
44
+ feedback_type?: 'LIKE' | 'DISLIKE' | null;
45
+ feedback_content?: string | null;
44
46
  }
45
47
 
46
48
  export interface SessionDetailResponse {
@@ -185,3 +187,15 @@ export interface IProductItem {
185
187
  vouchers: any[];
186
188
  warehouses: IWarehouseItem[];
187
189
  }
190
+
191
+ // Message Actions API Types
192
+ export interface SendFeedbackRequest {
193
+ message_id: string;
194
+ feedback_type: 'LIKE' | 'DISLIKE';
195
+ feedback_content: string;
196
+ }
197
+
198
+ export interface SendFeedbackResponse {
199
+ success: boolean;
200
+ message: string;
201
+ }
@@ -2,3 +2,4 @@ export * from './common';
2
2
  export * from './dto';
3
3
  export * from './chat';
4
4
  export * from './ui';
5
+ export * from './messageActions';
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Message Actions Types
3
+ * Type definitions for message action features (Like, Dislike, Audio, Copy, Export PDF, Share)
4
+ */
5
+
6
+ // Feedback Types
7
+ export enum FeedbackType {
8
+ like = 'LIKE',
9
+ dislike = 'DISLIKE',
10
+ }
11
+
12
+ export enum LikeReason {
13
+ suitable_product = 'Đề xuất sản phẩm phù hợp',
14
+ easy_explanation = 'Giải thích dễ hiểu',
15
+ accurate_info = 'Thông tin chính xác, hữu ích',
16
+ complete_answer = 'Trả lời đầy đủ câu hỏi, yêu cầu',
17
+ }
18
+
19
+ export enum DislikeReason {
20
+ wrong_suggestion = 'Chưa đề xuất đúng nhu cầu',
21
+ hard_explanation = 'Giải thích khó hiểu',
22
+ inaccurate_info = 'Thông tin chưa chính xác, đầy đủ',
23
+ irrelevant_answer = 'Trả lời không liên quan',
24
+ want_different_answer = 'Tôi muốn nhận câu trả lời khác',
25
+ }
26
+
27
+ export interface MessageFeedback {
28
+ messageId: string;
29
+ feedbackType: FeedbackType;
30
+ reason: string;
31
+ timestamp: string;
32
+ }
33
+
34
+ // Audio Types
35
+ export enum AudioState {
36
+ idle = 'idle',
37
+ loading = 'loading',
38
+ playing = 'playing',
39
+ }
40
+
41
+ export interface AudioPlayback {
42
+ messageId: string;
43
+ state: AudioState;
44
+ audioUrl?: string;
45
+ }
46
+
47
+ // Export Types
48
+ export enum ExportState {
49
+ idle = 'idle',
50
+ loading = 'loading',
51
+ success = 'success',
52
+ error = 'error',
53
+ }
54
+
55
+ export interface PdfExport {
56
+ messageId: string;
57
+ state: ExportState;
58
+ pdfUrl?: string;
59
+ error?: string;
60
+ }
61
+
62
+ // Share Types
63
+ export enum ShareState {
64
+ idle = 'idle',
65
+ loading = 'loading',
66
+ success = 'success',
67
+ error = 'error',
68
+ }
69
+
70
+ export interface ShareContent {
71
+ messageId: string;
72
+ text: string;
73
+ imageUrl?: string;
74
+ state: ShareState;
75
+ }
76
+
77
+ // Store State Interface
78
+ export interface MessageActionsState {
79
+ // Feedback
80
+ feedbacks: Record<string, MessageFeedback>;
81
+ activeFeedbackList: string | null;
82
+
83
+ // Audio
84
+ audioPlaybacks: Record<string, AudioPlayback>;
85
+ activeAudioMessageId: string | null;
86
+
87
+ // Export
88
+ pdfExports: Record<string, PdfExport>;
89
+
90
+ // Share
91
+ shareStates: Record<string, ShareContent>;
92
+ }
93
+
94
+ // Store Actions Interface
95
+ export interface MessageActionsActions {
96
+ // Feedback Actions
97
+ setFeedback: (
98
+ messageId: string,
99
+ feedbackType: FeedbackType,
100
+ reason: string
101
+ ) => void;
102
+ setActiveFeedbackList: (messageId: string | null) => void;
103
+ getFeedback: (messageId: string) => MessageFeedback | undefined;
104
+
105
+ // Audio Actions
106
+ setAudioState: (
107
+ messageId: string,
108
+ state: AudioState,
109
+ audioUrl?: string
110
+ ) => void;
111
+ setActiveAudio: (messageId: string | null) => void;
112
+ getAudioState: (messageId: string) => AudioPlayback | undefined;
113
+ stopAllAudio: () => void;
114
+
115
+ // Export Actions
116
+ setPdfExportState: (
117
+ messageId: string,
118
+ state: ExportState,
119
+ pdfUrl?: string,
120
+ error?: string
121
+ ) => void;
122
+ getPdfExport: (messageId: string) => PdfExport | undefined;
123
+
124
+ // Share Actions
125
+ setShareState: (messageId: string, state: ShareState) => void;
126
+ getShareState: (messageId: string) => ShareContent | undefined;
127
+
128
+ // Reset
129
+ resetMessageActions: (messageId: string) => void;
130
+ clearAllActions: () => void;
131
+ }
package/src/types/ui.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  // @ts-ignore
2
- import { KToastBarProps } from '@droppii/libs';
2
+ import { KBottomSheetProps, KPopupProps, KToastBarProps } from '@droppii/libs';
3
+ import { JSX } from 'react';
3
4
  // @ts-ignore
4
5
  import { StyleProp, ViewStyle } from 'react-native';
5
6
 
@@ -10,3 +11,20 @@ export interface WithToastProps {
10
11
  ) => void;
11
12
  dismiss: () => void;
12
13
  }
14
+
15
+ export interface KBottomSheetPropsEnhance extends KBottomSheetProps {
16
+ header: KBottomSheetProps['header'] & {
17
+ customRenderer?: (dismiss: () => void) => JSX.Element;
18
+ };
19
+ }
20
+
21
+ export interface WithBottomSheetProps {
22
+ open: (payload: KBottomSheetPropsEnhance) => void;
23
+ dismiss: () => void;
24
+ }
25
+
26
+ export interface WithPopupProps {
27
+ open: (payload: KPopupProps) => void;
28
+ dismiss: () => void;
29
+ dismissAll: () => void;
30
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Text Cleaning Utilities
3
+ * Utilities for cleaning markdown, truncating text, and validating content
4
+ */
5
+
6
+ /**
7
+ * Remove markdown formatting from text for cleaner copy/share
8
+ * @param text - Text with markdown formatting
9
+ * @returns Clean text without markdown
10
+ */
11
+ export const cleanMarkdown = (text: string): string => {
12
+ return text
13
+ .replace(/\*\*(.*?)\*\*/g, '$1') // Bold
14
+ .replace(/\*(.*?)\*/g, '$1') // Italic
15
+ .replace(/`(.*?)`/g, '$1') // Inline code
16
+ .replace(/\[(.*?)\]\(.*?\)/g, '$1') // Links
17
+ .replace(/<!--.*?-->/g, '') // HTML comments
18
+ .replace(/^#{1,6}\s+/gm, '') // Headers
19
+ .replace(/^>\s+/gm, '') // Blockquotes
20
+ .replace(/^[-*+]\s+/gm, '') // List items
21
+ .trim();
22
+ };
23
+
24
+ /**
25
+ * Truncate text to specified length with suffix
26
+ * @param text - Text to truncate
27
+ * @param maxLength - Maximum length
28
+ * @param suffix - Suffix to add (default: '...')
29
+ * @returns Truncated text
30
+ */
31
+ export const truncateText = (
32
+ text: string,
33
+ maxLength: number,
34
+ suffix = '...'
35
+ ): string => {
36
+ if (text.length <= maxLength) return text;
37
+ return text.substring(0, maxLength - suffix.length) + suffix;
38
+ };
39
+
40
+ /**
41
+ * Validate text content
42
+ * @param text - Text to validate
43
+ * @param minLength - Minimum length (default: 1)
44
+ * @param maxLength - Maximum length (default: 100000)
45
+ * @returns Validation result with error message if invalid
46
+ */
47
+ export const validateContent = (
48
+ text: string,
49
+ minLength = 1,
50
+ maxLength = 100000
51
+ ): { valid: boolean; error?: string } => {
52
+ if (!text || text.trim().length === 0) {
53
+ return { valid: false, error: 'Nội dung trống' };
54
+ }
55
+
56
+ if (text.length < minLength) {
57
+ return { valid: false, error: 'Nội dung quá ngắn' };
58
+ }
59
+
60
+ if (text.length > maxLength) {
61
+ return { valid: false, error: 'Nội dung quá dài' };
62
+ }
63
+
64
+ return { valid: true };
65
+ };
package/src/utils/ui.tsx CHANGED
@@ -1,8 +1,9 @@
1
1
  // @ts-ignore
2
2
  import { StyleProp, ViewStyle } from 'react-native';
3
- import { toastRef } from '../constants';
3
+ import { bottomSheetRef, popupRef, toastRef } from '../constants';
4
4
  // @ts-ignore
5
- import type { KToastBarProps } from '@droppii/libs';
5
+ import type { KPopupProps, KToastBarProps } from '@droppii/libs';
6
+ import { KBottomSheetPropsEnhance } from '../types';
6
7
 
7
8
  class UIUtils {
8
9
  toast = {
@@ -26,6 +27,32 @@ class UIUtils {
26
27
  toastRef.current?.open({ title: msg, theme: 'danger', stretch: true });
27
28
  return msg;
28
29
  },
30
+ showSuccess: (message: string) => {
31
+ toastRef.current?.open({
32
+ title: message,
33
+ theme: 'success',
34
+ stretch: true,
35
+ });
36
+ },
37
+ };
38
+ bottomSheet = {
39
+ open: (params: KBottomSheetPropsEnhance) => {
40
+ bottomSheetRef.current?.open(params);
41
+ },
42
+ dismiss: () => {
43
+ bottomSheetRef.current?.dismiss();
44
+ },
45
+ };
46
+ popup = {
47
+ open: (params: KPopupProps) => {
48
+ popupRef.current?.open(params);
49
+ },
50
+ dismiss: () => {
51
+ popupRef.current?.dismiss();
52
+ },
53
+ dismissAll: () => {
54
+ popupRef.current?.dismissAll();
55
+ },
29
56
  };
30
57
  }
31
58
 
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- export default {
4
- input_placeholder: 'Bạn muốn hỏi gì hôm nay?',
5
- ai_answer_note: 'Lưu ý: Thông tin từ AI chỉ mang tính tham khảo, cần xác minh với chuyên gia hoặc nguồn uy tín.',
6
- chat_empty_title: 'Bạn cần hỗ trợ gì hôm nay?',
7
- chat_empty_description_1: 'Hãy đặt câu hỏi hoặc chia sẻ vấn đề của bạn!',
8
- chat_empty_description_2: 'Những gợi ý dành cho bạn:',
9
- photo_library: 'Thư viện ảnh',
10
- camera: 'Chụp ảnh'
11
- };
12
- //# sourceMappingURL=vi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["input_placeholder","ai_answer_note","chat_empty_title","chat_empty_description_1","chat_empty_description_2","photo_library","camera"],"sourceRoot":"../../../../src","sources":["translation/resources/vi.ts"],"mappings":";;AAAA,eAAe;EACbA,iBAAiB,EAAE,0BAA0B;EAC7CC,cAAc,EACZ,gGAAgG;EAClGC,gBAAgB,EAAE,4BAA4B;EAC9CC,wBAAwB,EAAE,8CAA8C;EACxEC,wBAAwB,EAAE,2BAA2B;EACrDC,aAAa,EAAE,cAAc;EAC7BC,MAAM,EAAE;AACV,CAAC","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- declare const _default: {
2
- input_placeholder: string;
3
- ai_answer_note: string;
4
- chat_empty_title: string;
5
- chat_empty_description_1: string;
6
- chat_empty_description_2: string;
7
- photo_library: string;
8
- camera: string;
9
- };
10
- export default _default;
11
- //# sourceMappingURL=vi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vi.d.ts","sourceRoot":"","sources":["../../../../../src/translation/resources/vi.ts"],"names":[],"mappings":";;;;;;;;;AAAA,wBASE"}
@@ -1,10 +0,0 @@
1
- export default {
2
- input_placeholder: 'Bạn muốn hỏi gì hôm nay?',
3
- ai_answer_note:
4
- 'Lưu ý: Thông tin từ AI chỉ mang tính tham khảo, cần xác minh với chuyên gia hoặc nguồn uy tín.',
5
- chat_empty_title: 'Bạn cần hỗ trợ gì hôm nay?',
6
- chat_empty_description_1: 'Hãy đặt câu hỏi hoặc chia sẻ vấn đề của bạn!',
7
- chat_empty_description_2: 'Những gợi ý dành cho bạn:',
8
- photo_library: 'Thư viện ảnh',
9
- camera: 'Chụp ảnh',
10
- };