@aslaluroba/help-center-react 2.0.4 → 2.0.6

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 (38) hide show
  1. package/dist/core/api.d.ts +4 -1
  2. package/dist/index.d.ts +3 -2
  3. package/dist/index.esm.js +994 -25294
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +995 -25295
  6. package/dist/index.js.map +1 -1
  7. package/dist/lib/config.d.ts +1 -1
  8. package/dist/lib/types.d.ts +4 -0
  9. package/dist/ui/chatbot-popup/chat-window-screen/footer.d.ts +1 -0
  10. package/dist/ui/chatbot-popup/chat-window-screen/index.d.ts +1 -1
  11. package/dist/ui/help-center.d.ts +1 -1
  12. package/dist/ui/help-popup.d.ts +9 -3
  13. package/dist/ui/review-dialog/index.d.ts +8 -0
  14. package/dist/ui/review-dialog/rating.d.ts +12 -0
  15. package/package.json +26 -5
  16. package/src/assets/icons/arrowRight.svg +1 -1
  17. package/src/assets/icons/closeCircle.svg +1 -1
  18. package/src/components/ui/agent-response/agent-response.tsx +36 -34
  19. package/src/components/ui/header.tsx +2 -3
  20. package/src/core/SignalRService.ts +25 -25
  21. package/src/core/api.ts +180 -44
  22. package/src/globals.css +0 -9
  23. package/src/index.ts +3 -2
  24. package/src/lib/config.ts +25 -25
  25. package/src/lib/types.ts +5 -0
  26. package/src/locales/ar.json +18 -1
  27. package/src/locales/en.json +26 -8
  28. package/src/ui/chatbot-popup/chat-window-screen/footer.tsx +31 -33
  29. package/src/ui/chatbot-popup/chat-window-screen/header.tsx +47 -53
  30. package/src/ui/chatbot-popup/chat-window-screen/index.tsx +182 -88
  31. package/src/ui/chatbot-popup/options-list-screen/header.tsx +24 -20
  32. package/src/ui/chatbot-popup/options-list-screen/index.tsx +24 -24
  33. package/src/ui/chatbot-popup/options-list-screen/option-card.tsx +9 -4
  34. package/src/ui/help-center.tsx +189 -159
  35. package/src/ui/help-popup.tsx +241 -165
  36. package/src/ui/review-dialog/index.tsx +106 -0
  37. package/src/ui/review-dialog/rating.tsx +78 -0
  38. package/tsconfig.json +48 -0
package/src/globals.css CHANGED
@@ -10,15 +10,6 @@
10
10
  }
11
11
 
12
12
 
13
- @media (min-width: 1820px) {
14
-
15
- .babylai-help-center-container {
16
- bottom: 2%;
17
- }
18
-
19
- }
20
-
21
-
22
13
 
23
14
 
24
15
  /* Help-popup styles */
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: string
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,59 @@
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: string
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
27
  this.config = {
28
- baseUrl: config.baseUrl,
29
- hubUrl: config.hubUrl || config.baseUrl,
28
+ baseUrl: config.baseUrl || 'https://babylai.net/api',
29
+ hubUrl: config.hubUrl || config.baseUrl || 'https://babylai.net/api',
30
30
  tenantId: config.tenantId,
31
31
  apiKey: config.apiKey,
32
- getToken: config.getToken
33
- }
32
+ getToken: config.getToken,
33
+ };
34
34
 
35
35
  // Initialize API with the getToken function directly
36
36
  if (!this.config.getToken) {
37
- throw new Error('getToken function is required in configuration')
37
+ throw new Error('getToken function is required in configuration');
38
38
  }
39
39
 
40
- initializeAPI(this.config.baseUrl, this.config.getToken)
40
+ initializeAPI(this.config.baseUrl || 'https://babylai.net/api', this.config.getToken);
41
41
 
42
42
  // Initialize SignalR
43
- ClientSignalRService.initialize(this.config.hubUrl || this.config.baseUrl)
43
+ const hubUrl = this.config.hubUrl || this.config.baseUrl || 'https://babylai.net/api';
44
+ ClientSignalRService.initialize(hubUrl);
44
45
  }
45
46
 
46
47
  getConfig(): Config {
47
48
  if (!this.config) {
48
- throw new Error('Help Center not initialized. Call initialize() first with configuration.')
49
+ throw new Error('Help Center not initialized. Call initialize() first with configuration.');
49
50
  }
50
- console.log('🚀 ~ ConfigService ~ getConfig ~ config:', this.config)
51
- return this.config
51
+ return this.config;
52
52
  }
53
53
 
54
54
  async getToken(): Promise<string> {
55
- return await getValidToken()
55
+ return await getValidToken();
56
56
  }
