@samparkchat/sampark-web-chat 0.0.1 → 0.0.2

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 (88) hide show
  1. package/package.json +5 -2
  2. package/sampark/sampark-chat/App.js +2 -5
  3. package/sampark/sampark-chat/assets/beap/call-tone.mp3 +0 -0
  4. package/sampark/sampark-chat/components/Actions/GroupMessageActions.d.ts +19 -0
  5. package/sampark/sampark-chat/components/Actions/GroupMessageActions.js +183 -0
  6. package/sampark/sampark-chat/components/{MessageActions.js → Actions/MessageActions.js} +8 -2
  7. package/sampark/sampark-chat/components/AttachmentFileSharing.d.ts +17 -0
  8. package/sampark/sampark-chat/components/AttachmentFileSharing.js +219 -0
  9. package/sampark/sampark-chat/components/AttachmentGroupFileSharing.d.ts +17 -0
  10. package/sampark/sampark-chat/components/AttachmentGroupFileSharing.js +213 -0
  11. package/sampark/sampark-chat/components/GroupVideoCall.d.ts +18 -0
  12. package/sampark/sampark-chat/components/GroupVideoCall.js +2091 -0
  13. package/sampark/sampark-chat/components/Headers/ChatHeader.d.ts +4 -0
  14. package/sampark/sampark-chat/components/Headers/ChatHeader.js +123 -88
  15. package/sampark/sampark-chat/components/Headers/GroupChatHeader.d.ts +5 -0
  16. package/sampark/sampark-chat/components/Headers/GroupChatHeader.js +81 -58
  17. package/sampark/sampark-chat/components/Headers/HeaderPanel/CallHistory.d.ts +20 -0
  18. package/sampark/sampark-chat/components/Headers/HeaderPanel/CallHistory.js +284 -0
  19. package/sampark/sampark-chat/components/Headers/HeaderPanel/GroupList.d.ts +38 -0
  20. package/sampark/sampark-chat/components/Headers/HeaderPanel/GroupList.js +283 -0
  21. package/sampark/sampark-chat/components/Headers/HeaderPanel/UserList.d.ts +33 -0
  22. package/sampark/sampark-chat/components/Headers/HeaderPanel/UserList.js +80 -0
  23. package/sampark/sampark-chat/components/Headers/SamparkHeader.d.ts +5 -4
  24. package/sampark/sampark-chat/components/Headers/SamparkHeader.js +58 -154
  25. package/sampark/sampark-chat/components/IncomingCallModal.d.ts +14 -0
  26. package/sampark/sampark-chat/components/IncomingCallModal.js +222 -0
  27. package/sampark/sampark-chat/components/InitiateCallModal.d.ts +13 -0
  28. package/sampark/sampark-chat/components/InitiateCallModal.js +250 -0
  29. package/sampark/sampark-chat/components/MentionList.d.ts +19 -0
  30. package/sampark/sampark-chat/components/MentionList.js +107 -0
  31. package/sampark/sampark-chat/components/NotificationBanner.d.ts +7 -0
  32. package/sampark/sampark-chat/components/NotificationBanner.js +193 -0
  33. package/sampark/sampark-chat/components/VideoCall.d.ts +15 -0
  34. package/sampark/sampark-chat/components/VideoCall.js +766 -0
  35. package/sampark/sampark-chat/components/bottomsheets/GroupOptionBottomSheet.js +47 -117
  36. package/sampark/sampark-chat/components/lists/CommonList.d.ts +30 -0
  37. package/sampark/sampark-chat/components/lists/CommonList.js +357 -0
  38. package/sampark/sampark-chat/components/lists/ParticipantList.js +29 -111
  39. package/sampark/sampark-chat/components/lists/UserInfo.d.ts +12 -0
  40. package/sampark/sampark-chat/components/lists/UserInfo.js +211 -0
  41. package/sampark/sampark-chat/components/lists/ViewParticipents.d.ts +1 -0
  42. package/sampark/sampark-chat/components/lists/ViewParticipents.js +295 -231
  43. package/sampark/sampark-chat/components/models/ReactionModal.d.ts +22 -0
  44. package/sampark/sampark-chat/components/models/ReactionModal.js +118 -0
  45. package/sampark/sampark-chat/firebaseConfig.d.ts +1 -0
  46. package/sampark/sampark-chat/firebaseConfig.js +20 -0
  47. package/sampark/sampark-chat/index.d.ts +1 -5
  48. package/sampark/sampark-chat/index.js +13 -17
  49. package/sampark/sampark-chat/models/ConfirmActionModal.d.ts +13 -0
  50. package/sampark/sampark-chat/models/ConfirmActionModal.js +73 -0
  51. package/sampark/sampark-chat/screens/PeerChatScreen.d.ts +9 -1
  52. package/sampark/sampark-chat/screens/PeerChatScreen.js +534 -287
  53. package/sampark/sampark-chat/screens/SamparkchatScreen.js +1322 -199
  54. package/sampark/sampark-chat/screens/groupChatScreen.d.ts +19 -1
  55. package/sampark/sampark-chat/screens/groupChatScreen.js +857 -88
  56. package/sampark/sampark-chat/sdk/client/GroupCall.d.ts +23 -0
  57. package/sampark/sampark-chat/sdk/client/GroupCall.js +279 -0
  58. package/sampark/sampark-chat/sdk/client/Groupchat.d.ts +76 -2
  59. package/sampark/sampark-chat/sdk/client/Groupchat.js +194 -23
  60. package/sampark/sampark-chat/sdk/client/JanusClient.d.ts +26 -0
  61. package/sampark/sampark-chat/sdk/client/JanusClient.js +300 -0
  62. package/sampark/sampark-chat/sdk/client/PeerCall.d.ts +13 -0
  63. package/sampark/sampark-chat/sdk/client/PeerCall.js +29 -0
  64. package/sampark/sampark-chat/sdk/client/PeerChat.d.ts +69 -3
  65. package/sampark/sampark-chat/sdk/client/PeerChat.js +194 -7
  66. package/sampark/sampark-chat/sdk/client/SamparkChat.d.ts +3 -1
  67. package/sampark/sampark-chat/sdk/client/SamparkChat.js +6 -4
  68. package/sampark/sampark-chat/sdk/interface/SamparkGroupCallService.d.ts +7 -0
  69. package/sampark/sampark-chat/sdk/interface/SamparkGroupCallService.js +1 -0
  70. package/sampark/sampark-chat/sdk/interface/SamparkGroupChatService.d.ts +5 -1
  71. package/sampark/sampark-chat/sdk/interface/SamparkPeerCallService.d.ts +7 -0
  72. package/sampark/sampark-chat/sdk/interface/SamparkPeerCallService.js +1 -0
  73. package/sampark/sampark-chat/sdk/interface/SamparkPeerChatService.d.ts +1 -1
  74. package/sampark/sampark-chat/services/Common.d.ts +9 -2
  75. package/sampark/sampark-chat/services/Common.js +20 -0
  76. package/sampark/sampark-chat/services/DateFormat.d.ts +2 -0
  77. package/sampark/sampark-chat/services/DateFormat.js +56 -0
  78. package/sampark/sampark-chat/services/FirebaseMessaging.d.ts +2 -0
  79. package/sampark/sampark-chat/services/FirebaseMessaging.js +88 -0
  80. package/sampark/sampark-chat/theme/colors.d.ts +23 -0
  81. package/sampark/sampark-chat/theme/colors.js +27 -0
  82. package/sampark/sampark-chat/theme/fonts.d.ts +19 -0
  83. package/sampark/sampark-chat/theme/fonts.js +44 -0
  84. package/sampark/sampark-chat/theme/icons.d.ts +217 -0
  85. package/sampark/sampark-chat/theme/icons.js +55 -0
  86. package/sampark/sampark-chat/models/deleteModel.d.ts +0 -8
  87. package/sampark/sampark-chat/models/deleteModel.js +0 -63
  88. /package/sampark/sampark-chat/components/{MessageActions.d.ts → Actions/MessageActions.d.ts} +0 -0
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@samparkchat/sampark-web-chat",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "sampark/sampark-web-chat/index.js",
5
5
  "types": "sampark/sampark-web-chat/index.d.ts",
