@ion299/sdk-react-native 0.1.0-beta.1

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/CHANGELOG.md +17 -0
  2. package/ChatPlatformSdk.podspec +20 -0
  3. package/README.md +315 -0
  4. package/android/build.gradle +54 -0
  5. package/android/src/main/AndroidManifest.xml +18 -0
  6. package/android/src/main/java/com/chatplatform/sdk/ChatSdkDownloaderModule.kt +240 -0
  7. package/android/src/main/java/com/chatplatform/sdk/ChatSdkFilePickerModule.kt +165 -0
  8. package/android/src/main/java/com/chatplatform/sdk/ChatSdkPackage.kt +15 -0
  9. package/android/src/main/res/xml/chat_sdk_file_paths.xml +7 -0
  10. package/ios/ChatSdkDownloader.m +10 -0
  11. package/ios/ChatSdkDownloader.swift +141 -0
  12. package/ios/ChatSdkFilePicker.m +9 -0
  13. package/ios/ChatSdkFilePicker.swift +161 -0
  14. package/lib/commonjs/ChatSDK.js +193 -0
  15. package/lib/commonjs/ChatSDK.js.map +1 -0
  16. package/lib/commonjs/api.js +195 -0
  17. package/lib/commonjs/api.js.map +1 -0
  18. package/lib/commonjs/attachmentUtils.js +39 -0
  19. package/lib/commonjs/attachmentUtils.js.map +1 -0
  20. package/lib/commonjs/components/AttachmentGallery.js +367 -0
  21. package/lib/commonjs/components/AttachmentGallery.js.map +1 -0
  22. package/lib/commonjs/components/ChatScreen.js +286 -0
  23. package/lib/commonjs/components/ChatScreen.js.map +1 -0
  24. package/lib/commonjs/components/MessageBubble.js +227 -0
  25. package/lib/commonjs/components/MessageBubble.js.map +1 -0
  26. package/lib/commonjs/components/MessageInput.js +273 -0
  27. package/lib/commonjs/components/MessageInput.js.map +1 -0
  28. package/lib/commonjs/components/SurveyOverlay.js +499 -0
  29. package/lib/commonjs/components/SurveyOverlay.js.map +1 -0
  30. package/lib/commonjs/downloaders/defaultAttachmentDownloader.js +28 -0
  31. package/lib/commonjs/downloaders/defaultAttachmentDownloader.js.map +1 -0
  32. package/lib/commonjs/filePicker.js +25 -0
  33. package/lib/commonjs/filePicker.js.map +1 -0
  34. package/lib/commonjs/index.js +27 -0
  35. package/lib/commonjs/index.js.map +1 -0
  36. package/lib/commonjs/native/NativeChatSdkDownloader.js +28 -0
  37. package/lib/commonjs/native/NativeChatSdkDownloader.js.map +1 -0
  38. package/lib/commonjs/native/NativeChatSdkFilePicker.js +17 -0
  39. package/lib/commonjs/native/NativeChatSdkFilePicker.js.map +1 -0
  40. package/lib/commonjs/package.json +1 -0
  41. package/lib/commonjs/realtime.js +242 -0
  42. package/lib/commonjs/realtime.js.map +1 -0
  43. package/lib/commonjs/safeArea.js +18 -0
  44. package/lib/commonjs/safeArea.js.map +1 -0
  45. package/lib/commonjs/session.js +159 -0
  46. package/lib/commonjs/session.js.map +1 -0
  47. package/lib/commonjs/surveyCache.js +30 -0
  48. package/lib/commonjs/surveyCache.js.map +1 -0
  49. package/lib/commonjs/theme.js +29 -0
  50. package/lib/commonjs/theme.js.map +1 -0
  51. package/lib/commonjs/types.js +2 -0
  52. package/lib/commonjs/types.js.map +1 -0
  53. package/lib/commonjs/useChat.js +145 -0
  54. package/lib/commonjs/useChat.js.map +1 -0
  55. package/lib/module/ChatSDK.js +189 -0
  56. package/lib/module/ChatSDK.js.map +1 -0
  57. package/lib/module/api.js +190 -0
  58. package/lib/module/api.js.map +1 -0
  59. package/lib/module/attachmentUtils.js +33 -0
  60. package/lib/module/attachmentUtils.js.map +1 -0
  61. package/lib/module/components/AttachmentGallery.js +362 -0
  62. package/lib/module/components/AttachmentGallery.js.map +1 -0
  63. package/lib/module/components/ChatScreen.js +281 -0
  64. package/lib/module/components/ChatScreen.js.map +1 -0
  65. package/lib/module/components/MessageBubble.js +222 -0
  66. package/lib/module/components/MessageBubble.js.map +1 -0
  67. package/lib/module/components/MessageInput.js +268 -0
  68. package/lib/module/components/MessageInput.js.map +1 -0
  69. package/lib/module/components/SurveyOverlay.js +494 -0
  70. package/lib/module/components/SurveyOverlay.js.map +1 -0
  71. package/lib/module/downloaders/defaultAttachmentDownloader.js +22 -0
  72. package/lib/module/downloaders/defaultAttachmentDownloader.js.map +1 -0
  73. package/lib/module/filePicker.js +20 -0
  74. package/lib/module/filePicker.js.map +1 -0
  75. package/lib/module/index.js +6 -0
  76. package/lib/module/index.js.map +1 -0
  77. package/lib/module/native/NativeChatSdkDownloader.js +23 -0
  78. package/lib/module/native/NativeChatSdkDownloader.js.map +1 -0
  79. package/lib/module/native/NativeChatSdkFilePicker.js +13 -0
  80. package/lib/module/native/NativeChatSdkFilePicker.js.map +1 -0
  81. package/lib/module/package.json +1 -0
  82. package/lib/module/realtime.js +236 -0
  83. package/lib/module/realtime.js.map +1 -0
  84. package/lib/module/safeArea.js +14 -0
  85. package/lib/module/safeArea.js.map +1 -0
  86. package/lib/module/session.js +154 -0
  87. package/lib/module/session.js.map +1 -0
  88. package/lib/module/surveyCache.js +23 -0
  89. package/lib/module/surveyCache.js.map +1 -0
  90. package/lib/module/theme.js +25 -0
  91. package/lib/module/theme.js.map +1 -0
  92. package/lib/module/types.js +2 -0
  93. package/lib/module/types.js.map +1 -0
  94. package/lib/module/useChat.js +141 -0
  95. package/lib/module/useChat.js.map +1 -0
  96. package/lib/typescript/commonjs/ChatSDK.d.ts +49 -0
  97. package/lib/typescript/commonjs/ChatSDK.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/api.d.ts +31 -0
  99. package/lib/typescript/commonjs/api.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/attachmentUtils.d.ts +12 -0
  101. package/lib/typescript/commonjs/attachmentUtils.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/components/AttachmentGallery.d.ts +16 -0
  103. package/lib/typescript/commonjs/components/AttachmentGallery.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/components/ChatScreen.d.ts +16 -0
  105. package/lib/typescript/commonjs/components/ChatScreen.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/components/MessageBubble.d.ts +12 -0
  107. package/lib/typescript/commonjs/components/MessageBubble.d.ts.map +1 -0
  108. package/lib/typescript/commonjs/components/MessageInput.d.ts +14 -0
  109. package/lib/typescript/commonjs/components/MessageInput.d.ts.map +1 -0
  110. package/lib/typescript/commonjs/components/SurveyOverlay.d.ts +13 -0
  111. package/lib/typescript/commonjs/components/SurveyOverlay.d.ts.map +1 -0
  112. package/lib/typescript/commonjs/downloaders/defaultAttachmentDownloader.d.ts +3 -0
  113. package/lib/typescript/commonjs/downloaders/defaultAttachmentDownloader.d.ts.map +1 -0
  114. package/lib/typescript/commonjs/filePicker.d.ts +4 -0
  115. package/lib/typescript/commonjs/filePicker.d.ts.map +1 -0
  116. package/lib/typescript/commonjs/index.d.ts +7 -0
  117. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  118. package/lib/typescript/commonjs/native/NativeChatSdkDownloader.d.ts +24 -0
  119. package/lib/typescript/commonjs/native/NativeChatSdkDownloader.d.ts.map +1 -0
  120. package/lib/typescript/commonjs/native/NativeChatSdkFilePicker.d.ts +17 -0
  121. package/lib/typescript/commonjs/native/NativeChatSdkFilePicker.d.ts.map +1 -0
  122. package/lib/typescript/commonjs/package.json +1 -0
  123. package/lib/typescript/commonjs/realtime.d.ts +42 -0
  124. package/lib/typescript/commonjs/realtime.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/safeArea.d.ts +4 -0
  126. package/lib/typescript/commonjs/safeArea.d.ts.map +1 -0
  127. package/lib/typescript/commonjs/session.d.ts +45 -0
  128. package/lib/typescript/commonjs/session.d.ts.map +1 -0
  129. package/lib/typescript/commonjs/surveyCache.d.ts +5 -0
  130. package/lib/typescript/commonjs/surveyCache.d.ts.map +1 -0
  131. package/lib/typescript/commonjs/theme.d.ts +21 -0
  132. package/lib/typescript/commonjs/theme.d.ts.map +1 -0
  133. package/lib/typescript/commonjs/types.d.ts +156 -0
  134. package/lib/typescript/commonjs/types.d.ts.map +1 -0
  135. package/lib/typescript/commonjs/useChat.d.ts +16 -0
  136. package/lib/typescript/commonjs/useChat.d.ts.map +1 -0
  137. package/lib/typescript/module/ChatSDK.d.ts +49 -0
  138. package/lib/typescript/module/ChatSDK.d.ts.map +1 -0
  139. package/lib/typescript/module/api.d.ts +31 -0
  140. package/lib/typescript/module/api.d.ts.map +1 -0
  141. package/lib/typescript/module/attachmentUtils.d.ts +12 -0
  142. package/lib/typescript/module/attachmentUtils.d.ts.map +1 -0
  143. package/lib/typescript/module/components/AttachmentGallery.d.ts +16 -0
  144. package/lib/typescript/module/components/AttachmentGallery.d.ts.map +1 -0
  145. package/lib/typescript/module/components/ChatScreen.d.ts +16 -0
  146. package/lib/typescript/module/components/ChatScreen.d.ts.map +1 -0
  147. package/lib/typescript/module/components/MessageBubble.d.ts +12 -0
  148. package/lib/typescript/module/components/MessageBubble.d.ts.map +1 -0
  149. package/lib/typescript/module/components/MessageInput.d.ts +14 -0
  150. package/lib/typescript/module/components/MessageInput.d.ts.map +1 -0
  151. package/lib/typescript/module/components/SurveyOverlay.d.ts +13 -0
  152. package/lib/typescript/module/components/SurveyOverlay.d.ts.map +1 -0
  153. package/lib/typescript/module/downloaders/defaultAttachmentDownloader.d.ts +3 -0
  154. package/lib/typescript/module/downloaders/defaultAttachmentDownloader.d.ts.map +1 -0
  155. package/lib/typescript/module/filePicker.d.ts +4 -0
  156. package/lib/typescript/module/filePicker.d.ts.map +1 -0
  157. package/lib/typescript/module/index.d.ts +7 -0
  158. package/lib/typescript/module/index.d.ts.map +1 -0
  159. package/lib/typescript/module/native/NativeChatSdkDownloader.d.ts +24 -0
  160. package/lib/typescript/module/native/NativeChatSdkDownloader.d.ts.map +1 -0
  161. package/lib/typescript/module/native/NativeChatSdkFilePicker.d.ts +17 -0
  162. package/lib/typescript/module/native/NativeChatSdkFilePicker.d.ts.map +1 -0
  163. package/lib/typescript/module/package.json +1 -0
  164. package/lib/typescript/module/realtime.d.ts +42 -0
  165. package/lib/typescript/module/realtime.d.ts.map +1 -0
  166. package/lib/typescript/module/safeArea.d.ts +4 -0
  167. package/lib/typescript/module/safeArea.d.ts.map +1 -0
  168. package/lib/typescript/module/session.d.ts +45 -0
  169. package/lib/typescript/module/session.d.ts.map +1 -0
  170. package/lib/typescript/module/surveyCache.d.ts +5 -0
  171. package/lib/typescript/module/surveyCache.d.ts.map +1 -0
  172. package/lib/typescript/module/theme.d.ts +21 -0
  173. package/lib/typescript/module/theme.d.ts.map +1 -0
  174. package/lib/typescript/module/types.d.ts +156 -0
  175. package/lib/typescript/module/types.d.ts.map +1 -0
  176. package/lib/typescript/module/useChat.d.ts +16 -0
  177. package/lib/typescript/module/useChat.d.ts.map +1 -0
  178. package/package.json +75 -0
  179. package/react-native.config.js +10 -0
  180. package/src/ChatSDK.ts +237 -0
  181. package/src/api.ts +228 -0
  182. package/src/attachmentUtils.ts +49 -0
  183. package/src/components/AttachmentGallery.tsx +363 -0
  184. package/src/components/ChatScreen.tsx +267 -0
  185. package/src/components/MessageBubble.tsx +208 -0
  186. package/src/components/MessageInput.tsx +280 -0
  187. package/src/components/SurveyOverlay.tsx +469 -0
  188. package/src/downloaders/defaultAttachmentDownloader.ts +27 -0
  189. package/src/filePicker.ts +22 -0
  190. package/src/index.ts +30 -0
  191. package/src/native/NativeChatSdkDownloader.ts +49 -0
  192. package/src/native/NativeChatSdkFilePicker.ts +30 -0
  193. package/src/realtime.ts +278 -0
  194. package/src/safeArea.ts +8 -0
  195. package/src/session.ts +196 -0
  196. package/src/surveyCache.ts +24 -0
  197. package/src/theme.ts +49 -0
  198. package/src/types.ts +199 -0
  199. package/src/useChat.ts +190 -0
