@droppii-org/chat-mobile 0.2.7 → 0.2.8

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 (323) hide show
  1. package/lib/module/components/AttachmentPreview.js +250 -0
  2. package/lib/module/components/AttachmentPreview.js.map +1 -0
  3. package/lib/module/components/MediaViewer/index.js +2 -0
  4. package/lib/module/components/MediaViewer/index.js.map +1 -0
  5. package/lib/module/components/MediaViewerModal.js +57 -0
  6. package/lib/module/components/MediaViewerModal.js.map +1 -0
  7. package/lib/module/components/MergedImageGrid.js +173 -0
  8. package/lib/module/components/MergedImageGrid.js.map +1 -0
  9. package/lib/module/components/ThreadCard/thread-card.utils.js +80 -4
  10. package/lib/module/components/ThreadCard/thread-card.utils.js.map +1 -1
  11. package/lib/module/components/messages/fileMessage/index.js +26 -0
  12. package/lib/module/components/messages/fileMessage/index.js.map +1 -0
  13. package/lib/module/components/messages/imageMessage/index.js +118 -0
  14. package/lib/module/components/messages/imageMessage/index.js.map +1 -0
  15. package/lib/module/components/messages/linkMessage/index.js +122 -0
  16. package/lib/module/components/messages/linkMessage/index.js.map +1 -0
  17. package/lib/module/components/messages/mergedMessage/index.js +37 -0
  18. package/lib/module/components/messages/mergedMessage/index.js.map +1 -0
  19. package/lib/module/components/messages/styles.js +41 -0
  20. package/lib/module/components/messages/styles.js.map +1 -0
  21. package/lib/module/components/messages/textMessage/index.js +38 -0
  22. package/lib/module/components/messages/textMessage/index.js.map +1 -0
  23. package/lib/module/components/messages/types.js +14 -0
  24. package/lib/module/components/messages/types.js.map +1 -0
  25. package/lib/module/components/messages/videoMessage/index.js +110 -0
  26. package/lib/module/components/messages/videoMessage/index.js.map +1 -0
  27. package/lib/module/config/api-endpoints.js +66 -0
  28. package/lib/module/config/api-endpoints.js.map +1 -0
  29. package/lib/module/config/attachment-priority.js +81 -0
  30. package/lib/module/config/attachment-priority.js.map +1 -0
  31. package/lib/module/config/configuration.js +50 -0
  32. package/lib/module/config/configuration.js.map +1 -0
  33. package/lib/module/config/index.js +22 -0
  34. package/lib/module/config/index.js.map +1 -0
  35. package/lib/module/core/index.js +19 -1
  36. package/lib/module/core/index.js.map +1 -1
  37. package/lib/module/core/useChatListener.js +0 -14
  38. package/lib/module/core/useChatListener.js.map +1 -1
  39. package/lib/module/hooks/message/useSendMessage.js +10 -5
  40. package/lib/module/hooks/message/useSendMessage.js.map +1 -1
  41. package/lib/module/hooks/useChatMessages.js +0 -3
  42. package/lib/module/hooks/useChatMessages.js.map +1 -1
  43. package/lib/module/hooks/useImageAttachment.js +263 -0
  44. package/lib/module/hooks/useImageAttachment.js.map +1 -0
  45. package/lib/module/hooks/useMediaViewer.js +24 -0
  46. package/lib/module/hooks/useMediaViewer.js.map +1 -0
  47. package/lib/module/hooks/useSendAttachment.js +182 -0
  48. package/lib/module/hooks/useSendAttachment.js.map +1 -0
  49. package/lib/module/hooks/useVideoAttachment.js +251 -0
  50. package/lib/module/hooks/useVideoAttachment.js.map +1 -0
  51. package/lib/module/index.js +13 -1
  52. package/lib/module/index.js.map +1 -1
  53. package/lib/module/screens/MediaView/VideoPlayer.js +177 -0
  54. package/lib/module/screens/MediaView/VideoPlayer.js.map +1 -0
  55. package/lib/module/screens/MediaView/index.js +264 -0
  56. package/lib/module/screens/MediaView/index.js.map +1 -0
  57. package/lib/module/screens/chat-detail/ChatComposer.js +190 -196
  58. package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
  59. package/lib/module/screens/chat-detail/ChatDetail.js +94 -63
  60. package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
  61. package/lib/module/screens/chat-detail/ChatListLegend.js +5 -13
  62. package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
  63. package/lib/module/screens/chat-detail/components/ChatInputActions.js +51 -0
  64. package/lib/module/screens/chat-detail/components/ChatInputActions.js.map +1 -0
  65. package/lib/module/screens/chat-detail/components/ChatMessageInput.js +93 -0
  66. package/lib/module/screens/chat-detail/components/ChatMessageInput.js.map +1 -0
  67. package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js +221 -0
  68. package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js.map +1 -0
  69. package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js +114 -0
  70. package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js.map +1 -0
  71. package/lib/module/screens/chat-detail/hooks/useChatComposerState.js +26 -0
  72. package/lib/module/screens/chat-detail/hooks/useChatComposerState.js.map +1 -0
  73. package/lib/module/screens/chat-detail/index.js +0 -1
  74. package/lib/module/screens/chat-detail/index.js.map +1 -1
  75. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +33 -13
  76. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
  77. package/lib/module/screens/chat-detail/legend/messageTypes.js +15 -0
  78. package/lib/module/screens/chat-detail/legend/messageTypes.js.map +1 -0
  79. package/lib/module/screens/inbox/MessagesTab.js.map +1 -1
  80. package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js +61 -0
  81. package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js.map +1 -0
  82. package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js +54 -0
  83. package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js.map +1 -0
  84. package/lib/module/services/attachmentHandlers/index.js +12 -0
  85. package/lib/module/services/attachmentHandlers/index.js.map +1 -0
  86. package/lib/module/services/attachmentHandlers/videoAttachmentHandler.js +85 -0
  87. package/lib/module/services/attachmentHandlers/videoAttachmentHandler.js.map +1 -0
  88. package/lib/module/services/attachmentOrchestrator.js +225 -0
  89. package/lib/module/services/attachmentOrchestrator.js.map +1 -0
  90. package/lib/module/services/auth.js +35 -0
  91. package/lib/module/services/auth.js.map +1 -0
  92. package/lib/module/services/endpoints.js +20 -1
  93. package/lib/module/services/endpoints.js.map +1 -1
  94. package/lib/module/services/imageUpload.js +126 -0
  95. package/lib/module/services/imageUpload.js.map +1 -0
  96. package/lib/module/translation/resources/i18n.js +22 -8
  97. package/lib/module/translation/resources/i18n.js.map +1 -1
  98. package/lib/module/types/attachment.js +2 -0
  99. package/lib/module/types/attachment.js.map +1 -0
  100. package/lib/module/types/attachmentHandler.js +20 -0
  101. package/lib/module/types/attachmentHandler.js.map +1 -0
  102. package/lib/module/types/imageUpload.js +2 -0
  103. package/lib/module/types/imageUpload.js.map +1 -0
  104. package/lib/module/types/message.js +1 -0
  105. package/lib/module/types/message.js.map +1 -1
  106. package/lib/module/utils/chatImageDimens.js +148 -0
  107. package/lib/module/utils/chatImageDimens.js.map +1 -0
  108. package/lib/module/utils/device.js +65 -0
  109. package/lib/module/utils/device.js.map +1 -0
  110. package/lib/module/utils/imageUrlOptimizer.js +41 -0
  111. package/lib/module/utils/imageUrlOptimizer.js.map +1 -0
  112. package/lib/module/utils/imageUtils.js +69 -0
  113. package/lib/module/utils/imageUtils.js.map +1 -0
  114. package/lib/module/utils/resolveMessageType.js +3 -0
  115. package/lib/module/utils/resolveMessageType.js.map +1 -1
  116. package/lib/module/utils/ui.js +17 -0
  117. package/lib/module/utils/ui.js.map +1 -0
  118. package/lib/module/utils/url.js +1 -1
  119. package/lib/module/utils/url.js.map +1 -1
  120. package/lib/module/utils/videoThumbnail.js +62 -0
  121. package/lib/module/utils/videoThumbnail.js.map +1 -0
  122. package/lib/typescript/src/components/AttachmentPreview.d.ts +28 -0
  123. package/lib/typescript/src/components/AttachmentPreview.d.ts.map +1 -0
  124. package/lib/typescript/src/components/MediaViewer/index.d.ts +1 -0
  125. package/lib/typescript/src/components/MediaViewer/index.d.ts.map +1 -0
  126. package/lib/typescript/src/components/MediaViewerModal.d.ts +10 -0
  127. package/lib/typescript/src/components/MediaViewerModal.d.ts.map +1 -0
  128. package/lib/typescript/src/components/MergedImageGrid.d.ts +16 -0
  129. package/lib/typescript/src/components/MergedImageGrid.d.ts.map +1 -0
  130. package/lib/typescript/src/components/ThreadCard/thread-card.utils.d.ts.map +1 -1
  131. package/lib/typescript/src/components/messages/fileMessage/index.d.ts +3 -0
  132. package/lib/typescript/src/components/messages/fileMessage/index.d.ts.map +1 -0
  133. package/lib/typescript/src/components/messages/imageMessage/index.d.ts +3 -0
  134. package/lib/typescript/src/components/messages/imageMessage/index.d.ts.map +1 -0
  135. package/lib/typescript/src/components/messages/linkMessage/index.d.ts +9 -0
  136. package/lib/typescript/src/components/messages/linkMessage/index.d.ts.map +1 -0
  137. package/lib/typescript/src/components/messages/mergedMessage/index.d.ts +3 -0
  138. package/lib/typescript/src/components/messages/mergedMessage/index.d.ts.map +1 -0
  139. package/lib/typescript/src/components/messages/styles.d.ts +36 -0
  140. package/lib/typescript/src/components/messages/styles.d.ts.map +1 -0
  141. package/lib/typescript/src/components/messages/textMessage/index.d.ts +9 -0
  142. package/lib/typescript/src/components/messages/textMessage/index.d.ts.map +1 -0
  143. package/lib/typescript/src/components/messages/types.d.ts +10 -0
  144. package/lib/typescript/src/components/messages/types.d.ts.map +1 -0
  145. package/lib/typescript/src/components/messages/videoMessage/index.d.ts +3 -0
  146. package/lib/typescript/src/components/messages/videoMessage/index.d.ts.map +1 -0
  147. package/lib/typescript/src/config/api-endpoints.d.ts +40 -0
  148. package/lib/typescript/src/config/api-endpoints.d.ts.map +1 -0
  149. package/lib/typescript/src/config/attachment-priority.d.ts +31 -0
  150. package/lib/typescript/src/config/attachment-priority.d.ts.map +1 -0
  151. package/lib/typescript/src/config/configuration.d.ts +30 -0
  152. package/lib/typescript/src/config/configuration.d.ts.map +1 -0
  153. package/lib/typescript/src/config/index.d.ts +15 -0
  154. package/lib/typescript/src/config/index.d.ts.map +1 -0
  155. package/lib/typescript/src/core/index.d.ts +13 -1
  156. package/lib/typescript/src/core/index.d.ts.map +1 -1
  157. package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
  158. package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
  159. package/lib/typescript/src/hooks/useChatMessages.d.ts.map +1 -1
  160. package/lib/typescript/src/hooks/useImageAttachment.d.ts +20 -0
  161. package/lib/typescript/src/hooks/useImageAttachment.d.ts.map +1 -0
  162. package/lib/typescript/src/hooks/useMediaViewer.d.ts +13 -0
  163. package/lib/typescript/src/hooks/useMediaViewer.d.ts.map +1 -0
  164. package/lib/typescript/src/hooks/useSendAttachment.d.ts +59 -0
  165. package/lib/typescript/src/hooks/useSendAttachment.d.ts.map +1 -0
  166. package/lib/typescript/src/hooks/useVideoAttachment.d.ts +29 -0
  167. package/lib/typescript/src/hooks/useVideoAttachment.d.ts.map +1 -0
  168. package/lib/typescript/src/index.d.ts +14 -1
  169. package/lib/typescript/src/index.d.ts.map +1 -1
  170. package/lib/typescript/src/screens/MediaView/VideoPlayer.d.ts +12 -0
  171. package/lib/typescript/src/screens/MediaView/VideoPlayer.d.ts.map +1 -0
  172. package/lib/typescript/src/screens/MediaView/index.d.ts +11 -0
  173. package/lib/typescript/src/screens/MediaView/index.d.ts.map +1 -0
  174. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts +1 -1
  175. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
  176. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts +1 -1
  177. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
  178. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts +1 -1
  179. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
  180. package/lib/typescript/src/screens/chat-detail/components/ChatInputActions.d.ts +8 -0
  181. package/lib/typescript/src/screens/chat-detail/components/ChatInputActions.d.ts.map +1 -0
  182. package/lib/typescript/src/screens/chat-detail/components/ChatMessageInput.d.ts +15 -0
  183. package/lib/typescript/src/screens/chat-detail/components/ChatMessageInput.d.ts.map +1 -0
  184. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts +23 -0
  185. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts.map +1 -0
  186. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts +15 -0
  187. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts.map +1 -0
  188. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts +13 -0
  189. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts.map +1 -0
  190. package/lib/typescript/src/screens/chat-detail/index.d.ts +0 -2
  191. package/lib/typescript/src/screens/chat-detail/index.d.ts.map +1 -1
  192. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts +3 -1
  193. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
  194. package/lib/typescript/src/screens/chat-detail/legend/messageTypes.d.ts +13 -0
  195. package/lib/typescript/src/screens/chat-detail/legend/messageTypes.d.ts.map +1 -0
  196. package/lib/typescript/src/screens/chat-detail/types.d.ts +4 -1
  197. package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
  198. package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts +22 -0
  199. package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts.map +1 -0
  200. package/lib/typescript/src/services/attachmentHandlers/imageAttachmentHandler.d.ts +3 -0
  201. package/lib/typescript/src/services/attachmentHandlers/imageAttachmentHandler.d.ts.map +1 -0
  202. package/lib/typescript/src/services/attachmentHandlers/index.d.ts +5 -0
  203. package/lib/typescript/src/services/attachmentHandlers/index.d.ts.map +1 -0
  204. package/lib/typescript/src/services/attachmentHandlers/videoAttachmentHandler.d.ts +31 -0
  205. package/lib/typescript/src/services/attachmentHandlers/videoAttachmentHandler.d.ts.map +1 -0
  206. package/lib/typescript/src/services/attachmentOrchestrator.d.ts +5 -0
  207. package/lib/typescript/src/services/attachmentOrchestrator.d.ts.map +1 -0
  208. package/lib/typescript/src/services/auth.d.ts +19 -0
  209. package/lib/typescript/src/services/auth.d.ts.map +1 -0
  210. package/lib/typescript/src/services/endpoints.d.ts +11 -1
  211. package/lib/typescript/src/services/endpoints.d.ts.map +1 -1
  212. package/lib/typescript/src/services/imageUpload.d.ts +7 -0
  213. package/lib/typescript/src/services/imageUpload.d.ts.map +1 -0
  214. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  215. package/lib/typescript/src/types/attachment.d.ts +72 -0
  216. package/lib/typescript/src/types/attachment.d.ts.map +1 -0
  217. package/lib/typescript/src/types/attachmentHandler.d.ts +13 -0
  218. package/lib/typescript/src/types/attachmentHandler.d.ts.map +1 -0
  219. package/lib/typescript/src/types/imageUpload.d.ts +26 -0
  220. package/lib/typescript/src/types/imageUpload.d.ts.map +1 -0
  221. package/lib/typescript/src/types/message.d.ts +1 -0
  222. package/lib/typescript/src/types/message.d.ts.map +1 -1
  223. package/lib/typescript/src/utils/chatImageDimens.d.ts +34 -0
  224. package/lib/typescript/src/utils/chatImageDimens.d.ts.map +1 -0
  225. package/lib/typescript/src/utils/device.d.ts +7 -0
  226. package/lib/typescript/src/utils/device.d.ts.map +1 -0
  227. package/lib/typescript/src/utils/imageUrlOptimizer.d.ts +12 -0
  228. package/lib/typescript/src/utils/imageUrlOptimizer.d.ts.map +1 -0
  229. package/lib/typescript/src/utils/imageUtils.d.ts +9 -0
  230. package/lib/typescript/src/utils/imageUtils.d.ts.map +1 -0
  231. package/lib/typescript/src/utils/resolveMessageType.d.ts.map +1 -1
  232. package/lib/typescript/src/utils/ui.d.ts +13 -0
  233. package/lib/typescript/src/utils/ui.d.ts.map +1 -0
  234. package/lib/typescript/src/utils/videoThumbnail.d.ts +16 -0
  235. package/lib/typescript/src/utils/videoThumbnail.d.ts.map +1 -0
  236. package/package.json +15 -3
  237. package/src/components/AttachmentPreview.tsx +304 -0
  238. package/src/components/MediaViewer/index.tsx +0 -0
  239. package/src/components/MediaViewerModal.tsx +70 -0
  240. package/src/components/MergedImageGrid.tsx +238 -0
  241. package/src/components/ThreadCard/thread-card.utils.ts +95 -4
  242. package/src/components/messages/fileMessage/index.tsx +30 -0
  243. package/src/components/messages/imageMessage/index.tsx +137 -0
  244. package/src/components/messages/linkMessage/index.tsx +162 -0
  245. package/src/components/messages/mergedMessage/index.tsx +45 -0
  246. package/src/components/messages/styles.ts +39 -0
  247. package/src/components/messages/textMessage/index.tsx +53 -0
  248. package/src/components/messages/types.ts +22 -0
  249. package/src/components/messages/videoMessage/index.tsx +120 -0
  250. package/src/config/api-endpoints.ts +72 -0
  251. package/src/config/attachment-priority.ts +93 -0
  252. package/src/config/configuration.ts +50 -0
  253. package/src/config/index.ts +19 -0
  254. package/src/core/index.ts +25 -1
  255. package/src/core/useChatListener.ts +0 -21
  256. package/src/hooks/message/useSendMessage.ts +12 -5
  257. package/src/hooks/useChatMessages.ts +0 -4
  258. package/src/hooks/useImageAttachment.ts +348 -0
  259. package/src/hooks/useMediaViewer.ts +32 -0
  260. package/src/hooks/useSendAttachment.ts +295 -0
  261. package/src/hooks/useVideoAttachment.ts +334 -0
  262. package/src/index.tsx +13 -1
  263. package/src/screens/MediaView/VideoPlayer.tsx +211 -0
  264. package/src/screens/MediaView/index.tsx +327 -0
  265. package/src/screens/chat-detail/ChatComposer.tsx +206 -271
  266. package/src/screens/chat-detail/ChatDetail.tsx +142 -89
  267. package/src/screens/chat-detail/ChatListLegend.tsx +9 -11
  268. package/src/screens/chat-detail/components/ChatInputActions.tsx +71 -0
  269. package/src/screens/chat-detail/components/ChatMessageInput.tsx +127 -0
  270. package/src/screens/chat-detail/hooks/useAttachmentSendHandler.ts +291 -0
  271. package/src/screens/chat-detail/hooks/useChatComposerAnimation.ts +184 -0
  272. package/src/screens/chat-detail/hooks/useChatComposerState.ts +40 -0
  273. package/src/screens/chat-detail/index.ts +0 -2
  274. package/src/screens/chat-detail/legend/LegendChatMessage.tsx +47 -24
  275. package/src/screens/chat-detail/legend/messageTypes.tsx +13 -0
  276. package/src/screens/chat-detail/types.ts +5 -1
  277. package/src/screens/inbox/MessagesTab.tsx +1 -1
  278. package/src/services/attachmentHandlers/fileAttachmentHandler.ts +78 -0
  279. package/src/services/attachmentHandlers/imageAttachmentHandler.ts +54 -0
  280. package/src/services/attachmentHandlers/index.ts +10 -0
  281. package/src/services/attachmentHandlers/videoAttachmentHandler.ts +114 -0
  282. package/src/services/attachmentOrchestrator.ts +300 -0
  283. package/src/services/auth.ts +34 -0
  284. package/src/services/endpoints.ts +24 -1
  285. package/src/services/imageUpload.ts +162 -0
  286. package/src/translation/resources/i18n.ts +22 -8
  287. package/src/types/attachment.ts +85 -0
  288. package/src/types/attachmentHandler.ts +31 -0
  289. package/src/types/imageUpload.ts +28 -0
  290. package/src/types/message.ts +1 -0
  291. package/src/utils/chatImageDimens.ts +178 -0
  292. package/src/utils/device.ts +73 -0
  293. package/src/utils/imageUrlOptimizer.ts +56 -0
  294. package/src/utils/imageUtils.ts +76 -0
  295. package/src/utils/resolveMessageType.ts +2 -0
  296. package/src/utils/ui.ts +19 -0
  297. package/src/utils/url.ts +1 -1
  298. package/src/utils/videoThumbnail.ts +85 -0
  299. package/lib/module/screens/chat-detail/ChatList.js +0 -147
  300. package/lib/module/screens/chat-detail/ChatList.js.map +0 -1
  301. package/lib/module/screens/chat-detail/ChatTextBubble.js +0 -62
  302. package/lib/module/screens/chat-detail/ChatTextBubble.js.map +0 -1
  303. package/lib/module/screens/chat-detail/legend/message-types.js +0 -244
  304. package/lib/module/screens/chat-detail/legend/message-types.js.map +0 -1
  305. package/lib/module/screens/chat-detail/messages/ChatMessageBubble.js +0 -24
  306. package/lib/module/screens/chat-detail/messages/ChatMessageBubble.js.map +0 -1
  307. package/lib/module/screens/chat-detail/messages/types.js +0 -4
  308. package/lib/module/screens/chat-detail/messages/types.js.map +0 -1
  309. package/lib/typescript/src/screens/chat-detail/ChatList.d.ts +0 -3
  310. package/lib/typescript/src/screens/chat-detail/ChatList.d.ts.map +0 -1
  311. package/lib/typescript/src/screens/chat-detail/ChatTextBubble.d.ts +0 -3
  312. package/lib/typescript/src/screens/chat-detail/ChatTextBubble.d.ts.map +0 -1
  313. package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts +0 -13
  314. package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts.map +0 -1
  315. package/lib/typescript/src/screens/chat-detail/messages/ChatMessageBubble.d.ts +0 -3
  316. package/lib/typescript/src/screens/chat-detail/messages/ChatMessageBubble.d.ts.map +0 -1
  317. package/lib/typescript/src/screens/chat-detail/messages/types.d.ts +0 -13
  318. package/lib/typescript/src/screens/chat-detail/messages/types.d.ts.map +0 -1
  319. package/src/screens/chat-detail/ChatList.tsx +0 -190
  320. package/src/screens/chat-detail/ChatTextBubble.tsx +0 -73
  321. package/src/screens/chat-detail/legend/message-types.tsx +0 -304
  322. package/src/screens/chat-detail/messages/ChatMessageBubble.tsx +0 -23
  323. package/src/screens/chat-detail/messages/types.ts +0 -14
