@asgard-js/react 0.0.43-canary.19 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgard-js/react",
3
- "version": "0.0.43-canary.19",
3
+ "version": "0.0.43-canary.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
Binary file
@@ -1,51 +1,52 @@
1
- .api_key_input {
1
+ .container {
2
2
  width: 220px;
3
3
  background-color: var(--asg-color-bg);
4
4
  border-radius: 12px;
5
- padding: 12px 20px;
5
+ padding: 20px;
6
6
  border: 0.5px solid var(--asg-color-border);
7
7
  }
8
8
 
9
- .api_key_input__header {
10
- display: flex;
11
- flex-direction: column;
12
- gap: 4px;
13
- align-items: center;
14
- margin-bottom: 12px;
15
- }
16
-
17
- .api_key_input__icon {
18
- width: 24px;
19
- height: 24px;
20
- }
21
-
22
- .api_key_input__title {
23
- margin: 0;
24
- font-size: 18px;
25
- font-weight: 500;
26
- color: white;
27
- }
28
-
29
- .api_key_input__form {
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
- .api_key_input__label {
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
- .api_key_input__input_wrapper {
44
+ .inputWrapper {
44
45
  position: relative;
45
46
  width: 100%;
46
47
  }
47
48
 
48
- .api_key_input__input {
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
- &--error {
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
- &--disabled {
77
+ &.disabled {
77
78
  opacity: 0.5;
78
79
  cursor: not-allowed;
79
80
  }
80
81
  }
81
82
 
82
- .api_key_input__toggle_button {
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
- .api_key_input__toggle_icon {
110
+ .toggleIcon {
110
111
  width: 16px;
111
112
  height: 16px;
112
113
  }
113
114
 
114
- .api_key_input__error_message {
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
- .api_key_input__submit_button {
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,7 +146,7 @@
137
146
  transform: none;
138
147
  }
139
148
 
140
- &--loading {
149
+ &.loading {
141
150
  position: relative;
142
151
  color: transparent;
143
152
 
@@ -169,7 +178,7 @@
169
178
 
170
179
  // 響應式設計
171
180
  @media (max-width: 280px) {
172
- .api_key_input {
181
+ .container {
173
182
  width: 100%;
174
183
  min-width: 200px;
175
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.api_key_input, className)}
44
+ className={clsx(styles.container, className)}
52
45
  style={{
53
46
  backgroundColor: chatbot.backgroundColor,
54
47
  borderColor: chatbot.borderColor,
55
48
  }}
56
49
  >
57
- <div className={styles.api_key_input__header}>
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.api_key_input__label}>Key</label>
65
- <div className={styles.api_key_input__input_wrapper}>
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.api_key_input__input, {
72
- [styles['api_key_input__input--error']]: error,
73
- [styles['api_key_input__input--disabled']]: loading,
59
+ className={clsx(styles.input, {
60
+ [styles.error]: error,
61
+ [styles.disabled]: loading,
74
62
  })}
75
63
  disabled={loading}
76
64
  autoComplete="off"
@@ -79,31 +67,45 @@ export function ApiKeyInput({
79
67
  <button
80
68
  type="button"
81
69
  onClick={togglePasswordVisibility}
82
- className={styles.api_key_input__toggle_button}
70
+ className={styles.toggleButton}
83
71
  disabled={loading}
84
72
  aria-label={showPassword ? 'Hide password' : 'Show password'}
85
73
  >
86
- {showPassword ? (
87
- <EyeOffSvg className={styles.api_key_input__toggle_icon} />
88
- ) : (
89
- <EyeSvg className={styles.api_key_input__toggle_icon} />
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.api_key_input__error_message}>{error}</div>}
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.api_key_input__submit_button, {
101
- [styles['api_key_input__submit_button--loading']]: loading,
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>
@@ -116,7 +116,6 @@ export const Chatbot = forwardRef(function Chatbot(
116
116
  padding: '20px'
117
117
  }}>
118
118
  <ApiKeyInput
119
- title={title}
120
119
  onSubmit={onApiKeySubmit || (() => {})}
121
120
  placeholder="Enter your key"
122
121
  />
@@ -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,
@@ -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
@@ -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="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
3
- <circle cx="12" cy="12" r="3"/>
4
- </svg>