@aslaluroba/help-center-react 1.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 (100) hide show
  1. package/README.md +176 -0
  2. package/dist/components/index.d.ts +1 -0
  3. package/dist/components/shared/Button/button.d.ts +11 -0
  4. package/dist/components/shared/Button/index.d.ts +1 -0
  5. package/dist/components/shared/Card/card.d.ts +11 -0
  6. package/dist/components/shared/Card/index.d.ts +1 -0
  7. package/dist/components/shared/index.d.ts +2 -0
  8. package/dist/components/ui/agent-response/agent-response.d.ts +9 -0
  9. package/dist/components/ui/header.d.ts +6 -0
  10. package/dist/core/ApiService.d.ts +16 -0
  11. package/dist/core/SignalRService.d.ts +11 -0
  12. package/dist/core/api.d.ts +4 -0
  13. package/dist/core/token-service.d.ts +10 -0
  14. package/dist/i18n.d.ts +2 -0
  15. package/dist/index.d.ts +12 -0
  16. package/dist/index.esm.js +26076 -0
  17. package/dist/index.esm.js.map +1 -0
  18. package/dist/index.js +26110 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/lib/config.d.ts +19 -0
  21. package/dist/lib/custom-hooks/useTypewriter.d.ts +1 -0
  22. package/dist/lib/index.d.ts +1 -0
  23. package/dist/lib/types.d.ts +111 -0
  24. package/dist/lib/utils.d.ts +2 -0
  25. package/dist/ui/chatbot-popup/chat-window-screen/footer.d.ts +9 -0
  26. package/dist/ui/chatbot-popup/chat-window-screen/header.d.ts +11 -0
  27. package/dist/ui/chatbot-popup/chat-window-screen/index.d.ts +10 -0
  28. package/dist/ui/chatbot-popup/error-screen/index.d.ts +7 -0
  29. package/dist/ui/chatbot-popup/home-screen/card.d.ts +7 -0
  30. package/dist/ui/chatbot-popup/home-screen/chat-now-card.d.ts +6 -0
  31. package/dist/ui/chatbot-popup/home-screen/index.d.ts +7 -0
  32. package/dist/ui/chatbot-popup/loading-screen/index.d.ts +7 -0
  33. package/dist/ui/chatbot-popup/options-list-screen/expanded-option.d.ts +8 -0
  34. package/dist/ui/chatbot-popup/options-list-screen/header.d.ts +7 -0
  35. package/dist/ui/chatbot-popup/options-list-screen/index.d.ts +12 -0
  36. package/dist/ui/chatbot-popup/options-list-screen/option-card.d.ts +6 -0
  37. package/dist/ui/floating-message.d.ts +7 -0
  38. package/dist/ui/help-button.d.ts +6 -0
  39. package/dist/ui/help-center.d.ts +17 -0
  40. package/dist/ui/help-popup.d.ts +24 -0
  41. package/dist/useLocalTranslation.d.ts +5 -0
  42. package/package.json +86 -0
  43. package/src/assets/animatedLogo.gif +0 -0
  44. package/src/assets/icons/arrowRight.svg +3 -0
  45. package/src/assets/icons/chat.svg +4 -0
  46. package/src/assets/icons/close.svg +1 -0
  47. package/src/assets/icons/closeCircle.svg +3 -0
  48. package/src/assets/icons/closeCirclePrimary.svg +3 -0
  49. package/src/assets/icons/envelope.svg +3 -0
  50. package/src/assets/icons/seperator.svg +5 -0
  51. package/src/assets/icons/threeDots.svg +3 -0
  52. package/src/assets/icons/user.svg +3 -0
  53. package/src/assets/logo.svg +5 -0
  54. package/src/assets/logoColors.svg +5 -0
  55. package/src/assets/logo_ai.svg +14 -0
  56. package/src/assets/thinking-logo.svg +3 -0
  57. package/src/components/index.ts +1 -0
  58. package/src/components/shared/Button/button.tsx +46 -0
  59. package/src/components/shared/Button/index.ts +1 -0
  60. package/src/components/shared/Card/card.tsx +44 -0
  61. package/src/components/shared/Card/index.ts +1 -0
  62. package/src/components/shared/index.ts +2 -0
  63. package/src/components/ui/agent-response/agent-response.tsx +47 -0
  64. package/src/components/ui/agent-response/doc.md +88 -0
  65. package/src/components/ui/header.tsx +17 -0
  66. package/src/components/ui/index.ts +0 -0
  67. package/src/core/ApiService.ts +118 -0
  68. package/src/core/SignalRService.ts +83 -0
  69. package/src/core/api.ts +71 -0
  70. package/src/core/token-service.ts +35 -0
  71. package/src/globals.css +484 -0
  72. package/src/i18n.ts +17 -0
  73. package/src/index.ts +21 -0
  74. package/src/lib/config.ts +59 -0
  75. package/src/lib/custom-hooks/useTypewriter.ts +24 -0
  76. package/src/lib/index.ts +1 -0
  77. package/src/lib/types.ts +120 -0
  78. package/src/lib/utils.ts +6 -0
  79. package/src/locales/ar.json +13 -0
  80. package/src/locales/en.json +15 -0
  81. package/src/styles/tailwind.css +4 -0
  82. package/src/types/svg.d.ts +5 -0
  83. package/src/types.d.ts +9 -0
  84. package/src/ui/chatbot-popup/chat-window-screen/footer.tsx +42 -0
  85. package/src/ui/chatbot-popup/chat-window-screen/header.tsx +64 -0
  86. package/src/ui/chatbot-popup/chat-window-screen/index.tsx +103 -0
  87. package/src/ui/chatbot-popup/error-screen/index.tsx +22 -0
  88. package/src/ui/chatbot-popup/home-screen/card.tsx +34 -0
  89. package/src/ui/chatbot-popup/home-screen/chat-now-card.tsx +36 -0
  90. package/src/ui/chatbot-popup/home-screen/index.tsx +44 -0
  91. package/src/ui/chatbot-popup/loading-screen/index.tsx +33 -0
  92. package/src/ui/chatbot-popup/options-list-screen/expanded-option.tsx +38 -0
  93. package/src/ui/chatbot-popup/options-list-screen/header.tsx +38 -0
  94. package/src/ui/chatbot-popup/options-list-screen/index.tsx +59 -0
  95. package/src/ui/chatbot-popup/options-list-screen/option-card.tsx +20 -0
  96. package/src/ui/floating-message.tsx +25 -0
  97. package/src/ui/help-button.tsx +22 -0
  98. package/src/ui/help-center.tsx +303 -0
  99. package/src/ui/help-popup.tsx +264 -0
  100. package/src/useLocalTranslation.ts +14 -0
