@magmamath/students-features 0.7.0 → 0.8.0-rc.0
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/commonjs/features/chatbot/components/{ChatMessages/ChatbotMessages.js → Chat/Chat.js} +8 -15
- package/dist/commonjs/features/chatbot/components/Chat/Chat.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js +1 -1
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/ChatInput.js +74 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/ChatInput.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js +144 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.js +138 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js +66 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.js +106 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js +7 -4
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/Chatbot.js +2 -2
- package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/commonjs/features/chatbot/constants.js +6 -1
- package/dist/commonjs/features/chatbot/constants.js.map +1 -1
- package/dist/commonjs/features/chatbot/helpers.js +75 -1
- package/dist/commonjs/features/chatbot/helpers.js.map +1 -1
- package/dist/commonjs/features/chatbot/index.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js +49 -11
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotTextInput.js +16 -0
- package/dist/commonjs/features/chatbot/model/ChatBotTextInput.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js +11 -19
- package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/{translation.js → ChatbotTranslation.js} +29 -1
- package/dist/commonjs/features/chatbot/model/ChatbotTranslation.js.map +1 -0
- package/dist/commonjs/features/chatbot/types/model.types.js +6 -1
- package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/units.types.js +10 -0
- package/dist/commonjs/features/chatbot/types/units.types.js.map +1 -1
- package/dist/commonjs/shared/hooks/useKeyDownListener.js +3 -2
- package/dist/commonjs/shared/hooks/useKeyDownListener.js.map +1 -1
- package/dist/commonjs/shared/translation/localization/ca.json +3 -2
- package/dist/commonjs/shared/translation/localization/en.json +3 -2
- package/dist/commonjs/shared/translation/localization/gb.json +3 -2
- package/dist/commonjs/shared/translation/localization/sct.json +3 -2
- package/dist/commonjs/shared/translation/localization/sw.json +3 -2
- package/dist/module/features/chatbot/components/{ChatMessages/ChatbotMessages.js → Chat/Chat.js} +6 -13
- package/dist/module/features/chatbot/components/Chat/Chat.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js +1 -1
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatInput/ChatInput.js +67 -0
- package/dist/module/features/chatbot/components/ChatInput/ChatInput.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js +138 -0
- package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.js +131 -0
- package/dist/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js +60 -0
- package/dist/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.js +98 -0
- package/dist/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js +7 -4
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -1
- package/dist/module/features/chatbot/components/Chatbot.js +2 -2
- package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/module/features/chatbot/constants.js +5 -0
- package/dist/module/features/chatbot/constants.js.map +1 -1
- package/dist/module/features/chatbot/helpers.js +71 -0
- package/dist/module/features/chatbot/helpers.js.map +1 -1
- package/dist/module/features/chatbot/index.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBotModel.js +49 -11
- package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBotTextInput.js +11 -0
- package/dist/module/features/chatbot/model/ChatBotTextInput.js.map +1 -0
- package/dist/module/features/chatbot/model/ChatBotThreadManager.js +11 -19
- package/dist/module/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
- package/dist/module/features/chatbot/model/{translation.js → ChatbotTranslation.js} +29 -1
- package/dist/module/features/chatbot/model/ChatbotTranslation.js.map +1 -0
- package/dist/module/features/chatbot/types/model.types.js +5 -0
- package/dist/module/features/chatbot/types/model.types.js.map +1 -1
- package/dist/module/features/chatbot/types/units.types.js +6 -0
- package/dist/module/features/chatbot/types/units.types.js.map +1 -1
- package/dist/module/shared/hooks/useKeyDownListener.js +3 -2
- package/dist/module/shared/hooks/useKeyDownListener.js.map +1 -1
- package/dist/module/shared/translation/localization/ca.json +3 -2
- package/dist/module/shared/translation/localization/en.json +3 -2
- package/dist/module/shared/translation/localization/gb.json +3 -2
- package/dist/module/shared/translation/localization/sct.json +3 -2
- package/dist/module/shared/translation/localization/sw.json +3 -2
- package/dist/typescript/{module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts → commonjs/features/chatbot/components/Chat/Chat.d.ts} +3 -3
- package/dist/typescript/commonjs/features/chatbot/components/Chat/Chat.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/ChatInput.d.ts +9 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/ChatInput.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/RequestHintButton.d.ts +16 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts +16 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts +11 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts +10 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts +3 -1
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts +5 -0
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/helpers.d.ts +5 -0
- package/dist/typescript/commonjs/features/chatbot/helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +5 -6
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotTextInput.d.ts +8 -0
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotTextInput.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts +3 -2
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -1
- package/dist/typescript/{module/features/chatbot/model/translation.d.ts → commonjs/features/chatbot/model/ChatbotTranslation.d.ts} +3 -2
- package/dist/typescript/commonjs/features/chatbot/model/ChatbotTranslation.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +28 -6
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +28 -3
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts +5 -0
- package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts +5 -0
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/hooks/useKeyDownListener.d.ts +1 -1
- package/dist/typescript/commonjs/shared/hooks/useKeyDownListener.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/hooks/useKeyboard.d.ts +1 -1
- package/dist/typescript/commonjs/shared/hooks/useKeyboard.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/constants.d.ts +5 -0
- package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/model.d.ts +2 -0
- package/dist/typescript/commonjs/shared/translation/model.d.ts.map +1 -1
- package/dist/typescript/{commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts → module/features/chatbot/components/Chat/Chat.d.ts} +3 -3
- package/dist/typescript/module/features/chatbot/components/Chat/Chat.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatInput/ChatInput.d.ts +9 -0
- package/dist/typescript/module/features/chatbot/components/ChatInput/ChatInput.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatInput/RequestHintButton.d.ts +16 -0
- package/dist/typescript/module/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts +16 -0
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts +11 -0
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts +10 -0
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts +3 -1
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/constants.d.ts +5 -0
- package/dist/typescript/module/features/chatbot/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/helpers.d.ts +5 -0
- package/dist/typescript/module/features/chatbot/helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +5 -6
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotTextInput.d.ts +8 -0
- package/dist/typescript/module/features/chatbot/model/ChatBotTextInput.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts +3 -2
- package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -1
- package/dist/typescript/{commonjs/features/chatbot/model/translation.d.ts → module/features/chatbot/model/ChatbotTranslation.d.ts} +3 -2
- package/dist/typescript/module/features/chatbot/model/ChatbotTranslation.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts +28 -6
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts +28 -3
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/translation.types.d.ts +5 -0
- package/dist/typescript/module/features/chatbot/types/translation.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts +5 -0
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts.map +1 -1
- package/dist/typescript/module/shared/hooks/useKeyDownListener.d.ts +1 -1
- package/dist/typescript/module/shared/hooks/useKeyDownListener.d.ts.map +1 -1
- package/dist/typescript/module/shared/hooks/useKeyboard.d.ts +1 -1
- package/dist/typescript/module/shared/hooks/useKeyboard.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/constants.d.ts +5 -0
- package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/model.d.ts +2 -0
- package/dist/typescript/module/shared/translation/model.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/chatbot/components/{ChatMessages/ChatbotMessages.tsx → Chat/Chat.tsx} +13 -18
- package/src/features/chatbot/components/ChatControls/ChatControls.tsx +2 -2
- package/src/features/chatbot/components/ChatInput/ChatInput.tsx +88 -0
- package/src/features/chatbot/components/ChatInput/RequestHintButton.tsx +156 -0
- package/src/features/chatbot/components/ChatInput/freeText/ChatTextInput.tsx +156 -0
- package/src/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.tsx +71 -0
- package/src/features/chatbot/components/ChatInput/freeText/SendMessageButton.tsx +111 -0
- package/src/features/chatbot/components/ChatMessage/MessageLoader.tsx +6 -2
- package/src/features/chatbot/components/Chatbot.tsx +5 -3
- package/src/features/chatbot/constants.ts +7 -0
- package/src/features/chatbot/helpers.ts +70 -1
- package/src/features/chatbot/index.ts +1 -0
- package/src/features/chatbot/model/ChatBotModel.ts +82 -37
- package/src/features/chatbot/model/ChatBotTextInput.ts +10 -0
- package/src/features/chatbot/model/ChatBotThreadManager.ts +17 -19
- package/src/features/chatbot/model/{translation.ts → ChatbotTranslation.ts} +32 -2
- package/src/features/chatbot/types/api.types.ts +31 -6
- package/src/features/chatbot/types/model.types.ts +35 -2
- package/src/features/chatbot/types/translation.types.ts +6 -0
- package/src/features/chatbot/types/units.types.ts +6 -0
- package/src/shared/hooks/useKeyDownListener.ts +3 -1
- package/src/shared/translation/localization/ca.json +3 -2
- package/src/shared/translation/localization/en.json +3 -2
- package/src/shared/translation/localization/gb.json +3 -2
- package/src/shared/translation/localization/sct.json +3 -2
- package/src/shared/translation/localization/sw.json +3 -2
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js +0 -59
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js +0 -99
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +0 -1
- package/dist/commonjs/features/chatbot/model/translation.js.map +0 -1
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js +0 -53
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js.map +0 -1
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js +0 -92
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +0 -1
- package/dist/module/features/chatbot/model/translation.js.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts +0 -11
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts +0 -10
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts +0 -11
- package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts +0 -10
- package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/model/translation.d.ts.map +0 -1
- package/src/features/chatbot/components/Alternatives/Alternatives.tsx +0 -60
- package/src/features/chatbot/components/Alternatives/HelpRequestOption.tsx +0 -91
|
@@ -5,29 +5,29 @@ import { useStoreMap, useUnit } from 'effector-react'
|
|
|
5
5
|
import { ChatbotModel } from '../../model/ChatBotModel'
|
|
6
6
|
import { ChatMessage } from '../ChatMessage/ChatMessage'
|
|
7
7
|
import { MessageLoader } from '../ChatMessage/MessageLoader'
|
|
8
|
-
import {
|
|
8
|
+
import { ChatInput } from '../ChatInput/ChatInput'
|
|
9
9
|
import { MessageVariant } from '../../types/model.types'
|
|
10
10
|
import { ColorScheme } from '../../types/style.types'
|
|
11
11
|
|
|
12
|
-
type ChatbotMessagesProps = {
|
|
13
|
-
model: ChatbotModel
|
|
14
|
-
isHintFeedback: boolean
|
|
15
|
-
isTextToSpeechEnabled: boolean
|
|
16
|
-
colorScheme?: ColorScheme
|
|
17
|
-
}
|
|
18
|
-
|
|
19
12
|
const TOOLBAR_HEIGHT = 140
|
|
20
13
|
const BOTTOM_OFFSET = Platform.select({
|
|
21
14
|
web: 265,
|
|
22
15
|
default: 294,
|
|
23
16
|
})
|
|
24
17
|
|
|
25
|
-
|
|
18
|
+
type ChatProps = {
|
|
19
|
+
model: ChatbotModel
|
|
20
|
+
isHintFeedback: boolean
|
|
21
|
+
isTextToSpeechEnabled: boolean
|
|
22
|
+
colorScheme?: ColorScheme
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const Chat = ({
|
|
26
26
|
model,
|
|
27
27
|
isHintFeedback,
|
|
28
28
|
isTextToSpeechEnabled,
|
|
29
29
|
colorScheme = ColorScheme.Blue,
|
|
30
|
-
}:
|
|
30
|
+
}: ChatProps) => {
|
|
31
31
|
const dimensions = useWindowDimensions()
|
|
32
32
|
const ref = useRef<ScrollView>(null)
|
|
33
33
|
const isOpen = useUnit(model.$isOpen)
|
|
@@ -45,10 +45,6 @@ export const ChatbotMessages = ({
|
|
|
45
45
|
|
|
46
46
|
const MAX_HEIGHT = dimensions.height - TOOLBAR_HEIGHT - BOTTOM_OFFSET
|
|
47
47
|
|
|
48
|
-
const askChatForHelp = (message: string, translatedMessage?: string) => {
|
|
49
|
-
void model.sendHelpRequestFx({ message, translatedMessage })
|
|
50
|
-
}
|
|
51
|
-
|
|
52
48
|
return (
|
|
53
49
|
<View style={[styles.container, { maxHeight: MAX_HEIGHT }]}>
|
|
54
50
|
<ScrollView
|
|
@@ -88,12 +84,11 @@ export const ChatbotMessages = ({
|
|
|
88
84
|
</View>
|
|
89
85
|
)}
|
|
90
86
|
|
|
91
|
-
{
|
|
92
|
-
<
|
|
93
|
-
onPressAlternative={askChatForHelp}
|
|
94
|
-
hasMessages={messages.length > 1}
|
|
87
|
+
{isOpen && (
|
|
88
|
+
<ChatInput
|
|
95
89
|
isHintFeedback={isHintFeedback}
|
|
96
90
|
colorScheme={colorScheme}
|
|
91
|
+
hasMessages={messages.length > 1}
|
|
97
92
|
/>
|
|
98
93
|
)}
|
|
99
94
|
</ScrollView>
|
|
@@ -18,7 +18,7 @@ type ChatControlsProps = {
|
|
|
18
18
|
model: ChatbotModel
|
|
19
19
|
onPressChatIcon: () => void
|
|
20
20
|
onPressClose: () => void
|
|
21
|
-
ButtonWrapper
|
|
21
|
+
ButtonWrapper?: ComponentType<PropsWithChildren>
|
|
22
22
|
iconSize?: { width: number; height: number }
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -26,7 +26,7 @@ export const ChatControls = ({
|
|
|
26
26
|
model,
|
|
27
27
|
onPressChatIcon,
|
|
28
28
|
onPressClose,
|
|
29
|
-
ButtonWrapper,
|
|
29
|
+
ButtonWrapper = React.Fragment,
|
|
30
30
|
iconSize = { width: 80, height: 100 },
|
|
31
31
|
}: ChatControlsProps) => {
|
|
32
32
|
const isOpen = useUnit(model.$isOpen)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react'
|
|
2
|
+
import { IS_WEB } from '@magmamath/react-native-ui'
|
|
3
|
+
import { StyleSheet, View } from 'react-native'
|
|
4
|
+
import { useStoreMap, useUnit } from 'effector-react'
|
|
5
|
+
import { useChatModel } from '../../context/ChatBotModelContext'
|
|
6
|
+
import { ColorScheme } from '../../types/style.types'
|
|
7
|
+
import { HintButtonVariant, RequestHintButton } from './RequestHintButton'
|
|
8
|
+
import { FreeTextInputBlock } from './freeText/FreeTextInputBlock'
|
|
9
|
+
|
|
10
|
+
export type ChatInputProps = {
|
|
11
|
+
hasMessages: boolean
|
|
12
|
+
isHintFeedback: boolean
|
|
13
|
+
colorScheme?: ColorScheme
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const ChatInput = ({
|
|
17
|
+
isHintFeedback,
|
|
18
|
+
hasMessages,
|
|
19
|
+
colorScheme = ColorScheme.Blue,
|
|
20
|
+
}: ChatInputProps) => {
|
|
21
|
+
const model = useChatModel()
|
|
22
|
+
const alternatives = useUnit(model.$alternatives)
|
|
23
|
+
const isTranslated = useUnit(model.translation.$isTranslated)
|
|
24
|
+
const isTranslationPending = useUnit(model.translation.translateAllMessagesFx.pending)
|
|
25
|
+
const isHelpRequestPending = useUnit(model.sendHelpRequestFx.pending)
|
|
26
|
+
|
|
27
|
+
const lastMessageOptions = useStoreMap(model.$currentChatData, ({ messages }) => {
|
|
28
|
+
const lastMessage = messages.at(-1)
|
|
29
|
+
return lastMessage?.options ?? []
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const option = useMemo(() => {
|
|
33
|
+
if (hasMessages && lastMessageOptions.length) return lastMessageOptions[0]
|
|
34
|
+
|
|
35
|
+
const shouldShowNextHintOption =
|
|
36
|
+
(isHintFeedback && !!alternatives?.options.hints) || hasMessages || isHelpRequestPending
|
|
37
|
+
|
|
38
|
+
return shouldShowNextHintOption
|
|
39
|
+
? alternatives?.options.hints[0]
|
|
40
|
+
: alternatives?.options.default[0]
|
|
41
|
+
}, [hasMessages, isHintFeedback, isHelpRequestPending, lastMessageOptions, alternatives?.options])
|
|
42
|
+
|
|
43
|
+
const optionLabel =
|
|
44
|
+
(isTranslated && !isTranslationPending ? option?.translatedText : option?.text) ?? ''
|
|
45
|
+
|
|
46
|
+
if (!option) return null
|
|
47
|
+
|
|
48
|
+
const sendMessage = useCallback(() => {
|
|
49
|
+
void model.sendHelpRequestFx({
|
|
50
|
+
message: option.text,
|
|
51
|
+
translatedMessage: option.translatedText,
|
|
52
|
+
})
|
|
53
|
+
}, [option.text, option.translatedText])
|
|
54
|
+
|
|
55
|
+
const shouldDisableInput =
|
|
56
|
+
isHelpRequestPending || (hasMessages && lastMessageOptions.length === 0)
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<View style={styles.container}>
|
|
60
|
+
{IS_WEB && alternatives?.isOpenChatEnabled ? (
|
|
61
|
+
<FreeTextInputBlock
|
|
62
|
+
optionLabel={optionLabel}
|
|
63
|
+
onOptionPress={sendMessage}
|
|
64
|
+
disabled={shouldDisableInput}
|
|
65
|
+
colorScheme={colorScheme}
|
|
66
|
+
/>
|
|
67
|
+
) : (
|
|
68
|
+
<RequestHintButton
|
|
69
|
+
onPress={sendMessage}
|
|
70
|
+
label={optionLabel}
|
|
71
|
+
disabled={shouldDisableInput}
|
|
72
|
+
colorScheme={colorScheme}
|
|
73
|
+
variant={HintButtonVariant.Default}
|
|
74
|
+
/>
|
|
75
|
+
)}
|
|
76
|
+
</View>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const styles = StyleSheet.create({
|
|
81
|
+
container: {
|
|
82
|
+
flex: 1,
|
|
83
|
+
width: 305,
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
justifyContent: 'center',
|
|
86
|
+
marginVertical: 8,
|
|
87
|
+
},
|
|
88
|
+
})
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Pressable, StyleSheet } from 'react-native'
|
|
2
|
+
import React, { memo } from 'react'
|
|
3
|
+
import Animated, {
|
|
4
|
+
useSharedValue,
|
|
5
|
+
withTiming,
|
|
6
|
+
useAnimatedStyle,
|
|
7
|
+
interpolateColor,
|
|
8
|
+
} from 'react-native-reanimated'
|
|
9
|
+
import {
|
|
10
|
+
ArrowRightIcon,
|
|
11
|
+
ArrowUpIcon,
|
|
12
|
+
COLORS,
|
|
13
|
+
FONT_FAMILY,
|
|
14
|
+
IS_MOBILE,
|
|
15
|
+
SPACING,
|
|
16
|
+
} from '@magmamath/react-native-ui'
|
|
17
|
+
import { ColorScheme } from '@magmamath/students-features'
|
|
18
|
+
import { MESSAGE_COLORS_MAP } from '../../constants'
|
|
19
|
+
|
|
20
|
+
export enum HintButtonVariant {
|
|
21
|
+
Default = 'default',
|
|
22
|
+
Short = 'short',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const HOVER_ANIMATION_DURATION = 200
|
|
26
|
+
|
|
27
|
+
const REQUEST_HINT_BUTTON = {
|
|
28
|
+
[HintButtonVariant.Default]: {
|
|
29
|
+
width: 305,
|
|
30
|
+
fontSize: 20,
|
|
31
|
+
},
|
|
32
|
+
[HintButtonVariant.Short]: { width: 163, fontSize: 18 },
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type RequestHintButtonProps = {
|
|
36
|
+
onPress: () => void
|
|
37
|
+
label: string
|
|
38
|
+
disabled: boolean
|
|
39
|
+
colorScheme?: ColorScheme
|
|
40
|
+
variant: HintButtonVariant
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const RequestHintButton = memo(
|
|
44
|
+
({
|
|
45
|
+
onPress,
|
|
46
|
+
label,
|
|
47
|
+
disabled = false,
|
|
48
|
+
colorScheme = ColorScheme.Blue,
|
|
49
|
+
variant = HintButtonVariant.Default,
|
|
50
|
+
}: RequestHintButtonProps) => {
|
|
51
|
+
const hoverSv = useSharedValue(0)
|
|
52
|
+
|
|
53
|
+
const onHoverIn = () => {
|
|
54
|
+
if (!disabled) hoverSv.value = withTiming(1, { duration: HOVER_ANIMATION_DURATION })
|
|
55
|
+
}
|
|
56
|
+
const onHoverOut = () => {
|
|
57
|
+
if (!disabled) hoverSv.value = withTiming(0, { duration: HOVER_ANIMATION_DURATION })
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const animatedTextContainerStyle = useAnimatedStyle(() => {
|
|
61
|
+
if (disabled) {
|
|
62
|
+
return {
|
|
63
|
+
backgroundColor: COLORS.NEUTRAL_2,
|
|
64
|
+
borderColor: COLORS.NEUTRAL_5,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const defaultBorderColor =
|
|
69
|
+
variant === HintButtonVariant.Default
|
|
70
|
+
? COLORS.NEUTRAL_1
|
|
71
|
+
: MESSAGE_COLORS_MAP[colorScheme].sent.border
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
backgroundColor: interpolateColor(
|
|
75
|
+
hoverSv.value,
|
|
76
|
+
[0, 1],
|
|
77
|
+
[COLORS.NEUTRAL_1, MESSAGE_COLORS_MAP[colorScheme].sent.background],
|
|
78
|
+
),
|
|
79
|
+
borderColor: interpolateColor(
|
|
80
|
+
hoverSv.value,
|
|
81
|
+
[0, 1],
|
|
82
|
+
[defaultBorderColor, MESSAGE_COLORS_MAP[colorScheme].sent.border],
|
|
83
|
+
),
|
|
84
|
+
}
|
|
85
|
+
}, [hoverSv, disabled, colorScheme])
|
|
86
|
+
|
|
87
|
+
const animatedTextStyle = useAnimatedStyle(() => {
|
|
88
|
+
if (disabled) return { color: COLORS.NEUTRAL_5 }
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
color: interpolateColor(hoverSv.value, [0, 1], [COLORS.NEUTRAL_10, COLORS.NEUTRAL_1]),
|
|
92
|
+
}
|
|
93
|
+
}, [hoverSv, disabled])
|
|
94
|
+
|
|
95
|
+
const iconColor = disabled ? COLORS.NEUTRAL_5 : 'currentColor'
|
|
96
|
+
const { width, fontSize } = REQUEST_HINT_BUTTON[variant]
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Pressable
|
|
100
|
+
onHoverIn={onHoverIn}
|
|
101
|
+
onHoverOut={onHoverOut}
|
|
102
|
+
onPress={onPress}
|
|
103
|
+
style={[styles.button, { cursor: disabled ? 'auto' : 'pointer', width }]}
|
|
104
|
+
disabled={disabled}
|
|
105
|
+
accessibilityState={{ disabled }}
|
|
106
|
+
accessibilityRole="button"
|
|
107
|
+
>
|
|
108
|
+
<Animated.View style={[styles.content, animatedTextContainerStyle]}>
|
|
109
|
+
<Animated.Text numberOfLines={1} style={[styles.text, animatedTextStyle, { fontSize }]}>
|
|
110
|
+
{label}
|
|
111
|
+
</Animated.Text>
|
|
112
|
+
|
|
113
|
+
<Animated.Text style={[styles.iconWrapper, animatedTextStyle]}>
|
|
114
|
+
{variant === HintButtonVariant.Default ? (
|
|
115
|
+
<ArrowRightIcon color={iconColor} size={16} />
|
|
116
|
+
) : (
|
|
117
|
+
<ArrowUpIcon color={iconColor} size={16} />
|
|
118
|
+
)}
|
|
119
|
+
</Animated.Text>
|
|
120
|
+
</Animated.View>
|
|
121
|
+
</Pressable>
|
|
122
|
+
)
|
|
123
|
+
},
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
const styles = StyleSheet.create({
|
|
127
|
+
button: {
|
|
128
|
+
flexDirection: 'row',
|
|
129
|
+
justifyContent: 'flex-end',
|
|
130
|
+
},
|
|
131
|
+
text: {
|
|
132
|
+
fontWeight: '400',
|
|
133
|
+
fontFamily: FONT_FAMILY.buenosAires,
|
|
134
|
+
color: COLORS.NEUTRAL_10,
|
|
135
|
+
},
|
|
136
|
+
content: {
|
|
137
|
+
height: 44,
|
|
138
|
+
flex: 1,
|
|
139
|
+
flexDirection: 'row',
|
|
140
|
+
alignItems: 'center',
|
|
141
|
+
justifyContent: 'space-between',
|
|
142
|
+
paddingHorizontal: SPACING[400],
|
|
143
|
+
borderWidth: 1,
|
|
144
|
+
borderRadius: 48,
|
|
145
|
+
elevation: 3,
|
|
146
|
+
shadowColor: '#333',
|
|
147
|
+
shadowOffset: { width: 0, height: 1 },
|
|
148
|
+
shadowOpacity: 0.25,
|
|
149
|
+
shadowRadius: 3,
|
|
150
|
+
backgroundColor: COLORS.PRIMARY_BLUE,
|
|
151
|
+
borderColor: COLORS.PRIMARY_BLUE,
|
|
152
|
+
},
|
|
153
|
+
iconWrapper: {
|
|
154
|
+
top: IS_MOBILE ? 3 : 0,
|
|
155
|
+
},
|
|
156
|
+
})
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react'
|
|
2
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated'
|
|
3
|
+
import {
|
|
4
|
+
NativeSyntheticEvent,
|
|
5
|
+
Platform,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
TextInput,
|
|
8
|
+
TextInputFocusEventData,
|
|
9
|
+
} from 'react-native'
|
|
10
|
+
import { COLORS, FONT_FAMILY, SPACING } from '@magmamath/react-native-ui'
|
|
11
|
+
import { ColorScheme } from '@magmamath/students-features'
|
|
12
|
+
import { useKeyBoard } from '../../../../../shared/hooks/useKeyboard'
|
|
13
|
+
import { KeyboardKeys } from '../../../../../lib/constants'
|
|
14
|
+
|
|
15
|
+
import { SendMessageButton } from './SendMessageButton'
|
|
16
|
+
|
|
17
|
+
const MAX_AVAILABLE_MESSAGE_LENGTH = 500
|
|
18
|
+
const COMPACT_WIDTH = 134
|
|
19
|
+
const FULL_WIDTH = 305
|
|
20
|
+
const ANIMATION_DURATION = 200
|
|
21
|
+
|
|
22
|
+
type ChatTextInputProps = {
|
|
23
|
+
value: string
|
|
24
|
+
onSubmit: () => void
|
|
25
|
+
submitDisabled?: boolean
|
|
26
|
+
onChangeText?: (text: string) => void
|
|
27
|
+
onBlur?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void
|
|
28
|
+
onFocus?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void
|
|
29
|
+
placeholder?: string
|
|
30
|
+
colorScheme?: ColorScheme
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const ChatTextInput = ({
|
|
34
|
+
value,
|
|
35
|
+
submitDisabled,
|
|
36
|
+
onSubmit,
|
|
37
|
+
onChangeText,
|
|
38
|
+
onBlur,
|
|
39
|
+
onFocus,
|
|
40
|
+
colorScheme = ColorScheme.Blue,
|
|
41
|
+
placeholder,
|
|
42
|
+
}: ChatTextInputProps) => {
|
|
43
|
+
const inputRef = useRef<TextInput>(null)
|
|
44
|
+
const [isFocused, setIsFocused] = useState(false)
|
|
45
|
+
const widthSv = useSharedValue(value ? FULL_WIDTH : COMPACT_WIDTH )
|
|
46
|
+
|
|
47
|
+
const animatedStyle = useAnimatedStyle(
|
|
48
|
+
() => ({
|
|
49
|
+
width: widthSv.value,
|
|
50
|
+
}),
|
|
51
|
+
[widthSv],
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
const handleInputChange = (text: string) => {
|
|
55
|
+
if (text.length > MAX_AVAILABLE_MESSAGE_LENGTH) return
|
|
56
|
+
|
|
57
|
+
onChangeText?.(text)
|
|
58
|
+
|
|
59
|
+
const hasText = text.trim().length > 0
|
|
60
|
+
const isExpanded = widthSv.value > COMPACT_WIDTH
|
|
61
|
+
const shouldCollapseInput = !hasText && isExpanded
|
|
62
|
+
const shouldExpandInput = hasText && !isExpanded
|
|
63
|
+
|
|
64
|
+
if (shouldExpandInput) {
|
|
65
|
+
widthSv.value = withTiming(FULL_WIDTH, { duration: ANIMATION_DURATION })
|
|
66
|
+
} else if (shouldCollapseInput) {
|
|
67
|
+
widthSv.value = withTiming(COMPACT_WIDTH, { duration: ANIMATION_DURATION })
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const handleSendMessage = () => {
|
|
72
|
+
if (submitDisabled || value.trim().length < 1 || value.length > MAX_AVAILABLE_MESSAGE_LENGTH)
|
|
73
|
+
return
|
|
74
|
+
|
|
75
|
+
onSubmit?.()
|
|
76
|
+
handleInputChange('')
|
|
77
|
+
inputRef.current?.focus()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const handleOnFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
81
|
+
setIsFocused(true)
|
|
82
|
+
onFocus?.(e)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const handleOnBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
86
|
+
setIsFocused(false)
|
|
87
|
+
onBlur?.(e)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
useKeyBoard((event) => {
|
|
91
|
+
if (event.key === KeyboardKeys.ENTER) {
|
|
92
|
+
void handleSendMessage()
|
|
93
|
+
}
|
|
94
|
+
}, isFocused)
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<Animated.View style={[styles.inputWrapper, animatedStyle]}>
|
|
98
|
+
<TextInput
|
|
99
|
+
ref={inputRef}
|
|
100
|
+
value={value}
|
|
101
|
+
onChangeText={handleInputChange}
|
|
102
|
+
onBlur={handleOnBlur}
|
|
103
|
+
onFocus={handleOnFocus}
|
|
104
|
+
placeholder={placeholder}
|
|
105
|
+
placeholderTextColor={COLORS.NEUTRAL_6}
|
|
106
|
+
style={styles.input}
|
|
107
|
+
/>
|
|
108
|
+
<SendMessageButton
|
|
109
|
+
onPress={handleSendMessage}
|
|
110
|
+
disabled={!!submitDisabled}
|
|
111
|
+
colorScheme={colorScheme}
|
|
112
|
+
/>
|
|
113
|
+
</Animated.View>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const styles = StyleSheet.create({
|
|
118
|
+
container: {
|
|
119
|
+
position: 'relative',
|
|
120
|
+
width: '100%',
|
|
121
|
+
alignItems: 'flex-end',
|
|
122
|
+
height: 52,
|
|
123
|
+
justifyContent: 'center',
|
|
124
|
+
},
|
|
125
|
+
inputWrapper: {
|
|
126
|
+
position: 'absolute',
|
|
127
|
+
zIndex: 1,
|
|
128
|
+
left: 0,
|
|
129
|
+
flexDirection: 'row',
|
|
130
|
+
borderWidth: 1,
|
|
131
|
+
borderColor: COLORS.NEUTRAL_5,
|
|
132
|
+
borderRadius: 200,
|
|
133
|
+
backgroundColor: COLORS.NEUTRAL_1,
|
|
134
|
+
paddingHorizontal: SPACING[100],
|
|
135
|
+
paddingVertical: SPACING[100],
|
|
136
|
+
elevation: 3,
|
|
137
|
+
shadowColor: '#333',
|
|
138
|
+
shadowOffset: { width: 0, height: 1 },
|
|
139
|
+
shadowOpacity: 0.25,
|
|
140
|
+
shadowRadius: 3,
|
|
141
|
+
},
|
|
142
|
+
input: {
|
|
143
|
+
flex: 1,
|
|
144
|
+
fontSize: 16,
|
|
145
|
+
minWidth: 60,
|
|
146
|
+
minHeight: 22,
|
|
147
|
+
fontWeight: '400',
|
|
148
|
+
fontFamily: FONT_FAMILY.buenosAires,
|
|
149
|
+
paddingHorizontal: SPACING[200],
|
|
150
|
+
paddingVertical: SPACING[200],
|
|
151
|
+
...(Platform.OS === 'web' && { outlineStyle: 'none' }),
|
|
152
|
+
},
|
|
153
|
+
arrowWrapper: {
|
|
154
|
+
marginLeft: SPACING[200],
|
|
155
|
+
},
|
|
156
|
+
})
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { useUnit } from 'effector-react'
|
|
3
|
+
import { StyleSheet, View } from 'react-native'
|
|
4
|
+
import { ColorScheme } from '../../../types/style.types'
|
|
5
|
+
import { HintButtonVariant, RequestHintButton } from '../RequestHintButton'
|
|
6
|
+
import { useChatModel } from '../../../context/ChatBotModelContext'
|
|
7
|
+
import { t } from '../../../../../shared/translation'
|
|
8
|
+
import { ChatTextInput } from './ChatTextInput'
|
|
9
|
+
|
|
10
|
+
type FreeTextInputBlockProps = {
|
|
11
|
+
optionLabel: string
|
|
12
|
+
disabled: boolean
|
|
13
|
+
onOptionPress: () => void
|
|
14
|
+
colorScheme?: ColorScheme
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const FreeTextInputBlock = ({
|
|
18
|
+
optionLabel,
|
|
19
|
+
onOptionPress,
|
|
20
|
+
disabled,
|
|
21
|
+
colorScheme,
|
|
22
|
+
}: FreeTextInputBlockProps) => {
|
|
23
|
+
const model = useChatModel()
|
|
24
|
+
const inputValue = useUnit(model.textInput.$value)
|
|
25
|
+
|
|
26
|
+
const handleOnSubmit = async () => {
|
|
27
|
+
const translatedMessage = await model.translation.translateSingleMessageFx(inputValue)
|
|
28
|
+
|
|
29
|
+
void model.textInput.setValue('')
|
|
30
|
+
void model.sendHelpRequestFx({
|
|
31
|
+
message: inputValue,
|
|
32
|
+
translatedMessage,
|
|
33
|
+
isFreeText: true,
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
const handleOnBlur = () => model.textInput.setIsFocused(false)
|
|
37
|
+
const handleOnFocus = () => model.textInput.setIsFocused(true)
|
|
38
|
+
const handleOnChangeText = (text: string) => model.textInput.setValue(text)
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<View style={styles.container}>
|
|
42
|
+
<ChatTextInput
|
|
43
|
+
value={inputValue}
|
|
44
|
+
onSubmit={handleOnSubmit}
|
|
45
|
+
onChangeText={handleOnChangeText}
|
|
46
|
+
onBlur={handleOnBlur}
|
|
47
|
+
onFocus={handleOnFocus}
|
|
48
|
+
submitDisabled={disabled || inputValue.trim().length < 1}
|
|
49
|
+
colorScheme={colorScheme}
|
|
50
|
+
placeholder={t('chat.inputPlaceholder')}
|
|
51
|
+
/>
|
|
52
|
+
<RequestHintButton
|
|
53
|
+
onPress={onOptionPress}
|
|
54
|
+
label={optionLabel}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
colorScheme={colorScheme}
|
|
57
|
+
variant={HintButtonVariant.Short}
|
|
58
|
+
/>
|
|
59
|
+
</View>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const styles = StyleSheet.create({
|
|
64
|
+
container: {
|
|
65
|
+
position: 'relative',
|
|
66
|
+
width: '100%',
|
|
67
|
+
alignItems: 'flex-end',
|
|
68
|
+
height: 52,
|
|
69
|
+
justifyContent: 'center',
|
|
70
|
+
},
|
|
71
|
+
})
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Pressable, StyleSheet } from 'react-native'
|
|
3
|
+
import Animated, {
|
|
4
|
+
useSharedValue,
|
|
5
|
+
withTiming,
|
|
6
|
+
useAnimatedStyle,
|
|
7
|
+
interpolateColor,
|
|
8
|
+
} from 'react-native-reanimated'
|
|
9
|
+
import { ArrowUpIcon, COLORS, IS_MOBILE } from '@magmamath/react-native-ui'
|
|
10
|
+
import { ColorScheme } from '@magmamath/students-features'
|
|
11
|
+
import { MESSAGE_COLORS_MAP } from '../../../constants'
|
|
12
|
+
|
|
13
|
+
type SendMessageButtonProps = {
|
|
14
|
+
onPress: () => void
|
|
15
|
+
disabled: boolean
|
|
16
|
+
colorScheme?: ColorScheme
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const SendMessageButton = ({
|
|
20
|
+
onPress,
|
|
21
|
+
disabled = false,
|
|
22
|
+
colorScheme = ColorScheme.Blue,
|
|
23
|
+
}: SendMessageButtonProps) => {
|
|
24
|
+
const hoverSv = useSharedValue(0)
|
|
25
|
+
|
|
26
|
+
const onHoverIn = () => {
|
|
27
|
+
if (!disabled) hoverSv.value = withTiming(1, { duration: 200 })
|
|
28
|
+
}
|
|
29
|
+
const onHoverOut = () => {
|
|
30
|
+
if (!disabled) hoverSv.value = withTiming(0, { duration: 200 })
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const animatedIconStyle = useAnimatedStyle(() => {
|
|
34
|
+
const backgroundColor = interpolateColor(
|
|
35
|
+
hoverSv.value,
|
|
36
|
+
[0, 1],
|
|
37
|
+
[COLORS.NEUTRAL_1, MESSAGE_COLORS_MAP[colorScheme].sent.border],
|
|
38
|
+
)
|
|
39
|
+
const color = interpolateColor(hoverSv.value, [0, 1], [COLORS.NEUTRAL_10, COLORS.NEUTRAL_1])
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
backgroundColor: disabled ? COLORS.NEUTRAL_2 : backgroundColor,
|
|
43
|
+
borderColor: disabled ? COLORS.NEUTRAL_5 : MESSAGE_COLORS_MAP[colorScheme].sent.border,
|
|
44
|
+
color: disabled ? COLORS.NEUTRAL_5 : color,
|
|
45
|
+
}
|
|
46
|
+
}, [hoverSv, disabled])
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Pressable
|
|
50
|
+
onHoverIn={onHoverIn}
|
|
51
|
+
onHoverOut={onHoverOut}
|
|
52
|
+
onPress={onPress}
|
|
53
|
+
style={[styles.button, disabled && { cursor: 'auto' }]}
|
|
54
|
+
disabled={disabled}
|
|
55
|
+
accessibilityState={{ disabled }}
|
|
56
|
+
accessibilityRole="button"
|
|
57
|
+
>
|
|
58
|
+
{IS_MOBILE ? (
|
|
59
|
+
<Animated.View
|
|
60
|
+
style={[
|
|
61
|
+
styles.iconContainer,
|
|
62
|
+
animatedIconStyle,
|
|
63
|
+
{
|
|
64
|
+
borderColor: disabled
|
|
65
|
+
? COLORS.NEUTRAL_5
|
|
66
|
+
: MESSAGE_COLORS_MAP[colorScheme].sent.border,
|
|
67
|
+
},
|
|
68
|
+
]}
|
|
69
|
+
>
|
|
70
|
+
<ArrowUpIcon color={'currentColor'} size={16} />
|
|
71
|
+
</Animated.View>
|
|
72
|
+
) : (
|
|
73
|
+
<Animated.Text style={[styles.webIconContainer, animatedIconStyle]}>
|
|
74
|
+
<ArrowUpIcon color={'currentColor'} size={16} />
|
|
75
|
+
</Animated.Text>
|
|
76
|
+
)}
|
|
77
|
+
</Pressable>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const styles = StyleSheet.create({
|
|
82
|
+
button: {
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
justifyContent: 'flex-end',
|
|
85
|
+
height: 44,
|
|
86
|
+
width: 44,
|
|
87
|
+
},
|
|
88
|
+
iconContainer: {
|
|
89
|
+
justifyContent: 'center',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
padding: 12,
|
|
92
|
+
borderRadius: 21,
|
|
93
|
+
borderWidth: 1,
|
|
94
|
+
},
|
|
95
|
+
webIconContainer: {
|
|
96
|
+
flex: 1,
|
|
97
|
+
flexDirection: 'row',
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
paddingHorizontal: 13,
|
|
100
|
+
paddingVertical: 12,
|
|
101
|
+
borderWidth: 1,
|
|
102
|
+
borderRadius: 48,
|
|
103
|
+
elevation: 3,
|
|
104
|
+
shadowColor: '#333',
|
|
105
|
+
shadowOffset: { width: 0, height: 1 },
|
|
106
|
+
shadowOpacity: 0.25,
|
|
107
|
+
shadowRadius: 3,
|
|
108
|
+
backgroundColor: COLORS.NEUTRAL_1,
|
|
109
|
+
borderColor: COLORS.PRIMARY_BLUE,
|
|
110
|
+
},
|
|
111
|
+
})
|
|
@@ -6,6 +6,7 @@ import { ChatbotIcon } from '../../../../shared/icons/ChatbotIcon'
|
|
|
6
6
|
import { ThreeDotsLoader } from '../ThreeDotsLoader/ThreeDotsLoader'
|
|
7
7
|
import { CONTROLS_COLORS_MAP } from '../../constants'
|
|
8
8
|
import { ColorScheme } from '../../types/style.types'
|
|
9
|
+
import { LavaIconInGlasses } from '@magmamath/students-features'
|
|
9
10
|
|
|
10
11
|
type MessageLoaderProps = {
|
|
11
12
|
colorScheme?: ColorScheme
|
|
@@ -14,7 +15,7 @@ type MessageLoaderProps = {
|
|
|
14
15
|
export const MessageLoader = ({ colorScheme = ColorScheme.Blue }: MessageLoaderProps) => (
|
|
15
16
|
<View style={styles.container}>
|
|
16
17
|
<View style={styles.icon}>
|
|
17
|
-
<
|
|
18
|
+
<LavaIconInGlasses width={60} height={80} />
|
|
18
19
|
</View>
|
|
19
20
|
<View style={styles.loader}>
|
|
20
21
|
<ThreeDotsLoader backgroundColor={CONTROLS_COLORS_MAP[colorScheme].background} />
|
|
@@ -27,10 +28,13 @@ const styles = StyleSheet.create({
|
|
|
27
28
|
flexDirection: 'row',
|
|
28
29
|
width: 327,
|
|
29
30
|
alignItems: 'flex-end',
|
|
31
|
+
paddingLeft:70
|
|
30
32
|
},
|
|
31
33
|
icon: {
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
zIndex:1,
|
|
32
36
|
alignSelf: 'flex-end',
|
|
33
|
-
|
|
37
|
+
left: 0
|
|
34
38
|
},
|
|
35
39
|
loader: {
|
|
36
40
|
flex: 1,
|