@aslaluroba/help-center-react 2.0.4 → 2.0.5
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/dist/core/api.d.ts +4 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.esm.js +994 -25294
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +995 -25295
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +1 -1
- package/dist/lib/types.d.ts +4 -0
- package/dist/ui/chatbot-popup/chat-window-screen/footer.d.ts +1 -0
- package/dist/ui/chatbot-popup/chat-window-screen/index.d.ts +1 -1
- package/dist/ui/help-center.d.ts +1 -1
- package/dist/ui/help-popup.d.ts +9 -3
- package/dist/ui/review-dialog/index.d.ts +8 -0
- package/dist/ui/review-dialog/rating.d.ts +12 -0
- package/package.json +26 -5
- package/src/assets/icons/arrowRight.svg +1 -1
- package/src/assets/icons/closeCircle.svg +1 -1
- package/src/components/ui/agent-response/agent-response.tsx +36 -34
- package/src/components/ui/header.tsx +2 -3
- package/src/core/SignalRService.ts +25 -25
- package/src/core/api.ts +180 -44
- package/src/globals.css +0 -9
- package/src/index.ts +3 -2
- package/src/lib/config.ts +31 -25
- package/src/lib/types.ts +5 -0
- package/src/locales/ar.json +18 -1
- package/src/locales/en.json +26 -8
- package/src/ui/chatbot-popup/chat-window-screen/footer.tsx +31 -34
- package/src/ui/chatbot-popup/chat-window-screen/header.tsx +47 -53
- package/src/ui/chatbot-popup/chat-window-screen/index.tsx +178 -88
- package/src/ui/chatbot-popup/options-list-screen/header.tsx +24 -20
- package/src/ui/chatbot-popup/options-list-screen/index.tsx +24 -24
- package/src/ui/chatbot-popup/options-list-screen/option-card.tsx +9 -4
- package/src/ui/help-center.tsx +366 -136
- package/src/ui/help-popup.tsx +239 -165
- package/src/ui/review-dialog/index.tsx +106 -0
- package/src/ui/review-dialog/rating.tsx +78 -0
- package/tsconfig.json +48 -0
package/src/globals.css
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { configService } from './lib/config'
|
|
2
2
|
import { HelpCenter } from './ui/help-center'
|
|
3
|
+
import { TokenResponse } from './lib/types'
|
|
3
4
|
|
|
4
5
|
export type HelpCenterConfig = {
|
|
5
|
-
baseUrl
|
|
6
|
+
baseUrl?: string
|
|
6
7
|
hubUrl?: string
|
|
8
|
+
getToken?: () => Promise<TokenResponse>
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export function initializeHelpCenter(config: HelpCenterConfig) {
|
|
@@ -18,4 +20,3 @@ export * from './core/SignalRService'
|
|
|
18
20
|
// export * from './globals.css'
|
|
19
21
|
|
|
20
22
|
export { TokenService } from './core/token-service'
|
|
21
|
-
export { initializeAPI } from './core/api'
|
package/src/lib/config.ts
CHANGED
|
@@ -1,59 +1,65 @@
|
|
|
1
|
-
import { ClientSignalRService } from '../core/SignalRService'
|
|
2
|
-
import { initializeAPI, getValidToken } from '../core/api'
|
|
3
|
-
import { TokenResponse } from './types'
|
|
1
|
+
import { ClientSignalRService } from '../core/SignalRService';
|
|
2
|
+
import { initializeAPI, getValidToken } from '../core/api';
|
|
3
|
+
import { TokenResponse } from './types';
|
|
4
4
|
|
|
5
5
|
type Config = {
|
|
6
|
-
baseUrl
|
|
7
|
-
hubUrl?: string
|
|
8
|
-
tenantId?: string
|
|
9
|
-
apiKey?: string
|
|
10
|
-
getToken?: () => Promise<TokenResponse
|
|
11
|
-
}
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
hubUrl?: string;
|
|
8
|
+
tenantId?: string;
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
getToken?: () => Promise<TokenResponse>;
|
|
11
|
+
};
|
|
12
12
|
|
|
13
13
|
class ConfigService {
|
|
14
|
-
private static instance: ConfigService
|
|
15
|
-
private config: Config | null = null
|
|
14
|
+
private static instance: ConfigService;
|
|
15
|
+
private config: Config | null = null;
|
|
16
16
|
|
|
17
17
|
private constructor() {}
|
|
18
18
|
|
|
19
19
|
static getInstance(): ConfigService {
|
|
20
20
|
if (!ConfigService.instance) {
|
|
21
|
-
ConfigService.instance = new ConfigService()
|
|
21
|
+
ConfigService.instance = new ConfigService();
|
|
22
22
|
}
|
|
23
|
-
return ConfigService.instance
|
|
23
|
+
return ConfigService.instance;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
initialize(config: Config) {
|
|
27
|
+
console.log('🔧 Initializing config with:', config);
|
|
28
|
+
|
|
27
29
|
this.config = {
|
|
28
|
-
baseUrl: config.baseUrl,
|
|
29
|
-
hubUrl: config.hubUrl || config.baseUrl,
|
|
30
|
+
baseUrl: config.baseUrl || 'https://babylai.net/api',
|
|
31
|
+
hubUrl: config.hubUrl || config.baseUrl || 'https://babylai.net/api',
|
|
30
32
|
tenantId: config.tenantId,
|
|
31
33
|
apiKey: config.apiKey,
|
|
32
|
-
getToken: config.getToken
|
|
33
|
-
}
|
|
34
|
+
getToken: config.getToken,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
console.log('📋 Final config:', this.config);
|
|
34
38
|
|
|
35
39
|
// Initialize API with the getToken function directly
|
|
36
40
|
if (!this.config.getToken) {
|
|
37
|
-
throw new Error('getToken function is required in configuration')
|
|
41
|
+
throw new Error('getToken function is required in configuration');
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
console.log('🌐 Initializing API with baseUrl:', this.config.baseUrl);
|
|
45
|
+
initializeAPI(this.config.baseUrl || 'https://babylai.net/api', this.config.getToken);
|
|
41
46
|
|
|
42
47
|
// Initialize SignalR
|
|
43
|
-
|
|
48
|
+
const hubUrl = this.config.hubUrl || this.config.baseUrl || 'https://babylai.net/api';
|
|
49
|
+
console.log('🔌 Initializing SignalR with hubUrl:', hubUrl);
|
|
50
|
+
ClientSignalRService.initialize(hubUrl);
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
getConfig(): Config {
|
|
47
54
|
if (!this.config) {
|
|
48
|
-
throw new Error('Help Center not initialized. Call initialize() first with configuration.')
|
|
55
|
+
throw new Error('Help Center not initialized. Call initialize() first with configuration.');
|
|
49
56
|
}
|
|
50
|
-
|
|
51
|
-
return this.config
|
|
57
|
+
return this.config;
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
async getToken(): Promise<string> {
|
|
55
|
-
return await getValidToken()
|
|
61
|
+
return await getValidToken();
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
|
|
59
|
-
export const configService = ConfigService.getInstance()
|
|
65
|
+
export const configService = ConfigService.getInstance();
|
package/src/lib/types.ts
CHANGED
package/src/locales/ar.json
CHANGED
|
@@ -8,6 +8,23 @@
|
|
|
8
8
|
"pickTopic": "اختر موضوعًا",
|
|
9
9
|
"endChat": "إنهاء المحادثة",
|
|
10
10
|
"needAssistance": "هل تحتاج مساعدة؟ لاتردد في اخباري اضغط هنا",
|
|
11
|
-
"placeholder": "اكتب سؤالك هنا"
|
|
11
|
+
"placeholder": "اكتب سؤالك هنا",
|
|
12
|
+
"ReviewDialog": {
|
|
13
|
+
"title": "أضف تقييمك",
|
|
14
|
+
"description": "نحن نقدر ملاحظاتك! يُرجى تخصيص لحظة لتقييم تجربتك ومشاركة آرائك في قسم التعليقات أدناه. يساعدنا تقييمك في تحسين خدماتنا ويساعد المستخدمين الآخرين في اتخاذ قرارات مستنيرة. شكرًا لك!",
|
|
15
|
+
"rating_label": "التقييم:",
|
|
16
|
+
"comment_label": "التعليق:",
|
|
17
|
+
"submit_button": "إرسال التقييم",
|
|
18
|
+
"comment_error": "يجب أن يكون التعليق بين 10 و500 حرف.",
|
|
19
|
+
"rating_error": "يجب أن يكون التقييم بين 1 و5.",
|
|
20
|
+
"skip_button": "تخطي"
|
|
21
|
+
},
|
|
22
|
+
"ConfirmationModal": {
|
|
23
|
+
"title" : "تأكيد",
|
|
24
|
+
"message" : "هل أنت متأكد أنك تريد إنهاء المحادثة؟",
|
|
25
|
+
"confirmation_button": "إنهاء",
|
|
26
|
+
"cancel_button": "إلغاء"
|
|
27
|
+
}
|
|
28
|
+
|
|
12
29
|
}
|
|
13
30
|
}
|
package/src/locales/en.json
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
2
|
"homeSdk": {
|
|
3
3
|
"chatTitle": "Chat with",
|
|
4
4
|
"tryBabylAi": "Try Babyl AI for Free 🎉",
|
|
5
5
|
"contactSdk": "Contact us, Let's Talk!",
|
|
6
6
|
"welcomeMessage": "Hey there! 👋 I'm Babyl AI, here to assist you.",
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
"chatNow": "Chat Now",
|
|
8
|
+
"getstarted": "Get Started",
|
|
9
|
+
"pickTopic": "Pick a Topic to",
|
|
10
|
+
"endChat": "End Chat",
|
|
11
|
+
"needAssistance": "Need assistance Or You want to try the Product? Click here",
|
|
12
|
+
"placeholder": "write your message here...",
|
|
13
13
|
|
|
14
|
+
"ReviewDialog": {
|
|
15
|
+
"title": "Add your Review",
|
|
16
|
+
"description": "We appreciate your feedback! Please take a moment to rate your experience and share your thoughts in the comment section below. Your review helps us improve our services and assists other users in making informed decisions. Thank you!",
|
|
17
|
+
"rating_label": "Rating:",
|
|
18
|
+
"comment_label": "Comment:",
|
|
19
|
+
"submit_button": "Submit Review",
|
|
20
|
+
"comment_error": "Comment must be between 10 and 500 characters.",
|
|
21
|
+
"rating_error": "Rating must be between 1 and 5.",
|
|
22
|
+
"skip_button": "Skip"
|
|
23
|
+
},
|
|
24
|
+
"ConfirmationModal": {
|
|
25
|
+
"title": "Confirmation",
|
|
26
|
+
"message": "Are you sure you want to end the conversation?",
|
|
27
|
+
"confirmation_button": "Confirm",
|
|
28
|
+
"cancel_button": "Cancel",
|
|
29
|
+
"endAndStartNewChatTitle": "End and Start New Chat",
|
|
30
|
+
"endAndStartNewChatMessage": "Are you sure you want to end the current conversation and start a new one?"
|
|
31
|
+
}
|
|
14
32
|
}
|
|
15
|
-
}
|
|
33
|
+
}
|
|
@@ -1,42 +1,39 @@
|
|
|
1
|
-
import { Button } from '@/components'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import EnvelopeIcon from './../../../assets/icons/envelope.svg'
|
|
4
|
-
import { useLocalTranslation
|
|
1
|
+
import { Button } from '@/components'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import EnvelopeIcon from './../../../assets/icons/envelope.svg'
|
|
4
|
+
import { useLocalTranslation } from '../../../useLocalTranslation'
|
|
5
5
|
|
|
6
6
|
interface ChatWindowFooterProps {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
inputMessage: string
|
|
8
|
+
setInputMessage: (e: string) => void
|
|
9
|
+
handleKeyDown: (e: React.KeyboardEvent) => void
|
|
10
|
+
handleSendMessage: () => void
|
|
11
|
+
isLoading: boolean
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const ChatWindowFooter: React.FC<ChatWindowFooterProps> = (props) => {
|
|
14
|
-
const { t
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/>
|
|
37
|
-
</Button>
|
|
38
|
-
</footer>
|
|
39
|
-
)
|
|
15
|
+
const { t, dir } = useLocalTranslation()
|
|
16
|
+
return (
|
|
17
|
+
<footer className="babylai-flex babylai-items-center babylai-gap-2 babylai-relative babylai-rounded-full babylai-bg-white babylai-m-4 md:babylai-m-6 md:babylai-py-3 md:babylai-px-4">
|
|
18
|
+
<input
|
|
19
|
+
type="text"
|
|
20
|
+
value={props.inputMessage}
|
|
21
|
+
onChange={(e) => props.setInputMessage(e.target.value)}
|
|
22
|
+
onKeyDown={props.handleKeyDown}
|
|
23
|
+
placeholder={t('homeSdk.placeholder')}
|
|
24
|
+
className="babylai-flex-1 babylai-py-2 babylai-px-4 babylai-bg-transparent babylai-outline-none babylai-text-sm"
|
|
25
|
+
/>
|
|
26
|
+
<Button
|
|
27
|
+
variant="default"
|
|
28
|
+
size="icon"
|
|
29
|
+
onClick={props.handleSendMessage}
|
|
30
|
+
disabled={props?.isLoading}
|
|
31
|
+
className="babylai-rounded-full babylai-bg-purple-500 babylai-hover:babylai-bg-purple-600 babylai-w-8 babylai-h-8 babylai-disabled:babylai-opacity-50"
|
|
32
|
+
>
|
|
33
|
+
<EnvelopeIcon className={`babylai-w-4 babylai-h-4 ${dir === 'rtl' ? 'babylai-rotate-270' : ''}`} />
|
|
34
|
+
</Button>
|
|
35
|
+
</footer>
|
|
36
|
+
)
|
|
40
37
|
}
|
|
41
38
|
|
|
42
39
|
export default ChatWindowFooter
|
|
@@ -1,64 +1,58 @@
|
|
|
1
1
|
import Logo from '../../../assets/logo_ai.svg'
|
|
2
|
-
import { Button } from '@/components'
|
|
3
|
-
import React, { useState } from 'react'
|
|
4
|
-
import ArrowRight from './../../../assets/icons/arrowRight.svg'
|
|
5
|
-
import ThreeDots from './../../../assets/icons/threeDots.svg'
|
|
2
|
+
import { Button } from '@/components'
|
|
3
|
+
import React, { useState } from 'react'
|
|
4
|
+
import ArrowRight from './../../../assets/icons/arrowRight.svg'
|
|
5
|
+
import ThreeDots from './../../../assets/icons/threeDots.svg'
|
|
6
6
|
import { useLocalTranslation } from '../../../useLocalTranslation'
|
|
7
7
|
|
|
8
8
|
interface ChatWindowHeaderProps {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
isShowList: boolean
|
|
10
|
+
setIsShowList?: (isShowList: boolean) => void
|
|
11
|
+
showChat: boolean
|
|
12
|
+
onClose: () => void
|
|
13
|
+
handleBack: () => void
|
|
14
|
+
handleEndChat: () => void
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const ChatWindowHeader: React.FC<ChatWindowHeaderProps> = (props) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const [showMenu, setShowMenu] = useState(false)
|
|
19
|
+
const { t, i18n } = useLocalTranslation()
|
|
20
|
+
const isRTL = i18n.dir() === 'rtl'
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<Button variant="rounded-icon" size="icon" className="babylai-bg-primary-500/10" onClick={() => setShowMenu(!showMenu)}>
|
|
33
|
-
<ThreeDots className="babylai-w-[14px] babylai-h-[4px] babylai-text-primary-500" />
|
|
34
|
-
</Button>
|
|
22
|
+
return (
|
|
23
|
+
<header className="babylai-flex babylai-w-full babylai-items-center babylai-py-[18px] babylai-px-[18px] babylai-justify-between babylai-relative babylai-bg-black-white-50 babylai-rounded-t-3xl">
|
|
24
|
+
<div className="babylai-flex babylai-items-center babylai-gap-2">
|
|
25
|
+
<Button variant="rounded-icon" size="icon" className="babylai-bg-primary-500/10" onClick={props.handleBack}>
|
|
26
|
+
<ArrowRight className={`!babylai-w-[12px] babylai-h-[12px] ${isRTL ? '' : 'babylai-rotate-180'} babylai-text-primary-500`} />{' '}
|
|
27
|
+
</Button>
|
|
28
|
+
<div className="babylai-relative babylai-mr-2">
|
|
29
|
+
<Button variant="rounded-icon" size="icon" className="babylai-bg-primary-500/10" onClick={() => setShowMenu(!showMenu)}>
|
|
30
|
+
<ThreeDots className="babylai-w-[14px] babylai-h-[4px] babylai-text-primary-500" />
|
|
31
|
+
</Button>
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
)}
|
|
54
|
-
</div>
|
|
33
|
+
{showMenu && (
|
|
34
|
+
<div className="babylai-absolute babylai-top-10 babylai-left-0 babylai-w-48 babylai-rounded-md babylai-shadow-lg babylai-bg-white babylai-ring-1 babylai-ring-black babylai-ring-opacity-5 babylai-z-10">
|
|
35
|
+
<div className="babylai-py-1" role="menu" aria-orientation="vertical">
|
|
36
|
+
<button
|
|
37
|
+
className="babylai-block babylai-px-4 babylai-py-2 babylai-text-sm babylai-text-gray-700 babylai-hover:babylai-bg-gray-100 babylai-w-full babylai-text-left"
|
|
38
|
+
role="menuitem"
|
|
39
|
+
onClick={(e) => {
|
|
40
|
+
e.stopPropagation()
|
|
41
|
+
props.handleEndChat()
|
|
42
|
+
setShowMenu(false)
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
{t('homeSdk.endChat')}
|
|
46
|
+
</button>
|
|
47
|
+
</div>
|
|
55
48
|
</div>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
)}
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
<div className="babylai-flex babylai-items-center babylai-gap-2 babylai-absolute babylai-left-1/2 babylai-transform babylai--translate-x-1/2">
|
|
53
|
+
<Logo className="babylai-w-[124px] babylai-h-auto" />
|
|
54
|
+
</div>
|
|
55
|
+
</header>
|
|
56
|
+
)
|
|
63
57
|
}
|
|
64
|
-
export default ChatWindowHeader
|
|
58
|
+
export default ChatWindowHeader
|