ajaxter-chat 2.0.1 → 3.0.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 (94) hide show
  1. package/README.md +119 -128
  2. package/dist/components/BlockList/index.d.ts +10 -0
  3. package/dist/components/BlockList/index.js +33 -0
  4. package/dist/components/CallScreen/index.d.ts +13 -0
  5. package/dist/components/CallScreen/index.js +48 -0
  6. package/dist/components/ChatScreen/index.d.ts +10 -3
  7. package/dist/components/ChatScreen/index.js +142 -57
  8. package/dist/components/ChatWidget.js +192 -98
  9. package/dist/components/EmojiPicker/index.d.ts +8 -0
  10. package/dist/components/EmojiPicker/index.js +18 -0
  11. package/dist/components/HomeScreen/index.d.ts +2 -3
  12. package/dist/components/HomeScreen/index.js +25 -41
  13. package/dist/components/MaintenanceView/index.d.ts +0 -1
  14. package/dist/components/MaintenanceView/index.js +4 -6
  15. package/dist/components/RecentChatsScreen/index.d.ts +4 -3
  16. package/dist/components/RecentChatsScreen/index.js +7 -37
  17. package/dist/components/Tabs/BottomTabs.d.ts +1 -1
  18. package/dist/components/Tabs/BottomTabs.js +25 -20
  19. package/dist/components/TicketScreen/index.d.ts +3 -3
  20. package/dist/components/TicketScreen/index.js +39 -56
  21. package/dist/components/UserListScreen/index.d.ts +2 -4
  22. package/dist/components/UserListScreen/index.js +33 -62
  23. package/dist/config/index.d.ts +3 -3
  24. package/dist/config/index.js +18 -26
  25. package/dist/hooks/useChat.d.ts +8 -3
  26. package/dist/hooks/useChat.js +22 -18
  27. package/dist/hooks/useRemoteConfig.d.ts +6 -0
  28. package/dist/hooks/useRemoteConfig.js +22 -0
  29. package/dist/hooks/useWebRTC.d.ts +11 -0
  30. package/dist/hooks/useWebRTC.js +112 -0
  31. package/dist/index.d.ts +9 -5
  32. package/dist/index.js +8 -4
  33. package/dist/types/index.d.ts +62 -21
  34. package/dist/utils/chat.d.ts +13 -0
  35. package/dist/utils/chat.js +62 -0
  36. package/dist/utils/theme.d.ts +3 -1
  37. package/dist/utils/theme.js +14 -7
  38. package/package.json +4 -4
  39. package/public/chatData.json +162 -0
  40. package/src/components/BlockList/index.tsx +94 -0
  41. package/src/components/CallScreen/index.tsx +144 -0
  42. package/src/components/ChatScreen/index.tsx +403 -139
  43. package/src/components/ChatWidget.tsx +394 -250
  44. package/src/components/EmojiPicker/index.tsx +48 -0
  45. package/src/components/HomeScreen/index.tsx +58 -82
  46. package/src/components/MaintenanceView/index.tsx +6 -9
  47. package/src/components/RecentChatsScreen/index.tsx +51 -96
  48. package/src/components/Tabs/BottomTabs.tsx +45 -37
  49. package/src/components/TicketScreen/index.tsx +87 -133
  50. package/src/components/UserListScreen/index.tsx +75 -153
  51. package/src/config/index.ts +22 -28
  52. package/src/hooks/useChat.ts +31 -14
  53. package/src/hooks/useRemoteConfig.ts +20 -0
  54. package/src/hooks/useWebRTC.ts +130 -0
  55. package/src/index.ts +26 -15
  56. package/src/types/index.ts +85 -40
  57. package/src/utils/chat.ts +70 -0
  58. package/src/utils/theme.ts +18 -7
  59. package/dist/hooks/useUsers.d.ts +0 -7
  60. package/dist/hooks/useUsers.js +0 -26
  61. package/dist/services/userService.d.ts +0 -2
  62. package/dist/services/userService.js +0 -9
  63. package/dist/src/components/ChatScreen/index.d.ts +0 -12
  64. package/dist/src/components/ChatScreen/index.js +0 -83
  65. package/dist/src/components/ChatWidget.d.ts +0 -4
  66. package/dist/src/components/ChatWidget.js +0 -141
  67. package/dist/src/components/HomeScreen/index.d.ts +0 -9
  68. package/dist/src/components/HomeScreen/index.js +0 -71
  69. package/dist/src/components/MaintenanceView/index.d.ts +0 -7
  70. package/dist/src/components/MaintenanceView/index.js +0 -16
  71. package/dist/src/components/RecentChatsScreen/index.d.ts +0 -16
  72. package/dist/src/components/RecentChatsScreen/index.js +0 -38
  73. package/dist/src/components/Tabs/BottomTabs.d.ts +0 -10
  74. package/dist/src/components/Tabs/BottomTabs.js +0 -29
  75. package/dist/src/components/TicketScreen/index.d.ts +0 -9
  76. package/dist/src/components/TicketScreen/index.js +0 -71
  77. package/dist/src/components/UserListScreen/index.d.ts +0 -13
  78. package/dist/src/components/UserListScreen/index.js +0 -64
  79. package/dist/src/config/index.d.ts +0 -3
  80. package/dist/src/config/index.js +0 -38
  81. package/dist/src/hooks/useChat.d.ts +0 -8
  82. package/dist/src/hooks/useChat.js +0 -26
  83. package/dist/src/hooks/useUsers.d.ts +0 -7
  84. package/dist/src/hooks/useUsers.js +0 -26
  85. package/dist/src/index.d.ts +0 -14
  86. package/dist/src/index.js +0 -13
  87. package/dist/src/services/userService.d.ts +0 -2
  88. package/dist/src/services/userService.js +0 -9
  89. package/dist/src/types/index.d.ts +0 -59
  90. package/dist/src/types/index.js +0 -1
  91. package/dist/src/utils/theme.d.ts +0 -3
  92. package/dist/src/utils/theme.js +0 -13
  93. package/src/hooks/useUsers.ts +0 -27
  94. package/src/services/userService.ts +0 -9
