@asgard-js/react 0.0.43-canary.18 → 0.0.43-canary.2
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 -2
- 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/context/asgard-theme-context.d.ts +0 -2
- package/dist/context/asgard-theme-context.d.ts.map +1 -1
- package/dist/index.js +11147 -11147
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/.DS_Store +0 -0
- package/src/components/chatbot/api-key-input/api-key-input.module.scss +46 -38
- package/src/components/chatbot/api-key-input/api-key-input.tsx +35 -33
- package/src/components/chatbot/chatbot.tsx +0 -1
- package/src/context/asgard-theme-context.tsx +0 -7
- package/src/icons/eye-off.svg +0 -4
- package/src/icons/eye.svg +0 -4
package/package.json
CHANGED
package/src/components/.DS_Store
CHANGED
|
Binary file
|
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
.
|
|
1
|
+
.container {
|
|
2
2
|
width: 220px;
|
|
3
3
|
background-color: var(--asg-color-bg);
|
|
4
4
|
border-radius: 12px;
|
|
5
|
-
padding:
|
|
5
|
+
padding: 20px;
|
|
6
6
|
border: 0.5px solid var(--asg-color-border);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
9
|
+
// Header styles removed as header is now handled by ChatbotHeader
|
|
10
|
+
// .header {
|
|
11
|
+
// display: flex;
|
|
12
|
+
// flex-direction: column;
|
|
13
|
+
// gap: 4px;
|
|
14
|
+
// align-items: center;
|
|
15
|
+
// margin-bottom: 12px;
|
|
16
|
+
// }
|
|
17
|
+
//
|
|
18
|
+
// .icon {
|
|
19
|
+
// width: 24px;
|
|
20
|
+
// height: 24px;
|
|
21
|
+
// }
|
|
22
|
+
//
|
|
23
|
+
// .title {
|
|
24
|
+
// margin: 0;
|
|
25
|
+
// font-size: 18px;
|
|
26
|
+
// font-weight: 500;
|
|
27
|
+
// color: white;
|
|
28
|
+
// }
|
|
29
|
+
|
|
30
|
+
.form {
|
|
30
31
|
width: 100%;
|
|
31
32
|
display: flex;
|
|
32
33
|
flex-direction: column;
|
|
33
34
|
gap: 20px;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
.
|
|
37
|
+
.label {
|
|
37
38
|
display: block;
|
|
38
39
|
font-size: 14px;
|
|
39
40
|
color: rgba(255, 255, 255, 0.7);
|
|
40
41
|
margin-bottom: 8px;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
.
|
|
44
|
+
.inputWrapper {
|
|
44
45
|
position: relative;
|
|
45
46
|
width: 100%;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
.
|
|
49
|
+
.input {
|
|
49
50
|
width: 100%;
|
|
50
51
|
height: 42px;
|
|
51
52
|
padding: 0 40px 0 12px;
|
|
@@ -68,18 +69,18 @@
|
|
|
68
69
|
background: rgba(255, 255, 255, 0.08);
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
|
|
72
|
+
&.error {
|
|
72
73
|
border-color: rgba(255, 69, 58, 0.6);
|
|
73
74
|
background: rgba(255, 69, 58, 0.05);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
&.disabled {
|
|
77
78
|
opacity: 0.5;
|
|
78
79
|
cursor: not-allowed;
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
.
|
|
83
|
+
.toggleButton {
|
|
83
84
|
position: absolute;
|
|
84
85
|
right: 8px;
|
|
85
86
|
top: 50%;
|
|
@@ -106,23 +107,23 @@
|
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
.
|
|
110
|
+
.toggleIcon {
|
|
110
111
|
width: 16px;
|
|
111
112
|
height: 16px;
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
.
|
|
115
|
+
.errorMessage {
|
|
115
116
|
margin-top: 6px;
|
|
116
117
|
font-size: 12px;
|
|
117
118
|
color: rgba(255, 69, 58, 0.8);
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
.
|
|
121
|
+
.submitButton {
|
|
121
122
|
width: 100%;
|
|
122
123
|
height: 42px;
|
|
124
|
+
background: #5856d6;
|
|
123
125
|
border: none;
|
|
124
126
|
border-radius: 6px;
|
|
125
|
-
background-color: #5856d6;
|
|
126
127
|
color: white;
|
|
127
128
|
font-size: 14px;
|
|
128
129
|
font-weight: 500;
|
|
@@ -130,6 +131,14 @@
|
|
|
130
131
|
transition: all 0.2s ease;
|
|
131
132
|
outline: none;
|
|
132
133
|
|
|
134
|
+
&:hover:not(:disabled) {
|
|
135
|
+
background: #4845c7;
|
|
136
|
+
transform: translateY(-1px);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&:active:not(:disabled) {
|
|
140
|
+
transform: translateY(0);
|
|
141
|
+
}
|
|
133
142
|
|
|
134
143
|
&:disabled {
|
|
135
144
|
opacity: 0.5;
|
|
@@ -137,10 +146,9 @@
|
|
|
137
146
|
transform: none;
|
|
138
147
|
}
|
|
139
148
|
|
|
140
|
-
|
|
149
|
+
&.loading {
|
|
141
150
|
position: relative;
|
|
142
151
|
color: transparent;
|
|
143
|
-
background-color: transparent !important;
|
|
144
152
|
|
|
145
153
|
&::after {
|
|
146
154
|
content: '';
|
|
@@ -151,8 +159,8 @@
|
|
|
151
159
|
height: 16px;
|
|
152
160
|
margin-left: -8px;
|
|
153
161
|
margin-top: -8px;
|
|
154
|
-
border: 2px solid
|
|
155
|
-
border-top: 2px solid
|
|
162
|
+
border: 2px solid transparent;
|
|
163
|
+
border-top: 2px solid white;
|
|
156
164
|
border-radius: 50%;
|
|
157
165
|
animation: spin 1s linear infinite;
|
|
158
166
|
}
|
|
@@ -170,7 +178,7 @@
|
|
|
170
178
|
|
|
171
179
|
// 響應式設計
|
|
172
180
|
@media (max-width: 280px) {
|
|
173
|
-
.
|
|
181
|
+
.container {
|
|
174
182
|
width: 100%;
|
|
175
183
|
min-width: 200px;
|
|
176
184
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { useState, FormEvent, ChangeEvent } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
4
|
-
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
5
|
-
import { ProfileIcon } from '../profile-icon';
|
|
6
|
-
import EyeSvg from '../../../icons/eye.svg?react';
|
|
7
|
-
import EyeOffSvg from '../../../icons/eye-off.svg?react';
|
|
8
4
|
import styles from './api-key-input.module.scss';
|
|
9
5
|
|
|
10
6
|
export interface ApiKeyInputProps {
|
|
@@ -12,7 +8,6 @@ export interface ApiKeyInputProps {
|
|
|
12
8
|
loading?: boolean;
|
|
13
9
|
error?: string;
|
|
14
10
|
placeholder?: string;
|
|
15
|
-
title?: string;
|
|
16
11
|
showToggle?: boolean;
|
|
17
12
|
className?: string;
|
|
18
13
|
}
|
|
@@ -22,14 +17,12 @@ export function ApiKeyInput({
|
|
|
22
17
|
loading = false,
|
|
23
18
|
error,
|
|
24
19
|
placeholder = 'Enter your key',
|
|
25
|
-
title = 'Preview',
|
|
26
20
|
showToggle = true,
|
|
27
21
|
className,
|
|
28
22
|
}: ApiKeyInputProps): JSX.Element {
|
|
29
23
|
const [apiKey, setApiKey] = useState('');
|
|
30
24
|
const [showPassword, setShowPassword] = useState(false);
|
|
31
25
|
const { chatbot } = useAsgardThemeContext();
|
|
32
|
-
const { avatar } = useAsgardContext();
|
|
33
26
|
|
|
34
27
|
const handleSubmit = (e: FormEvent): void => {
|
|
35
28
|
e.preventDefault();
|
|
@@ -48,29 +41,24 @@ export function ApiKeyInput({
|
|
|
48
41
|
|
|
49
42
|
return (
|
|
50
43
|
<div
|
|
51
|
-
className={clsx(styles.
|
|
44
|
+
className={clsx(styles.container, className)}
|
|
52
45
|
style={{
|
|
53
46
|
backgroundColor: chatbot.backgroundColor,
|
|
54
47
|
borderColor: chatbot.borderColor,
|
|
55
48
|
}}
|
|
56
49
|
>
|
|
57
|
-
<
|
|
58
|
-
<ProfileIcon avatar={avatar} />
|
|
59
|
-
<h2 className={styles.api_key_input__title} style={chatbot?.header?.title?.style}>{title}</h2>
|
|
60
|
-
</div>
|
|
61
|
-
|
|
62
|
-
<form onSubmit={handleSubmit} className={styles.api_key_input__form}>
|
|
50
|
+
<form onSubmit={handleSubmit} className={styles.form}>
|
|
63
51
|
<div className={styles.inputGroup}>
|
|
64
|
-
<label className={styles.
|
|
65
|
-
<div className={styles.
|
|
52
|
+
<label className={styles.label}>Key</label>
|
|
53
|
+
<div className={styles.inputWrapper}>
|
|
66
54
|
<input
|
|
67
55
|
type={showPassword ? 'text' : 'password'}
|
|
68
56
|
value={apiKey}
|
|
69
57
|
onChange={handleInputChange}
|
|
70
58
|
placeholder={placeholder}
|
|
71
|
-
className={clsx(styles.
|
|
72
|
-
[styles
|
|
73
|
-
[styles
|
|
59
|
+
className={clsx(styles.input, {
|
|
60
|
+
[styles.error]: error,
|
|
61
|
+
[styles.disabled]: loading,
|
|
74
62
|
})}
|
|
75
63
|
disabled={loading}
|
|
76
64
|
autoComplete="off"
|
|
@@ -79,33 +67,47 @@ export function ApiKeyInput({
|
|
|
79
67
|
<button
|
|
80
68
|
type="button"
|
|
81
69
|
onClick={togglePasswordVisibility}
|
|
82
|
-
className={styles.
|
|
70
|
+
className={styles.toggleButton}
|
|
83
71
|
disabled={loading}
|
|
84
72
|
aria-label={showPassword ? 'Hide password' : 'Show password'}
|
|
85
73
|
>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
74
|
+
<svg
|
|
75
|
+
className={styles.toggleIcon}
|
|
76
|
+
width="16"
|
|
77
|
+
height="16"
|
|
78
|
+
viewBox="0 0 24 24"
|
|
79
|
+
fill="none"
|
|
80
|
+
stroke="currentColor"
|
|
81
|
+
strokeWidth="2"
|
|
82
|
+
strokeLinecap="round"
|
|
83
|
+
strokeLinejoin="round"
|
|
84
|
+
>
|
|
85
|
+
{showPassword ? (
|
|
86
|
+
<>
|
|
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" />
|
|
89
|
+
</>
|
|
90
|
+
) : (
|
|
91
|
+
<>
|
|
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" />
|
|
94
|
+
</>
|
|
95
|
+
)}
|
|
96
|
+
</svg>
|
|
91
97
|
</button>
|
|
92
98
|
)}
|
|
93
99
|
</div>
|
|
94
|
-
{error && <div className={styles.
|
|
100
|
+
{error && <div className={styles.errorMessage}>{error}</div>}
|
|
95
101
|
</div>
|
|
96
102
|
|
|
97
103
|
<button
|
|
98
104
|
type="submit"
|
|
99
105
|
disabled={!apiKey.trim() || loading}
|
|
100
|
-
className={clsx(styles.
|
|
101
|
-
[styles
|
|
106
|
+
className={clsx(styles.submitButton, {
|
|
107
|
+
[styles.loading]: loading,
|
|
102
108
|
})}
|
|
103
|
-
style={{
|
|
104
|
-
backgroundColor: chatbot?.mainColor,
|
|
105
|
-
color: chatbot?.secondaryColor,
|
|
106
|
-
}}
|
|
107
109
|
>
|
|
108
|
-
{
|
|
110
|
+
{loading ? 'Loading...' : 'Continue'}
|
|
109
111
|
</button>
|
|
110
112
|
</form>
|
|
111
113
|
</div>
|
|
@@ -31,8 +31,6 @@ export interface AsgardThemeContextValue {
|
|
|
31
31
|
backgroundColor?: CSSProperties['backgroundColor'];
|
|
32
32
|
borderColor?: CSSProperties['borderColor'];
|
|
33
33
|
inactiveColor?: CSSProperties['color'];
|
|
34
|
-
mainColor?: CSSProperties['color'];
|
|
35
|
-
secondaryColor?: CSSProperties['color'];
|
|
36
34
|
primaryComponent?: {
|
|
37
35
|
mainColor?: CSSProperties['color'];
|
|
38
36
|
secondaryColor?: CSSProperties['color'];
|
|
@@ -269,9 +267,6 @@ export function AsgardThemeContextProvider(
|
|
|
269
267
|
chatbot: {
|
|
270
268
|
backgroundColor: themeFromAnnotations.chatbot?.backgroundColor,
|
|
271
269
|
borderColor: themeFromAnnotations.chatbot?.borderColor,
|
|
272
|
-
mainColor: themeFromAnnotations.chatbot?.primaryComponent?.mainColor,
|
|
273
|
-
secondaryColor: themeFromAnnotations.chatbot?.primaryComponent?.secondaryColor,
|
|
274
|
-
|
|
275
270
|
header: {
|
|
276
271
|
style: {
|
|
277
272
|
borderBottomColor: themeFromAnnotations.chatbot?.borderColor,
|
|
@@ -412,8 +407,6 @@ export function AsgardThemeContextProvider(
|
|
|
412
407
|
chatbot: {
|
|
413
408
|
backgroundColor: propsTheme.chatbot?.backgroundColor,
|
|
414
409
|
borderColor: propsTheme.chatbot?.borderColor,
|
|
415
|
-
mainColor: propsTheme.chatbot?.primaryComponent?.mainColor,
|
|
416
|
-
secondaryColor: propsTheme.chatbot?.primaryComponent?.secondaryColor,
|
|
417
410
|
header: {
|
|
418
411
|
style: {
|
|
419
412
|
borderBottomColor: propsTheme.chatbot?.borderColor,
|
package/src/icons/eye-off.svg
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
-
<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"/>
|
|
3
|
-
<line x1="1" y1="1" x2="23" y2="23"/>
|
|
4
|
-
</svg>
|
package/src/icons/eye.svg
DELETED