@asgard-js/react 0.0.42-canary.5 → 0.0.43-canary.10
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/chatbot/api-key-input/api-key-input.d.ts +1 -1
- package/dist/components/chatbot/api-key-input/api-key-input.d.ts.map +1 -1
- package/dist/components/chatbot/chatbot.d.ts.map +1 -1
- package/dist/index.js +7938 -7910
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/chatbot/api-key-input/api-key-input.module.scss +13 -21
- package/src/components/chatbot/api-key-input/api-key-input.tsx +27 -17
- package/src/components/chatbot/chatbot.tsx +26 -14
package/package.json
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
.container {
|
|
2
2
|
width: 220px;
|
|
3
|
-
background:
|
|
3
|
+
background-color: var(--asg-color-bg);
|
|
4
4
|
border-radius: 12px;
|
|
5
|
-
padding:
|
|
6
|
-
|
|
7
|
-
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
8
|
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
|
9
|
-
color: white;
|
|
10
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
|
5
|
+
padding: 12px 20px;
|
|
6
|
+
border: 0.5px solid var(--asg-color-border);
|
|
11
7
|
}
|
|
12
8
|
|
|
13
9
|
.header {
|
|
14
10
|
display: flex;
|
|
15
11
|
flex-direction: column;
|
|
12
|
+
gap: 4px;
|
|
16
13
|
align-items: center;
|
|
17
|
-
margin-bottom:
|
|
14
|
+
margin-bottom: 12px;
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
.icon {
|
|
21
|
-
width:
|
|
22
|
-
height:
|
|
23
|
-
margin-bottom: 12px;
|
|
24
|
-
opacity: 0.7;
|
|
18
|
+
width: 24px;
|
|
19
|
+
height: 24px;
|
|
25
20
|
}
|
|
26
21
|
|
|
27
22
|
.title {
|
|
@@ -29,21 +24,18 @@
|
|
|
29
24
|
font-size: 18px;
|
|
30
25
|
font-weight: 500;
|
|
31
26
|
color: white;
|
|
32
|
-
text-align: center;
|
|
33
27
|
}
|
|
34
28
|
|
|
35
29
|
.form {
|
|
36
30
|
width: 100%;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
margin-bottom: 20px;
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
gap: 20px;
|
|
41
34
|
}
|
|
42
35
|
|
|
43
36
|
.label {
|
|
44
37
|
display: block;
|
|
45
38
|
font-size: 14px;
|
|
46
|
-
font-weight: 400;
|
|
47
39
|
color: rgba(255, 255, 255, 0.7);
|
|
48
40
|
margin-bottom: 8px;
|
|
49
41
|
}
|
|
@@ -128,9 +120,9 @@
|
|
|
128
120
|
.submitButton {
|
|
129
121
|
width: 100%;
|
|
130
122
|
height: 42px;
|
|
131
|
-
background: #5856D6;
|
|
132
123
|
border: none;
|
|
133
124
|
border-radius: 6px;
|
|
125
|
+
background-color: #5856d6;
|
|
134
126
|
color: white;
|
|
135
127
|
font-size: 14px;
|
|
136
128
|
font-weight: 500;
|
|
@@ -139,7 +131,7 @@
|
|
|
139
131
|
outline: none;
|
|
140
132
|
|
|
141
133
|
&:hover:not(:disabled) {
|
|
142
|
-
|
|
134
|
+
opacity: 0.9;
|
|
143
135
|
transform: translateY(-1px);
|
|
144
136
|
}
|
|
145
137
|
|
|
@@ -189,4 +181,4 @@
|
|
|
189
181
|
width: 100%;
|
|
190
182
|
min-width: 200px;
|
|
191
183
|
}
|
|
192
|
-
}
|
|
184
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useState, FormEvent, ChangeEvent } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import
|
|
3
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
4
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
5
|
+
import { ProfileIcon } from '../profile-icon';
|
|
4
6
|
import styles from './api-key-input.module.scss';
|
|
5
7
|
|
|
6
8
|
export interface ApiKeyInputProps {
|
|
@@ -21,30 +23,38 @@ export function ApiKeyInput({
|
|
|
21
23
|
title = 'Preview',
|
|
22
24
|
showToggle = true,
|
|
23
25
|
className,
|
|
24
|
-
}: ApiKeyInputProps) {
|
|
26
|
+
}: ApiKeyInputProps): JSX.Element {
|
|
25
27
|
const [apiKey, setApiKey] = useState('');
|
|
26
28
|
const [showPassword, setShowPassword] = useState(false);
|
|
29
|
+
const { chatbot } = useAsgardThemeContext();
|
|
30
|
+
const { avatar } = useAsgardContext();
|
|
27
31
|
|
|
28
|
-
const handleSubmit = (e: FormEvent) => {
|
|
32
|
+
const handleSubmit = (e: FormEvent): void => {
|
|
29
33
|
e.preventDefault();
|
|
30
34
|
if (apiKey.trim() && !loading) {
|
|
31
35
|
onSubmit(apiKey.trim());
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
|
|
35
|
-
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
39
|
+
const handleInputChange = (e: ChangeEvent<HTMLInputElement>): void => {
|
|
36
40
|
setApiKey(e.target.value);
|
|
37
41
|
};
|
|
38
42
|
|
|
39
|
-
const togglePasswordVisibility = () => {
|
|
43
|
+
const togglePasswordVisibility = (): void => {
|
|
40
44
|
setShowPassword(!showPassword);
|
|
41
45
|
};
|
|
42
46
|
|
|
43
47
|
return (
|
|
44
|
-
<div
|
|
48
|
+
<div
|
|
49
|
+
className={clsx(styles.container, className)}
|
|
50
|
+
style={{
|
|
51
|
+
backgroundColor: chatbot.backgroundColor,
|
|
52
|
+
borderColor: chatbot.borderColor,
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
45
55
|
<div className={styles.header}>
|
|
46
|
-
<
|
|
47
|
-
<h2 className={styles.title}>{title}</h2>
|
|
56
|
+
<ProfileIcon avatar={avatar} />
|
|
57
|
+
<h2 className={styles.title} style={chatbot?.header?.title?.style}>{title}</h2>
|
|
48
58
|
</div>
|
|
49
59
|
|
|
50
60
|
<form onSubmit={handleSubmit} className={styles.form}>
|
|
@@ -84,24 +94,20 @@ export function ApiKeyInput({
|
|
|
84
94
|
>
|
|
85
95
|
{showPassword ? (
|
|
86
96
|
<>
|
|
87
|
-
<path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/>
|
|
88
|
-
<line x1="1" y1="1" x2="23" y2="23"/>
|
|
97
|
+
<path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" />
|
|
98
|
+
<line x1="1" y1="1" x2="23" y2="23" />
|
|
89
99
|
</>
|
|
90
100
|
) : (
|
|
91
101
|
<>
|
|
92
|
-
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
|
|
93
|
-
<circle cx="12" cy="12" r="3"/>
|
|
102
|
+
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" />
|
|
103
|
+
<circle cx="12" cy="12" r="3" />
|
|
94
104
|
</>
|
|
95
105
|
)}
|
|
96
106
|
</svg>
|
|
97
107
|
</button>
|
|
98
108
|
)}
|
|
99
109
|
</div>
|
|
100
|
-
{error &&
|
|
101
|
-
<div className={styles.errorMessage}>
|
|
102
|
-
{error}
|
|
103
|
-
</div>
|
|
104
|
-
)}
|
|
110
|
+
{error && <div className={styles.errorMessage}>{error}</div>}
|
|
105
111
|
</div>
|
|
106
112
|
|
|
107
113
|
<button
|
|
@@ -110,6 +116,10 @@ export function ApiKeyInput({
|
|
|
110
116
|
className={clsx(styles.submitButton, {
|
|
111
117
|
[styles.loading]: loading,
|
|
112
118
|
})}
|
|
119
|
+
style={{
|
|
120
|
+
backgroundColor: chatbot?.primaryComponent?.mainColor,
|
|
121
|
+
color: chatbot?.primaryComponent?.secondaryColor,
|
|
122
|
+
}}
|
|
113
123
|
>
|
|
114
124
|
{loading ? 'Loading...' : 'Continue'}
|
|
115
125
|
</button>
|
|
@@ -199,23 +199,35 @@ export const Chatbot = forwardRef(function Chatbot(
|
|
|
199
199
|
);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
// For non-authenticated states,
|
|
202
|
+
// For non-authenticated states, provide AsgardServiceContextProvider but without SSE connection
|
|
203
203
|
return (
|
|
204
204
|
<AsgardThemeContextProvider theme={theme}>
|
|
205
|
-
<
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
<AsgardServiceContextProvider
|
|
206
|
+
parentRef={ref}
|
|
207
|
+
avatar={avatar}
|
|
208
|
+
config={config}
|
|
209
|
+
customChannelId={customChannelId}
|
|
210
|
+
initMessages={initMessages}
|
|
211
|
+
onSseMessage={onSseMessage}
|
|
212
|
+
onAuthError={onAuthError}
|
|
213
|
+
botTypingPlaceholder={botTypingPlaceholder}
|
|
214
|
+
inputPlaceholder={inputPlaceholder}
|
|
209
215
|
>
|
|
210
|
-
<
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
<ChatbotContainer
|
|
217
|
+
fullScreen={fullScreen}
|
|
218
|
+
className={className}
|
|
219
|
+
style={style}
|
|
220
|
+
>
|
|
221
|
+
<ChatbotHeader
|
|
222
|
+
title={title}
|
|
223
|
+
onReset={onReset}
|
|
224
|
+
onClose={onClose}
|
|
225
|
+
customActions={customActions}
|
|
226
|
+
maintainConnectionWhenClosed={maintainConnectionWhenClosed}
|
|
227
|
+
/>
|
|
228
|
+
{renderContent()}
|
|
229
|
+
</ChatbotContainer>
|
|
230
|
+
</AsgardServiceContextProvider>
|
|
219
231
|
</AsgardThemeContextProvider>
|
|
220
232
|
);
|
|
221
233
|
});
|