@asgard-js/react 0.0.43-canary.24 → 0.0.43-canary.26

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.24",
3
+ "version": "0.0.43-canary.26",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -54,7 +54,7 @@
54
54
  "vitest": "^1.6.0"
55
55
  },
56
56
  "peerDependencies": {
57
- "@asgard-js/core": "^0.0.42-canary.1",
57
+ "@asgard-js/core": "^0.0.43-canary.26",
58
58
  "react": "^18.0.0",
59
59
  "react-dom": "^18.0.0"
60
60
  },
@@ -20,12 +20,12 @@ export function ChatbotFullScreenContainer(
20
20
 
21
21
  usePreventOverScrolling(containerRef);
22
22
 
23
- useOnScreenKeyboardScrollFix();
24
-
25
23
  const [, height] = useViewportSize() ?? [];
26
24
 
27
25
  const isOnScreenKeyboardOpen = useIsOnScreenKeyboardOpen();
28
26
 
27
+ useOnScreenKeyboardScrollFix(isOnScreenKeyboardOpen);
28
+
29
29
  const styles = useMemo(() => {
30
30
  return Object.assign(
31
31
  theme?.chatbot?.backgroundColor
@@ -0,0 +1,24 @@
1
+ .chatbot__auth_state_container {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ flex: 1;
6
+ padding: 20px;
7
+ }
8
+
9
+ .chatbot__error_state {
10
+ color: #ff6b6b;
11
+ }
12
+
13
+ .chatbot__error_state__content {
14
+ text-align: center;
15
+ }
16
+
17
+ .chatbot__error_state__icon {
18
+ font-size: 16px;
19
+ margin-bottom: 8px;
20
+ }
21
+
22
+ .chatbot__error_state__message {
23
+ // No additional styles needed - uses default text styling
24
+ }
@@ -18,11 +18,13 @@ import {
18
18
  AsgardServiceContextProviderProps,
19
19
  } from '../../context';
20
20
  import { AuthState } from '@asgard-js/core';
21
+ import clsx from 'clsx';
21
22
  import { ApiKeyInput } from './api-key-input';
22
23
  import { ChatbotHeader } from './chatbot-header';
23
24
  import { ChatbotBody } from './chatbot-body';
24
25
  import { ChatbotFooter } from './chatbot-footer';
25
26
  import { ChatbotContainer } from './chatbot-container/chatbot-container';
27
+ import styles from './chatbot.module.scss';
26
28
 
27
29
  interface ChatbotProps extends AsgardTemplateContextValue {
28
30
  className?: string;
@@ -94,26 +96,14 @@ export const Chatbot = forwardRef(function Chatbot(
94
96
  switch (authState) {
95
97
  case 'loading':
96
98
  return (
97
- <div style={{
98
- display: 'flex',
99
- alignItems: 'center',
100
- justifyContent: 'center',
101
- flex: 1,
102
- padding: '20px'
103
- }}>
99
+ <div className={styles.chatbot__auth_state_container}>
104
100
  {loadingComponent || <div>Loading...</div>}
105
101
  </div>
106
102
  );
107
103
 
108
104
  case 'needApiKey':
109
105
  return (
110
- <div style={{
111
- display: 'flex',
112
- alignItems: 'center',
113
- justifyContent: 'center',
114
- flex: 1,
115
- padding: '20px'
116
- }}>
106
+ <div className={styles.chatbot__auth_state_container}>
117
107
  <ApiKeyInput
118
108
  title={title}
119
109
  onSubmit={onApiKeySubmit || (() => {})}
@@ -124,13 +114,7 @@ export const Chatbot = forwardRef(function Chatbot(
124
114
 
125
115
  case 'invalidApiKey':
126
116
  return (
127
- <div style={{
128
- display: 'flex',
129
- alignItems: 'center',
130
- justifyContent: 'center',
131
- flex: 1,
132
- padding: '20px'
133
- }}>
117
+ <div className={styles.chatbot__auth_state_container}>
134
118
  <ApiKeyInput
135
119
  title={title}
136
120
  onSubmit={onApiKeySubmit || (() => {})}
@@ -142,17 +126,10 @@ export const Chatbot = forwardRef(function Chatbot(
142
126
 
143
127
  case 'error':
144
128
  return (
145
- <div style={{
146
- display: 'flex',
147
- alignItems: 'center',
148
- justifyContent: 'center',
149
- flex: 1,
150
- padding: '20px',
151
- color: '#ff6b6b'
152
- }}>
153
- <div style={{ textAlign: 'center' }}>
154
- <div style={{ fontSize: '16px', marginBottom: '8px' }}>⚠️</div>
155
- <div>Something went wrong. Please try again later.</div>
129
+ <div className={clsx(styles.chatbot__auth_state_container, styles.chatbot__error_state)}>
130
+ <div className={styles.chatbot__error_state__content}>
131
+ <div className={styles.chatbot__error_state__icon}>⚠️</div>
132
+ <div className={styles.chatbot__error_state__message}>Something went wrong. Please try again later.</div>
156
133
  </div>
157
134
  </div>
158
135
  );
@@ -1,7 +1,9 @@
1
1
  import { useEffect } from 'react';
2
2
 
3
- export function useOnScreenKeyboardScrollFix(): void {
3
+ export function useOnScreenKeyboardScrollFix(isOnScreenKeyboardOpen: boolean): void {
4
4
  useEffect(() => {
5
+ if (!isOnScreenKeyboardOpen) return;
6
+
5
7
  function handleScroll(): void {
6
8
  window.scrollTo(0, 0);
7
9
  }
@@ -11,5 +13,5 @@ export function useOnScreenKeyboardScrollFix(): void {
11
13
  return (): void => {
12
14
  window.removeEventListener('scroll', handleScroll);
13
15
  };
14
- }, []);
16
+ }, [isOnScreenKeyboardOpen]);
15
17
  }