@@ -1,51 +1,39 @@
1
- import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
- import {
3
- Keyboard,
4
- Platform,
5
- StyleSheet,
6
- TextInput,
7
- type NativeSyntheticEvent,
8
- type TextInputContentSizeChangeEventData,
9
- } from 'react-native';
10
- import Reanimated, {
11
- runOnJS,
12
- useAnimatedReaction,
13
- useAnimatedStyle,
14
- useSharedValue,
15
- withTiming,
16
- } from 'react-native-reanimated';
17
- import {
18
- useKeyboardState,
19
- useReanimatedKeyboardAnimation,
20
- } from 'react-native-keyboard-controller';
1
+ import { memo, useCallback, useEffect, useMemo } from 'react';
2
+ import { Platform, StyleSheet } from 'react-native';
3
+ import Reanimated from 'react-native-reanimated';
21
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
22
- import { KContainer, KImage, KColors, KSpacingValue } from '@droppii/libs';
23
- import { ChatQuickActions } from './ChatQuickActions';
24
- import { ChatAttachmentPanel } from './ChatAttachmentPanel';
25
- import { ChatLinkPreview } from './ChatLinkPreview';
26
- import { getAttachmentPanelHeight } from './constants';
27
- import type { ChatComposerProps } from './types';
28
- import { useLinkPreview } from '../../hooks/useLinkPreview/useLinkPreview';
5
+ import { KContainer, KColors, KImage } from '@droppii/libs';
29
6
 
