@aslaluroba/help-center-react 3.0.6 → 3.0.8
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/index.css +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.esm.js +92 -55
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +91 -54
- package/dist/index.js.map +1 -1
- package/dist/lib/LanguageContext.d.ts +11 -0
- package/dist/lib/index.d.ts +2 -1
- package/dist/ui/confirmation-modal/index.d.ts +1 -1
- package/dist/useLocalTranslation.d.ts +1 -1
- package/package.json +1 -2
- package/src/components/shared/Button/button.tsx +3 -3
- package/src/components/shared/Card/card.tsx +8 -8
- package/src/index.ts +0 -1
- package/src/lib/LanguageContext.tsx +28 -0
- package/src/lib/index.ts +2 -1
- package/src/ui/chatbot-popup/chat-window-screen/footer.tsx +1 -1
- package/src/ui/chatbot-popup/chat-window-screen/header.tsx +7 -8
- package/src/ui/chatbot-popup/chat-window-screen/index.tsx +1 -1
- package/src/ui/chatbot-popup/error-screen/index.tsx +1 -1
- package/src/ui/chatbot-popup/home-screen/card.tsx +1 -1
- package/src/ui/chatbot-popup/home-screen/index.tsx +2 -2
- package/src/ui/chatbot-popup/loading-screen/index.tsx +1 -1
- package/src/ui/chatbot-popup/options-list-screen/header.tsx +2 -2
- package/src/ui/chatbot-popup/options-list-screen/index.tsx +3 -3
- package/src/ui/chatbot-popup/options-list-screen/option-card.tsx +1 -1
- package/src/ui/confirmation-modal/index.tsx +1 -1
- package/src/ui/floating-message.tsx +1 -1
- package/src/ui/help-center.tsx +26 -4
- package/src/ui/help-popup.tsx +3 -3
- package/src/ui/review-dialog/index.tsx +6 -6
- package/src/ui/review-dialog/rating.tsx +7 -7
- package/src/useLocalTranslation.ts +6 -5
- package/dist/core/SignalRService.d.ts +0 -11
- package/src/core/SignalRService.ts +0 -83
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
interface LanguageContextType {
|
|
3
|
+
language: string;
|
|
4
|
+
}
|
|
5
|
+
interface LanguageProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
language: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const LanguageProvider: React.FC<LanguageProviderProps>;
|
|
10
|
+
export declare const useLanguage: () => LanguageContextType | null;
|
|
11
|
+
export {};
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./LanguageContext";
|
|
2
|
+
export * from "./utils";
|
|
@@ -4,5 +4,5 @@ interface ConfirmationModalProps {
|
|
|
4
4
|
onCancel: () => void;
|
|
5
5
|
onConfirm: () => void;
|
|
6
6
|
}
|
|
7
|
-
declare const ConfirmationModal: ({ title, message, onCancel, onConfirm
|
|
7
|
+
declare const ConfirmationModal: ({ title, message, onCancel, onConfirm }: ConfirmationModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export default ConfirmationModal;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "dist/index.js",
|
|
4
4
|
"module": "dist/index.esm.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
-
"version": "3.0.
|
|
6
|
+
"version": "3.0.8",
|
|
7
7
|
"description": "BabylAI Help Center Widget for React and Next.js",
|
|
8
8
|
"private": false,
|
|
9
9
|
"exports": {
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@ably/chat": "^0.8.0",
|
|
62
|
-
"@microsoft/signalr": "^7.0.14",
|
|
63
62
|
"@tabler/icons-react": "^3.34.1",
|
|
64
63
|
"clsx": "^2.1.1",
|
|
65
64
|
"tailwind-merge": "^3.3.1",
|
|
@@ -8,14 +8,14 @@ const buttonVariants = cva(
|
|
|
8
8
|
variant: {
|
|
9
9
|
default: 'babylai-bg-primary-500 babylai-p-2 babylai-text-white babylai-text-xs babylai-font-semibold hover:babylai-bg-primary-600',
|
|
10
10
|
destructive:
|
|
11
|
-
'babylai-bg-destructive babylai-p-2 babylai-text-destructive-foreground babylai-shadow-sm
|
|
11
|
+
'babylai-bg-destructive babylai-p-2 babylai-text-destructive-foreground babylai-shadow-sm hover:babylai-bg-destructive/90',
|
|
12
12
|
outline:
|
|
13
13
|
'babylai-border babylai-border-primary-500 babylai-bg-background-transparent hover:babylai-border-primary-600 hover:babylai-text-primary-600 babylai-text-primary-500 babylai-font-bold',
|
|
14
14
|
secondary:
|
|
15
15
|
'babylai-bg-secondary babylai-p-2 babylai-text-secondary-foreground babylai-shadow-sm babylai-hover:babylai-bg-secondary/80',
|
|
16
16
|
ghost:
|
|
17
|
-
'babylai-bg-transparent babylai-p-2 babylai-text-secondary-foreground babylai-shadow-sm
|
|
18
|
-
link: 'babylai-text-primary babylai-underline-offset-4
|
|
17
|
+
'babylai-bg-transparent babylai-p-2 babylai-text-secondary-foreground babylai-shadow-sm hover:babylai-bg-secondary/80',
|
|
18
|
+
link: 'babylai-text-primary babylai-underline-offset-4 hover:babylai-underline',
|
|
19
19
|
'rounded-icon': '!babylai-p-2'
|
|
20
20
|
},
|
|
21
21
|
size: {
|
|
@@ -7,9 +7,9 @@ interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
7
7
|
|
|
8
8
|
const Card = React.forwardRef<HTMLDivElement, CardProps>(({ className, variant = 'default', ...props }, ref) => {
|
|
9
9
|
const variantStyles = {
|
|
10
|
-
default: 'rounded-xl border bg-card text-card-foreground shadow',
|
|
11
|
-
rounded: 'rounded-3xl bg-black-white-50 py-4 px-3',
|
|
12
|
-
shadowed: 'rounded-xl border bg-card text-card-foreground shadow-lg'
|
|
10
|
+
default: 'babylai-rounded-xl babylai-border babylai-bg-card babylai-text-card-foreground babylai-shadow',
|
|
11
|
+
rounded: 'babylai-rounded-3xl babylai-bg-black-white-50 babylai-py-4 babylai-px-3',
|
|
12
|
+
shadowed: 'babylai-rounded-xl babylai-border babylai-bg-card babylai-text-card-foreground babylai-shadow-lg'
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
return <div ref={ref} className={cn(variantStyles[variant], className)} {...props} />
|
|
@@ -17,27 +17,27 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(({ className, variant =
|
|
|
17
17
|
Card.displayName = 'Card'
|
|
18
18
|
|
|
19
19
|
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
|
20
|
-
<div ref={ref} className={cn('flex flex-col space-y-1.5 p-6', className)} {...props} />
|
|
20
|
+
<div ref={ref} className={cn('babylai-flex babylai-flex-col babylai-space-y-1.5 babylai-p-6', className)} {...props} />
|
|
21
21
|
))
|
|
22
22
|
CardHeader.displayName = 'CardHeader'
|
|
23
23
|
|
|
24
24
|
const CardTitle = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
|
25
|
-
<div ref={ref} className={cn('font-semibold leading-none tracking-tight', className)} {...props} />
|
|
25
|
+
<div ref={ref} className={cn('babylai-font-semibold babylai-leading-none babylai-tracking-tight', className)} {...props} />
|
|
26
26
|
))
|
|
27
27
|
CardTitle.displayName = 'CardTitle'
|
|
28
28
|
|
|
29
29
|
const CardDescription = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
|
30
|
-
<div ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
|
|
30
|
+
<div ref={ref} className={cn('babylai-text-sm babylai-text-muted-foreground', className)} {...props} />
|
|
31
31
|
))
|
|
32
32
|
CardDescription.displayName = 'CardDescription'
|
|
33
33
|
|
|
34
34
|
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
|
35
|
-
<div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
|
|
35
|
+
<div ref={ref} className={cn('babylai-p-6 babylai-pt-0', className)} {...props} />
|
|
36
36
|
))
|
|
37
37
|
CardContent.displayName = 'CardContent'
|
|
38
38
|
|
|
39
39
|
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
|
40
|
-
<div ref={ref} className={cn('flex items-center p-6 pt-0', className)} {...props} />
|
|
40
|
+
<div ref={ref} className={cn('babylai-flex babylai-items-center babylai-p-6 babylai-pt-0', className)} {...props} />
|
|
41
41
|
))
|
|
42
42
|
CardFooter.displayName = 'CardFooter'
|
|
43
43
|
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { createContext, ReactNode, useContext } from "react";
|
|
2
|
+
|
|
3
|
+
interface LanguageContextType {
|
|
4
|
+
language: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const LanguageContext = createContext<LanguageContextType | null>(null);
|
|
8
|
+
|
|
9
|
+
interface LanguageProviderProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
language: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const LanguageProvider: React.FC<LanguageProviderProps> = ({
|
|
15
|
+
children,
|
|
16
|
+
language,
|
|
17
|
+
}) => {
|
|
18
|
+
return (
|
|
19
|
+
<LanguageContext.Provider value={{ language }}>
|
|
20
|
+
{children}
|
|
21
|
+
</LanguageContext.Provider>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const useLanguage = () => {
|
|
26
|
+
const context = useContext(LanguageContext);
|
|
27
|
+
return context;
|
|
28
|
+
};
|
package/src/lib/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./LanguageContext";
|
|
2
|
+
export * from "./utils";
|
|
@@ -27,7 +27,7 @@ const ChatWindowFooter: React.FC<ChatWindowFooterProps> = (props) => {
|
|
|
27
27
|
size='icon'
|
|
28
28
|
onClick={props.handleSendMessage}
|
|
29
29
|
disabled={props?.isLoading}
|
|
30
|
-
className='babylai-rounded-full babylai-bg-purple-500 babylai-hover:babylai-bg-purple-600 babylai-w-8 babylai-h-8
|
|
30
|
+
className='babylai-rounded-full babylai-bg-purple-500 babylai-hover:babylai-bg-purple-600 babylai-w-8 babylai-h-8 disabled:babylai-opacity-50'
|
|
31
31
|
>
|
|
32
32
|
<EnvelopeIcon className={`babylai-w-4 babylai-h-4 ${dir === 'rtl' ? 'babylai-rotate-270' : ''}`} />
|
|
33
33
|
</Button>
|
|
@@ -29,28 +29,28 @@ const ChatWindowHeader: React.FC<ChatWindowHeaderProps> = (props) => {
|
|
|
29
29
|
onClick={props.handleBack}
|
|
30
30
|
>
|
|
31
31
|
<ArrowRight
|
|
32
|
-
className={`!babylai-w-
|
|
32
|
+
className={`!babylai-w-3 babylai-h-3 ${isRTL ? "" : "babylai-rotate-180"} babylai-text-primary-500 dark:babylai-text-white`}
|
|
33
33
|
/>{" "}
|
|
34
34
|
</Button>
|
|
35
|
-
<div className="babylai-relative babylai-
|
|
35
|
+
<div className="babylai-relative babylai-me-2">
|
|
36
36
|
<Button
|
|
37
37
|
variant="rounded-icon"
|
|
38
38
|
size="icon"
|
|
39
39
|
className="babylai-bg-primary-500/10 dark:babylai-bg-storm-dust-950"
|
|
40
40
|
onClick={() => setShowMenu(!showMenu)}
|
|
41
41
|
>
|
|
42
|
-
<ThreeDots className="babylai-w-
|
|
42
|
+
<ThreeDots className="babylai-w-3.5 babylai-h-1 babylai-text-primary-500 dark:babylai-text-white" />
|
|
43
43
|
</Button>
|
|
44
44
|
|
|
45
45
|
{showMenu && (
|
|
46
|
-
<div className="babylai-absolute babylai-top-10 babylai-start-0 babylai-w-48 babylai-rounded-md babylai-shadow-lg babylai-bg-white dark:!babylai-bg-storm-dust-950 babylai-ring-1 babylai-ring-black babylai-ring-opacity-5 babylai-z-10">
|
|
46
|
+
<div className="babylai-absolute babylai-top-10 babylai-start-0 babylai-w-48 babylai-rounded-md babylai-shadow-lg babylai-bg-white dark:!babylai-bg-storm-dust-950 babylai-ring-1 babylai-ring-black-white-700 babylai-ring-opacity-5 babylai-z-10">
|
|
47
47
|
<div
|
|
48
48
|
className="babylai-py-1"
|
|
49
49
|
role="menu"
|
|
50
50
|
aria-orientation="vertical"
|
|
51
51
|
>
|
|
52
52
|
<button
|
|
53
|
-
className="babylai-block babylai-px-4 babylai-py-2 babylai-text-sm babylai-text-gray-700 dark:babylai-text-white
|
|
53
|
+
className="babylai-block babylai-px-4 babylai-py-2 babylai-text-sm babylai-text-gray-700 dark:babylai-text-white hover:babylai-bg-gray-100 babylai-w-full babylai-text-start"
|
|
54
54
|
role="menuitem"
|
|
55
55
|
onClick={(e) => {
|
|
56
56
|
e.stopPropagation();
|
|
@@ -65,9 +65,8 @@ const ChatWindowHeader: React.FC<ChatWindowHeaderProps> = (props) => {
|
|
|
65
65
|
)}
|
|
66
66
|
</div>
|
|
67
67
|
</div>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
</div>
|
|
68
|
+
|
|
69
|
+
<Logo className="babylai-w-[124px] babylai-h-auto dark:babylai-text-white" />
|
|
71
70
|
</header>
|
|
72
71
|
);
|
|
73
72
|
};
|
|
@@ -32,7 +32,7 @@ const MessageComponent = React.memo(
|
|
|
32
32
|
}) => {
|
|
33
33
|
const isFirstInSequence = index === 0 || messages[index - 1].senderType !== message.senderType;
|
|
34
34
|
const isFirstHumanAgentMessage = index === firstHumanAgentIndex && message.senderType === 2;
|
|
35
|
-
const textDirection = message.senderType === 1 ? 'justify-end' : 'justify-start';
|
|
35
|
+
const textDirection = message.senderType === 1 ? 'babylai-justify-end' : 'babylai-justify-start';
|
|
36
36
|
|
|
37
37
|
return (
|
|
38
38
|
<div key={message.id}>
|
|
@@ -8,7 +8,7 @@ interface ChatBotErrorScreenProps {
|
|
|
8
8
|
const ChatBotErrorScreen: React.FC<ChatBotErrorScreenProps> = (props) => {
|
|
9
9
|
return (
|
|
10
10
|
<div className="babylai-w-full babylai-h-full babylai-bg-black-white-50 babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col">
|
|
11
|
-
<div className="h-full
|
|
11
|
+
<div className="babylai-h-full babylai-rounded-3xl babylai-flex babylai-flex-col babylai-bg-gradient-to-b babylai-from-primary-500 babylai-to-primary-500/60 babylai-py-6 md:babylai-py-8 babylai-px-6 babylai-gap-4 md:babylai-gap-8">
|
|
12
12
|
<Header onClose={props.onClose} />
|
|
13
13
|
<div className="babylai-flex babylai-flex-col babylai-items-center babylai-justify-center babylai-w-full babylai-h-full babylai-px-6 babylai-py-16 md:babylai-py-28">
|
|
14
14
|
<div className="babylai-text-white babylai-text-lg">Error: {props.error}</div>
|
|
@@ -11,7 +11,7 @@ const Card: React.FC<CardProps> = (props) => {
|
|
|
11
11
|
const { dir } = useLocalTranslation();
|
|
12
12
|
const isLTR = dir === "ltr";
|
|
13
13
|
return (
|
|
14
|
-
<div className="babylai-flex
|
|
14
|
+
<div className="babylai-flex babylai-items-center babylai-justify-between babylai-gap-4 babylai-bg-black-white-50 babylai-rounded-3xl babylai-p-6">
|
|
15
15
|
<p className="babylai-text-base md:babylai-text-lg babylai-font-medium babylai-text-black-white-800">
|
|
16
16
|
{props.text}
|
|
17
17
|
</p>
|
|
@@ -20,7 +20,7 @@ const HomeScreen: React.FC<HomeScreenProps> = (props) => {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
|
-
<div className="babylai-h-full babylai-flex babylai-flex-col babylai-overflow-y-auto babylai-py-6 md:babylai-py-8 babylai-px-6 gap-4 md:gap-8">
|
|
23
|
+
<div className="babylai-h-full babylai-flex babylai-flex-col babylai-overflow-y-auto babylai-py-6 md:babylai-py-8 babylai-px-6 babylai-gap-4 md:babylai-gap-8">
|
|
24
24
|
<Header onClose={props.onClose} />
|
|
25
25
|
|
|
26
26
|
<h1 className="babylai-text-2xl md:babylai-text-4xl babylai-font-bold babylai-text-white">
|
|
@@ -29,7 +29,7 @@ const HomeScreen: React.FC<HomeScreenProps> = (props) => {
|
|
|
29
29
|
BabylAI 🚀
|
|
30
30
|
</h1>
|
|
31
31
|
|
|
32
|
-
<div className="babylai-flex babylai-flex-col gap-3">
|
|
32
|
+
<div className="babylai-flex babylai-flex-col babylai-gap-3">
|
|
33
33
|
<ChatNowCard setIsShowList={props.setIsShowList} />
|
|
34
34
|
|
|
35
35
|
<Card handleClick={handleNavigateTo} text={t('homeSdk.tryBabylAi')} />
|
|
@@ -12,7 +12,7 @@ const ChatBotLoadingScreen: React.FC<ChatBotLoadingScreenProps> = (props) => {
|
|
|
12
12
|
<div className="babylai-w-full babylai-h-full babylai-bg-black-white-50 dark:babylai-bg-storm-dust-950 babylai-rounded-3xl babylai-shadow-lg babylai-flex babylai-flex-col">
|
|
13
13
|
<div
|
|
14
14
|
className={cn(
|
|
15
|
-
'babylai-rounded-3xl babylai-h-full babylai-flex babylai-flex-col babylai-py-6 md:babylai-py-8 babylai-px-6 gap-4 md:gap-8',
|
|
15
|
+
'babylai-rounded-3xl babylai-h-full babylai-flex babylai-flex-col babylai-py-6 md:babylai-py-8 babylai-px-6 babylai-gap-4 md:babylai-gap-8',
|
|
16
16
|
{
|
|
17
17
|
'babylai-bg-gradient-to-b babylai-from-primary-500 babylai-to-primary-500/60': !props.isShowList,
|
|
18
18
|
'babylai-bg-black-white-100 dark:babylai-bg-storm-dust-950': props.isShowList
|
|
@@ -19,7 +19,7 @@ const OptionsListHeader: React.FC<OptionsListHeaderProps> = ({
|
|
|
19
19
|
return (
|
|
20
20
|
<header
|
|
21
21
|
dir={dir}
|
|
22
|
-
className={`babylai-flex babylai-w-full babylai-items-center mb-2 ${
|
|
22
|
+
className={`babylai-flex babylai-w-full babylai-items-center babylai-mb-2 ${
|
|
23
23
|
!showHelpScreen ? "babylai-justify-end" : "babylai-justify-between"
|
|
24
24
|
}`}
|
|
25
25
|
>
|
|
@@ -37,7 +37,7 @@ const OptionsListHeader: React.FC<OptionsListHeaderProps> = ({
|
|
|
37
37
|
<CloseCircle className="!babylai-w-full !babylai-h-full babylai-cursor-pointer" />
|
|
38
38
|
)}
|
|
39
39
|
</Button>
|
|
40
|
-
<ThinkingLogo className="babylai-w-40 babylai-h-40 babylai-text-primary-500 babylai-absolute babylai-top-0 babylai-
|
|
40
|
+
<ThinkingLogo className="babylai-w-40 babylai-h-40 babylai-text-primary-500 babylai-absolute babylai-top-0 babylai-right-1 babylai-overflow-hidden" />
|
|
41
41
|
</header>
|
|
42
42
|
);
|
|
43
43
|
};
|
|
@@ -30,10 +30,10 @@ const OptionsListScreen: React.FC<OptionsListScreenProps> = ({
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
|
-
<div className='babylai-px-8 babylai-pb-12 babylai-pt-8 babylai-overflow-y-auto
|
|
33
|
+
<div className='babylai-px-8 babylai-pb-12 babylai-pt-8 babylai-overflow-y-auto babylai-h-full'>
|
|
34
34
|
<OptionsListHeader handleBack={handleBack} showHelpScreen={showHelpScreen} />
|
|
35
35
|
|
|
36
|
-
<h1 className='babylai-text-4xl babylai-font-bold mb-4 babylai-text-black-white-800 dark:babylai-text-white'>
|
|
36
|
+
<h1 className='babylai-text-4xl babylai-font-bold babylai-mb-4 babylai-text-black-white-800 dark:babylai-text-white'>
|
|
37
37
|
{helpScreen?.title}
|
|
38
38
|
</h1>
|
|
39
39
|
|
|
@@ -43,7 +43,7 @@ const OptionsListScreen: React.FC<OptionsListScreenProps> = ({
|
|
|
43
43
|
<Card
|
|
44
44
|
key={option.id}
|
|
45
45
|
variant='rounded'
|
|
46
|
-
className='babylai-cursor-pointer babylai-transition-all
|
|
46
|
+
className='babylai-cursor-pointer babylai-transition-all hover:babylai-shadow-md !babylai-px-2 !babylai-py-1 dark:!babylai-bg-storm-dust-900'
|
|
47
47
|
onClick={() => handleToggleExpandOption(option)}
|
|
48
48
|
>
|
|
49
49
|
<OptionCard title={option.title} />
|
|
@@ -20,7 +20,7 @@ const OptionCard: React.FC<OptionCardProps> = (props) => {
|
|
|
20
20
|
className="babylai-text-primary-500 hover:babylai-bg-primary-100"
|
|
21
21
|
>
|
|
22
22
|
<ArrowRight
|
|
23
|
-
className={`babylai-w-
|
|
23
|
+
className={`babylai-w-3 babylai-h-3 ${
|
|
24
24
|
isLTR ? "" : "babylai-rotate-180"
|
|
25
25
|
} babylai-text-primary-500`}
|
|
26
26
|
/>
|
|
@@ -8,7 +8,7 @@ interface ConfirmationModalProps {
|
|
|
8
8
|
onConfirm: () => void;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const ConfirmationModal = ({ title, message, onCancel, onConfirm
|
|
11
|
+
const ConfirmationModal = ({ title, message, onCancel, onConfirm }: ConfirmationModalProps) => {
|
|
12
12
|
const { t } = useLocalTranslation();
|
|
13
13
|
|
|
14
14
|
return (
|
|
@@ -13,7 +13,7 @@ export function FloatingMessage({ message, onClose }: FloatingMessageProps) {
|
|
|
13
13
|
<div className="babylai-bg-primary-500 babylai-text-white babylai-py-3 babylai-px-4 babylai-rounded-3xl babylai-shadow-lg babylai-mb-4 babylai-max-w-[200px] babylai-relative after:babylai-content-[''] after:babylai-absolute after:babylai--bottom-[10px] after:babylai-right-5 after:babylai-w-0 after:babylai-h-0 after:babylai-border-l-[10px] after:babylai-border-r-[10px] after:babylai-border-t-[10px] after:babylai-border-l-transparent after:babylai-border-r-transparent after:babylai-border-t-primary-500">
|
|
14
14
|
<p className="babylai-text-xs babylai-font-bold babylai-m-0">{message}</p>
|
|
15
15
|
<button
|
|
16
|
-
className="babylai-absolute babylai--top-2 babylai--right-2 babylai-w-5 babylai-h-5 babylai-rounded-full babylai-bg-white babylai-border-none babylai-cursor-pointer babylai-flex babylai-items-center babylai-justify-center babylai-text-black babylai-p-[3px] babylai-
|
|
16
|
+
className="babylai-absolute babylai--top-2 babylai--right-2 babylai-w-5 babylai-h-5 babylai-rounded-full babylai-bg-white babylai-border-none babylai-cursor-pointer babylai-flex babylai-items-center babylai-justify-center babylai-text-black-white-700 babylai-p-[3px] hover:babylai-bg-primary-400 babylai-hover:text-white babylai-shadow-md"
|
|
17
17
|
onClick={onClose}
|
|
18
18
|
>
|
|
19
19
|
<CloseIcon className="babylai-w-8 babylai-h-8" />
|
package/src/ui/help-center.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import { FloatingMessage } from './floating-message';
|
|
|
9
9
|
import { HelpButton } from './help-button';
|
|
10
10
|
import { HelpPopup } from './help-popup';
|
|
11
11
|
import { defaultLanguage } from '@/i18n';
|
|
12
|
+
import { LanguageProvider } from '@/lib/LanguageContext';
|
|
12
13
|
|
|
13
14
|
interface HelpCenterProps {
|
|
14
15
|
helpScreenId: string;
|
|
@@ -24,15 +25,14 @@ interface HelpCenterProps {
|
|
|
24
25
|
showHelpScreen?: boolean;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
function HelpCenterContent({
|
|
28
29
|
helpScreenId,
|
|
29
30
|
user,
|
|
30
31
|
showArrow = true,
|
|
31
|
-
language = defaultLanguage,
|
|
32
32
|
messageLabel = null,
|
|
33
33
|
showHelpScreen = false,
|
|
34
|
-
}: HelpCenterProps) {
|
|
35
|
-
const { t } = useLocalTranslation(
|
|
34
|
+
}: Omit<HelpCenterProps, 'language'>) {
|
|
35
|
+
const { t } = useLocalTranslation();
|
|
36
36
|
const [isOpen, setIsOpen] = useState(false);
|
|
37
37
|
const [showArrowAnimation, setShowArrowAnimation] = useState(showArrow);
|
|
38
38
|
const [helpScreenData, setHelpScreenData] = useState<HelpScreenData | null>(null);
|
|
@@ -309,3 +309,25 @@ export function HelpCenter({
|
|
|
309
309
|
</div>
|
|
310
310
|
);
|
|
311
311
|
}
|
|
312
|
+
|
|
313
|
+
// Main HelpCenter component that provides the language context
|
|
314
|
+
export function HelpCenter({
|
|
315
|
+
helpScreenId,
|
|
316
|
+
user,
|
|
317
|
+
showArrow = true,
|
|
318
|
+
language = defaultLanguage,
|
|
319
|
+
messageLabel = null,
|
|
320
|
+
showHelpScreen = false,
|
|
321
|
+
}: HelpCenterProps) {
|
|
322
|
+
return (
|
|
323
|
+
<LanguageProvider language={language}>
|
|
324
|
+
<HelpCenterContent
|
|
325
|
+
helpScreenId={helpScreenId}
|
|
326
|
+
user={user}
|
|
327
|
+
showArrow={showArrow}
|
|
328
|
+
messageLabel={messageLabel}
|
|
329
|
+
showHelpScreen={showHelpScreen}
|
|
330
|
+
/>
|
|
331
|
+
</LanguageProvider>
|
|
332
|
+
);
|
|
333
|
+
}
|
package/src/ui/help-popup.tsx
CHANGED
|
@@ -247,7 +247,7 @@ export function HelpPopup({
|
|
|
247
247
|
if (status === 'loading' && !helpScreen) {
|
|
248
248
|
return (
|
|
249
249
|
<div
|
|
250
|
-
className='babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-
|
|
250
|
+
className='babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-h-[calc(100vh-240px)] babylai-max-h-[800px]
|
|
251
251
|
babylai-overflow-auto babylai-w-full babylai-bg-black-white-50 md:babylai-mb-4
|
|
252
252
|
md:babylai-bottom-[6rem] md:babylai-right-4 babylai-rounded-none md:babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col'
|
|
253
253
|
>
|
|
@@ -259,7 +259,7 @@ md:babylai-bottom-[6rem] md:babylai-right-4 babylai-rounded-none md:babylai-roun
|
|
|
259
259
|
if (error) {
|
|
260
260
|
return (
|
|
261
261
|
<div
|
|
262
|
-
className='babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-
|
|
262
|
+
className='babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-h-[calc(100vh-240px)] babylai-max-h-[800px]
|
|
263
263
|
babylai-overflow-auto babylai-w-full babylai-bg-black-white-50 md:babylai-mb-4
|
|
264
264
|
md:babylai-bottom-[6rem] md:babylai-right-4 babylai-rounded-none md:babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col'
|
|
265
265
|
>
|
|
@@ -270,7 +270,7 @@ md:babylai-bottom-[6rem] md:babylai-right-4 babylai-rounded-none md:babylai-roun
|
|
|
270
270
|
|
|
271
271
|
return (
|
|
272
272
|
<div
|
|
273
|
-
className='babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-
|
|
273
|
+
className='babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-h-[calc(100vh-240px)] babylai-max-h-[800px]
|
|
274
274
|
babylai-overflow-auto babylai-w-full babylai-bg-black-white-50 md:babylai-mb-4
|
|
275
275
|
md:babylai-bottom-[6rem] md:babylai-right-4 babylai-rounded-none md:babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col'
|
|
276
276
|
>
|
|
@@ -52,19 +52,19 @@ const ReviewDialog: React.FC<ReviewDialogProps> = (props) => {
|
|
|
52
52
|
|
|
53
53
|
return (
|
|
54
54
|
<section className="babylai-p-6 babylai-gap-6 babylai-max-w-sm babylai-max-h-[calc(100vh-90px)] babylai-overflow-auto babylai-w-full babylai-bg-black-white-50 dark:babylai-bg-storm-dust-950 babylai-fixed babylai-bottom-20 babylai-right-0 md:babylai-right-4 babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col">
|
|
55
|
-
<header className='border-b pb-4 babylai-flex babylai-items-center babylai-justify-between babylai-gap-4'>
|
|
55
|
+
<header className='babylai-border-b babylai-pb-4 babylai-flex babylai-items-center babylai-justify-between babylai-gap-4'>
|
|
56
56
|
<h2 className="babylai-text-lg babylai-font-semibold dark:babylai-text-white">{t('homeSdk.ReviewDialog.title')}</h2>
|
|
57
57
|
<CloseCircle className="babylai-w-6 babylai-h-6 babylai-cursor-pointer dark:babylai-text-white" onClick={props.onClose} />
|
|
58
58
|
</header>
|
|
59
59
|
<div className="babylai-flex babylai-flex-col babylai-gap-2">
|
|
60
|
-
<p className="babylai-text-sm babylai-text-gray-600 mb-3 dark:babylai-text-white">
|
|
60
|
+
<p className="babylai-text-sm babylai-text-gray-600 babylai-mb-3 dark:babylai-text-white">
|
|
61
61
|
{t('homeSdk.ReviewDialog.description')}
|
|
62
62
|
</p>
|
|
63
63
|
|
|
64
64
|
<div className="babylai-flex babylai-items-center babylai-gap-2">
|
|
65
65
|
<span className="babylai-text-base babylai-font-medium dark:babylai-text-white">{t('homeSdk.ReviewDialog.rating_label')}</span>
|
|
66
66
|
<Rating value={rating} onChange={handleRatingChange} />
|
|
67
|
-
<span className={`babylai-text-sm babylai-text-red-500 transition-opacity duration-300 ${error.rating ? 'opacity-100' : 'opacity-0'}`}>
|
|
67
|
+
<span className={`babylai-text-sm babylai-text-red-500 babylai-transition-opacity babylai-duration-300 ${error.rating ? 'babylai-opacity-100' : 'babylai-opacity-0'}`}>
|
|
68
68
|
{error.rating}
|
|
69
69
|
</span>
|
|
70
70
|
</div>
|
|
@@ -79,7 +79,7 @@ const ReviewDialog: React.FC<ReviewDialogProps> = (props) => {
|
|
|
79
79
|
value={comment}
|
|
80
80
|
onChange={(e) => handleCommentChange(e.target.value)}
|
|
81
81
|
/>
|
|
82
|
-
<span className={`babylai-text-sm babylai-text-red-500 transition-opacity duration-300 ${error.comment ? 'opacity-100' : 'opacity-0'}`}>
|
|
82
|
+
<span className={`babylai-text-sm babylai-text-red-500 babylai-transition-opacity babylai-duration-300 ${error.comment ? 'babylai-opacity-100' : 'babylai-opacity-0'}`}>
|
|
83
83
|
{error.comment}
|
|
84
84
|
</span>
|
|
85
85
|
</div>
|
|
@@ -87,13 +87,13 @@ const ReviewDialog: React.FC<ReviewDialogProps> = (props) => {
|
|
|
87
87
|
|
|
88
88
|
<footer className="babylai-flex babylai-justify-between babylai-gap-4 babylai-border-t babylai-pt-4">
|
|
89
89
|
<button
|
|
90
|
-
className="babylai-px-4 babylai-py-2 babylai-rounded-lg babylai-bg-gray-200 babylai-text-gray-700 hover:babylai-bg-gray-300 transition-all"
|
|
90
|
+
className="babylai-px-4 babylai-py-2 babylai-rounded-lg babylai-bg-gray-200 babylai-text-gray-700 hover:babylai-bg-gray-300 babylai-transition-all"
|
|
91
91
|
onClick={props.onClose}
|
|
92
92
|
>
|
|
93
93
|
{t('homeSdk.ReviewDialog.skip_button')}
|
|
94
94
|
</button>
|
|
95
95
|
<button
|
|
96
|
-
className='babylai-px-4 babylai-py-2 babylai-rounded-lg babylai-shadow transition-all babylai-bg-primary-500 babylai-text-white hover:babylai-bg-primary-600'
|
|
96
|
+
className='babylai-px-4 babylai-py-2 babylai-rounded-lg babylai-shadow babylai-transition-all babylai-bg-primary-500 babylai-text-white hover:babylai-bg-primary-600'
|
|
97
97
|
onClick={validateAndSubmit}
|
|
98
98
|
>
|
|
99
99
|
{t('homeSdk.ReviewDialog.submit_button')}
|
|
@@ -20,9 +20,9 @@ const iconMap = {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const sizeMap = {
|
|
23
|
-
sm: 'w-4 h-4',
|
|
24
|
-
md: 'w-6 h-6',
|
|
25
|
-
lg: 'w-8 h-8'
|
|
23
|
+
sm: 'babylai-w-4 babylai-h-4',
|
|
24
|
+
md: 'babylai-w-6 babylai-h-6',
|
|
25
|
+
lg: 'babylai-w-8 babylai-h-8'
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
@@ -47,7 +47,7 @@ export const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return (
|
|
50
|
-
<div ref={ref} className={cn('flex items-center', className)} {...props}>
|
|
50
|
+
<div ref={ref} className={cn('babylai-flex babylai-items-center', className)} {...props}>
|
|
51
51
|
{[...Array(max)].map((_, index) => {
|
|
52
52
|
const filled = (hoverValue !== null ? hoverValue : value) > index
|
|
53
53
|
|
|
@@ -56,9 +56,9 @@ export const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
|
56
56
|
key={index}
|
|
57
57
|
className={cn(
|
|
58
58
|
sizeMap[size],
|
|
59
|
-
'cursor-pointer transition-colors',
|
|
60
|
-
filled ? 'text-yellow-400 fill-yellow-400' : 'text-gray-300',
|
|
61
|
-
readOnly && 'cursor-default'
|
|
59
|
+
'babylai-cursor-pointer babylai-transition-colors',
|
|
60
|
+
filled ? 'babylai-text-yellow-400 babylai-fill-yellow-400' : 'babylai-text-gray-300',
|
|
61
|
+
readOnly && 'babylai-cursor-default'
|
|
62
62
|
)}
|
|
63
63
|
onMouseEnter={() => handleMouseEnter(index + 1)}
|
|
64
64
|
onMouseLeave={handleMouseLeave}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import { createHelpCenterI18n, defaultLanguage } from "
|
|
2
|
+
import { createHelpCenterI18n, defaultLanguage } from "@/i18n";
|
|
3
|
+
import { useLanguage } from "@/lib/LanguageContext";
|
|
3
4
|
|
|
4
|
-
export const useLocalTranslation = (
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export const useLocalTranslation = () => {
|
|
6
|
+
// Get language from context, fallback to default if not available
|
|
7
|
+
const context = useLanguage();
|
|
8
|
+
const language = context?.language || defaultLanguage;
|
|
7
9
|
|
|
8
10
|
const i18n = useMemo(() => createHelpCenterI18n(language), [language]);
|
|
9
|
-
|
|
10
11
|
const t = (key: string) => i18n.t(key);
|
|
11
12
|
const dir = i18n.dir();
|
|
12
13
|
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import * as signalR from '@microsoft/signalr';
|
|
2
|
-
|
|
3
|
-
export class ClientSignalRService {
|
|
4
|
-
private static connection: signalR.HubConnection | null = null;
|
|
5
|
-
private static isConnected: boolean = false;
|
|
6
|
-
private static hubUrl: string = '';
|
|
7
|
-
|
|
8
|
-
static initialize(hubUrl: string) {
|
|
9
|
-
this.hubUrl = hubUrl;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static async startConnection(sessionId: string, apiKey: string, onMessageReceived: Function) {
|
|
13
|
-
// Prevent multiple connections
|
|
14
|
-
if (this.isConnected) return;
|
|
15
|
-
|
|
16
|
-
// Build the SignalR connection
|
|
17
|
-
this.connection = new signalR.HubConnectionBuilder()
|
|
18
|
-
.withUrl(`${this.hubUrl}/clientHub?access_token=${encodeURIComponent(apiKey)}`, {
|
|
19
|
-
withCredentials: true, // Ensure credentials are passed with the WebSocket request
|
|
20
|
-
transport: signalR.HttpTransportType.WebSockets | signalR.HttpTransportType.LongPolling,
|
|
21
|
-
headers: {
|
|
22
|
-
Authorization: `Bearer ${apiKey}`,
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
.configureLogging(signalR.LogLevel.Information)
|
|
26
|
-
.build();
|
|
27
|
-
|
|
28
|
-
// Define callback function for receiving messages
|
|
29
|
-
this.connection.on('ReceiveMessage', (message: any, senderType: number, needsAgent: boolean) => {
|
|
30
|
-
onMessageReceived(message, senderType, needsAgent);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
// Start the connection
|
|
35
|
-
await this.connection.start();
|
|
36
|
-
|
|
37
|
-
// Set the isConnected flag after the connection is fully established
|
|
38
|
-
this.isConnected = true;
|
|
39
|
-
|
|
40
|
-
// Join the session group after connection is fully established
|
|
41
|
-
await this.joinGroup(sessionId);
|
|
42
|
-
} catch (error) {
|
|
43
|
-
this.isConnected = false; // Ensure isConnected is false if connection fails
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static async joinGroup(sessionId: string) {
|
|
49
|
-
if (this.connection) {
|
|
50
|
-
try {
|
|
51
|
-
await this.connection.invoke('JoinGroup', sessionId);
|
|
52
|
-
} catch (error) {
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static async leaveGroup(sessionId: string) {
|
|
59
|
-
if (this.connection && this.isConnected) {
|
|
60
|
-
try {
|
|
61
|
-
await this.connection.invoke('LeaveGroup', sessionId);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
static async stopConnection() {
|
|
69
|
-
if (this.connection && this.isConnected) {
|
|
70
|
-
try {
|
|
71
|
-
await this.connection.stop();
|
|
72
|
-
this.isConnected = false;
|
|
73
|
-
this.connection = null;
|
|
74
|
-
} catch (error) {
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static isConnectionActive(): boolean {
|
|
81
|
-
return this.isConnected;
|
|
82
|
-
}
|
|
83
|
-
}
|