ajaxter-chat 1.0.3 → 2.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 +96 -204
- package/dist/components/ChatScreen/index.d.ts +12 -0
- package/dist/components/ChatScreen/index.js +83 -0
- package/dist/components/ChatWidget.d.ts +0 -24
- package/dist/components/ChatWidget.js +129 -38
- package/dist/components/HomeScreen/index.d.ts +9 -0
- package/dist/components/HomeScreen/index.js +71 -0
- package/dist/components/MaintenanceView/index.d.ts +1 -1
- package/dist/components/MaintenanceView/index.js +15 -52
- package/dist/components/RecentChatsScreen/index.d.ts +16 -0
- package/dist/components/RecentChatsScreen/index.js +38 -0
- package/dist/components/Tabs/BottomTabs.d.ts +10 -0
- package/dist/components/Tabs/BottomTabs.js +29 -0
- package/dist/components/TicketScreen/index.d.ts +9 -0
- package/dist/components/TicketScreen/index.js +71 -0
- package/dist/components/UserListScreen/index.d.ts +13 -0
- package/dist/components/UserListScreen/index.js +64 -0
- package/dist/config/index.d.ts +0 -13
- package/dist/config/index.js +20 -95
- package/dist/hooks/useChat.d.ts +3 -7
- package/dist/hooks/useChat.js +8 -30
- package/dist/hooks/useUsers.d.ts +3 -10
- package/dist/hooks/useUsers.js +5 -11
- package/dist/index.d.ts +8 -7
- package/dist/index.js +7 -12
- package/dist/services/userService.d.ts +0 -5
- package/dist/services/userService.js +6 -15
- package/dist/src/components/ChatScreen/index.d.ts +12 -0
- package/dist/src/components/ChatScreen/index.js +83 -0
- package/dist/src/components/ChatWidget.d.ts +4 -0
- package/dist/src/components/ChatWidget.js +141 -0
- package/dist/src/components/HomeScreen/index.d.ts +9 -0
- package/dist/src/components/HomeScreen/index.js +71 -0
- package/dist/src/components/MaintenanceView/index.d.ts +7 -0
- package/dist/src/components/MaintenanceView/index.js +16 -0
- package/dist/src/components/RecentChatsScreen/index.d.ts +16 -0
- package/dist/src/components/RecentChatsScreen/index.js +38 -0
- package/dist/src/components/Tabs/BottomTabs.d.ts +10 -0
- package/dist/src/components/Tabs/BottomTabs.js +29 -0
- package/dist/src/components/TicketScreen/index.d.ts +9 -0
- package/dist/src/components/TicketScreen/index.js +71 -0
- package/dist/src/components/UserListScreen/index.d.ts +13 -0
- package/dist/src/components/UserListScreen/index.js +64 -0
- package/dist/src/config/index.d.ts +3 -0
- package/dist/src/config/index.js +38 -0
- package/dist/src/hooks/useChat.d.ts +8 -0
- package/dist/src/hooks/useChat.js +26 -0
- package/dist/src/hooks/useUsers.d.ts +7 -0
- package/dist/src/hooks/useUsers.js +26 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +13 -0
- package/dist/src/services/userService.d.ts +2 -0
- package/dist/src/services/userService.js +9 -0
- package/dist/src/types/index.d.ts +59 -0
- package/dist/src/types/index.js +1 -0
- package/dist/src/utils/theme.d.ts +3 -0
- package/dist/src/utils/theme.js +13 -0
- package/dist/types/index.d.ts +23 -36
- package/dist/utils/theme.d.ts +0 -1
- package/dist/utils/theme.js +3 -18
- package/package.json +10 -20
- package/src/components/ChatScreen/index.tsx +205 -0
- package/src/components/ChatWidget.tsx +327 -0
- package/src/components/HomeScreen/index.tsx +130 -0
- package/src/components/MaintenanceView/index.tsx +41 -0
- package/src/components/RecentChatsScreen/index.tsx +108 -0
- package/src/components/Tabs/BottomTabs.tsx +82 -0
- package/src/components/TicketScreen/index.tsx +170 -0
- package/src/components/UserListScreen/index.tsx +181 -0
- package/src/config/index.ts +46 -0
- package/src/hooks/useChat.ts +31 -0
- package/src/hooks/useUsers.ts +27 -0
- package/src/index.ts +18 -0
- package/src/services/userService.ts +9 -0
- package/src/types/index.ts +82 -0
- package/src/utils/theme.ts +16 -0
- package/dist/components/BottomNav/index.d.ts +0 -10
- package/dist/components/BottomNav/index.js +0 -32
- package/dist/components/ChatBox/index.d.ts +0 -15
- package/dist/components/ChatBox/index.js +0 -228
- package/dist/components/ChatButton/index.d.ts +0 -9
- package/dist/components/ChatButton/index.js +0 -17
- package/dist/components/ChatWindow/index.d.ts +0 -10
- package/dist/components/ChatWindow/index.js +0 -286
- package/dist/components/HomeView/index.d.ts +0 -12
- package/dist/components/HomeView/index.js +0 -51
- package/dist/components/UserList/index.d.ts +0 -13
- package/dist/components/UserList/index.js +0 -136
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface HomeViewProps {
|
|
3
|
-
primaryColor: string;
|
|
4
|
-
fontFamily: string;
|
|
5
|
-
showNeedSupport: boolean;
|
|
6
|
-
showNewConversation: boolean;
|
|
7
|
-
onNeedSupport: () => void;
|
|
8
|
-
onNewConversation: () => void;
|
|
9
|
-
onRaiseTicket: () => void;
|
|
10
|
-
onClose: () => void;
|
|
11
|
-
}
|
|
12
|
-
export declare const HomeView: React.FC<HomeViewProps>;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
const SendIcon = ({ color }) => (_jsx("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", "aria-hidden": true, children: _jsx("path", { d: "M22 2L11 13M22 2L15 22L11 13L2 9L22 2Z", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
3
|
-
export const HomeView = ({ primaryColor, fontFamily, showNeedSupport, showNewConversation, onNeedSupport, onNewConversation, onRaiseTicket, onClose, }) => {
|
|
4
|
-
const cardStyle = {
|
|
5
|
-
width: '100%',
|
|
6
|
-
backgroundColor: '#fff',
|
|
7
|
-
borderRadius: '12px',
|
|
8
|
-
padding: '16px 18px',
|
|
9
|
-
display: 'flex',
|
|
10
|
-
alignItems: 'center',
|
|
11
|
-
justifyContent: 'space-between',
|
|
12
|
-
gap: '12px',
|
|
13
|
-
border: 'none',
|
|
14
|
-
cursor: 'pointer',
|
|
15
|
-
textAlign: 'left',
|
|
16
|
-
fontFamily,
|
|
17
|
-
boxShadow: '0 2px 12px rgba(0,0,0,0.06)',
|
|
18
|
-
transition: 'transform 0.15s ease, box-shadow 0.15s ease',
|
|
19
|
-
};
|
|
20
|
-
return (_jsxs("div", { style: {
|
|
21
|
-
flex: 1,
|
|
22
|
-
display: 'flex',
|
|
23
|
-
flexDirection: 'column',
|
|
24
|
-
backgroundColor: primaryColor,
|
|
25
|
-
fontFamily,
|
|
26
|
-
minHeight: 0,
|
|
27
|
-
}, children: [_jsx("div", { style: {
|
|
28
|
-
padding: '20px 20px 8px',
|
|
29
|
-
display: 'flex',
|
|
30
|
-
justifyContent: 'flex-end',
|
|
31
|
-
}, children: _jsx("button", { type: "button", onClick: onClose, "aria-label": "Close", style: {
|
|
32
|
-
background: 'transparent',
|
|
33
|
-
border: 'none',
|
|
34
|
-
color: '#fff',
|
|
35
|
-
cursor: 'pointer',
|
|
36
|
-
padding: '4px',
|
|
37
|
-
}, children: _jsxs("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", children: [_jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }), _jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })] }) }) }), _jsxs("div", { style: { padding: '0 24px 20px', flexShrink: 0 }, children: [_jsx("h1", { style: {
|
|
38
|
-
margin: 0,
|
|
39
|
-
color: '#fff',
|
|
40
|
-
fontSize: '26px',
|
|
41
|
-
fontWeight: 700,
|
|
42
|
-
letterSpacing: '-0.02em',
|
|
43
|
-
}, children: "Hi there \uD83D\uDC4B" }), _jsx("p", { style: { margin: '10px 0 0', color: 'rgba(255,255,255,0.92)', fontSize: '14px', lineHeight: 1.5 }, children: "Need help? start a conversation:" })] }), _jsxs("div", { style: {
|
|
44
|
-
flex: 1,
|
|
45
|
-
padding: '0 20px 16px',
|
|
46
|
-
display: 'flex',
|
|
47
|
-
flexDirection: 'column',
|
|
48
|
-
gap: '12px',
|
|
49
|
-
overflowY: 'auto',
|
|
50
|
-
}, children: [showNeedSupport && (_jsxs("button", { type: "button", onClick: onNeedSupport, style: cardStyle, children: [_jsxs("div", { children: [_jsx("div", { style: { fontWeight: 700, fontSize: '15px', color: '#1a1a2e' }, children: "Need Support" }), _jsx("div", { style: { fontSize: '13px', color: '#888', marginTop: '4px' }, children: "We typically reply in a few minutes" })] }), _jsx(SendIcon, { color: primaryColor })] })), showNewConversation && (_jsxs("button", { type: "button", onClick: onNewConversation, style: cardStyle, children: [_jsxs("div", { children: [_jsx("div", { style: { fontWeight: 700, fontSize: '15px', color: '#1a1a2e' }, children: "New Conversation" }), _jsx("div", { style: { fontSize: '13px', color: '#888', marginTop: '4px' }, children: "With your colleague" })] }), _jsx(SendIcon, { color: primaryColor })] })), _jsxs("button", { type: "button", onClick: onRaiseTicket, style: cardStyle, children: [_jsxs("div", { children: [_jsx("div", { style: { fontWeight: 700, fontSize: '15px', color: '#1a1a2e' }, children: "Raise Ticket" }), _jsx("div", { style: { fontSize: '13px', color: '#888', marginTop: '4px' }, children: "For major changes" })] }), _jsx(SendIcon, { color: primaryColor })] })] })] }));
|
|
51
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ChatUser } from '../../types';
|
|
3
|
-
interface UserListProps {
|
|
4
|
-
users: ChatUser[];
|
|
5
|
-
loading: boolean;
|
|
6
|
-
error: string | null;
|
|
7
|
-
activeUserId: string | null;
|
|
8
|
-
onSelectUser: (user: ChatUser) => void;
|
|
9
|
-
primaryColor: string;
|
|
10
|
-
fontFamily: string;
|
|
11
|
-
}
|
|
12
|
-
export declare const UserList: React.FC<UserListProps>;
|
|
13
|
-
export {};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
export const UserList = ({ users, loading, error, activeUserId, onSelectUser, primaryColor, fontFamily, }) => {
|
|
3
|
-
if (loading) {
|
|
4
|
-
return (_jsx("div", { style: { padding: '16px', fontFamily }, children: [1, 2, 3, 4].map((i) => (_jsx(SkeletonUser, {}, i))) }));
|
|
5
|
-
}
|
|
6
|
-
if (error) {
|
|
7
|
-
return (_jsxs("div", { style: {
|
|
8
|
-
padding: '32px 20px',
|
|
9
|
-
textAlign: 'center',
|
|
10
|
-
fontFamily,
|
|
11
|
-
display: 'flex',
|
|
12
|
-
flexDirection: 'column',
|
|
13
|
-
alignItems: 'center',
|
|
14
|
-
gap: '10px',
|
|
15
|
-
}, children: [_jsxs("svg", { width: "36", height: "36", viewBox: "0 0 24 24", fill: "none", children: [_jsx("circle", { cx: "12", cy: "12", r: "10", stroke: "#ff6b6b", strokeWidth: "2" }), _jsx("line", { x1: "12", y1: "8", x2: "12", y2: "12", stroke: "#ff6b6b", strokeWidth: "2", strokeLinecap: "round" }), _jsx("line", { x1: "12", y1: "16", x2: "12.01", y2: "16", stroke: "#ff6b6b", strokeWidth: "2", strokeLinecap: "round" })] }), _jsx("p", { style: { margin: 0, fontSize: '13px', color: '#ff6b6b', fontWeight: 600 }, children: "Failed to load users" }), _jsx("p", { style: { margin: 0, fontSize: '12px', color: '#999', lineHeight: 1.5 }, children: error })] }));
|
|
16
|
-
}
|
|
17
|
-
if (users.length === 0) {
|
|
18
|
-
return (_jsxs("div", { style: {
|
|
19
|
-
padding: '40px 20px',
|
|
20
|
-
textAlign: 'center',
|
|
21
|
-
fontFamily,
|
|
22
|
-
display: 'flex',
|
|
23
|
-
flexDirection: 'column',
|
|
24
|
-
alignItems: 'center',
|
|
25
|
-
gap: '10px',
|
|
26
|
-
}, children: [_jsxs("svg", { width: "40", height: "40", viewBox: "0 0 24 24", fill: "none", children: [_jsx("path", { d: "M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2", stroke: "#ccc", strokeWidth: "2", strokeLinecap: "round" }), _jsx("circle", { cx: "9", cy: "7", r: "4", stroke: "#ccc", strokeWidth: "2" }), _jsx("path", { d: "M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75", stroke: "#ccc", strokeWidth: "2", strokeLinecap: "round" })] }), _jsx("p", { style: { margin: 0, fontSize: '13px', color: '#bbb', fontWeight: 600 }, children: "No users available" }), _jsx("p", { style: { margin: 0, fontSize: '12px', color: '#ccc' }, children: "Check back later" })] }));
|
|
27
|
-
}
|
|
28
|
-
return (_jsx("div", { style: { overflowY: 'auto', flex: 1, fontFamily }, children: users.map((user) => {
|
|
29
|
-
const isActive = user.uid === activeUserId;
|
|
30
|
-
const initials = user.name
|
|
31
|
-
.split(' ')
|
|
32
|
-
.map((n) => n[0])
|
|
33
|
-
.join('')
|
|
34
|
-
.toUpperCase()
|
|
35
|
-
.slice(0, 2);
|
|
36
|
-
return (_jsxs("button", { onClick: () => onSelectUser(user), style: {
|
|
37
|
-
width: '100%',
|
|
38
|
-
padding: '12px 16px',
|
|
39
|
-
display: 'flex',
|
|
40
|
-
alignItems: 'center',
|
|
41
|
-
gap: '12px',
|
|
42
|
-
background: isActive ? `${primaryColor}12` : 'transparent',
|
|
43
|
-
border: 'none',
|
|
44
|
-
borderLeft: isActive ? `3px solid ${primaryColor}` : '3px solid transparent',
|
|
45
|
-
cursor: 'pointer',
|
|
46
|
-
textAlign: 'left',
|
|
47
|
-
transition: 'all 0.18s ease',
|
|
48
|
-
borderRadius: '0',
|
|
49
|
-
}, onMouseEnter: (e) => {
|
|
50
|
-
if (!isActive) {
|
|
51
|
-
e.currentTarget.style.backgroundColor = '#f8f8ff';
|
|
52
|
-
}
|
|
53
|
-
}, onMouseLeave: (e) => {
|
|
54
|
-
if (!isActive) {
|
|
55
|
-
e.currentTarget.style.backgroundColor = 'transparent';
|
|
56
|
-
}
|
|
57
|
-
}, children: [_jsx("div", { style: {
|
|
58
|
-
width: '40px',
|
|
59
|
-
height: '40px',
|
|
60
|
-
borderRadius: '50%',
|
|
61
|
-
backgroundColor: isActive ? primaryColor : stringToColor(user.name),
|
|
62
|
-
display: 'flex',
|
|
63
|
-
alignItems: 'center',
|
|
64
|
-
justifyContent: 'center',
|
|
65
|
-
color: '#fff',
|
|
66
|
-
fontSize: '13px',
|
|
67
|
-
fontWeight: 700,
|
|
68
|
-
flexShrink: 0,
|
|
69
|
-
transition: 'background 0.2s',
|
|
70
|
-
}, children: initials }), _jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [_jsx("div", { style: {
|
|
71
|
-
fontSize: '14px',
|
|
72
|
-
fontWeight: 600,
|
|
73
|
-
color: isActive ? primaryColor : '#1a1a2e',
|
|
74
|
-
whiteSpace: 'nowrap',
|
|
75
|
-
overflow: 'hidden',
|
|
76
|
-
textOverflow: 'ellipsis',
|
|
77
|
-
}, children: user.name }), _jsx("div", { style: {
|
|
78
|
-
fontSize: '12px',
|
|
79
|
-
color: '#999',
|
|
80
|
-
whiteSpace: 'nowrap',
|
|
81
|
-
overflow: 'hidden',
|
|
82
|
-
textOverflow: 'ellipsis',
|
|
83
|
-
}, children: user.project || user.email })] }), _jsx("span", { style: {
|
|
84
|
-
fontSize: '10px',
|
|
85
|
-
fontWeight: 700,
|
|
86
|
-
padding: '3px 8px',
|
|
87
|
-
borderRadius: '20px',
|
|
88
|
-
textTransform: 'uppercase',
|
|
89
|
-
letterSpacing: '0.05em',
|
|
90
|
-
flexShrink: 0,
|
|
91
|
-
backgroundColor: user.type === 'developer' ? '#e8f5e9' : '#e3f2fd',
|
|
92
|
-
color: user.type === 'developer' ? '#2e7d32' : '#1565c0',
|
|
93
|
-
}, children: user.type === 'developer' ? 'Dev' : 'User' })] }, user.uid));
|
|
94
|
-
}) }));
|
|
95
|
-
};
|
|
96
|
-
const SkeletonUser = () => (_jsxs("div", { style: {
|
|
97
|
-
display: 'flex',
|
|
98
|
-
alignItems: 'center',
|
|
99
|
-
gap: '12px',
|
|
100
|
-
padding: '12px 16px',
|
|
101
|
-
}, children: [_jsx("div", { style: {
|
|
102
|
-
width: '40px',
|
|
103
|
-
height: '40px',
|
|
104
|
-
borderRadius: '50%',
|
|
105
|
-
background: 'linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%)',
|
|
106
|
-
backgroundSize: '200% 100%',
|
|
107
|
-
animation: 'shimmer 1.5s infinite',
|
|
108
|
-
flexShrink: 0,
|
|
109
|
-
} }), _jsxs("div", { style: { flex: 1 }, children: [_jsx("div", { style: {
|
|
110
|
-
height: '12px',
|
|
111
|
-
width: '60%',
|
|
112
|
-
borderRadius: '6px',
|
|
113
|
-
background: 'linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%)',
|
|
114
|
-
backgroundSize: '200% 100%',
|
|
115
|
-
animation: 'shimmer 1.5s infinite',
|
|
116
|
-
marginBottom: '8px',
|
|
117
|
-
} }), _jsx("div", { style: {
|
|
118
|
-
height: '10px',
|
|
119
|
-
width: '40%',
|
|
120
|
-
borderRadius: '6px',
|
|
121
|
-
background: 'linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%)',
|
|
122
|
-
backgroundSize: '200% 100%',
|
|
123
|
-
animation: 'shimmer 1.5s infinite',
|
|
124
|
-
} })] })] }));
|
|
125
|
-
// Generate consistent color from name string
|
|
126
|
-
function stringToColor(str) {
|
|
127
|
-
let hash = 0;
|
|
128
|
-
for (let i = 0; i < str.length; i++) {
|
|
129
|
-
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
130
|
-
}
|
|
131
|
-
const colors = [
|
|
132
|
-
'#7C3AED', '#2563EB', '#059669', '#D97706',
|
|
133
|
-
'#DC2626', '#7C2D12', '#0E7490', '#4F46E5',
|
|
134
|
-
];
|
|
135
|
-
return colors[Math.abs(hash) % colors.length];
|
|
136
|
-
}
|