57
57
  }
58
58
 
59
- export const configService = ConfigService.getInstance()
59
+ export const configService = ConfigService.getInstance();
package/src/lib/types.ts CHANGED
@@ -118,3 +118,8 @@ export interface Option {
118
118
  hasNestedOptions: boolean
119
119
  order: number
120
120
  }
121
+
122
+ export interface ReviewProps {
123
+ comment: string
124
+ rating: number
125
+ }
@@ -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
  }
@@ -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
- "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..."
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,40 @@
1
1
  import { Button } from '@/components';
2
2
  import React from 'react';
3
3
  import EnvelopeIcon from './../../../assets/icons/envelope.svg';
4
- import { useLocalTranslation } from '../../../useLocalTranslation'
4
+ import { useLocalTranslation } from '../../../useLocalTranslation';
5
5
 
6
6
  interface ChatWindowFooterProps {
7
- inputMessage: string;
8
- setInputMessage: (e: string) => void;
9
- handleKeyDown: (e: React.KeyboardEvent) => void;
10
- handleSendMessage: () => void;
7
+ inputMessage: string;
8
+ setInputMessage: (e: string) => void;
9
+ handleKeyDown: (e: React.KeyboardEvent) => void;
10
+ handleSendMessage: () => void;
11
+ isLoading: boolean;
12
+ isSignalRConnected: boolean;
11
13
  }
12
14
 
13
15
  const ChatWindowFooter: React.FC<ChatWindowFooterProps> = (props) => {
14
- const { t , i18n} = useLocalTranslation();
15
- const isRTL = i18n.dir() === 'rtl';
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
- className="babylai-rounded-full babylai-bg-purple-500 babylai-hover:babylai-bg-purple-600 babylai-w-8 babylai-h-8"
31
- >
32
- <EnvelopeIcon
33
- className={`babylai-w-4 babylai-h-4 ${
34
- isRTL ? 'babylai-rotate-270' : ''
35
- }`}
36
- />
37
- </Button>
38
- </footer>
39
- )
40
- }
16
+ const { t, dir } = useLocalTranslation();
17
+ return (
18
+ <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'>
19
+ <input
20
+ type='text'
21
+ value={props.inputMessage}
22
+ onChange={(e) => props.setInputMessage(e.target.value)}
23
+ onKeyDown={props.handleKeyDown}
24
+ placeholder={t('homeSdk.placeholder')}
25
+ className='babylai-flex-1 babylai-py-2 babylai-px-4 babylai-bg-transparent babylai-outline-none babylai-text-sm'
26
+ />
27
+ <Button
28
+ variant='default'
29
+ size='icon'
30
+ onClick={props.handleSendMessage}
31
+ disabled={props?.isLoading || !props.isSignalRConnected}
32
+ 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'
33
+ >
34
+ <EnvelopeIcon className={`babylai-w-4 babylai-h-4 ${dir === 'rtl' ? 'babylai-rotate-270' : ''}`} />
35
+ </Button>
36
+ </footer>
37
+ );
38
+ };
41
39
 
42
- export default ChatWindowFooter
40
+ 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
- isShowList: boolean;
10
- setIsShowList?: (isShowList: boolean) => void;
11
- showChat: boolean;
12
- onClose: () => void;
13
- handleBack: () => void;
14
- handleEndChat: () => void;
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
- const [showMenu, setShowMenu] = useState(false)
19
- const { t , i18n} = useLocalTranslation();
20
- const isRTL = i18n.dir() === 'rtl';
18
+ const [showMenu, setShowMenu] = useState(false)
19
+ const { t, i18n } = useLocalTranslation()
20
+ const isRTL = i18n.dir() === 'rtl'
21
21
 
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
27
- className={`babylai-w-[12px] babylai-h-[12px] ${
28
- isRTL ? '' : 'babylai-rotate-180'
29
- } babylai-text-primary-500`}
30
- /> </Button>
31
- <div className="babylai-relative babylai-mr-2">
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
- {showMenu && (
37
- <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">
38
- <div className="babylai-py-1" role="menu" aria-orientation="vertical">
39
- <button
40
- 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"
41
- role="menuitem"
42
- onClick={(e) => {
43
- e.stopPropagation()
44
- props.handleEndChat()
45
- setShowMenu(false)
46
- }}
47
- >
48
- {t('homeSdk.endChat')}
49
-
50
- </button>
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
- <div className="babylai-flex babylai-items-center babylai-gap-2 babylai-absolute babylai-left-1/2 babylai-transform babylai--translate-x-1/2">
57
- <Logo className="babylai-w-[124px] babylai-h-auto" />
58
- </div>
59
-
60
- </header>
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