30
- const ACCESSORY_ANIMATION_MS = 250;
31
- const ACCESSORY_SETTLE_MS = 150;
32
7
  const IS_IOS = Platform.OS === 'ios';
33
- const INPUT_FONT_SIZE = 16;
34
8
  const INPUT_LINE_HEIGHT = 22.4;
35
- const INPUT_MAX_HEIGHT = INPUT_LINE_HEIGHT * 5;
36
- // Android's onContentSizeChange includes paddingVertical (4*2=8) in reported height
37
9
  const WRAPPED_HEIGHT_THRESHOLD = IS_IOS
38
10
  ? INPUT_LINE_HEIGHT + 4
39
11
  : INPUT_LINE_HEIGHT + 12;
40
12
 
13
+ import { ChatQuickActions } from './ChatQuickActions';
14
+ import { ChatAttachmentPanel } from './ChatAttachmentPanel';
15
+ import { ChatLinkPreview } from './ChatLinkPreview';
16
+ import { ChatMessageInput } from './components/ChatMessageInput';
17
+ import { AttachmentPreview } from '../../components/AttachmentPreview';
18
+
19
+ import { getAttachmentPanelHeight } from './constants';
20
+ import type { ChatComposerProps } from './types';
21
+ import { useLinkPreview } from '../../hooks/useLinkPreview/useLinkPreview';
22
+ import { useImageAttachment } from '../../hooks/useImageAttachment';
23
+ import { useSendAttachment } from '../../hooks/useSendAttachment';
24
+ import { useChatComposerState } from './hooks/useChatComposerState';
25
+ import { useChatComposerAnimation } from './hooks/useChatComposerAnimation';
26
+ import { useAttachmentSendHandler } from './hooks/useAttachmentSendHandler';
27
+ import { isVideoFromPicker } from '../../utils/imageUtils';
28
+
41
29
  export const ChatComposer = memo(
42
30
  ({
43
31
  value,
44
32
  placeholder = 'Nhập tin nhắn...',
45
33
  onChangeText,
46
34
  onSend,
47
- onPressAttach,
48
- onPressEmoji,
35
+ onMessageSent,
36
+ onPressEmoji: _onPressEmoji,
49
37
  showQuickActions = true,
50
38
  quickActions,
51
39
  attachmentActions,
@@ -56,14 +44,10 @@ export const ChatComposer = memo(
56
44
  renderAttachmentAction,
57
45
  attachmentColumns,
58
46
  }: ChatComposerProps) => {
59
- const hasAttachmentActions = !!attachmentActions?.length;
60
- const inputRef = useRef<TextInput>(null);
61
- const isSwitchingToAttachmentRef = useRef(false);
62
- const [isAttachmentOpen, setIsAttachmentOpen] = useState(false);
63
- const [isInputFocused, setIsInputFocused] = useState(false);
64
- const [isInputWrapped, setIsInputWrapped] = useState(false);
65
47
  const insets = useSafeAreaInsets();
48
+ const hasAttachmentActions = !!attachmentActions?.length;
66
49
 
50
+ // Link preview
67
51
  const {
68
52
  isVisible: showLinkPreview,
69
53
  metadata: urlMetadata,
@@ -71,10 +55,58 @@ export const ChatComposer = memo(
71
55
  dismiss: handleDismissPreview,
72
56
  } = useLinkPreview(value);
73
57
 
74
- const isKeyboardVisible = useKeyboardState((state) => state.isVisible);
75
- const keyboardHeight = useKeyboardState((state) => state.height);
76
- const { progress: keyboardProgress } = useReanimatedKeyboardAnimation();
58
+ // Image attachment
59
+ const {
60
+ selectedImages,
61
+ isImagePreviewVisible,
62
+ handleImageAttach,
63
+ handleImageRemove,
64
+ clearAllImages,
65
+ } = useImageAttachment();
66
+
67
+ // Send attachment
68
+ const { send: sendAttachments } = useSendAttachment();
69
+
70
+ // Callback to send text message (with optional preview link)
71
+ // This is used when sending text after attachments
72
+ const handleSendText = useCallback(
73
+ (text: string, previewMetadata?: any) => {
74
+ // Send with the captured text and preview metadata
75
+ // Note: ChatDetail's handleSend will read currentInput, but for text sent
76
+ // after attachments, we want to use the captured text instead
77
+ // So we pass it via a special handling in the metadata
78
+ const metadataWithText = previewMetadata
79
+ ? { ...previewMetadata, _capturedText: text }
80
+ : undefined;
81
+ onSend?.(metadataWithText);
82
+ },
83
+ [onSend]
84
+ );
85
+
86
+ // Attachment send handler
87
+ const { handleSend: handleAttachmentSend } = useAttachmentSendHandler({
88
+ selectedImages,
89
+ sendAttachments,
90
+ clearAllImages,
91
+ onSend,
92
+ onMessageSent,
93
+ textMessage: (value ?? '').trim(),
94
+ urlMetadata: showLinkPreview ? urlMetadata : undefined,
95
+ onSendText: handleSendText,
96
+ });
77
97
 
98
+ // Composer state
99
+ const {
100
+ isAttachmentOpen,
101
+ setIsAttachmentOpen,
102
+ isInputFocused,
103
+ setIsInputFocused,
104
+ setIsInputWrapped,
105
+ isMultilineInput,
106
+ inputRef,
107
+ } = useChatComposerState(value as string);
108
+
109
+ // Panel height calculation
78
110
  const panelHeight = useMemo(
79
111
  () =>
80
112
  hasAttachmentActions
@@ -86,194 +118,119 @@ export const ChatComposer = memo(
86
118
  [attachmentActions, attachmentColumns, hasAttachmentActions]
87
119
  );
88
120
 
89
- const attachmentHeightSV = useSharedValue(0);
90
- const panelHeightSV = useSharedValue(panelHeight);
91
- const switchKeyboardHeightSV = useSharedValue(0);
92
- const isKeyboardToAttachmentSwitchSV = useSharedValue(false);
93
-
94
- useEffect(() => {
95
- panelHeightSV.value = panelHeight;
96
- }, [panelHeight, panelHeightSV]);
97
-
98
- const openAttachment = useCallback(() => {
99
- attachmentHeightSV.value = withTiming(panelHeight, {
100
- duration: ACCESSORY_ANIMATION_MS,
121
+ // Animation
122
+ const { accessorySlotStyle, toggleAttachmentVisibility, closeAttachment } =
123
+ useChatComposerAnimation({
124
+ isAttachmentOpen,
125
+ panelHeight,
126
+ onAttachmentOpenChange: setIsAttachmentOpen,
101
127
  });
102
- setIsAttachmentOpen(true);
103
- }, [attachmentHeightSV, panelHeight]);
104
-
105
- const closeAttachment = useCallback(() => {
106
- attachmentHeightSV.value = withTiming(0, {
107
- duration: ACCESSORY_ANIMATION_MS,
108
- });
109
- setIsAttachmentOpen(false);
110
- }, [attachmentHeightSV]);
111
-
112
- const finishKeyboardToAttachmentSwitch = useCallback(() => {
113
- if (!isSwitchingToAttachmentRef.current) {
114
- return;
115
- }
116
-
117
- isSwitchingToAttachmentRef.current = false;
118
- isKeyboardToAttachmentSwitchSV.value = false;
119
128
 
120
- const targetHeight = panelHeightSV.value;
121
- const startHeight = switchKeyboardHeightSV.value;
122
-
123
- if (Math.abs(startHeight - targetHeight) < 1) {
124
- attachmentHeightSV.value = targetHeight;
125
- return;
126
- }
127
-
128
- attachmentHeightSV.value = withTiming(targetHeight, {
129
- duration: ACCESSORY_SETTLE_MS,
130
- });
131
- }, [
132
- attachmentHeightSV,
133
- isKeyboardToAttachmentSwitchSV,
134
- panelHeightSV,
135
- switchKeyboardHeightSV,
136
- ]);
137
-
138
- useEffect(() => {
139
- if (!isKeyboardVisible && isSwitchingToAttachmentRef.current) {
140
- finishKeyboardToAttachmentSwitch();
141
- }
142
- }, [finishKeyboardToAttachmentSwitch, isKeyboardVisible]);
143
-
144
- useAnimatedReaction(
145
- () => ({
146
- switching: isKeyboardToAttachmentSwitchSV.value,
147
- progress: keyboardProgress.value,
148
- }),
149
- (current, previous) => {
150
- if (
151
- current.switching &&
152
- current.progress === 0 &&
153
- (previous?.progress ?? 1) > 0
154
- ) {
155
- runOnJS(finishKeyboardToAttachmentSwitch)();
156
- }
157
- },
158
- [finishKeyboardToAttachmentSwitch]
129
+ // Check if any attachments are currently uploading
130
+ const isUploadingAttachments = useMemo(
131
+ () => selectedImages.some((img: any) => img.isUploading),
132
+ [selectedImages]
159
133
  );
160
134
 
161
- useEffect(() => {
162
- if (isSwitchingToAttachmentRef.current) {
163
- return;
164
- }
165
-
166
- if (isKeyboardVisible && isAttachmentOpen) {
167
- closeAttachment();
168
- }
169
- }, [closeAttachment, isAttachmentOpen, isKeyboardVisible]);
170
-
171
- const accessorySlotStyle = useAnimatedStyle(() => {
172
- if (isKeyboardToAttachmentSwitchSV.value) {
173
- return {
174
- height: switchKeyboardHeightSV.value * (1 - keyboardProgress.value),
175
- };
176
- }
177
-
178
- return {
179
- height: attachmentHeightSV.value,
180
- };
181
- });
182
-
135
+ // Send handler - includes attachment and preview link features
183
136
  const handleSend = useCallback(() => {
184
- onSend?.(showLinkPreview ? urlMetadata : undefined);
185
- }, [onSend, urlMetadata, showLinkPreview]);
186
-
187
- const handleToggleAttachment = useCallback(() => {
188
- if (!hasAttachmentActions) {
137
+ const hasAttachments = selectedImages.length > 0;
138
+ const hasText = (value ?? '').trim().length > 0;
139
+ // Only send metadata if preview is CURRENTLY visible (user didn't dismiss it)
140
+ const previewMetadata = showLinkPreview ? urlMetadata : undefined;
141
+ const hasPreview = !!previewMetadata;
142
+
143
+ // Prevent sending while files are uploading
144
+ if (isUploadingAttachments) {
145
+ console.warn(
146
+ '[ChatComposer] Cannot send message while files are uploading'
147
+ );
189
148
  return;
190
149
  }
191
150
 
192
- if (isAttachmentOpen) {
193
- closeAttachment();
151
+ // Validate: must have at least one of: attachments, text, or preview link
152
+ if (!hasAttachments && !hasText && !hasPreview) {
153
+ console.warn(
154
+ '[ChatComposer] No attachments, text, or preview link to send'
155
+ );
194
156
  return;
195
157
  }
196
158
 
197
- onPressAttach?.();
198
- inputRef.current?.blur();
199
-
200
- if (isKeyboardVisible && keyboardHeight > 0) {
201
- isSwitchingToAttachmentRef.current = true;
202
- switchKeyboardHeightSV.value = keyboardHeight;
203
- isKeyboardToAttachmentSwitchSV.value = true;
204
- setIsAttachmentOpen(true);
205
- Keyboard.dismiss();
206
- return;
159
+ if (hasAttachments) {
160
+ // Send attachments (+ text if present, handled in attachment handler)
161
+ handleAttachmentSend();
162
+ } else {
163
+ // Send text/preview link only
164
+ console.log('[ChatComposer] handleSend - text message:', {
165
+ hasText,
166
+ hasPreview,
167
+ previewUrl: previewMetadata?.url,
168
+ });
169
+
170
+ onSend?.(previewMetadata);
207
171
  }
208
-
209
- openAttachment();
210
172
  }, [
211
- closeAttachment,
212
- isAttachmentOpen,
213
- isKeyboardVisible,
214
- keyboardHeight,
215
- isKeyboardToAttachmentSwitchSV,
216
- onPressAttach,
217
- hasAttachmentActions,
218
- openAttachment,
219
- switchKeyboardHeightSV,
173
+ onSend,
174
+ urlMetadata,
175
+ showLinkPreview,
176
+ selectedImages,
177
+ handleAttachmentSend,
178
+ value,
179
+ isUploadingAttachments,
220
180
  ]);
221
181
 
222
182
  const handleInputFocus = useCallback(() => {
223
183
  setIsInputFocused(true);
224
-
225
- if (!isAttachmentOpen) {
226
- return;
184
+ // Close attachment panel with animation when input is focused
185
+ if (isAttachmentOpen) {
186
+ closeAttachment();
227
187
  }
228
-
229
- closeAttachment();
230
- }, [closeAttachment, isAttachmentOpen]);
188
+ }, [closeAttachment, isAttachmentOpen, setIsInputFocused]);
231
189
 
232
190
  const handleInputBlur = useCallback(() => {
233
191
  setIsInputFocused(false);
234
- }, []);
192
+ }, [setIsInputFocused]);
193
+
194
+ const handleChangeText = useCallback(
195
+ (text?: string) => {
196
+ onChangeText?.(text);
197
+ },
198
+ [onChangeText]
199
+ );
235
200
 
236
201
  const handleInputContentSizeChange = useCallback(
237
- (event: NativeSyntheticEvent<TextInputContentSizeChangeEventData>) => {
202
+ (event: any) => {
238
203
  const { height } = event.nativeEvent.contentSize;
239
204
  setIsInputWrapped(height > WRAPPED_HEIGHT_THRESHOLD);
240
205
  },
241
- []
206
+ [setIsInputWrapped]
242
207
  );
243
208
 
244
- const isMultilineInput = useMemo(() => {
245
- if (!value) {
246
- return false;
247
- }
248
-
249
- return value.includes('\n') || isInputWrapped;
250
- }, [isInputWrapped, value]);
251
-
209
+ // Reset wrapped state when value is cleared
252
210
  useEffect(() => {
253
211
  if (!value) {
254
212
  setIsInputWrapped(false);
255
213
  }
256
- }, [value]);
257
-
258
- const renderEmojiNode = useCallback(
259
- () => (
260
- <KContainer.Touchable marginR="0.5rem" onPress={onPressEmoji}>
261
- <KImage.VectorIcons
262
- name="sticker-o"
263
- size={24}
264
- color={KColors.gray.normal}
265
- />
266
- </KContainer.Touchable>
267
- ),
268
- [onPressEmoji]
214
+ }, [value, setIsInputWrapped]);
215
+
216
+ // Attachment action handler
217
+ const handleAttachmentActionInternal = useCallback(
218
+ async (action: any) => {
219
+ if (action.id === 'gallery') {
220
+ await handleImageAttach();
221
+ } else {
222
+ onAttachmentAction?.(action);
223
+ }
224
+ },
225
+ [onAttachmentAction, handleImageAttach]
269
226
  );
270
227
 
228
+ // Input row padding
271
229
  const inputRowStyle = useMemo(
272
230
  () => ({
273
- paddingBottom:
274
- isAttachmentOpen || isKeyboardVisible ? 8 : insets.bottom + 12,
231
+ paddingBottom: isAttachmentOpen ? 8 : insets.bottom + 12,
275
232
  }),
276
- [insets.bottom, isAttachmentOpen, isKeyboardVisible]
233
+ [insets.bottom, isAttachmentOpen]
277
234
  );
278
235
 
279
236
  return (
@@ -286,13 +243,39 @@ export const ChatComposer = memo(
286
243
  renderQuickActions={renderQuickActions}
287
244
  />
288
245
 
289
- {showLinkPreview ? (
246
+ {showLinkPreview && (
290
247
  <ChatLinkPreview
291
248
  metadata={urlMetadata}
292
249
  isLoading={isMetadataLoading}
293
250
  onDismiss={handleDismissPreview}
294
251
  />
295
- ) : null}
252
+ )}
253
+
254
+ <AttachmentPreview
255
+ visible={isImagePreviewVisible}
256
+ attachments={selectedImages.map((img: any) => {
257
+ const isVideo = isVideoFromPicker(img.image);
258
+ return {
259
+ type: isVideo ? ('video' as const) : ('image' as const),
260
+ metadata: {
261
+ path: img.image.path,
262
+ filename: img.image.filename,
263
+ size: img.image.size,
264
+ width: img.image.width,
265
+ height: img.image.height,
266
+ ...(isVideo && { duration: (img.image as any).duration }),
267
+ },
268
+ uploadProgress: img.uploadProgress,
269
+ error: img.error,
270
+ isUploading: img.isUploading,
271
+ uploadedUrl: img.uploadedUrl,
272
+ ...(isVideo && { thumbnailUrl: img.thumbnailUrl }),
273
+ };
274
+ })}
275
+ onRemove={(type, index) => {
276
+ handleImageRemove(index);
277
+ }}
278
+ />
296
279
 
297
280
  <KContainer.View
298
281
  row
@@ -302,9 +285,9 @@ export const ChatComposer = memo(
302
285
  paddingB="0.75rem"
303
286
  style={inputRowStyle}
304
287
  >
305
- {hasAttachmentActions ? (
288
+ {hasAttachmentActions && (
306
289
  <KContainer.Touchable
307
- onPress={handleToggleAttachment}
290
+ onPress={toggleAttachmentVisibility}
308
291
  center
309
292
  br="round"
310
293
  >
@@ -318,65 +301,35 @@ export const ChatComposer = memo(
318
301
  }
319
302
  />
320
303
  </KContainer.Touchable>
321
- ) : null}
322
-
323
- <KContainer.View
324
- flex
325
- marginL={hasAttachmentActions ? '0.75rem' : undefined}
326
- style={styles.inputWrapper}
327
- >
328
- <KContainer.View
329
- row
330
- alignItems={isMultilineInput ? 'flex-end' : 'center'}
331
- brW={1}
332
- brC={
333
- isInputFocused
334
- ? KColors.palette.primary.w400
335
- : KColors.palette.gray.w100
336
- }
337
- background={KColors.white}
338
- paddingL="0.75rem"
339
- style={styles.inputContainer}
340
- >
341
- <KContainer.View marginR="0.75rem">
342
- <KImage.VectorIcons
343
- name="chat-suggest-o"
344
- size={24}
345
- color={KColors.gray.normal}
346
- />
347
- </KContainer.View>
348
-
349
- <TextInput
350
- ref={inputRef}
351
- placeholder={placeholder}
352
- placeholderTextColor={KColors.palette.gray.w200}
353
- value={value}
354
- onChangeText={onChangeText}
355
- onFocus={handleInputFocus}
356
- onBlur={handleInputBlur}
357
- onContentSizeChange={handleInputContentSizeChange}
358
- multiline
359
- blurOnSubmit={false}
360
- scrollEnabled
361
- allowFontScaling={false}
362
- underlineColorAndroid={KColors.transparent}
363
- selectionColor={KColors.selector}
364
- textAlignVertical={isMultilineInput ? 'top' : 'center'}
365
- style={[styles.textInput]}
366
- />
367
-
368
- {renderEmojiNode()}
369
- </KContainer.View>
370
- </KContainer.View>
304
+ )}
305
+
306
+ <ChatMessageInput
307
+ value={value as string}
308
+ placeholder={placeholder}
309
+ onChangeText={handleChangeText}
310
+ onFocus={handleInputFocus}
311
+ onBlur={handleInputBlur}
312
+ onContentSizeChange={handleInputContentSizeChange}
313
+ isInputFocused={isInputFocused}
314
+ isMultilineInput={isMultilineInput}
315
+ // onEmojiPress={onPressEmoji}
316
+ inputRef={inputRef}
317
+ />
371
318
 
372
319
  <KContainer.Touchable
373
- onPress={handleSend}
320
+ onPress={isUploadingAttachments ? undefined : handleSend}
321
+ pointerEvents={isUploadingAttachments ? 'none' : 'auto'}
374
322
  width={40}
375
323
  height={40}
376
324
  center
377
325
  br="round"
378
- background={KColors.palette.primary.w400}
326
+ background={
327
+ isUploadingAttachments
328
+ ? KColors.palette.gray.w400
329
+ : KColors.palette.primary.w400
330
+ }
379
331
  marginL="0.75rem"
332
+ opacity={isUploadingAttachments ? 0.6 : 1}
380
333
  >
381
334
  <KImage.VectorIcons
382
335
  name="send"
@@ -387,7 +340,7 @@ export const ChatComposer = memo(
387
340
  </KContainer.Touchable>
388
341
  </KContainer.View>
389
342
 
390
- {hasAttachmentActions ? (
343
+ {hasAttachmentActions && (
391
344
  <Reanimated.View
392
345
  style={[styles.accessorySlot, accessorySlotStyle]}
393
346
  pointerEvents={isAttachmentOpen ? 'auto' : 'none'}
@@ -395,11 +348,11 @@ export const ChatComposer = memo(
395
348
  <ChatAttachmentPanel
396
349
  actions={attachmentActions}
397
350
  columns={attachmentColumns}
398
- onActionPress={onAttachmentAction}
351
+ onActionPress={handleAttachmentActionInternal}
399
352
  renderAction={renderAttachmentAction}
400
353
  />
401
354
  </Reanimated.View>
402
- ) : null}
355
+ )}
403
356
  </KContainer.View>
404
357
  );
405
358
  }
@@ -412,22 +365,4 @@ const styles = StyleSheet.create({
412
365
  overflow: 'hidden',
413
366
  backgroundColor: KColors.palette.gray.w25,
414
367
  },
415
- inputWrapper: {
416
- overflow: 'hidden',
417
- },
418
- inputContainer: {
419
- borderRadius: KSpacingValue['1.25rem'],
420
- minHeight: 48,
421
- paddingVertical: KSpacingValue['0.25rem'],
422
- },
423
- textInput: {
424
- flex: 1,
425
- maxHeight: INPUT_MAX_HEIGHT,
426
- fontSize: INPUT_FONT_SIZE,
427
- lineHeight: INPUT_LINE_HEIGHT,
428
- color: KColors.palette.gray.w900,
429
- paddingVertical: IS_IOS ? 0 : 4,
430
- paddingHorizontal: IS_IOS ? 2 : 0,
431
- includeFontPadding: false,
432
- },
433
368
  });