package/README.md ADDED
@@ -0,0 +1,176 @@
1
+ # BabylAI Help Center
2
+
3
+ A React component library for integrating BabylAI's help center widget into your web applications. This widget provides real-time chat support functionality with AI assistance and human agent escalation capabilities.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @babylai/help-center
9
+ # or
10
+ yarn add @babylai/help-center
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```jsx
16
+ import { HelpCenter, initializeHelpCenter } from '@babylai/help-center'
17
+
18
+ // Initialize the help center with your configuration
19
+ initializeHelpCenter({
20
+ baseUrl: 'https://your-api-url.com',
21
+ hubUrl: 'https://your-hub-url.com'
22
+ })
23
+
24
+ // Use the component
25
+ function App() {
26
+ return <HelpCenter helpScreenId="your-help-screen-id" messageLabel="Need help? Click here!" />
27
+ }
28
+ ```
29
+
30
+ ## Configuration
31
+
32
+ ### Initialize Help Center
33
+
34
+ Before using the component, initialize the help center with your configuration:
35
+
36
+ ```javascript
37
+ import { initializeHelpCenter } from '@babylai/help-center'
38
+
39
+ initializeHelpCenter({
40
+ baseUrl: 'https://your-api-url.com', // Base URL for the API
41
+ hubUrl: 'https://your-hub-url.com' // SignalR hub URL
42
+ })
43
+ ```
44
+
45
+ ## Props
46
+
47
+ ### HelpCenter Component
48
+
49
+ | Prop | Type | Required | Description |
50
+ | -------------- | ------- | -------- | ---------------------------------------------------------- |
51
+ | `helpScreenId` | string | Yes | Unique identifier for the help screen configuration |
52
+ | `user` | object | No | Optional user information for the chat session |
53
+ | `showArrow` | boolean | No | Whether to show the floating arrow message (default: true) |
54
+ | `messageLabel` | string | No | Custom message for the floating arrow |
55
+
56
+ ### Optional User Object Structure
57
+
58
+ ```typescript
59
+ interface User {
60
+ id?: string
61
+ name?: string
62
+ email?: string
63
+ avatar?: string
64
+ }
65
+ ```
66
+
67
+ ## Features
68
+
69
+ - 🤖 AI-powered chat support
70
+ - 👥 Human agent escalation
71
+ - 💬 Real-time messaging
72
+ - 📱 Responsive design
73
+ - 🎨 Customizable styling
74
+ - 🔒 Secure authentication
75
+ - 🌐 Multi-language support
76
+
77
+ ## Examples
78
+
79
+ ### Basic Usage
80
+
81
+ ```jsx
82
+ import { HelpCenter } from '@babylai/help-center'
83
+
84
+ function App() {
85
+ return <HelpCenter helpScreenId="your-help-screen-id" />
86
+ }
87
+ ```
88
+
89
+ ### With Optional User Information
90
+
91
+ ```jsx
92
+ import { HelpCenter } from '@babylai/help-center'
93
+
94
+ function App() {
95
+ return (
96
+ <HelpCenter
97
+ helpScreenId="your-help-screen-id"
98
+ user={{
99
+ name: 'John Doe',
100
+ email: 'john@example.com',
101
+ avatar: 'https://example.com/avatar.jpg'
102
+ }}
103
+ messageLabel="How can we help you?"
104
+ />
105
+ )
106
+ }
107
+ ```
108
+
109
+ ## Styling
110
+
111
+ The widget comes with default styling but can be customized using CSS. The main component classes are:
112
+
113
+ ```css
114
+ .help-center-container {
115
+ /* Container styles */
116
+ }
117
+ .helpButton {
118
+ /* Help button styles */
119
+ }
120
+ .popup {
121
+ /* Chat popup styles */
122
+ }
123
+ /* ... other classes available in the CSS files */
124
+ ```
125
+
126
+ ## Events
127
+
128
+ The widget handles various events internally:
129
+
130
+ - Chat session creation
131
+ - Message sending/receiving
132
+ - Agent escalation
133
+ - Session termination
134
+
135
+ ## Error Handling
136
+
137
+ The widget includes built-in error handling for common scenarios:
138
+
139
+ - Network connectivity issues
140
+ - Authentication failures
141
+ - API errors
142
+
143
+ ## Browser Support
144
+
145
+ The widget supports all modern browsers:
146
+
147
+ - Chrome (latest)
148
+ - Firefox (latest)
149
+ - Safari (latest)
150
+ - Edge (latest)
151
+
152
+ ## Development
153
+
154
+ To build the package locally:
155
+
156
+ ```bash
157
+ # Install dependencies
158
+ npm install
159
+
160
+ # Build the package
161
+ npm run build
162
+
163
+ # Run tests
164
+ npm test
165
+
166
+ # Development mode
167
+ npm run dev
168
+ ```
169
+
170
+ ## License
171
+
172
+ MIT © BabylAI
173
+
174
+ ## Support
175
+
176
+ For support, please contact support@babylai.com or visit our [documentation](https://docs.babylai.com).
@@ -0,0 +1 @@
1
+ export * from './shared';
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { type VariantProps } from 'class-variance-authority';
3
+ declare const buttonVariants: (props?: ({
4
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | "rounded-icon" | null | undefined;
5
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
6
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
+ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
8
+ asChild?: boolean;
9
+ }
10
+ export declare const Button: ({ children, className, variant, size, ...props }: ButtonProps) => React.JSX.Element;
11
+ export {};
@@ -0,0 +1 @@
1
+ export * from './button';
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ variant?: 'default' | 'rounded' | 'shadowed';
4
+ }
5
+ declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>>;
6
+ declare const CardHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
7
+ declare const CardTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
8
+ declare const CardDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
9
+ declare const CardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
10
+ declare const CardFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
11
+ export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
@@ -0,0 +1 @@
1
+ export * from './card';
@@ -0,0 +1,2 @@
1
+ export * from './Button';
2
+ export * from './Card';
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface AgentResponseProps {
3
+ messageContent: string;
4
+ senderType: number;
5
+ messageId: number;
6
+ onType?: () => void;
7
+ }
8
+ declare const AgentResponse: ({ senderType, messageContent, messageId, onType }: AgentResponseProps) => React.JSX.Element;
9
+ export default AgentResponse;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface HeaderProps {
3
+ onClose: () => void;
4
+ }
5
+ export declare function Header({ onClose }: HeaderProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,16 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { HelpCenterConfig } from '../lib/types';
3
+ export declare class ApiService {
4
+ private axiosInstance;
5
+ private config;
6
+ private tokenExpiryTime;
7
+ private currentToken;
8
+ constructor(config: HelpCenterConfig);
9
+ private setupInterceptors;
10
+ private getValidToken;
11
+ get<T>(endpoint: string, config?: AxiosRequestConfig): Promise<T>;
12
+ post<T>(endpoint: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>;
13
+ put<T>(endpoint: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>;
14
+ delete<T>(endpoint: string, config?: AxiosRequestConfig): Promise<T>;
15
+ private handleError;
16
+ }
@@ -0,0 +1,11 @@
1
+ export declare class ClientSignalRService {
2
+ private static connection;
3
+ private static isConnected;
4
+ private static hubUrl;
5
+ static initialize(hubUrl: string): void;
6
+ static startConnection(sessionId: string, apiKey: string, onMessageReceived: Function): Promise<void>;
7
+ static joinGroup(sessionId: string): Promise<void>;
8
+ static leaveGroup(sessionId: string): Promise<void>;
9
+ static stopConnection(): Promise<void>;
10
+ static isConnectionActive(): boolean;
11
+ }
@@ -0,0 +1,4 @@
1
+ import { TokenResponse } from '../lib/types';
2
+ export declare function initializeAPI(url: string, getToken: () => Promise<TokenResponse>): void;
3
+ export declare function getValidToken(forceRefresh?: boolean): Promise<string>;
4
+ export declare function apiRequest(endpoint: string, method?: string, body?: any): Promise<Response>;
@@ -0,0 +1,10 @@
1
+ type TokenResponse = {
2
+ token: string;
3
+ expiresIn: number;
4
+ };
5
+ export declare class TokenService {
6
+ private baseUrl;
7
+ constructor(baseUrl: string);
8
+ getToken(): Promise<TokenResponse>;
9
+ }
10
+ export {};
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { i18n as I18nType } from 'i18next';
2
+ export declare const createHelpCenterI18n: (lng?: string) => I18nType;
@@ -0,0 +1,12 @@
1
+ import { HelpCenter } from './ui/help-center';
2
+ export type HelpCenterConfig = {
3
+ baseUrl: string;
4
+ hubUrl?: string;
5
+ };
6
+ export declare function initializeHelpCenter(config: HelpCenterConfig): void;
7
+ export { HelpCenter };
8
+ export * from './lib/types';
9
+ export * from './core/ApiService';
10
+ export * from './core/SignalRService';
11
+ export { TokenService } from './core/token-service';
12
+ export { initializeAPI } from './core/api';