@droppii-org/chat-mobile 0.2.17 → 0.2.19

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 (199) hide show
  1. package/lib/module/assets/images/icon_excel.png +0 -0
  2. package/lib/module/assets/images/icon_img.png +0 -0
  3. package/lib/module/assets/images/icon_pdf.png +0 -0
  4. package/lib/module/assets/images/icon_txt.png +0 -0
  5. package/lib/module/assets/images/icon_word.png +0 -0
  6. package/lib/module/assets/images/index.js +5 -0
  7. package/lib/module/assets/images/index.js.map +1 -1
  8. package/lib/module/components/AttachmentPreview/FilePreview.js +107 -0
  9. package/lib/module/components/AttachmentPreview/FilePreview.js.map +1 -0
  10. package/lib/module/components/AttachmentPreview/MediaPreview.js +212 -0
  11. package/lib/module/components/AttachmentPreview/MediaPreview.js.map +1 -0
  12. package/lib/module/components/AttachmentPreview/index.js +49 -0
  13. package/lib/module/components/AttachmentPreview/index.js.map +1 -0
  14. package/lib/module/components/ThreadCard/AvatarSection.js.map +1 -1
  15. package/lib/module/components/ThreadCard/ThreadCard.js +17 -9
  16. package/lib/module/components/ThreadCard/ThreadCard.js.map +1 -1
  17. package/lib/module/components/flows/inputButtons/index.js +7 -3
  18. package/lib/module/components/flows/inputButtons/index.js.map +1 -1
  19. package/lib/module/components/messages/fileMessage/index.js +122 -12
  20. package/lib/module/components/messages/fileMessage/index.js.map +1 -1
  21. package/lib/module/context/ChatContext.js +27 -4
  22. package/lib/module/context/ChatContext.js.map +1 -1
  23. package/lib/module/context/ChatDetailContext.js.map +1 -1
  24. package/lib/module/core/useChatListener.js +2 -4
  25. package/lib/module/core/useChatListener.js.map +1 -1
  26. package/lib/module/core/useUserListener.js +0 -7
  27. package/lib/module/core/useUserListener.js.map +1 -1
  28. package/lib/module/hooks/flows/useFlow.js +14 -3
  29. package/lib/module/hooks/flows/useFlow.js.map +1 -1
  30. package/lib/module/hooks/message/useSendMessage.js +1 -1
  31. package/lib/module/hooks/message/useSendMessage.js.map +1 -1
  32. package/lib/module/hooks/useConversationList.js +3 -27
  33. package/lib/module/hooks/useConversationList.js.map +1 -1
  34. package/lib/module/hooks/useFileAttachment.js +116 -0
  35. package/lib/module/hooks/useFileAttachment.js.map +1 -0
  36. package/lib/module/hooks/useFileDownload.js +175 -0
  37. package/lib/module/hooks/useFileDownload.js.map +1 -0
  38. package/lib/module/hooks/useLinkPreview/useLinkPreview.js +1 -1
  39. package/lib/module/hooks/useLinkPreview/useLinkPreview.js.map +1 -1
  40. package/lib/module/index.js +1 -1
  41. package/lib/module/index.js.map +1 -1
  42. package/lib/module/screens/chat-detail/ChatComposer.js +44 -36
  43. package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
  44. package/lib/module/screens/chat-detail/ChatDetail.js +1 -6
  45. package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
  46. package/lib/module/screens/chat-detail/ChatDetailHeader.js +6 -6
  47. package/lib/module/screens/chat-detail/ChatDetailHeader.js.map +1 -1
  48. package/lib/module/screens/chat-detail/ChatLinkPreview.js +3 -1
  49. package/lib/module/screens/chat-detail/ChatLinkPreview.js.map +1 -1
  50. package/lib/module/screens/chat-detail/ChatListLegend.js +2 -2
  51. package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
  52. package/lib/module/screens/chat-detail/conversationHeader.utils.js +9 -0
  53. package/lib/module/screens/chat-detail/conversationHeader.utils.js.map +1 -1
  54. package/lib/module/screens/chat-detail/hooks/useAttachmentMapping.js +51 -0
  55. package/lib/module/screens/chat-detail/hooks/useAttachmentMapping.js.map +1 -0
  56. package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js +39 -13
  57. package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js.map +1 -1
  58. package/lib/module/screens/inbox/Inbox.js +5 -1
  59. package/lib/module/screens/inbox/Inbox.js.map +1 -1
  60. package/lib/module/services/apis.js +0 -20
  61. package/lib/module/services/apis.js.map +1 -1
  62. package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js +6 -6
  63. package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js.map +1 -1
  64. package/lib/module/services/attachmentHandlers/index.js +1 -1
  65. package/lib/module/services/attachmentHandlers/index.js.map +1 -1
  66. package/lib/module/store/conversation.js +1 -38
  67. package/lib/module/store/conversation.js.map +1 -1
  68. package/lib/module/translation/resources/i18n.js +9 -0
  69. package/lib/module/translation/resources/i18n.js.map +1 -1
  70. package/lib/module/types/auth.js.map +1 -1
  71. package/lib/module/types/chat.js.map +1 -1
  72. package/lib/module/utils/conversation.js +1 -28
  73. package/lib/module/utils/conversation.js.map +1 -1
  74. package/lib/module/utils/device.js +32 -0
  75. package/lib/module/utils/device.js.map +1 -1
  76. package/lib/module/utils/imageUtils.js +44 -28
  77. package/lib/module/utils/imageUtils.js.map +1 -1
  78. package/lib/module/utils/message.js.map +1 -1
  79. package/lib/module/utils/messageUtils.js +5 -3
  80. package/lib/module/utils/messageUtils.js.map +1 -1
  81. package/lib/typescript/src/assets/images/index.d.ts +5 -0
  82. package/lib/typescript/src/assets/images/index.d.ts.map +1 -1
  83. package/lib/typescript/src/components/AttachmentPreview/FilePreview.d.ts +6 -0
  84. package/lib/typescript/src/components/AttachmentPreview/FilePreview.d.ts.map +1 -0
  85. package/lib/typescript/src/components/AttachmentPreview/MediaPreview.d.ts +9 -0
  86. package/lib/typescript/src/components/AttachmentPreview/MediaPreview.d.ts.map +1 -0
  87. package/lib/typescript/src/components/AttachmentPreview/index.d.ts +9 -0
  88. package/lib/typescript/src/components/AttachmentPreview/index.d.ts.map +1 -0
  89. package/lib/typescript/src/components/ThreadCard/AvatarSection.d.ts +2 -2
  90. package/lib/typescript/src/components/ThreadCard/AvatarSection.d.ts.map +1 -1
  91. package/lib/typescript/src/components/ThreadCard/ThreadCard.d.ts.map +1 -1
  92. package/lib/typescript/src/components/messages/fileMessage/index.d.ts.map +1 -1
  93. package/lib/typescript/src/context/ChatContext.d.ts.map +1 -1
  94. package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
  95. package/lib/typescript/src/core/useUserListener.d.ts.map +1 -1
  96. package/lib/typescript/src/hooks/flows/useFlow.d.ts.map +1 -1
  97. package/lib/typescript/src/hooks/useConversationList.d.ts +2 -2
  98. package/lib/typescript/src/hooks/useConversationList.d.ts.map +1 -1
  99. package/lib/typescript/src/hooks/useFileAttachment.d.ts +20 -0
  100. package/lib/typescript/src/hooks/useFileAttachment.d.ts.map +1 -0
  101. package/lib/typescript/src/hooks/useFileDownload.d.ts +15 -0
  102. package/lib/typescript/src/hooks/useFileDownload.d.ts.map +1 -0
  103. package/lib/typescript/src/hooks/useImageAttachment.d.ts +1 -2
  104. package/lib/typescript/src/hooks/useImageAttachment.d.ts.map +1 -1
  105. package/lib/typescript/src/hooks/useLinkPreview/useLinkPreview.d.ts.map +1 -1
  106. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
  107. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts +1 -1
  108. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
  109. package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts +1 -1
  110. package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts.map +1 -1
  111. package/lib/typescript/src/screens/chat-detail/ChatLinkPreview.d.ts.map +1 -1
  112. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
  113. package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts +7 -5
  114. package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts.map +1 -1
  115. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentMapping.d.ts +10 -0
  116. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentMapping.d.ts.map +1 -0
  117. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts +4 -1
  118. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts.map +1 -1
  119. package/lib/typescript/src/screens/chat-detail/types.d.ts +6 -9
  120. package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
  121. package/lib/typescript/src/screens/inbox/Inbox.d.ts.map +1 -1
  122. package/lib/typescript/src/services/apis.d.ts +0 -4
  123. package/lib/typescript/src/services/apis.d.ts.map +1 -1
  124. package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts +2 -2
  125. package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts.map +1 -1
  126. package/lib/typescript/src/services/attachmentHandlers/index.d.ts +1 -1
  127. package/lib/typescript/src/services/attachmentHandlers/index.d.ts.map +1 -1
  128. package/lib/typescript/src/store/conversation.d.ts +5 -8
  129. package/lib/typescript/src/store/conversation.d.ts.map +1 -1
  130. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  131. package/lib/typescript/src/types/attachment.d.ts +22 -1
  132. package/lib/typescript/src/types/attachment.d.ts.map +1 -1
  133. package/lib/typescript/src/types/auth.d.ts +1 -0
  134. package/lib/typescript/src/types/auth.d.ts.map +1 -1
  135. package/lib/typescript/src/types/chat.d.ts +15 -13
  136. package/lib/typescript/src/types/chat.d.ts.map +1 -1
  137. package/lib/typescript/src/utils/conversation.d.ts +2 -5
  138. package/lib/typescript/src/utils/conversation.d.ts.map +1 -1
  139. package/lib/typescript/src/utils/device.d.ts +7 -0
  140. package/lib/typescript/src/utils/device.d.ts.map +1 -1
  141. package/lib/typescript/src/utils/imageUtils.d.ts +1 -0
  142. package/lib/typescript/src/utils/imageUtils.d.ts.map +1 -1
  143. package/lib/typescript/src/utils/message.d.ts +3 -3
  144. package/lib/typescript/src/utils/message.d.ts.map +1 -1
  145. package/lib/typescript/src/utils/messageUtils.d.ts +2 -1
  146. package/lib/typescript/src/utils/messageUtils.d.ts.map +1 -1
  147. package/package.json +6 -2
  148. package/src/assets/images/icon_excel.png +0 -0
  149. package/src/assets/images/icon_img.png +0 -0
  150. package/src/assets/images/icon_pdf.png +0 -0
  151. package/src/assets/images/icon_txt.png +0 -0
  152. package/src/assets/images/icon_word.png +0 -0
  153. package/src/assets/images/index.ts +5 -0
  154. package/src/components/AttachmentPreview/FilePreview.tsx +137 -0
  155. package/src/components/AttachmentPreview/MediaPreview.tsx +238 -0
  156. package/src/components/AttachmentPreview/index.tsx +68 -0
  157. package/src/components/ThreadCard/AvatarSection.tsx +2 -3
  158. package/src/components/ThreadCard/ThreadCard.tsx +22 -15
  159. package/src/components/flows/inputButtons/index.tsx +4 -1
  160. package/src/components/messages/fileMessage/index.tsx +156 -13
  161. package/src/context/ChatContext.tsx +35 -3
  162. package/src/context/ChatDetailContext.tsx +1 -1
  163. package/src/core/useChatListener.ts +2 -4
  164. package/src/core/useUserListener.ts +0 -8
  165. package/src/hooks/flows/useFlow.ts +12 -3
  166. package/src/hooks/message/useSendMessage.ts +1 -1
  167. package/src/hooks/useConversationList.ts +6 -40
  168. package/src/hooks/useFileAttachment.ts +163 -0
  169. package/src/hooks/useFileDownload.ts +200 -0
  170. package/src/hooks/useImageAttachment.ts +1 -1
  171. package/src/hooks/useLinkPreview/useLinkPreview.ts +6 -1
  172. package/src/screens/chat-detail/ChatComposer.tsx +61 -30
  173. package/src/screens/chat-detail/ChatDetail.tsx +1 -7
  174. package/src/screens/chat-detail/ChatDetailHeader.tsx +6 -7
  175. package/src/screens/chat-detail/ChatLinkPreview.tsx +16 -12
  176. package/src/screens/chat-detail/ChatListLegend.tsx +2 -6
  177. package/src/screens/chat-detail/conversationHeader.utils.ts +16 -6
  178. package/src/screens/chat-detail/hooks/useAttachmentMapping.ts +58 -0
  179. package/src/screens/chat-detail/hooks/useAttachmentSendHandler.ts +50 -11
  180. package/src/screens/chat-detail/types.ts +6 -13
  181. package/src/screens/inbox/Inbox.tsx +5 -1
  182. package/src/services/apis.ts +0 -38
  183. package/src/services/attachmentHandlers/fileAttachmentHandler.ts +8 -7
  184. package/src/services/attachmentHandlers/index.ts +4 -1
  185. package/src/store/conversation.ts +6 -55
  186. package/src/translation/resources/i18n.ts +9 -0
  187. package/src/types/attachment.ts +23 -1
  188. package/src/types/auth.ts +1 -0
  189. package/src/types/chat.ts +16 -20
  190. package/src/utils/conversation.ts +2 -40
  191. package/src/utils/device.ts +58 -0
  192. package/src/utils/imageUtils.ts +50 -28
  193. package/src/utils/message.ts +3 -2
  194. package/src/utils/messageUtils.ts +11 -3
  195. package/lib/module/components/AttachmentPreview.js +0 -252
  196. package/lib/module/components/AttachmentPreview.js.map +0 -1
  197. package/lib/typescript/src/components/AttachmentPreview.d.ts +0 -28
  198. package/lib/typescript/src/components/AttachmentPreview.d.ts.map +0 -1
  199. package/src/components/AttachmentPreview.tsx +0 -310