@@ -1,26 +0,0 @@
1
- import { useState, useEffect, useCallback } from 'react';
2
- import { fetchUsers } from '../services/userService';
3
- export function useUsers(url, filterType, enabled = true) {
4
- const [users, setUsers] = useState([]);
5
- const [loading, setLoading] = useState(false);
6
- const [error, setError] = useState(null);
7
- const load = useCallback(async () => {
8
- if (!enabled)
9
- return;
10
- setLoading(true);
11
- setError(null);
12
- try {
13
- const data = await fetchUsers(url);
14
- setUsers(filterType ? data.filter(u => u.type === filterType) : data);
15
- }
16
- catch (e) {
17
- setError(e instanceof Error ? e.message : 'Unknown error');
18
- setUsers([]);
19
- }
20
- finally {
21
- setLoading(false);
22
- }
23
- }, [url, filterType, enabled]);
24
- useEffect(() => { load(); }, [load]);
25
- return { users, loading, error, refetch: load };
26
- }
@@ -1,14 +0,0 @@
1
- export { ChatWidget, default } from './components/ChatWidget';
2
- export { HomeScreen } from './components/HomeScreen';
3
- export { UserListScreen } from './components/UserListScreen';
4
- export { ChatScreen } from './components/ChatScreen';
5
- export { RecentChatsScreen } from './components/RecentChatsScreen';
6
- export { TicketScreen } from './components/TicketScreen';
7
- export { MaintenanceView } from './components/MaintenanceView';
8
- export { BottomTabs } from './components/Tabs/BottomTabs';
9
- export { useUsers } from './hooks/useUsers';
10
- export { useChat } from './hooks/useChat';
11
- export { loadChatConfig, buildUserListUrl } from './config';
12
- export { fetchUsers } from './services/userService';
13
- export { defaultTheme, mergeTheme } from './utils/theme';
14
- export type { ChatUser, ChatMessage, ChatConfig, ChatWidgetTheme, ChatWidgetProps, ChatStatus, ChatType, UserType, Screen, BottomTab, UserListContext, Ticket, } from './types';
package/dist/src/index.js DELETED
@@ -1,13 +0,0 @@
1
- export { ChatWidget, default } from './components/ChatWidget';
2
- export { HomeScreen } from './components/HomeScreen';
3
- export { UserListScreen } from './components/UserListScreen';
4
- export { ChatScreen } from './components/ChatScreen';
5
- export { RecentChatsScreen } from './components/RecentChatsScreen';
6
- export { TicketScreen } from './components/TicketScreen';
7
- export { MaintenanceView } from './components/MaintenanceView';
8
- export { BottomTabs } from './components/Tabs/BottomTabs';
9
- export { useUsers } from './hooks/useUsers';
10
- export { useChat } from './hooks/useChat';
11
- export { loadChatConfig, buildUserListUrl } from './config';
12
- export { fetchUsers } from './services/userService';
13
- export { defaultTheme, mergeTheme } from './utils/theme';
@@ -1,2 +0,0 @@
1
- import { ChatUser } from '../types';
2
- export declare function fetchUsers(url: string): Promise<ChatUser[]>;
@@ -1,9 +0,0 @@
1
- export async function fetchUsers(url) {
2
- const res = await fetch(url, { headers: { 'Content-Type': 'application/json' } });
3
- if (!res.ok)
4
- throw new Error(`Failed to fetch users: ${res.status}`);
5
- const data = await res.json();
6
- if (!Array.isArray(data))
7
- throw new Error('User API did not return an array');
8
- return data;
9
- }
@@ -1,59 +0,0 @@
1
- export type ChatStatus = 'ACTIVE' | 'DISABLE' | 'MAINTENANCE';
2
- export type ChatType = 'SUPPORT' | 'CHAT' | 'BOTH';
3
- export type UserType = 'developer' | 'user';
4
- export type Screen = 'home' | 'user-list' | 'chat' | 'recent-chats' | 'tickets';
5
- export type UserListContext = 'support' | 'conversation';
6
- export type BottomTab = 'home' | 'chats' | 'tickets';
7
- export type WidgetSize = 'normal' | 'maximized';
8
- export interface ChatUser {
9
- name: string;
10
- uid: string;
11
- email: string;
12
- mobile: string;
13
- project: string;
14
- type: UserType;
15
- }
16
- export interface ChatMessage {
17
- id: string;
18
- senderId: string;
19
- receiverId: string;
20
- text: string;
21
- timestamp: Date;
22
- status: 'sent' | 'delivered' | 'read';
23
- }
24
- export interface RecentChat {
25
- id: string;
26
- user: ChatUser;
27
- lastMessage: string;
28
- lastTime: Date;
29
- unread: number;
30
- }
31
- export interface Ticket {
32
- id: string;
33
- title: string;
34
- description: string;
35
- status: 'open' | 'in-progress' | 'resolved' | 'closed';
36
- priority: 'low' | 'medium' | 'high';
37
- createdAt: Date;
38
- updatedAt: Date;
39
- }
40
- export interface ChatConfig {
41
- hostUrl: string;
42
- hostPort: number | null;
43
- userListEndpoint: string;
44
- status: ChatStatus;
45
- chatType: ChatType;
46
- }
47
- export interface ChatWidgetTheme {
48
- primaryColor?: string;
49
- fontFamily?: string;
50
- buttonColor?: string;
51
- buttonTextColor?: string;
52
- buttonLabel?: string;
53
- buttonPosition?: 'bottom-right' | 'bottom-left';
54
- borderRadius?: string;
55
- backgroundColor?: string;
56
- }
57
- export interface ChatWidgetProps {
58
- theme?: ChatWidgetTheme;
59
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { ChatWidgetTheme } from '../types';
2
- export declare const defaultTheme: Required<ChatWidgetTheme>;
3
- export declare function mergeTheme(custom?: ChatWidgetTheme): Required<ChatWidgetTheme>;
@@ -1,13 +0,0 @@
1
- export const defaultTheme = {
2
- primaryColor: '#1aaa96',
3
- fontFamily: "'DM Sans', 'Segoe UI', sans-serif",
4
- buttonColor: '#1aaa96',
5
- buttonTextColor: '#ffffff',
6
- buttonLabel: 'Chat with us',
7
- buttonPosition: 'bottom-right',
8
- borderRadius: '16px',
9
- backgroundColor: '#ffffff',
10
- };
11
- export function mergeTheme(custom) {
12
- return Object.assign(Object.assign({}, defaultTheme), custom);
13
- }
@@ -1,27 +0,0 @@
1
- import { useState, useEffect, useCallback } from 'react';
2
- import { ChatUser, UserType } from '../types';
3
- import { fetchUsers } from '../services/userService';
4
-
5
- export function useUsers(url: string, filterType?: UserType, enabled = true) {
6
- const [users, setUsers] = useState<ChatUser[]>([]);
7
- const [loading, setLoading] = useState(false);
8
- const [error, setError] = useState<string | null>(null);
9
-
10
- const load = useCallback(async () => {
11
- if (!enabled) return;
12
- setLoading(true); setError(null);
13
- try {
14
- const data = await fetchUsers(url);
15
- setUsers(filterType ? data.filter(u => u.type === filterType) : data);
16
- } catch (e) {
17
- setError(e instanceof Error ? e.message : 'Unknown error');
18
- setUsers([]);
19
- } finally {
20
- setLoading(false);
21
- }
22
- }, [url, filterType, enabled]);
23
-
24
- useEffect(() => { load(); }, [load]);
25
-
26
- return { users, loading, error, refetch: load };
27
- }
@@ -1,9 +0,0 @@
1
- import { ChatUser } from '../types';
2
-
3
- export async function fetchUsers(url: string): Promise<ChatUser[]> {
4
- const res = await fetch(url, { headers: { 'Content-Type': 'application/json' } });
5
- if (!res.ok) throw new Error(`Failed to fetch users: ${res.status}`);
6
- const data = await res.json();
7
- if (!Array.isArray(data)) throw new Error('User API did not return an array');
8
- return data as ChatUser[];
9
- }