@clikvn/agent-widget-embedded 0.0.5-dev → 0.0.7-dev
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/components/Chat/AudioPlayer.d.ts.map +1 -1
- package/dist/components/Chat/MultimodalInput.d.ts.map +1 -1
- package/dist/components/Chat/Overview.d.ts.map +1 -1
- package/dist/hooks/useConfiguration.d.ts +7 -0
- package/dist/hooks/useConfiguration.d.ts.map +1 -1
- package/dist/index.html +12 -4
- package/dist/register.d.ts +14 -0
- package/dist/register.d.ts.map +1 -1
- package/dist/web.js +1 -1
- package/package.json +1 -1
- package/src/components/Chat/AudioPlayer.tsx +2 -1
- package/src/components/Chat/MultimodalInput.tsx +3 -1
- package/src/components/Chat/Overview.tsx +21 -22
- package/src/hooks/useConfiguration.tsx +8 -2
- package/src/register.tsx +14 -0
package/package.json
CHANGED
|
@@ -18,7 +18,6 @@ const AudioPlayer = ({
|
|
|
18
18
|
} else {
|
|
19
19
|
audioRef.current.play();
|
|
20
20
|
}
|
|
21
|
-
setIsPlaying(!isPlaying);
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
return (
|
|
@@ -35,6 +34,8 @@ const AudioPlayer = ({
|
|
|
35
34
|
src={src}
|
|
36
35
|
autoPlay={autoplay}
|
|
37
36
|
onEnded={() => setIsPlaying(false)}
|
|
37
|
+
onPause={() => setIsPlaying(false)}
|
|
38
|
+
onPlay={() => setIsPlaying(true)}
|
|
38
39
|
></audio>
|
|
39
40
|
</>
|
|
40
41
|
);
|
|
@@ -31,6 +31,7 @@ import { Button } from './ui/Button';
|
|
|
31
31
|
import { Textarea } from './ui/Textarea';
|
|
32
32
|
import { useAudioRecording } from '../../hooks/useAudioRecording';
|
|
33
33
|
import { useChatData } from '../../hooks/useChatData';
|
|
34
|
+
import { useConfiguration } from '../../hooks/useConfiguration';
|
|
34
35
|
|
|
35
36
|
type PropsType = {
|
|
36
37
|
input: string;
|
|
@@ -72,6 +73,7 @@ export const MultimodalInput: FC<PropsType> = ({
|
|
|
72
73
|
setEnableTTS,
|
|
73
74
|
enableTTS,
|
|
74
75
|
}) => {
|
|
76
|
+
const { theme } = useConfiguration();
|
|
75
77
|
const { suggestedActions = [] } = useChatData();
|
|
76
78
|
const {
|
|
77
79
|
isRecording,
|
|
@@ -352,7 +354,7 @@ export const MultimodalInput: FC<PropsType> = ({
|
|
|
352
354
|
|
|
353
355
|
<Textarea
|
|
354
356
|
ref={textareaRef}
|
|
355
|
-
placeholder=
|
|
357
|
+
placeholder={theme?.input?.placeholder || 'Send a message...'}
|
|
356
358
|
value={input}
|
|
357
359
|
onChange={handleInput}
|
|
358
360
|
className={cn(
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { motion } from 'framer-motion';
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
import { BotType } from '../../types/bot.type';
|
|
4
|
+
import { useConfiguration } from '../../hooks/useConfiguration';
|
|
4
5
|
|
|
5
6
|
type PropsType = {
|
|
6
7
|
bot: BotType | null;
|
|
7
8
|
};
|
|
8
9
|
export const Overview: FC<PropsType> = ({ bot }: PropsType) => {
|
|
10
|
+
const { theme } = useConfiguration();
|
|
9
11
|
return (
|
|
10
12
|
<motion.div
|
|
11
13
|
key="overview"
|
|
12
|
-
className="max-w-3xl
|
|
14
|
+
className="max-w-3xl m-auto md:mt-20"
|
|
13
15
|
initial={{ opacity: 0, scale: 0.98 }}
|
|
14
16
|
animate={{ opacity: 1, scale: 1 }}
|
|
15
17
|
exit={{ opacity: 0, scale: 0.98 }}
|
|
@@ -17,28 +19,25 @@ export const Overview: FC<PropsType> = ({ bot }: PropsType) => {
|
|
|
17
19
|
>
|
|
18
20
|
<div className="rounded-xl p-6 flex flex-col gap-2 leading-relaxed text-center max-w-xl">
|
|
19
21
|
<p className="flex flex-row justify-center gap-4 items-center"></p>
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
{!theme?.overview ? (
|
|
23
|
+
<>
|
|
24
|
+
{bot?.avatar && (
|
|
25
|
+
<img
|
|
26
|
+
src={bot?.avatar}
|
|
27
|
+
alt={bot?.name ?? 'Avatar'}
|
|
28
|
+
width={40}
|
|
29
|
+
height={40}
|
|
30
|
+
className="rounded-full m-auto"
|
|
31
|
+
/>
|
|
32
|
+
)}
|
|
33
|
+
<p className="font-semibold text-xl">{bot?.name}</p>
|
|
34
|
+
</>
|
|
35
|
+
) : (
|
|
36
|
+
<>
|
|
37
|
+
<p className="font-semibold text-xl">{theme?.overview?.title}</p>
|
|
38
|
+
<p>{theme?.overview?.description}</p>
|
|
39
|
+
</>
|
|
28
40
|
)}
|
|
29
|
-
|
|
30
|
-
<p className="font-semibold text-xl">{`${bot?.name}`}</p>
|
|
31
|
-
<p>
|
|
32
|
-
{/* You can learn more about the AI by visiting the{' '}*/}
|
|
33
|
-
{/* <Link*/}
|
|
34
|
-
{/* className="font-medium underline underline-offset-4"*/}
|
|
35
|
-
{/* href="https://showai.ai"*/}
|
|
36
|
-
{/* target="_blank"*/}
|
|
37
|
-
{/* >*/}
|
|
38
|
-
{/* ShowAI*/}
|
|
39
|
-
{/* </Link>*/}
|
|
40
|
-
{/* .*/}
|
|
41
|
-
</p>
|
|
42
41
|
</div>
|
|
43
42
|
</motion.div>
|
|
44
43
|
);
|
|
@@ -6,6 +6,13 @@ type ConfigurationData = {
|
|
|
6
6
|
overrideConfig?: Record<string, any>;
|
|
7
7
|
theme?: {
|
|
8
8
|
avatar?: string;
|
|
9
|
+
input?: {
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
};
|
|
12
|
+
overview?: {
|
|
13
|
+
title: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
};
|
|
9
16
|
} & Record<string, unknown>;
|
|
10
17
|
};
|
|
11
18
|
|
|
@@ -21,8 +28,7 @@ export const ConfigurationProvider = ({
|
|
|
21
28
|
config: ConfigurationData;
|
|
22
29
|
}) => {
|
|
23
30
|
const [configuration, setConfiguration] = useState<ConfigurationData>({
|
|
24
|
-
|
|
25
|
-
agentId: config.agentId,
|
|
31
|
+
...config,
|
|
26
32
|
});
|
|
27
33
|
|
|
28
34
|
useEffect(() => {
|
package/src/register.tsx
CHANGED
|
@@ -14,6 +14,13 @@ export type AgentWidgetType = {
|
|
|
14
14
|
} & Record<string, unknown>;
|
|
15
15
|
theme?: {
|
|
16
16
|
avatar?: string;
|
|
17
|
+
input?: {
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
};
|
|
20
|
+
overview?: {
|
|
21
|
+
title: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
};
|
|
17
24
|
} & Record<string, unknown>;
|
|
18
25
|
listeners?: Record<EVENT_TYPE, (props: any) => void>;
|
|
19
26
|
};
|
|
@@ -28,6 +35,13 @@ export class AgentWidgetComponent extends HTMLElement {
|
|
|
28
35
|
} & Record<string, unknown>;
|
|
29
36
|
theme?: {
|
|
30
37
|
avatar?: string;
|
|
38
|
+
input?: {
|
|
39
|
+
placeholder?: string;
|
|
40
|
+
};
|
|
41
|
+
overview?: {
|
|
42
|
+
title: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
};
|
|
31
45
|
} & Record<string, unknown>;
|
|
32
46
|
listeners?: Record<EVENT_TYPE, (props: any) => void>;
|
|
33
47
|
constructor() {
|