@@ -1,310 +0,0 @@
1
- import { memo } from 'react';
2
- import { ScrollView, StyleSheet } from 'react-native';
3
- import { KContainer, KImage, KColors, KLabel } from '@droppii/libs';
4
-
5
- type AttachmentType = 'image' | 'video' | 'audio' | 'document' | 'file';
6
-
7
- interface AttachmentMetadata {
8
- path: string;
9
- filename?: string;
10
- size?: number;
11
- duration?: number;
12
- mimeType?: string;
13
- width?: number;
14
- height?: number;
15
- }
16
-
17
- interface AttachmentItem {
18
- metadata: AttachmentMetadata;
19
- uploadProgress: number;
20
- error: string | null;
21
- isUploading: boolean;
22
- uploadedUrl?: string;
23
- thumbnailUrl?: string;
24
- }
25
-
26
- interface AttachmentPreviewProps {
27
- visible: boolean;
28
- attachments?: Array<AttachmentItem & { type: AttachmentType }>;
29
- onRemove: (type: AttachmentType, index: number) => void;
30
- }
31
-
32
- const formatDuration = (seconds: number): string => {
33
- const totalSecs = Math.floor(seconds);
34
- const mins = Math.floor(totalSecs / 60);
35
- const secs = totalSecs % 60;
36
- return `${mins.toString().padStart(2, '0')}:${secs
37
- .toString()
38
- .padStart(2, '0')}`;
39
- };
40
-
41
- const getAttachmentIcon = (type: AttachmentType): string => {
42
- switch (type) {
43
- case 'image':
44
- return 'image';
45
- case 'video':
46
- return 'play-circle';
47
- case 'audio':
48
- return 'music';
49
- case 'document':
50
- return 'file-document';
51
- case 'file':
52
- default:
53
- return 'file';
54
- }
55
- };
56
-
57
- export const AttachmentPreview = memo(
58
- ({ visible, attachments, onRemove }: AttachmentPreviewProps) => {
59
- if (!visible || !attachments?.length) {
60
- return null;
61
- }
62
-
63
- return (
64
- <KContainer.View
65
- paddingH="0.75rem"
66
- // paddingV="0.75rem"
67
- brW={1}
68
- brC={KColors.palette.gray.w100}
69
- background={KColors.white}
70
- style={styles.container}
71
- >
72
- <KContainer.View row alignItems minH={70}>
73
- <KContainer.View flex>
74
- <ScrollView
75
- horizontal
76
- showsHorizontalScrollIndicator={false}
77
- scrollEventThrottle={16}
78
- contentContainerStyle={styles.scrollContent}
79
- >
80
- {attachments.map((item, index) => {
81
- const {
82
- type,
83
- metadata,
84
- uploadProgress,
85
- error,
86
- isUploading,
87
- thumbnailUrl,
88
- } = item;
89
-
90
- const isImage = type === 'image';
91
- const isVideo = type === 'video';
92
- const hasPreview = isImage || isVideo;
93
-
94
- return (
95
- <KContainer.View key={`${type}-${index}`}>
96
- <KContainer.View style={styles.thumbnail} center>
97
- {/* Video thumbnail */}
98
- {isVideo && thumbnailUrl && (
99
- <KImage.Base
100
- uri={thumbnailUrl}
101
- width={48}
102
- height={48}
103
- resizeMode="cover"
104
- />
105
- )}
106
-
107
- {/* Video placeholder (no thumbnail yet) */}
108
- {isVideo && !thumbnailUrl && (
109
- <KContainer.View
110
- style={[styles.videoBg, styles.videoThumbnail]}
111
- />
112
- )}
113
-
114
- {/* Image preview */}
115
- {isImage && (
116
- <KImage.Base
117
- uri={`file://${metadata.path}`}
118
- width={48}
119
- height={48}
120
- />
121
- )}
122
-
123
- {/* Show icon overlay for non-media files */}
124
- {!hasPreview && (
125
- <KContainer.View
126
- style={styles.iconOverlay}
127
- center
128
- background={KColors.palette.gray.w100}
129
- >
130
- <KImage.VectorIcons
131
- name={getAttachmentIcon(type)}
132
- provider="MaterialCommunityIcons"
133
- size={24}
134
- color={KColors.palette.primary.w400}
135
- />
136
- </KContainer.View>
137
- )}
138
-
139
- {/* Video duration badge */}
140
- {isVideo && !!metadata.duration && (
141
- <KContainer.View style={styles.durationBadge} center>
142
- <KLabel.Text
143
- typo="TextXsNormal"
144
- color={KColors.white}
145
- style={styles.durationText}
146
- >
147
- {formatDuration(metadata.duration / 1000)}
148
- </KLabel.Text>
149
- </KContainer.View>
150
- )}
151
-
152
- {/* Type icon for non-preview items */}
153
- {!hasPreview && (
154
- <KContainer.View style={styles.typeIcon} center>
155
- <KImage.VectorIcons
156
- name={getAttachmentIcon(type)}
157
- provider="MaterialCommunityIcons"
158
- size={14}
159
- color={KColors.white}
160
- />
161
- </KContainer.View>
162
- )}
163
-
164
- {/* Error state */}
165
- {error && (
166
- <KContainer.View style={styles.errorOverlay} center>
167
- <KImage.VectorIcons
168
- name="close-circle"
169
- provider="MaterialCommunityIcons"
170
- size={28}
171
- color={KColors.white}
172
- />
173
- </KContainer.View>
174
- )}
175
-
176
- {/* Progress overlay */}
177
- {isUploading && (
178
- <KContainer.View style={styles.progressOverlay} center>
179
- <KLabel.Text
180
- typo="TextSmNormal"
181
- color={KColors.white}
182
- >
183
- {uploadProgress}%
184
- </KLabel.Text>
185
- </KContainer.View>
186
- )}
187
- </KContainer.View>
188
- {/* Remove button */}
189
- <KContainer.Touchable
190
- style={styles.removeButton}
191
- center
192
- br="round"
193
- background={KColors.black}
194
- onPress={() => onRemove(type, index)}
195
- disabled={isUploading}
196
- hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
197
- >
198
- <KImage.VectorIcons
199
- name="close"
200
- provider="MaterialCommunityIcons"
201
- size={14}
202
- color={KColors.white}
203
- />
204
- </KContainer.Touchable>
205
- </KContainer.View>
206
- );
207
- })}
208
- </ScrollView>
209
- </KContainer.View>
210
- </KContainer.View>
211
- </KContainer.View>
212
- );
213
- }
214
- );
215
-
216
- AttachmentPreview.displayName = 'AttachmentPreview';
217
-
218
- const styles = StyleSheet.create({
219
- container: {
220
- // minHeight: 80,
221
- },
222
- scrollContent: {
223
- alignItems: 'center',
224
- },
225
- thumbnail: {
226
- position: 'relative',
227
- width: 48,
228
- height: 48,
229
- borderRadius: 4,
230
- overflow: 'hidden',
231
- marginRight: 8,
232
- backgroundColor: KColors.palette.gray.w50,
233
- },
234
- durationBadge: {
235
- position: 'absolute',
236
- bottom: 4,
237
- right: 4,
238
- backgroundColor: 'rgba(0, 0, 0, 0.8)',
239
- borderRadius: 3,
240
- paddingVertical: 2,
241
- paddingHorizontal: 4,
242
- },
243
- durationText: {
244
- fontSize: 11,
245
- fontWeight: '600',
246
- },
247
- iconOverlay: {
248
- width: 48,
249
- height: 48,
250
- borderRadius: 4,
251
- },
252
- videoIcon: {
253
- position: 'absolute',
254
- top: 2,
255
- right: 2,
256
- backgroundColor: 'rgba(0, 0, 0, 0.6)',
257
- borderRadius: 8,
258
- width: 20,
259
- height: 20,
260
- },
261
- typeIcon: {
262
- position: 'absolute',
263
- bottom: 2,
264
- right: 2,
265
- backgroundColor: 'rgba(0, 0, 0, 0.7)',
266
- borderRadius: 6,
267
- width: 16,
268
- height: 16,
269
- },
270
- videoBg: {
271
- width: 48,
272
- height: 48,
273
- borderRadius: 4,
274
- },
275
- videoThumbnail: {
276
- backgroundColor: KColors.black,
277
- },
278
- progressOverlay: {
279
- position: 'absolute',
280
- top: 0,
281
- left: 0,
282
- right: 0,
283
- bottom: 0,
284
- backgroundColor: 'rgba(0, 0, 0, 0.6)',
285
- },
286
- errorOverlay: {
287
- position: 'absolute',
288
- top: 0,
289
- left: 0,
290
- right: 0,
291
- bottom: 0,
292
- backgroundColor: 'rgba(255, 59, 48, 0.8)',
293
- },
294
- removeButton: {
295
- position: 'absolute',
296
- top: -8,
297
- right: 2,
298
- width: 22,
299
- height: 22,
300
- shadowColor: '#000',
301
- shadowOffset: { width: 0, height: 1 },
302
- shadowOpacity: 0.2,
303
- shadowRadius: 2,
304
- elevation: 3,
305
- },
306
- sendButton: {
307
- width: 48,
308
- height: 48,
309
- },
310
- });