@@ -0,0 +1,367 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AttachmentGallery = AttachmentGallery;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _attachmentUtils = require("../attachmentUtils.js");
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
+ const {
13
+ width: SW
14
+ } = _reactNative.Dimensions.get('window');
15
+ function formatBytes(bytes) {
16
+ if (bytes <= 0) return '';
17
+ if (bytes < 1024) return `${bytes} Б`;
18
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} КБ`;
19
+ return `${(bytes / (1024 * 1024)).toFixed(1)} МБ`;
20
+ }
21
+ function GallerySlide({
22
+ item,
23
+ isVisible
24
+ }) {
25
+ const [loading, setLoading] = (0, _react.useState)(true);
26
+ const displayName = (0, _attachmentUtils.attachmentDisplayName)(item);
27
+ if (item.type === 'image') {
28
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
29
+ style: slide.root,
30
+ children: [loading && isVisible && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
31
+ color: "#fff",
32
+ size: "large",
33
+ style: _reactNative.StyleSheet.absoluteFill
34
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
35
+ source: {
36
+ uri: item.url
37
+ },
38
+ style: slide.image,
39
+ resizeMode: "contain",
40
+ onLoadStart: () => setLoading(true),
41
+ onLoadEnd: () => setLoading(false)
42
+ })]
43
+ });
44
+ }
45
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
46
+ style: [slide.root, slide.doc],
47
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
48
+ style: slide.docName,
49
+ numberOfLines: 6,
50
+ children: displayName
51
+ }), item.size > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
52
+ style: slide.docSize,
53
+ children: formatBytes(item.size)
54
+ })]
55
+ });
56
+ }
57
+ function AttachmentGallery({
58
+ attachments,
59
+ initialIndex,
60
+ visible,
61
+ onClose,
62
+ downloadLabel = 'Скачать',
63
+ onDownloadAttachment,
64
+ theme
65
+ }) {
66
+ const listRef = (0, _react.useRef)(null);
67
+ const [currentIndex, setCurrentIndex] = (0, _react.useState)(initialIndex);
68
+ const [isDownloading, setIsDownloading] = (0, _react.useState)(false);
69
+ const current = attachments[currentIndex];
70
+ (0, _react.useEffect)(() => {
71
+ if (visible) {
72
+ setCurrentIndex(initialIndex);
73
+ }
74
+ }, [visible, initialIndex]);
75
+ const handleViewableChange = (0, _react.useCallback)(({
76
+ viewableItems
77
+ }) => {
78
+ if (viewableItems[0]?.index != null) {
79
+ setCurrentIndex(viewableItems[0].index);
80
+ }
81
+ }, []);
82
+ const viewabilityConfig = (0, _react.useRef)({
83
+ viewAreaCoveragePercentThreshold: 50
84
+ });
85
+ const scrollTo = index => {
86
+ listRef.current?.scrollToIndex({
87
+ index,
88
+ animated: true
89
+ });
90
+ setCurrentIndex(index);
91
+ };
92
+ const handleDownload = async () => {
93
+ if (!current || isDownloading) return;
94
+ setIsDownloading(true);
95
+ try {
96
+ await onDownloadAttachment(current);
97
+ } catch (e) {
98
+ const message = e instanceof Error ? e.message : 'Не удалось скачать файл';
99
+ _reactNative.Alert.alert('Ошибка', message);
100
+ } finally {
101
+ setIsDownloading(false);
102
+ }
103
+ };
104
+ const renderItem = ({
105
+ item,
106
+ index
107
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(GallerySlide, {
108
+ item: item,
109
+ isVisible: index === currentIndex
110
+ });
111
+ const counterText = attachments.length > 1 ? `${currentIndex + 1} / ${attachments.length}` : '';
112
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
113
+ visible: visible,
114
+ transparent: false,
115
+ animationType: "fade",
116
+ onRequestClose: onClose,
117
+ statusBarTranslucent: true,
118
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
119
+ style: styles.root,
120
+ children: [_reactNative.Platform.OS === 'android' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.StatusBar, {
121
+ barStyle: "light-content",
122
+ backgroundColor: "#000",
123
+ translucent: true
124
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.SafeAreaView, {
125
+ style: styles.headerSafe,
126
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
127
+ style: styles.header,
128
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
129
+ style: styles.headerSide
130
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
131
+ style: styles.counter,
132
+ children: counterText
133
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
134
+ style: styles.closeBtn,
135
+ onPress: onClose,
136
+ hitSlop: 12,
137
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
138
+ style: styles.closeIcon,
139
+ children: "\u2715"
140
+ })
141
+ })]
142
+ })
143
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
144
+ style: styles.listWrap,
145
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.FlatList, {
146
+ ref: listRef,
147
+ data: attachments,
148
+ keyExtractor: a => String(a.id),
149
+ renderItem: renderItem,
150
+ horizontal: true,
151
+ pagingEnabled: true,
152
+ showsHorizontalScrollIndicator: false,
153
+ initialScrollIndex: initialIndex,
154
+ getItemLayout: (_, index) => ({
155
+ length: SW,
156
+ offset: SW * index,
157
+ index
158
+ }),
159
+ onViewableItemsChanged: handleViewableChange,
160
+ viewabilityConfig: viewabilityConfig.current,
161
+ style: styles.list
162
+ }), attachments.length > 1 && currentIndex > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
163
+ style: [styles.navBtn, styles.navLeft],
164
+ onPress: () => scrollTo(currentIndex - 1),
165
+ activeOpacity: 0.7,
166
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
167
+ style: styles.navIcon,
168
+ children: "\u2039"
169
+ })
170
+ }), attachments.length > 1 && currentIndex < attachments.length - 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
171
+ style: [styles.navBtn, styles.navRight],
172
+ onPress: () => scrollTo(currentIndex + 1),
173
+ activeOpacity: 0.7,
174
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
175
+ style: styles.navIcon,
176
+ children: "\u203A"
177
+ })
178
+ })]
179
+ }), current && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.SafeAreaView, {
180
+ style: styles.footerSafe,
181
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
182
+ style: styles.footer,
183
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
184
+ style: styles.meta,
185
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
186
+ style: styles.metaName,
187
+ numberOfLines: 1,
188
+ children: (0, _attachmentUtils.attachmentDisplayName)(current)
189
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
190
+ style: styles.metaInfo,
191
+ children: [formatBytes(current.size), current.messageTime].filter(Boolean).join(' · ')
192
+ })]
193
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
194
+ style: [styles.downloadBtn, {
195
+ backgroundColor: theme.primaryColor
196
+ }],
197
+ onPress: () => void handleDownload(),
198
+ activeOpacity: 0.85,
199
+ disabled: isDownloading,
200
+ children: isDownloading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
201
+ color: "#fff",
202
+ size: "small"
203
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
204
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
205
+ style: styles.downloadIcon,
206
+ children: "\u2193"
207
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
208
+ style: styles.downloadText,
209
+ children: downloadLabel
210
+ })]
211
+ })
212
+ })]
213
+ })
214
+ })]
215
+ })
216
+ });
217
+ }
218
+ const slide = _reactNative.StyleSheet.create({
219
+ root: {
220
+ width: SW,
221
+ flex: 1,
222
+ alignItems: 'center',
223
+ justifyContent: 'center'
224
+ },
225
+ image: {
226
+ width: SW,
227
+ height: '100%'
228
+ },
229
+ doc: {
230
+ paddingHorizontal: 32,
231
+ gap: 12
232
+ },
233
+ docName: {
234
+ color: '#fff',
235
+ fontSize: 20,
236
+ fontWeight: '600',
237
+ textAlign: 'center',
238
+ lineHeight: 28
239
+ },
240
+ docSize: {
241
+ color: 'rgba(255,255,255,0.7)',
242
+ fontSize: 15,
243
+ textAlign: 'center'
244
+ }
245
+ });
246
+ const styles = _reactNative.StyleSheet.create({
247
+ root: {
248
+ flex: 1,
249
+ backgroundColor: '#000'
250
+ },
251
+ headerSafe: {
252
+ backgroundColor: 'rgba(0,0,0,0.85)',
253
+ borderBottomWidth: _reactNative.StyleSheet.hairlineWidth,
254
+ borderBottomColor: 'rgba(255,255,255,0.15)'
255
+ },
256
+ header: {
257
+ flexDirection: 'row',
258
+ alignItems: 'center',
259
+ paddingHorizontal: 16,
260
+ paddingVertical: 10
261
+ },
262
+ headerSide: {
263
+ width: 40
264
+ },
265
+ counter: {
266
+ flex: 1,
267
+ color: '#fff',
268
+ fontSize: 16,
269
+ fontWeight: '600',
270
+ textAlign: 'center'
271
+ },
272
+ closeBtn: {
273
+ width: 40,
274
+ height: 40,
275
+ borderRadius: 20,
276
+ backgroundColor: '#fff',
277
+ alignItems: 'center',
278
+ justifyContent: 'center'
279
+ },
280
+ closeIcon: {
281
+ color: '#111',
282
+ fontSize: 18,
283
+ fontWeight: '700',
284
+ lineHeight: 20
285
+ },
286
+ listWrap: {
287
+ flex: 1
288
+ },
289
+ list: {
290
+ flex: 1
291
+ },
292
+ navBtn: {
293
+ position: 'absolute',
294
+ top: 0,
295
+ bottom: 0,
296
+ width: 56,
297
+ alignItems: 'center',
298
+ justifyContent: 'center'
299
+ },
300
+ navLeft: {
301
+ left: 0
302
+ },
303
+ navRight: {
304
+ right: 0
305
+ },
306
+ navIcon: {
307
+ color: '#fff',
308
+ fontSize: 40,
309
+ lineHeight: 44,
310
+ textShadowColor: 'rgba(0,0,0,0.8)',
311
+ textShadowOffset: {
312
+ width: 0,
313
+ height: 1
314
+ },
315
+ textShadowRadius: 6
316
+ },
317
+ footerSafe: {
318
+ backgroundColor: 'rgba(0,0,0,0.9)',
319
+ borderTopWidth: _reactNative.StyleSheet.hairlineWidth,
320
+ borderTopColor: 'rgba(255,255,255,0.15)'
321
+ },
322
+ footer: {
323
+ flexDirection: 'row',
324
+ alignItems: 'center',
325
+ paddingHorizontal: 20,
326
+ paddingVertical: 16,
327
+ gap: 12
328
+ },
329
+ meta: {
330
+ flex: 1,
331
+ gap: 4
332
+ },
333
+ metaName: {
334
+ color: '#fff',
335
+ fontSize: 15,
336
+ fontWeight: '600',
337
+ lineHeight: 20
338
+ },
339
+ metaInfo: {
340
+ color: 'rgba(255,255,255,0.7)',
341
+ fontSize: 13,
342
+ lineHeight: 18
343
+ },
344
+ downloadBtn: {
345
+ flexDirection: 'row',
346
+ alignItems: 'center',
347
+ justifyContent: 'center',
348
+ minWidth: 110,
349
+ borderRadius: 20,
350
+ paddingHorizontal: 18,
351
+ paddingVertical: 10,
352
+ gap: 6,
353
+ flexShrink: 0
354
+ },
355
+ downloadIcon: {
356
+ color: '#fff',
357
+ fontSize: 16,
358
+ fontWeight: 'bold',
359
+ lineHeight: 18
360
+ },
361
+ downloadText: {
362
+ color: '#fff',
363
+ fontSize: 14,
364
+ fontWeight: '600'
365
+ }
366
+ });
367
+ //# sourceMappingURL=AttachmentGallery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_attachmentUtils","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","width","SW","Dimensions","formatBytes","bytes","toFixed","GallerySlide","item","isVisible","loading","setLoading","useState","displayName","attachmentDisplayName","type","jsxs","View","style","slide","root","children","jsx","ActivityIndicator","color","size","StyleSheet","absoluteFill","Image","source","uri","url","image","resizeMode","onLoadStart","onLoadEnd","doc","Text","docName","numberOfLines","docSize","AttachmentGallery","attachments","initialIndex","visible","onClose","downloadLabel","onDownloadAttachment","theme","listRef","useRef","currentIndex","setCurrentIndex","isDownloading","setIsDownloading","current","useEffect","handleViewableChange","useCallback","viewableItems","index","viewabilityConfig","viewAreaCoveragePercentThreshold","scrollTo","scrollToIndex","animated","handleDownload","message","Error","Alert","alert","renderItem","counterText","length","Modal","transparent","animationType","onRequestClose","statusBarTranslucent","styles","Platform","OS","StatusBar","barStyle","backgroundColor","translucent","SafeAreaView","headerSafe","header","headerSide","counter","TouchableOpacity","closeBtn","onPress","hitSlop","closeIcon","listWrap","FlatList","ref","data","keyExtractor","a","String","id","horizontal","pagingEnabled","showsHorizontalScrollIndicator","initialScrollIndex","getItemLayout","_","offset","onViewableItemsChanged","list","navBtn","navLeft","activeOpacity","navIcon","navRight","footerSafe","footer","meta","metaName","metaInfo","messageTime","filter","Boolean","join","downloadBtn","primaryColor","disabled","Fragment","downloadIcon","downloadText","create","flex","alignItems","justifyContent","height","paddingHorizontal","gap","fontSize","fontWeight","textAlign","lineHeight","borderBottomWidth","hairlineWidth","borderBottomColor","flexDirection","paddingVertical","borderRadius","position","top","bottom","left","right","textShadowColor","textShadowOffset","textShadowRadius","borderTopWidth","borderTopColor","minWidth","flexShrink"],"sourceRoot":"..\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AM;IACboH,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjBE,UAAU,EAAE;EACd,CAAC;EACDrB,QAAQ,EAAE;IACRlG,KAAK,EAAE,uBAAuB;IAC9BoH,QAAQ,EAAE,EAAE;IACZG,UAAU,EAAE;EACd,CAAC;EACDhB,WAAW,EAAE;IACXoB,aAAa,EAAE,KAAK;IACpBZ,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBwB,QAAQ,EAAE,GAAG;IACbX,YAAY,EAAE,EAAE;IAChBX,iBAAiB,EAAE,EAAE;IACrBU,eAAe,EAAE,EAAE;IACnBT,GAAG,EAAE,CAAC;IACNsB,UAAU,EAAE;EACd,CAAC;EACD9B,YAAY,EAAE;IACZ3G,KAAK,EAAE,MAAM;IACboH,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBE,UAAU,EAAE;EACd,CAAC;EACDX,YAAY,EAAE;IACZ5G,KAAK,EAAE,MAAM;IACboH,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ChatScreen = ChatScreen;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _safeArea = require("../safeArea.js");
10
+ var _ChatSDK = require("../ChatSDK.js");
11
+ var _theme = require("../theme.js");
12
+ var _useChat = require("../useChat.js");
13
+ var _defaultAttachmentDownloader = require("../downloaders/defaultAttachmentDownloader.js");
14
+ var _MessageBubble = require("./MessageBubble.js");
15
+ var _MessageInput = require("./MessageInput.js");
16
+ var _SurveyOverlay = require("./SurveyOverlay.js");
17
+ var _AttachmentGallery = require("./AttachmentGallery.js");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
20
+ const DEFAULT_STRINGS = {
21
+ headerTitle: 'Чат',
22
+ emptyStateText: 'Начните диалог — оператор ответит в ближайшее время',
23
+ inputPlaceholder: 'Сообщение…',
24
+ sendingText: 'Отправка…',
25
+ errorRetry: 'Повторить',
26
+ surveyTitle: 'Оцените качество поддержки',
27
+ surveySubmit: 'Отправить',
28
+ surveySkip: 'Пропустить',
29
+ surveyClose: 'Закрыть',
30
+ galleryDownload: 'Скачать'
31
+ };
32
+ function ChatScreen({
33
+ onClose,
34
+ theme: themeOverride,
35
+ strings,
36
+ onPickFiles,
37
+ onDownloadAttachment
38
+ }) {
39
+ const config = _ChatSDK.ChatSDK.getSDKConfig();
40
+ const baseTheme = (0, _theme.buildTheme)(config);
41
+ const theme = themeOverride ? {
42
+ ...baseTheme,
43
+ ...themeOverride
44
+ } : baseTheme;
45
+ const listRef = (0, _react.useRef)(null);
46
+ const t = {
47
+ ...DEFAULT_STRINGS,
48
+ ...strings
49
+ };
50
+ const {
51
+ messages,
52
+ isLoading,
53
+ isSending,
54
+ error,
55
+ survey,
56
+ sendMessage,
57
+ sendCallback,
58
+ submitSurvey,
59
+ dismissSurvey,
60
+ retry
61
+ } = (0, _useChat.useChat)();
62
+ const [galleryIndex, setGalleryIndex] = (0, _react.useState)(0);
63
+ const [galleryVisible, setGalleryVisible] = (0, _react.useState)(false);
64
+ const galleryAttachments = (0, _react.useMemo)(() => messages.flatMap(m => (m.attachments ?? []).filter(a => a.id > 0).map(a => ({
65
+ ...a,
66
+ messageTime: m.time
67
+ }))), [messages]);
68
+ const openGallery = attachment => {
69
+ const idx = galleryAttachments.findIndex(a => a.id === attachment.id);
70
+ setGalleryIndex(Math.max(0, idx));
71
+ setGalleryVisible(true);
72
+ };
73
+ const showInitialLoader = isLoading && messages.length === 0;
74
+ const title = strings?.headerTitle ?? config?.widgetTitle ?? DEFAULT_STRINGS.headerTitle;
75
+ (0, _react.useEffect)(() => {
76
+ if (messages.length > 0) {
77
+ setTimeout(() => listRef.current?.scrollToEnd({
78
+ animated: true
79
+ }), 100);
80
+ }
81
+ }, [messages.length]);
82
+ const headerContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
83
+ children: [onClose && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
84
+ onPress: onClose,
85
+ style: styles.backBtn,
86
+ hitSlop: 8,
87
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
88
+ style: [styles.backIcon, {
89
+ color: theme.headerText
90
+ }],
91
+ children: "\u2039"
92
+ })
93
+ }), config?.imageLogo ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
94
+ source: {
95
+ uri: config.imageLogo
96
+ },
97
+ style: styles.logo
98
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
99
+ style: [styles.headerTitle, {
100
+ color: theme.headerText
101
+ }],
102
+ numberOfLines: 2,
103
+ ellipsizeMode: "tail",
104
+ children: title
105
+ })]
106
+ });
107
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
108
+ style: [styles.root, {
109
+ backgroundColor: theme.background
110
+ }],
111
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.KeyboardAvoidingView, {
112
+ style: styles.flex,
113
+ behavior: _reactNative.Platform.OS === 'ios' ? 'padding' : undefined,
114
+ children: [_reactNative.Platform.OS === 'ios' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.SafeAreaView, {
115
+ style: {
116
+ backgroundColor: theme.headerBg
117
+ },
118
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
119
+ style: styles.header,
120
+ children: headerContent
121
+ })
122
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
123
+ style: [styles.header, {
124
+ backgroundColor: theme.headerBg,
125
+ paddingTop: (0, _safeArea.getAndroidStatusBarHeight)() + 8
126
+ }],
127
+ children: headerContent
128
+ }), error && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
129
+ style: styles.errorBanner,
130
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
131
+ style: styles.errorText,
132
+ children: error
133
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
134
+ onPress: retry,
135
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
136
+ style: [styles.retryText, {
137
+ color: theme.primaryColor
138
+ }],
139
+ children: t.errorRetry
140
+ })
141
+ })]
142
+ }), showInitialLoader ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
143
+ style: styles.loader,
144
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
145
+ color: theme.primaryColor,
146
+ size: "large"
147
+ })
148
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.FlatList, {
149
+ ref: listRef,
150
+ style: styles.list,
151
+ data: messages,
152
+ keyExtractor: m => m.id,
153
+ renderItem: ({
154
+ item
155
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_MessageBubble.MessageBubble, {
156
+ message: item,
157
+ theme: theme,
158
+ onButtonPress: (cbData, serverId) => void sendCallback(serverId, cbData),
159
+ onAttachmentPress: openGallery
160
+ }),
161
+ contentContainerStyle: [styles.messageList, messages.length === 0 && styles.messageListEmpty],
162
+ showsVerticalScrollIndicator: false,
163
+ ListEmptyComponent: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
164
+ style: styles.emptyWrap,
165
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
166
+ style: [styles.emptyText, {
167
+ color: theme.systemText
168
+ }],
169
+ children: t.emptyStateText
170
+ })
171
+ })
172
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_MessageInput.MessageInput, {
173
+ theme: theme,
174
+ isSending: isSending,
175
+ onSend: (text, files) => void sendMessage(text, files),
176
+ onPickFiles: onPickFiles,
177
+ strings: t
178
+ })]
179
+ }), survey && /*#__PURE__*/(0, _jsxRuntime.jsx)(_SurveyOverlay.SurveyOverlay, {
180
+ config: survey,
181
+ theme: theme,
182
+ strings: t,
183
+ onSubmit: submitSurvey,
184
+ onDismiss: dismissSurvey
185
+ }), galleryAttachments.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_AttachmentGallery.AttachmentGallery, {
186
+ attachments: galleryAttachments,
187
+ initialIndex: galleryIndex,
188
+ visible: galleryVisible,
189
+ onClose: () => setGalleryVisible(false),
190
+ downloadLabel: t.galleryDownload,
191
+ onDownloadAttachment: onDownloadAttachment ?? _defaultAttachmentDownloader.defaultAttachmentDownloader,
192
+ theme: theme
193
+ })]
194
+ });
195
+ }
196
+ const styles = _reactNative.StyleSheet.create({
197
+ root: {
198
+ flex: 1
199
+ },
200
+ flex: {
201
+ flex: 1
202
+ },
203
+ list: {
204
+ flex: 1
205
+ },
206
+ header: {
207
+ flexDirection: 'row',
208
+ alignItems: 'center',
209
+ paddingHorizontal: 16,
210
+ paddingBottom: 14,
211
+ gap: 10,
212
+ elevation: 2,
213
+ shadowColor: '#000',
214
+ shadowOffset: {
215
+ width: 0,
216
+ height: 1
217
+ },
218
+ shadowOpacity: 0.12,
219
+ shadowRadius: 3
220
+ },
221
+ backBtn: {
222
+ padding: 4,
223
+ flexShrink: 0
224
+ },
225
+ backIcon: {
226
+ fontSize: 28,
227
+ lineHeight: 28,
228
+ fontWeight: '300'
229
+ },
230
+ logo: {
231
+ width: 32,
232
+ height: 32,
233
+ borderRadius: 16,
234
+ flexShrink: 0
235
+ },
236
+ headerTitle: {
237
+ fontSize: 17,
238
+ fontWeight: '600',
239
+ flex: 1,
240
+ flexShrink: 1,
241
+ minWidth: 0
242
+ },
243
+ messageList: {
244
+ paddingTop: 12,
245
+ paddingBottom: 8,
246
+ flexGrow: 1
247
+ },
248
+ messageListEmpty: {
249
+ justifyContent: 'center'
250
+ },
251
+ loader: {
252
+ flex: 1,
253
+ alignItems: 'center',
254
+ justifyContent: 'center'
255
+ },
256
+ emptyWrap: {
257
+ alignItems: 'center',
258
+ justifyContent: 'center',
259
+ paddingHorizontal: 32,
260
+ paddingVertical: 60
261
+ },
262
+ emptyText: {
263
+ fontSize: 14,
264
+ textAlign: 'center',
265
+ lineHeight: 20
266
+ },
267
+ errorBanner: {
268
+ flexDirection: 'row',
269
+ alignItems: 'center',
270
+ justifyContent: 'space-between',
271
+ backgroundColor: '#fff3f3',
272
+ paddingHorizontal: 16,
273
+ paddingVertical: 8,
274
+ gap: 8
275
+ },
276
+ errorText: {
277
+ color: '#cc2222',
278
+ fontSize: 13,
279
+ flex: 1
280
+ },
281
+ retryText: {
282
+ fontSize: 13,
283
+ fontWeight: '500'
284
+ }
285
+ });
286
+ //# sourceMappingURL=ChatScreen.js.map