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.
- package/README.md +119 -128
- package/dist/components/BlockList/index.d.ts +10 -0
- package/dist/components/BlockList/index.js +33 -0
- package/dist/components/CallScreen/index.d.ts +13 -0
- package/dist/components/CallScreen/index.js +48 -0
- package/dist/components/ChatScreen/index.d.ts +10 -3
- package/dist/components/ChatScreen/index.js +142 -57
- package/dist/components/ChatWidget.js +192 -98
- package/dist/components/EmojiPicker/index.d.ts +8 -0
- package/dist/components/EmojiPicker/index.js +18 -0
- package/dist/components/HomeScreen/index.d.ts +2 -3
- package/dist/components/HomeScreen/index.js +25 -41
- package/dist/components/MaintenanceView/index.d.ts +0 -1
- package/dist/components/MaintenanceView/index.js +4 -6
- package/dist/components/RecentChatsScreen/index.d.ts +4 -3
- package/dist/components/RecentChatsScreen/index.js +7 -37
- package/dist/components/Tabs/BottomTabs.d.ts +1 -1
- package/dist/components/Tabs/BottomTabs.js +25 -20
- package/dist/components/TicketScreen/index.d.ts +3 -3
- package/dist/components/TicketScreen/index.js +39 -56
- package/dist/components/UserListScreen/index.d.ts +2 -4
- package/dist/components/UserListScreen/index.js +33 -62
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +18 -26
- package/dist/hooks/useChat.d.ts +8 -3
- package/dist/hooks/useChat.js +22 -18
- package/dist/hooks/useRemoteConfig.d.ts +6 -0
- package/dist/hooks/useRemoteConfig.js +22 -0
- package/dist/hooks/useWebRTC.d.ts +11 -0
- package/dist/hooks/useWebRTC.js +112 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.js +8 -4
- package/dist/types/index.d.ts +62 -21
- package/dist/utils/chat.d.ts +13 -0
- package/dist/utils/chat.js +62 -0
- package/dist/utils/theme.d.ts +3 -1
- package/dist/utils/theme.js +14 -7
- package/package.json +4 -4
- package/public/chatData.json +162 -0
- package/src/components/BlockList/index.tsx +94 -0
- package/src/components/CallScreen/index.tsx +144 -0
- package/src/components/ChatScreen/index.tsx +403 -139
- package/src/components/ChatWidget.tsx +394 -250
- package/src/components/EmojiPicker/index.tsx +48 -0
- package/src/components/HomeScreen/index.tsx +58 -82
- package/src/components/MaintenanceView/index.tsx +6 -9
- package/src/components/RecentChatsScreen/index.tsx +51 -96
- package/src/components/Tabs/BottomTabs.tsx +45 -37
- package/src/components/TicketScreen/index.tsx +87 -133
- package/src/components/UserListScreen/index.tsx +75 -153
- package/src/config/index.ts +22 -28
- package/src/hooks/useChat.ts +31 -14
- package/src/hooks/useRemoteConfig.ts +20 -0
- package/src/hooks/useWebRTC.ts +130 -0
- package/src/index.ts +26 -15
- package/src/types/index.ts +85 -40
- package/src/utils/chat.ts +70 -0
- package/src/utils/theme.ts +18 -7
- package/dist/hooks/useUsers.d.ts +0 -7
- package/dist/hooks/useUsers.js +0 -26
- package/dist/services/userService.d.ts +0 -2
- package/dist/services/userService.js +0 -9
- package/dist/src/components/ChatScreen/index.d.ts +0 -12
- package/dist/src/components/ChatScreen/index.js +0 -83
- package/dist/src/components/ChatWidget.d.ts +0 -4
- package/dist/src/components/ChatWidget.js +0 -141
- package/dist/src/components/HomeScreen/index.d.ts +0 -9
- package/dist/src/components/HomeScreen/index.js +0 -71
- package/dist/src/components/MaintenanceView/index.d.ts +0 -7
- package/dist/src/components/MaintenanceView/index.js +0 -16
- package/dist/src/components/RecentChatsScreen/index.d.ts +0 -16
- package/dist/src/components/RecentChatsScreen/index.js +0 -38
- package/dist/src/components/Tabs/BottomTabs.d.ts +0 -10
- package/dist/src/components/Tabs/BottomTabs.js +0 -29
- package/dist/src/components/TicketScreen/index.d.ts +0 -9
- package/dist/src/components/TicketScreen/index.js +0 -71
- package/dist/src/components/UserListScreen/index.d.ts +0 -13
- package/dist/src/components/UserListScreen/index.js +0 -64
- package/dist/src/config/index.d.ts +0 -3
- package/dist/src/config/index.js +0 -38
- package/dist/src/hooks/useChat.d.ts +0 -8
- package/dist/src/hooks/useChat.js +0 -26
- package/dist/src/hooks/useUsers.d.ts +0 -7
- package/dist/src/hooks/useUsers.js +0 -26
- package/dist/src/index.d.ts +0 -14
- package/dist/src/index.js +0 -13
- package/dist/src/services/userService.d.ts +0 -2
- package/dist/src/services/userService.js +0 -9
- package/dist/src/types/index.d.ts +0 -59
- package/dist/src/types/index.js +0 -1
- package/dist/src/utils/theme.d.ts +0 -3
- package/dist/src/utils/theme.js +0 -13
- package/src/hooks/useUsers.ts +0 -27
- 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
|
-
}
|
package/dist/src/index.d.ts
DELETED
|
@@ -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,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
|
-
}
|
package/dist/src/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/src/utils/theme.js
DELETED
|
@@ -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
|
-
}
|
package/src/hooks/useUsers.ts
DELETED
|
@@ -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
|
-
}
|