6
6
  "private": false,
7
7
  "dependencies": {
8
+ "@fontsource/poppins": "^5.2.6",
8
9
  "@fortawesome/fontawesome-svg-core": "^7.0.0",
9
10
  "@fortawesome/free-solid-svg-icons": "^7.0.0",
10
11
  "@fortawesome/react-fontawesome": "^0.2.3",
12
+ "@samparkchat/sampark-web-chat": "^0.0.1",
11
13
  "@testing-library/dom": "^10.4.1",
12
14
  "@testing-library/jest-dom": "^6.6.4",
13
15
  "@testing-library/react": "^16.3.0",
@@ -15,6 +17,7 @@
15
17
  "axios": "^1.7.7",
16
18
  "crypto-js": "^4.2.0",
17
19
  "emoji-picker-react": "^4.13.2",
20
+ "firebase": "^12.2.1",
18
21
  "react": ">=16.8.0",
19
22
  "react-dom": ">=16.8.0",
20
23
  "react-scripts": "5.0.1",
@@ -24,7 +27,7 @@
24
27
  "scripts": {
25
28
  "start": "react-scripts start",
26
29
  "build": "tsc && npm run copy-assets",
27
- "copy-assets": "copyfiles -u 1 src/assets/**/* sampark/sampark-web-chat",
30
+ "copy-assets": "copyfiles -u 1 src/assets/**/* sampark/sampark-chat",
28
31
  "prepublishOnly": "npm run build",
29
32
  "test": "react-scripts test",
30
33
  "eject": "react-scripts eject",
@@ -3,9 +3,6 @@ import './App.css';
3
3
  import SamparkChat from './sdk/client/SamparkChat';
4
4
  import SamparkChatProvider from './screens/SamparkChatProvider';
5
5
  import SamparkChatScreen from './screens/SamparkchatScreen';
6
- // import { SamparkChatProvider, SamparkChatScreen } from './sampark/sampark-chat';
7
- // import SamparkChatProvider from './screens/SamparkChatProvider';
8
- // import SamparkChatScreen from './screens/SamparkchatScreen';
9
6
  // import { SamparkChatProvider } from './sampark/sampark-chat/screens/SamparkChatProvider';
10
7
  // import SamparkChatScreen from './sampark/sampark-chat/screens/SamparkchatScreen';
11
8
  function App() {
@@ -19,8 +16,8 @@ function App() {
19
16
  { user_id: 'user004', user_name: 'Sachin', profile_pic: '' },
20
17
  { user_id: 'user005', user_name: 'Deepak', profile_pic: '' },
21
18
  ]), userList = _d[0], setUserList = _d[1];
22
- var appId = 'vEGPyfeTjxTer69G2LvXwkJNjksUmwG0';
23
- var secretKey = 'erGQjMJoihMiDxTofogn0U9ydSfgFxtSzPceawg4Sv2oHuSAL8AdVcp';
19
+ var appId = 'INmD4HqR1yEs6f0NRwecDZoAyc9geghk';
20
+ var secretKey = 'ux7YMNSeFzKv6a1HA2aCDnN7Cpwlt7X1ZFiAFXiu7ZcRq8Wqb3b5agc';
24
21
  //Staging
25
22
  // const appId = 'FZReo0rOJX7TDH65feuZ9jysumIY9ftU';
26
23
  // const secretKey = '1YYnT3yit6fmLpDbhKB5pooJx2QdgBo2HymZ5dMoxjLJZRY8eVBfJVK';
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ interface GroupMessageActionsProps {
3
+ showEmojiPicker: boolean;
4
+ showMenu: boolean;
5
+ onEmojiClick: () => void;
6
+ onMenuClick: () => void;
7
+ onEmojiSelect: (emoji: {
8
+ emoji: string;
9
+ } | any) => void;
10
+ onCloseEmojiPicker: () => void;
11
+ onCloseMenu: () => void;
12
+ message: string;
13
+ position?: 'left' | 'right';
14
+ canEdit?: boolean;
15
+ onEditClick?: () => void;
16
+ onReplyClick?: () => void;
17
+ }
18
+ declare const GroupMessageActions: React.FC<GroupMessageActionsProps>;
19
+ export default GroupMessageActions;
@@ -0,0 +1,183 @@
1
+ import React from 'react';
2
+ import EmojiPicker from 'emoji-picker-react';
3
+ var GroupMessageActions = function (_a) {
4
+ var _b;
5
+ var showEmojiPicker = _a.showEmojiPicker, showMenu = _a.showMenu, onEmojiClick = _a.onEmojiClick, onMenuClick = _a.onMenuClick, onEmojiSelect = _a.onEmojiSelect, onCloseEmojiPicker = _a.onCloseEmojiPicker, onCloseMenu = _a.onCloseMenu, message = _a.message, _c = _a.position, position = _c === void 0 ? 'right' : _c, _d = _a.canEdit, canEdit = _d === void 0 ? false : _d, onEditClick = _a.onEditClick, onReplyClick = _a.onReplyClick;
6
+ var _e = React.useState(false), copied = _e[0], setCopied = _e[1];
7
+ var handleCopy = function () {
8
+ if (navigator && navigator.clipboard) {
9
+ navigator.clipboard.writeText(message);
10
+ setCopied(true);
11
+ setTimeout(function () { return setCopied(false); }, 1200);
12
+ }
13
+ };
14
+ return (React.createElement("div", { className: "chat-message-icons", style: (_b = {
15
+ display: 'flex',
16
+ flexDirection: 'row',
17
+ alignItems: 'center',
18
+ gap: '7px',
19
+ position: 'absolute'
20
+ },
21
+ _b[position === 'right' ? 'right' : 'left'] = '-60px',
22
+ _b.top = '50%',
23
+ _b.transform = 'translateY(-50%)',
24
+ _b.opacity = 0,
25
+ _b.pointerEvents = 'none',
26
+ _b.zIndex = 10,
27
+ _b.minWidth = '80px',
28
+ _b.transition = 'opacity 0.2s',
29
+ _b) },
30
+ React.createElement("span", { style: {
31
+ display: 'flex',
32
+ alignItems: 'center',
33
+ justifyContent: 'center',
34
+ width: '30px',
35
+ height: '30px',
36
+ background: '#fff',
37
+ borderRadius: '50%',
38
+ boxShadow: '0 2px 8px rgba(0,0,0,0.10)',
39
+ border: '1px solid #eee',
40
+ } },
41
+ React.createElement("button", { style: {
42
+ background: 'none',
43
+ border: 'none',
44
+ padding: 0,
45
+ cursor: 'pointer',
46
+ color: '#888',
47
+ fontSize: '20px',
48
+ display: 'flex',
49
+ alignItems: 'center',
50
+ justifyContent: 'center',
51
+ }, onClick: onEmojiClick },
52
+ React.createElement("i", { className: "fas fa-smile" }))),
53
+ React.createElement("span", { style: {
54
+ display: 'flex',
55
+ alignItems: 'center',
56
+ justifyContent: 'center',
57
+ width: '30px',
58
+ height: '30px',
59
+ background: '#fff',
60
+ borderRadius: '50%',
61
+ boxShadow: '0 2px 8px rgba(0,0,0,0.10)',
62
+ border: '1px solid #eee',
63
+ } },
64
+ React.createElement("button", { style: {
65
+ background: 'none',
66
+ border: 'none',
67
+ padding: 0,
68
+ cursor: 'pointer',
69
+ color: '#888',
70
+ fontSize: '20px',
71
+ display: 'flex',
72
+ alignItems: 'center',
73
+ justifyContent: 'center',
74
+ }, onClick: onMenuClick },
75
+ React.createElement("i", { className: "fas fa-ellipsis-h" }))),
76
+ showEmojiPicker && (React.createElement("div", { className: "emoji-picker-container", style: {
77
+ position: 'absolute',
78
+ zIndex: 9999,
79
+ backgroundColor: 'white',
80
+ borderRadius: '12px',
81
+ boxShadow: '0 4px 20px rgba(0,0,0,0.15)',
82
+ border: '1px solid #e0e0e0',
83
+ } },
84
+ React.createElement(EmojiPicker, { onEmojiClick: function (emojiData) {
85
+ var _a;
86
+ var emojiId = emojiData.unified; // unique
87
+ var rawType = ((_a = emojiData.names) === null || _a === void 0 ? void 0 : _a[0]) || "unknown"; // no slug in type
88
+ var emojiType = rawType.toLowerCase().replace(/\s+/g, "_");
89
+ onEmojiSelect({ emojiId: emojiId, emojiType: emojiType });
90
+ }, width: 300, height: 300, previewConfig: { showPreview: false }, searchDisabled: true }))),
91
+ showMenu && (React.createElement("div", { className: "message-menu-container", style: {
92
+ position: 'absolute',
93
+ zIndex: 9999,
94
+ background: '#fff',
95
+ borderRadius: '16px',
96
+ boxShadow: '0 4px 20px rgba(0,0,0,0.15)',
97
+ border: '1px solid #e0e0e0',
98
+ minWidth: '170px',
99
+ padding: '12px 0',
100
+ display: 'flex',
101
+ flexDirection: 'column',
102
+ gap: '2px',
103
+ } },
104
+ React.createElement("button", { style: {
105
+ background: 'none',
106
+ border: 'none',
107
+ width: '100%',
108
+ display: 'flex',
109
+ alignItems: 'center',
110
+ gap: '14px',
111
+ padding: '12px 24px',
112
+ fontSize: '16px',
113
+ color: '#444',
114
+ cursor: 'pointer',
115
+ }, onClick: function () {
116
+ onCloseMenu();
117
+ onReplyClick === null || onReplyClick === void 0 ? void 0 : onReplyClick();
118
+ } },
119
+ React.createElement("i", { className: "fas fa-reply", style: { fontSize: '18px', color: '#888' } }),
120
+ " Reply"),
121
+ React.createElement("button", { style: {
122
+ background: 'none',
123
+ border: 'none',
124
+ width: '100%',
125
+ display: 'flex',
126
+ alignItems: 'center',
127
+ gap: '14px',
128
+ padding: '12px 24px',
129
+ fontSize: '16px',
130
+ color: copied ? '#007bff' : '#444',
131
+ cursor: 'pointer',
132
+ position: 'relative',
133
+ }, onClick: handleCopy },
134
+ React.createElement("i", { className: "fas fa-copy", style: { fontSize: '18px', color: copied ? '#007bff' : '#888' } }),
135
+ " ",
136
+ copied ? 'Copied' : 'Copy'),
137
+ canEdit && (React.createElement("button", { style: {
138
+ background: 'none',
139
+ border: 'none',
140
+ width: '100%',
141
+ display: 'flex',
142
+ alignItems: 'center',
143
+ gap: '14px',
144
+ padding: '12px 24px',
145
+ fontSize: '16px',
146
+ color: '#444',
147
+ cursor: 'pointer',
148
+ }, onClick: function () {
149
+ onCloseMenu();
150
+ onEditClick && onEditClick();
151
+ } },
152
+ React.createElement("i", { className: "fas fa-pencil-alt", style: { fontSize: '18px', color: '#888' } }),
153
+ " Edit")),
154
+ React.createElement("button", { style: {
155
+ background: 'none',
156
+ border: 'none',
157
+ width: '100%',
158
+ display: 'flex',
159
+ alignItems: 'center',
160
+ gap: '14px',
161
+ padding: '12px 24px',
162
+ fontSize: '16px',
163
+ color: '#444',
164
+ cursor: 'pointer',
165
+ } },
166
+ React.createElement("i", { className: "fas fa-info-circle", style: { fontSize: '18px', color: '#888' } }),
167
+ " Info"),
168
+ React.createElement("button", { style: {
169
+ background: 'none',
170
+ border: 'none',
171
+ width: '100%',
172
+ display: 'flex',
173
+ alignItems: 'center',
174
+ gap: '14px',
175
+ padding: '12px 24px',
176
+ fontSize: '16px',
177
+ color: '#444',
178
+ cursor: 'pointer',
179
+ } },
180
+ React.createElement("i", { className: "fas fa-trash", style: { fontSize: '18px', color: '#888' } }),
181
+ " Delete")))));
182
+ };
183
+ export default GroupMessageActions;
@@ -81,7 +81,13 @@ var MessageActions = function (_a) {
81
81
  boxShadow: '0 4px 20px rgba(0,0,0,0.15)',
82
82
  border: '1px solid #e0e0e0',
83
83
  } },
84
- React.createElement(EmojiPicker, { onEmojiClick: onEmojiSelect, width: 300, height: 300, previewConfig: { showPreview: false }, searchDisabled: true, skinTonesDisabled: false, autoFocusSearch: false }))),
84
+ React.createElement(EmojiPicker, { onEmojiClick: function (emojiData) {
85
+ var _a;
86
+ var emojiId = emojiData.unified; // unique
87
+ var rawType = ((_a = emojiData.names) === null || _a === void 0 ? void 0 : _a[0]) || "unknown"; // no slug in type
88
+ var emojiType = rawType.toLowerCase().replace(/\s+/g, "_");
89
+ onEmojiSelect({ emojiId: emojiId, emojiType: emojiType });
90
+ }, width: 300, height: 300, previewConfig: { showPreview: false }, searchDisabled: true }))),
85
91
  showMenu && (React.createElement("div", { className: "message-menu-container", style: {
86
92
  position: 'absolute',
87
93
  zIndex: 9999,
@@ -108,7 +114,7 @@ var MessageActions = function (_a) {
108
114
  cursor: 'pointer',
109
115
  }, onClick: function () {
110
116
  onCloseMenu();
111
- onReplyClick === null || onReplyClick === void 0 ? void 0 : onReplyClick(); // NEW
117
+ onReplyClick === null || onReplyClick === void 0 ? void 0 : onReplyClick();
112
118
  } },
113
119
  React.createElement("i", { className: "fas fa-reply", style: { fontSize: '18px', color: '#888' } }),
114
120
  " Reply"),
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ interface AttachmentFileSharingProps {
3
+ isVisible: boolean;
4
+ onClose: () => void;
5
+ onAttachImage?: (files?: FileList) => void;
6
+ onAttachVideo?: (files?: FileList) => void;
7
+ onAttachAudio?: (files?: FileList) => void;
8
+ onAttachFile?: (files?: FileList) => void;
9
+ client?: any;
10
+ roomId?: string;
11
+ userId?: string;
12
+ userName?: string;
13
+ uploadSource?: string;
14
+ onFileUpload?: (fileId: string) => void;
15
+ }
16
+ declare const AttachmentFileSharing: React.FC<AttachmentFileSharingProps>;
17
+ export default AttachmentFileSharing;
@@ -0,0 +1,219 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import React, { useRef } from 'react';
38
+ var AttachmentFileSharing = function (_a) {
39
+ var isVisible = _a.isVisible, onClose = _a.onClose, onAttachImage = _a.onAttachImage, onAttachVideo = _a.onAttachVideo, onAttachAudio = _a.onAttachAudio, onAttachFile = _a.onAttachFile, client = _a.client, roomId = _a.roomId, userId = _a.userId, userName = _a.userName, _b = _a.uploadSource, uploadSource = _b === void 0 ? 'peer_chat' : _b, onFileUpload = _a.onFileUpload;
40
+ var imageInputRef = useRef(null);
41
+ var videoInputRef = useRef(null);
42
+ var audioInputRef = useRef(null);
43
+ var fileInputRef = useRef(null);
44
+ var handleFileUpload = function (file) { return __awaiter(void 0, void 0, void 0, function () {
45
+ var uploadResult, error_1;
46
+ return __generator(this, function (_a) {
47
+ switch (_a.label) {
48
+ case 0:
49
+ if (!client || !roomId || !userId || !userName) {
50
+ console.error('Missing required data for file upload');
51
+ alert('Cannot upload file: Missing required information');
52
+ return [2 /*return*/];
53
+ }
54
+ _a.label = 1;
55
+ case 1:
56
+ _a.trys.push([1, 6, , 7]);
57
+ console.log('[AttachmentFileSharing] uploading file:', file.name);
58
+ uploadResult = void 0;
59
+ if (!(client.peerChat && uploadSource === 'peer_chat')) return [3 /*break*/, 3];
60
+ return [4 /*yield*/, client.peerChat.uploadFile(file, roomId, userId, userName, "file_".concat(Date.now()), uploadSource)];
61
+ case 2:
62
+ uploadResult = _a.sent();
63
+ return [3 /*break*/, 5];
64
+ case 3:
65
+ if (!(client.groupchat && uploadSource === 'group_chat')) return [3 /*break*/, 5];
66
+ return [4 /*yield*/, client.groupchat.uploadFile(file, roomId, userId, userName, "file_".concat(Date.now()), uploadSource)];
67
+ case 4:
68
+ uploadResult = _a.sent();
69
+ _a.label = 5;
70
+ case 5:
71
+ if (uploadResult) {
72
+ console.log('[AttachmentFileSharing] file uploaded successfully:', uploadResult);
73
+ onFileUpload === null || onFileUpload === void 0 ? void 0 : onFileUpload(uploadResult.fileId);
74
+ onClose();
75
+ }
76
+ else {
77
+ console.error('[AttachmentFileSharing] file upload failed');
78
+ alert('Failed to upload file. Please try again.');
79
+ }
80
+ return [3 /*break*/, 7];
81
+ case 6:
82
+ error_1 = _a.sent();
83
+ console.error('[AttachmentFileSharing] error:', error_1);
84
+ alert('Failed to upload file. Please try again.');
85
+ return [3 /*break*/, 7];
86
+ case 7: return [2 /*return*/];
87
+ }
88
+ });
89
+ }); };
90
+ var handleFileSelection = function (files) {
91
+ if (!files || files.length === 0)
92
+ return;
93
+ var file = files[0];
94
+ var maxSize = 10 * 1024 * 1024; // 10MB
95
+ if (file.size > maxSize) {
96
+ alert('File size must be less than 10MB');
97
+ return;
98
+ }
99
+ handleFileUpload(file);
100
+ };
101
+ if (!isVisible)
102
+ return null;
103
+ var styles = {
104
+ attachmentMenuItem: {
105
+ display: 'flex',
106
+ alignItems: 'center',
107
+ padding: '12px 16px',
108
+ cursor: 'pointer',
109
+ borderRadius: '8px',
110
+ transition: 'background-color 0.2s'
111
+ },
112
+ attachmentIcon: {
113
+ width: '32px',
114
+ height: '32px',
115
+ backgroundColor: '#6c5ce7',
116
+ borderRadius: '8px',
117
+ display: 'flex',
118
+ alignItems: 'center',
119
+ justifyContent: 'center',
120
+ marginRight: '12px'
121
+ },
122
+ iconStyle: {
123
+ color: 'white',
124
+ fontSize: '16px'
125
+ },
126
+ attachmentText: {
127
+ fontSize: '16px',
128
+ color: '#333'
129
+ }
130
+ };
131
+ return (React.createElement("div", { className: "attachment-menu", style: {
132
+ position: 'absolute',
133
+ bottom: '70px',
134
+ left: '20px',
135
+ backgroundColor: 'white',
136
+ borderRadius: '12px',
137
+ boxShadow: '0 4px 12px rgba(0,0,0,0.15)',
138
+ padding: '8px',
139
+ minWidth: '200px',
140
+ zIndex: 1000
141
+ } },
142
+ React.createElement("div", { style: styles.attachmentMenuItem, onMouseEnter: function (e) { return e.currentTarget.style.backgroundColor = '#f5f5f5'; }, onMouseLeave: function (e) { return e.currentTarget.style.backgroundColor = 'transparent'; }, onClick: function () {
143
+ var _a;
144
+ (_a = imageInputRef.current) === null || _a === void 0 ? void 0 : _a.click();
145
+ } },
146
+ React.createElement("div", { style: styles.attachmentIcon },
147
+ React.createElement("i", { className: "fas fa-image", style: styles.iconStyle })),
148
+ React.createElement("span", { style: styles.attachmentText }, "Attach Image")),
149
+ React.createElement("div", { style: styles.attachmentMenuItem, onMouseEnter: function (e) { return e.currentTarget.style.backgroundColor = '#f5f5f5'; }, onMouseLeave: function (e) { return e.currentTarget.style.backgroundColor = 'transparent'; }, onClick: function () {
150
+ var _a;
151
+ (_a = videoInputRef.current) === null || _a === void 0 ? void 0 : _a.click();
152
+ } },
153
+ React.createElement("div", { style: styles.attachmentIcon },
154
+ React.createElement("i", { className: "fas fa-video", style: styles.iconStyle })),
155
+ React.createElement("span", { style: styles.attachmentText }, "Attach Video")),
156
+ React.createElement("div", { style: styles.attachmentMenuItem, onMouseEnter: function (e) { return e.currentTarget.style.backgroundColor = '#f5f5f5'; }, onMouseLeave: function (e) { return e.currentTarget.style.backgroundColor = 'transparent'; }, onClick: function () {
157
+ var _a;
158
+ (_a = audioInputRef.current) === null || _a === void 0 ? void 0 : _a.click();
159
+ } },
160
+ React.createElement("div", { style: styles.attachmentIcon },
161
+ React.createElement("i", { className: "fas fa-play-circle", style: styles.iconStyle })),
162
+ React.createElement("span", { style: styles.attachmentText }, "Attach Audio")),
163
+ React.createElement("div", { style: styles.attachmentMenuItem, onMouseEnter: function (e) { return e.currentTarget.style.backgroundColor = '#f5f5f5'; }, onMouseLeave: function (e) { return e.currentTarget.style.backgroundColor = 'transparent'; }, onClick: function () {
164
+ var _a;
165
+ (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click();
166
+ } },
167
+ React.createElement("div", { style: styles.attachmentIcon },
168
+ React.createElement("i", { className: "fas fa-file-alt", style: styles.iconStyle })),
169
+ React.createElement("span", { style: styles.attachmentText }, "Attach File")),
170
+ React.createElement("input", { type: "file", ref: imageInputRef, accept: "image/*", style: { display: 'none' }, onChange: function (e) {
171
+ var files = e.target.files;
172
+ if (onAttachImage) {
173
+ onAttachImage(files || undefined);
174
+ onClose();
175
+ }
176
+ else {
177
+ handleFileSelection(files);
178
+ }
179
+ if (e.target)
180
+ e.target.value = '';
181
+ } }),
182
+ React.createElement("input", { type: "file", ref: videoInputRef, accept: "video/*", style: { display: 'none' }, onChange: function (e) {
183
+ var files = e.target.files;
184
+ if (onAttachVideo) {
185
+ onAttachVideo(files || undefined);
186
+ onClose();
187
+ }
188
+ else {
189
+ handleFileSelection(files);
190
+ }
191
+ if (e.target)
192
+ e.target.value = '';
193
+ } }),
194
+ React.createElement("input", { type: "file", ref: audioInputRef, accept: "audio/*", style: { display: 'none' }, onChange: function (e) {
195
+ var files = e.target.files;
196
+ if (onAttachAudio) {
197
+ onAttachAudio(files || undefined);
198
+ onClose();
199
+ }
200
+ else {
201
+ handleFileSelection(files);
202
+ }
203
+ if (e.target)
204
+ e.target.value = '';
205
+ } }),
206
+ React.createElement("input", { type: "file", ref: fileInputRef, style: { display: 'none' }, onChange: function (e) {
207
+ var files = e.target.files;
208
+ if (onAttachFile) {
209
+ onAttachFile(files || undefined);
210
+ onClose();
211
+ }
212
+ else {
213
+ handleFileSelection(files);
214
+ }
215
+ if (e.target)
216
+ e.target.value = '';
217
+ } })));
218
+ };
219
+ export default AttachmentFileSharing;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ interface AttachmentGroupFileSharingProps {
3
+ isVisible: boolean;
4
+ onClose: () => void;
5
+ onAttachImage?: (files?: FileList) => void;
6
+ onAttachVideo?: (files?: FileList) => void;
7
+ onAttachAudio?: (files?: FileList) => void;
8
+ onAttachFile?: (files?: FileList) => void;
9
+ client?: any;
10
+ roomId?: string;
11
+ userId?: string;
12
+ userName?: string;
13
+ uploadSource?: string;
14
+ onFileUpload?: (fileId: string) => void;
15
+ }
16
+ declare const AttachmentGroupFileSharing: React.FC<AttachmentGroupFileSharingProps>;
17
+ export default AttachmentGroupFileSharing;