@asgard-js/react 0.0.43-canary.13 → 0.0.43-canary.15

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.13",
3
+ "version": "0.0.43-canary.15",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
Binary file
@@ -1,4 +1,4 @@
1
- .container {
1
+ .api_key_input {
2
2
  width: 220px;
3
3
  background-color: var(--asg-color-bg);
4
4
  border-radius: 12px;
@@ -6,7 +6,7 @@
6
6
  border: 0.5px solid var(--asg-color-border);
7
7
  }
8
8
 
9
- .header {
9
+ .api_key_input__header {
10
10
  display: flex;
11
11
  flex-direction: column;
12
12
  gap: 4px;
@@ -14,38 +14,38 @@
14
14
  margin-bottom: 12px;
15
15
  }
16
16
 
17
- .icon {
17
+ .api_key_input__icon {
18
18
  width: 24px;
19
19
  height: 24px;
20
20
  }
21
21
 
22
- .title {
22
+ .api_key_input__title {
23
23
  margin: 0;
24
24
  font-size: 18px;
25
25
  font-weight: 500;
26
26
  color: white;
27
27
  }
28
28
 
29
- .form {
29
+ .api_key_input__form {
30
30
  width: 100%;
31
31
  display: flex;
32
32
  flex-direction: column;
33
33
  gap: 20px;
34
34
  }
35
35
 
36
- .label {
36
+ .api_key_input__label {
37
37
  display: block;
38
38
  font-size: 14px;
39
39
  color: rgba(255, 255, 255, 0.7);
40
40
  margin-bottom: 8px;
41
41
  }
42
42
 
43
- .inputWrapper {
43
+ .api_key_input__input_wrapper {
44
44
  position: relative;
45
45
  width: 100%;
46
46
  }
47
47
 
48
- .input {
48
+ .api_key_input__input {
49
49
  width: 100%;
50
50
  height: 42px;
51
51
  padding: 0 40px 0 12px;
@@ -68,18 +68,18 @@
68
68
  background: rgba(255, 255, 255, 0.08);
69
69
  }
70
70
 
71
- &.error {
71
+ &--error {
72
72
  border-color: rgba(255, 69, 58, 0.6);
73
73
  background: rgba(255, 69, 58, 0.05);
74
74
  }
75
75
 
76
- &.disabled {
76
+ &--disabled {
77
77
  opacity: 0.5;
78
78
  cursor: not-allowed;
79
79
  }
80
80
  }
81
81
 
82
- .toggleButton {
82
+ .api_key_input__toggle_button {
83
83
  position: absolute;
84
84
  right: 8px;
85
85
  top: 50%;
@@ -106,18 +106,18 @@
106
106
  }
107
107
  }
108
108
 
109
- .toggleIcon {
109
+ .api_key_input__toggle_icon {
110
110
  width: 16px;
111
111
  height: 16px;
112
112
  }
113
113
 
114
- .errorMessage {
114
+ .api_key_input__error_message {
115
115
  margin-top: 6px;
116
116
  font-size: 12px;
117
117
  color: rgba(255, 69, 58, 0.8);
118
118
  }
119
119
 
120
- .submitButton {
120
+ .api_key_input__submit_button {
121
121
  width: 100%;
122
122
  height: 42px;
123
123
  border: none;
@@ -145,7 +145,7 @@
145
145
  transform: none;
146
146
  }
147
147
 
148
- &.loading {
148
+ &--loading {
149
149
  position: relative;
150
150
  color: transparent;
151
151
 
@@ -177,7 +177,7 @@
177
177
 
178
178
  // 響應式設計
179
179
  @media (max-width: 280px) {
180
- .container {
180
+ .api_key_input {
181
181
  width: 100%;
182
182
  min-width: 200px;
183
183
  }
@@ -3,6 +3,8 @@ import clsx from 'clsx';
3
3
  import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
4
4
  import { useAsgardContext } from '../../../context/asgard-service-context';
5
5
  import { ProfileIcon } from '../profile-icon';
6
+ import EyeSvg from '../../../icons/eye.svg?react';
7
+ import EyeOffSvg from '../../../icons/eye-off.svg?react';
6
8
  import styles from './api-key-input.module.scss';
7
9
 
8
10
  export interface ApiKeyInputProps {
@@ -28,8 +30,6 @@ export function ApiKeyInput({
28
30
  const [showPassword, setShowPassword] = useState(false);
29
31
  const { chatbot } = useAsgardThemeContext();
30
32
  const { avatar } = useAsgardContext();
31
- console.log('chatbot', chatbot);
32
- console.log('chatbot.primaryComponent', chatbot.primaryComponent);
33
33
 
34
34
  const handleSubmit = (e: FormEvent): void => {
35
35
  e.preventDefault();
@@ -48,29 +48,29 @@ export function ApiKeyInput({
48
48
 
49
49
  return (
50
50
  <div
51
- className={clsx(styles.container, className)}
51
+ className={clsx(styles.api_key_input, className)}
52
52
  style={{
53
53
  backgroundColor: chatbot.backgroundColor,
54
54
  borderColor: chatbot.borderColor,
55
55
  }}
56
56
  >
57
- <div className={styles.header}>
57
+ <div className={styles.api_key_input__header}>
58
58
  <ProfileIcon avatar={avatar} />
59
- <h2 className={styles.title} style={chatbot?.header?.title?.style}>{title}</h2>
59
+ <h2 className={styles.api_key_input__title} style={chatbot?.header?.title?.style}>{title}</h2>
60
60
  </div>
61
61
 
62
- <form onSubmit={handleSubmit} className={styles.form}>
62
+ <form onSubmit={handleSubmit} className={styles.api_key_input__form}>
63
63
  <div className={styles.inputGroup}>
64
- <label className={styles.label}>Key</label>
65
- <div className={styles.inputWrapper}>
64
+ <label className={styles.api_key_input__label}>Key</label>
65
+ <div className={styles.api_key_input__input_wrapper}>
66
66
  <input
67
67
  type={showPassword ? 'text' : 'password'}
68
68
  value={apiKey}
69
69
  onChange={handleInputChange}
70
70
  placeholder={placeholder}
71
- className={clsx(styles.input, {
72
- [styles.error]: error,
73
- [styles.disabled]: loading,
71
+ className={clsx(styles.api_key_input__input, {
72
+ [styles['api_key_input__input--error']]: error,
73
+ [styles['api_key_input__input--disabled']]: loading,
74
74
  })}
75
75
  disabled={loading}
76
76
  autoComplete="off"
@@ -79,48 +79,30 @@ export function ApiKeyInput({
79
79
  <button
80
80
  type="button"
81
81
  onClick={togglePasswordVisibility}
82
- className={styles.toggleButton}
82
+ className={styles.api_key_input__toggle_button}
83
83
  disabled={loading}
84
84
  aria-label={showPassword ? 'Hide password' : 'Show password'}
85
85
  >
86
- <svg
87
- className={styles.toggleIcon}
88
- width="16"
89
- height="16"
90
- viewBox="0 0 24 24"
91
- fill="none"
92
- stroke="currentColor"
93
- strokeWidth="2"
94
- strokeLinecap="round"
95
- strokeLinejoin="round"
96
- >
97
- {showPassword ? (
98
- <>
99
- <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" />
100
- <line x1="1" y1="1" x2="23" y2="23" />
101
- </>
102
- ) : (
103
- <>
104
- <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" />
105
- <circle cx="12" cy="12" r="3" />
106
- </>
107
- )}
108
- </svg>
86
+ {showPassword ? (
87
+ <EyeOffSvg className={styles.api_key_input__toggle_icon} />
88
+ ) : (
89
+ <EyeSvg className={styles.api_key_input__toggle_icon} />
90
+ )}
109
91
  </button>
110
92
  )}
111
93
  </div>
112
- {error && <div className={styles.errorMessage}>{error}</div>}
94
+ {error && <div className={styles.api_key_input__error_message}>{error}</div>}
113
95
  </div>
114
96
 
115
97
  <button
116
98
  type="submit"
117
99
  disabled={!apiKey.trim() || loading}
118
- className={clsx(styles.submitButton, {
119
- [styles.loading]: loading,
100
+ className={clsx(styles.api_key_input__submit_button, {
101
+ [styles['api_key_input__submit_button--loading']]: loading,
120
102
  })}
121
103
  style={{
122
- backgroundColor: chatbot?.primaryComponent?.mainColor,
123
- color: chatbot?.primaryComponent?.secondaryColor,
104
+ backgroundColor: chatbot?.mainColor,
105
+ color: chatbot?.secondaryColor,
124
106
  }}
125
107
  >
126
108
  {loading ? 'Loading...' : 'Continue'}
@@ -31,6 +31,8 @@ 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'];
34
36
  primaryComponent?: {
35
37
  mainColor?: CSSProperties['color'];
36
38
  secondaryColor?: CSSProperties['color'];
@@ -267,8 +269,8 @@ export function AsgardThemeContextProvider(
267
269
  chatbot: {
268
270
  backgroundColor: themeFromAnnotations.chatbot?.backgroundColor,
269
271
  borderColor: themeFromAnnotations.chatbot?.borderColor,
270
- inactiveColor: themeFromAnnotations.chatbot?.inactiveColor,
271
- primaryComponent: themeFromAnnotations.chatbot?.primaryComponent,
272
+ mainColor: themeFromAnnotations.chatbot?.primaryComponent?.mainColor,
273
+ secondaryColor: themeFromAnnotations.chatbot?.primaryComponent?.secondaryColor,
272
274
 
273
275
  header: {
274
276
  style: {
@@ -410,8 +412,8 @@ export function AsgardThemeContextProvider(
410
412
  chatbot: {
411
413
  backgroundColor: propsTheme.chatbot?.backgroundColor,
412
414
  borderColor: propsTheme.chatbot?.borderColor,
413
- inactiveColor: propsTheme.chatbot?.inactiveColor,
414
- primaryComponent: propsTheme.chatbot?.primaryComponent,
415
+ mainColor: propsTheme.chatbot?.primaryComponent?.mainColor,
416
+ secondaryColor: propsTheme.chatbot?.primaryComponent?.secondaryColor,
415
417
  header: {
416
418
  style: {
417
419
  borderBottomColor: propsTheme.chatbot?.borderColor,
@@ -0,0 +1,4 @@
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>
@@ -0,0 +1,4 @@
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>