@magmamath/students-features 0.7.1 → 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/features/exampleSolution/components/ExampleSolutionModalContent.js +8 -0
- package/dist/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.js.map +1 -1
- package/dist/commonjs/features/exampleSolution/components/LavaIcon.js +44 -0
- package/dist/commonjs/features/exampleSolution/components/LavaIcon.js.map +1 -0
- package/dist/commonjs/features/exampleSolution/components/MessageBlock.js +61 -0
- package/dist/commonjs/features/exampleSolution/components/MessageBlock.js.map +1 -0
- 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/features/exampleSolution/components/ExampleSolutionModalContent.js +8 -0
- package/dist/module/features/exampleSolution/components/ExampleSolutionModalContent.js.map +1 -1
- package/dist/module/features/exampleSolution/components/LavaIcon.js +36 -0
- package/dist/module/features/exampleSolution/components/LavaIcon.js.map +1 -0
- package/dist/module/features/exampleSolution/components/MessageBlock.js +53 -0
- package/dist/module/features/exampleSolution/components/MessageBlock.js.map +1 -0
- 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/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/exampleSolution/components/LavaIcon.d.ts +10 -0
- package/dist/typescript/commonjs/features/exampleSolution/components/LavaIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/exampleSolution/components/MessageBlock.d.ts +10 -0
- package/dist/typescript/commonjs/features/exampleSolution/components/MessageBlock.d.ts.map +1 -0
- 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/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +1 -1
- package/dist/typescript/module/features/exampleSolution/components/LavaIcon.d.ts +10 -0
- package/dist/typescript/module/features/exampleSolution/components/LavaIcon.d.ts.map +1 -0
- package/dist/typescript/module/features/exampleSolution/components/MessageBlock.d.ts +10 -0
- package/dist/typescript/module/features/exampleSolution/components/MessageBlock.d.ts.map +1 -0
- 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/features/exampleSolution/components/ExampleSolutionModalContent.tsx +4 -0
- package/src/features/exampleSolution/components/LavaIcon.tsx +35 -0
- package/src/features/exampleSolution/components/MessageBlock.tsx +67 -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
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
attach,
|
|
3
|
+
combine,
|
|
4
|
+
createEffect,
|
|
5
|
+
createEvent,
|
|
6
|
+
createStore,
|
|
7
|
+
restore,
|
|
8
|
+
sample,
|
|
9
|
+
type Store,
|
|
10
|
+
} from 'effector'
|
|
11
|
+
import { IS_WEB } from '@magmamath/react-native-ui'
|
|
2
12
|
import {
|
|
3
13
|
ChatbotContext,
|
|
4
14
|
ChatbotModelProps,
|
|
5
15
|
IChatDrawBoardAdapter,
|
|
16
|
+
ReinitConversationProps,
|
|
6
17
|
SendHelpParams,
|
|
7
18
|
SendHelpProps,
|
|
8
19
|
SetHintMessageProps,
|
|
@@ -11,19 +22,17 @@ import {
|
|
|
11
22
|
} from '../types/model.types'
|
|
12
23
|
import { GetAlternativesResponse } from '../types/api.types'
|
|
13
24
|
import { ChatbotAPI } from './ChatbotApi'
|
|
14
|
-
import { ChatbotTranslation } from './
|
|
25
|
+
import { ChatbotTranslation } from './ChatbotTranslation'
|
|
15
26
|
import { ChatTextToSpeechModel, T2SConfig } from './t2s'
|
|
16
27
|
import { messagesHelper } from './messagesHelper'
|
|
17
28
|
import { ChatBotThreadManager } from './ChatBotThreadManager'
|
|
18
29
|
import { ChatsCacheModel, defaultChatData } from './ChatsCacheModel'
|
|
19
30
|
import { ErrorSpottingModel } from '../errorSpotting/ErrorSpottingModel'
|
|
31
|
+
import { ChatBotTextInput } from './ChatBotTextInput'
|
|
20
32
|
import { withEvent } from '../../../lib/effector/withEvent'
|
|
21
33
|
import { ChatBotTextManager } from './ChatBoxTextManager'
|
|
22
34
|
import { ControlledSample } from '../../../lib/effector/ControlledSample'
|
|
23
|
-
|
|
24
|
-
type ReinitConversationProps = {
|
|
25
|
-
key: string
|
|
26
|
-
}
|
|
35
|
+
import { transformAlternatives } from '../helpers'
|
|
27
36
|
|
|
28
37
|
export class ChatbotModel {
|
|
29
38
|
public readonly textManager = new ChatBotTextManager()
|
|
@@ -37,6 +46,7 @@ export class ChatbotModel {
|
|
|
37
46
|
public readonly translation: ChatbotTranslation
|
|
38
47
|
public readonly t2s: ChatTextToSpeechModel
|
|
39
48
|
public readonly errorSpotting: ErrorSpottingModel
|
|
49
|
+
public readonly textInput = new ChatBotTextInput()
|
|
40
50
|
|
|
41
51
|
private readonly setCurrentKey = createEvent<string>()
|
|
42
52
|
public readonly $currentKey = restore(this.setCurrentKey, '')
|
|
@@ -72,13 +82,14 @@ export class ChatbotModel {
|
|
|
72
82
|
constructor({ api, $key, threadMessagesLimit, settings = {} }: ChatbotModelProps) {
|
|
73
83
|
this.api = new ChatbotAPI({ ...api, postMessage: this.threadManager.postMessage })
|
|
74
84
|
|
|
75
|
-
this.threadManager.setApi({ getHint: api.requestHint })
|
|
85
|
+
this.threadManager.setApi({ getHint: api.requestHint, sendMessage: api.sendMessage })
|
|
76
86
|
if (threadMessagesLimit) {
|
|
77
87
|
this.threadManager.setMessagesLimit(threadMessagesLimit)
|
|
78
88
|
}
|
|
79
89
|
|
|
80
|
-
this.$alternatives =
|
|
81
|
-
.on(this.
|
|
90
|
+
this.$alternatives = createStore<GetAlternativesResponse | null>(null)
|
|
91
|
+
.on(this.api.getAlternativesFx.doneData, (_, payload) => transformAlternatives(payload))
|
|
92
|
+
.on(this.setAlternatives, (_, payload) => transformAlternatives(payload))
|
|
82
93
|
.reset(this.resetAlternatives)
|
|
83
94
|
|
|
84
95
|
this.t2s = new ChatTextToSpeechModel({ api: this.api })
|
|
@@ -120,6 +131,11 @@ export class ChatbotModel {
|
|
|
120
131
|
target: this.cache.update,
|
|
121
132
|
})
|
|
122
133
|
|
|
134
|
+
sample({
|
|
135
|
+
clock: this.resetAlternatives,
|
|
136
|
+
target: this.textInput.reset,
|
|
137
|
+
})
|
|
138
|
+
|
|
123
139
|
if (settings.closeOnKeyChange) {
|
|
124
140
|
sample({
|
|
125
141
|
clock: this.$currentKey.updates,
|
|
@@ -152,43 +168,70 @@ export class ChatbotModel {
|
|
|
152
168
|
},
|
|
153
169
|
),
|
|
154
170
|
})
|
|
171
|
+
|
|
172
|
+
this.api.getAlternativesFx.doneData.watch((alternatives) => {
|
|
173
|
+
// Use short text for another hint option if openChatEnabled
|
|
174
|
+
if (alternatives?.chatAccess && alternatives?.isOpenChatEnabled && IS_WEB) {
|
|
175
|
+
this.textManager.update((creator) => ({
|
|
176
|
+
anotherHintOption: creator.createOption('chat.giveHint'),
|
|
177
|
+
}))
|
|
178
|
+
}
|
|
179
|
+
})
|
|
155
180
|
}
|
|
156
181
|
|
|
157
182
|
private createSendHelpRequestFx() {
|
|
158
183
|
const effect = attach({
|
|
159
|
-
source: [this.$currentKey, this.$context],
|
|
160
|
-
mapParams: (params: SendHelpParams, [key, context]) => ({
|
|
184
|
+
source: [this.$currentKey, this.$context, this.cache.$data],
|
|
185
|
+
mapParams: (params: SendHelpParams, [key, context, cache]) => ({
|
|
161
186
|
message: params.message,
|
|
162
187
|
translatedMessage: params.translatedMessage,
|
|
188
|
+
isFreeText: params.isFreeText,
|
|
189
|
+
cache,
|
|
163
190
|
context,
|
|
164
191
|
key,
|
|
165
192
|
}),
|
|
166
|
-
effect: createEffect(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
193
|
+
effect: createEffect(
|
|
194
|
+
async ({ message, translatedMessage, key, context, isFreeText, cache }: SendHelpProps) => {
|
|
195
|
+
if (!context) throw new Error('Trying to send message in chat without context')
|
|
196
|
+
this.setLastMessageKey(key)
|
|
197
|
+
this.cache.addMessages(key, {
|
|
198
|
+
messages: [messagesHelper.createOwn({ message, translatedMessage })],
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
// Request is overridden by ThreadManager.postMessage (delegates to sendMessage/getHint)
|
|
202
|
+
const response = await this.api.postMessageFx({
|
|
203
|
+
answer: context.answer,
|
|
204
|
+
answerOptions: context.answerOptions,
|
|
205
|
+
problemDescription: context.problem,
|
|
206
|
+
problemAnswer: context.problemAnswer,
|
|
207
|
+
language: context.language,
|
|
208
|
+
imageAltText: context.imageDescription,
|
|
209
|
+
imageCdnId: context.imageCdnId,
|
|
210
|
+
conversationId: cache[key].conversationId,
|
|
211
|
+
...(isFreeText && { freeTextMessage: message }),
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
const thread = this.threadManager.get(key)
|
|
215
|
+
const messages = [
|
|
216
|
+
messagesHelper.createAnswer(response, { isInitial: thread?.history.length === 1 }),
|
|
217
|
+
]
|
|
218
|
+
|
|
219
|
+
if (response.endMessage) {
|
|
220
|
+
messages.push(messagesHelper.createLast(this.defaultMessages.endMessage))
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const translatedMessages = await this.translation.applyTranslationFx(messages)
|
|
224
|
+
|
|
225
|
+
this.cache.addMessages(key, {
|
|
226
|
+
messages: translatedMessages,
|
|
227
|
+
thread,
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
if (response.conversationId) {
|
|
231
|
+
this.cache.update({ key, data: { conversationId: response.conversationId } })
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
),
|
|
192
235
|
})
|
|
193
236
|
|
|
194
237
|
sample({
|
|
@@ -272,6 +315,7 @@ export class ChatbotModel {
|
|
|
272
315
|
this.api.postMessageFx.controller.abort()
|
|
273
316
|
this.removeLastMessage()
|
|
274
317
|
}
|
|
318
|
+
this.textInput.reset()
|
|
275
319
|
|
|
276
320
|
this.t2s.stop()
|
|
277
321
|
void this.t2s.reset()
|
|
@@ -284,6 +328,7 @@ export class ChatbotModel {
|
|
|
284
328
|
this.resetAlternatives()
|
|
285
329
|
this.threadManager.reset()
|
|
286
330
|
this.errorSpotting.reset()
|
|
331
|
+
this.textInput.reset()
|
|
287
332
|
})
|
|
288
333
|
|
|
289
334
|
public unbindKey() {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createEvent, restore } from 'effector'
|
|
2
|
+
|
|
3
|
+
export class ChatBotTextInput {
|
|
4
|
+
public readonly setValue = createEvent<string>()
|
|
5
|
+
public readonly setIsFocused = createEvent<boolean>()
|
|
6
|
+
public readonly reset = createEvent()
|
|
7
|
+
|
|
8
|
+
public readonly $value = restore(this.setValue, '').reset(this.reset)
|
|
9
|
+
public readonly $isFocused = restore(this.setIsFocused, false).reset(this.reset)
|
|
10
|
+
}
|
|
@@ -4,12 +4,16 @@ import {
|
|
|
4
4
|
ChatHintResponse,
|
|
5
5
|
PostMessagePayload,
|
|
6
6
|
PostMessageResponse,
|
|
7
|
+
SendMessagePayload,
|
|
8
|
+
SendMessageResponse,
|
|
7
9
|
} from '../types/api.types'
|
|
8
|
-
import { ChatbotMessages, IChatDrawBoardAdapter } from '../types/model.types'
|
|
10
|
+
import { ChatbotMessages, ChatRequestType, IChatDrawBoardAdapter } from '../types/model.types'
|
|
9
11
|
import { CHAT_BOT_MODEL_DEFAULTS } from './constants'
|
|
12
|
+
import { prepareChatRequestPayload } from '../helpers'
|
|
10
13
|
|
|
11
14
|
type ThreadManagerApi = {
|
|
12
15
|
getHint: (props: ChatHintPayload) => Promise<ChatHintResponse>
|
|
16
|
+
sendMessage: (props: SendMessagePayload) => Promise<SendMessageResponse>
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
type ChatBotThreadManagerProps = {
|
|
@@ -63,35 +67,28 @@ export class ChatBotThreadManager {
|
|
|
63
67
|
this.drawBoardAdapter = adapter
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
public readonly postMessage = async (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
answer,
|
|
70
|
-
language,
|
|
71
|
-
imageAltText,
|
|
72
|
-
imageCdnId,
|
|
73
|
-
}: PostMessagePayload): Promise<PostMessageResponse> => {
|
|
70
|
+
public readonly postMessage = async (
|
|
71
|
+
payload: PostMessagePayload,
|
|
72
|
+
): Promise<PostMessageResponse> => {
|
|
74
73
|
if (!this.api) {
|
|
75
74
|
throw new Error(
|
|
76
75
|
'API is not set in ThreadManagersApi, pls provide API before sending requests',
|
|
77
76
|
)
|
|
78
77
|
}
|
|
79
78
|
const threadItem = await this.getThreadItem()
|
|
79
|
+
const { type, data } = prepareChatRequestPayload(payload, threadItem)
|
|
80
80
|
|
|
81
|
-
const result
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
userAnswer: answer,
|
|
86
|
-
language,
|
|
87
|
-
imageAltText,
|
|
88
|
-
imageCdnId,
|
|
89
|
-
})
|
|
81
|
+
const result: SendMessageResponse | ChatHintResponse =
|
|
82
|
+
type === ChatRequestType.Freetext
|
|
83
|
+
? await this.api.sendMessage(data)
|
|
84
|
+
: await this.api.getHint(data)
|
|
90
85
|
|
|
91
86
|
threadItem.history.push(result.message)
|
|
92
|
-
|
|
87
|
+
|
|
88
|
+
if ('errorStrokeIds' in result && result?.errorStrokeIds) {
|
|
93
89
|
threadItem.setErrorStrokesIds(result.errorStrokeIds)
|
|
94
90
|
}
|
|
91
|
+
|
|
95
92
|
const nextOptions =
|
|
96
93
|
threadItem.history.length < this.messagesLimit ? [this.defaultMessages.anotherHintOption] : []
|
|
97
94
|
|
|
@@ -100,6 +97,7 @@ export class ChatBotThreadManager {
|
|
|
100
97
|
options: nextOptions,
|
|
101
98
|
endMessage: !nextOptions.length,
|
|
102
99
|
threadId: threadItem.id,
|
|
100
|
+
conversationId: result?.conversationId ?? null,
|
|
103
101
|
}
|
|
104
102
|
}
|
|
105
103
|
|
|
@@ -4,9 +4,11 @@ import {
|
|
|
4
4
|
ApplyTranslationProps,
|
|
5
5
|
TranslateBatchFxProps,
|
|
6
6
|
TranslateRequestProps,
|
|
7
|
+
TranslateSingleMessageFxParams,
|
|
7
8
|
} from '../types/translation.types'
|
|
8
9
|
import { ChatbotContext, ChatbotMessages } from '../types/model.types'
|
|
9
10
|
import { GetAlternativesResponse } from '../types/api.types'
|
|
11
|
+
import { ConversationMessage } from '../types/units.types'
|
|
10
12
|
import { decodeHTMLEntities } from '../helpers'
|
|
11
13
|
import { ChatbotAPI } from './ChatbotApi'
|
|
12
14
|
import {
|
|
@@ -14,9 +16,7 @@ import {
|
|
|
14
16
|
addTranslationToOptions,
|
|
15
17
|
getOptionsForTranslation,
|
|
16
18
|
} from './translation.helpers'
|
|
17
|
-
|
|
18
19
|
import { ChatsCacheModel } from './ChatsCacheModel'
|
|
19
|
-
import { ConversationMessage } from '../types/units.types'
|
|
20
20
|
|
|
21
21
|
type ChatbotTranslationProps = {
|
|
22
22
|
api: ChatbotAPI
|
|
@@ -41,6 +41,7 @@ export class ChatbotTranslation {
|
|
|
41
41
|
readonly $isTranslated = restore(this.setIsTranslated, false)
|
|
42
42
|
|
|
43
43
|
public readonly translateAllMessagesFx
|
|
44
|
+
public readonly translateSingleMessageFx
|
|
44
45
|
public readonly applyTranslationFx
|
|
45
46
|
|
|
46
47
|
constructor({
|
|
@@ -77,6 +78,35 @@ export class ChatbotTranslation {
|
|
|
77
78
|
effect: this.translateBatchFx,
|
|
78
79
|
})
|
|
79
80
|
|
|
81
|
+
this.translateSingleMessageFx = attach({
|
|
82
|
+
source: { context: this.$context, isTranslationActive: this.$isTranslated },
|
|
83
|
+
mapParams: (message: string, { context, isTranslationActive }) => ({
|
|
84
|
+
message,
|
|
85
|
+
targetLanguage: context?.translationTargetLanguage ?? null,
|
|
86
|
+
isTranslationActive,
|
|
87
|
+
}),
|
|
88
|
+
effect: createEffect(
|
|
89
|
+
async ({
|
|
90
|
+
message,
|
|
91
|
+
targetLanguage,
|
|
92
|
+
isTranslationActive,
|
|
93
|
+
}: TranslateSingleMessageFxParams) => {
|
|
94
|
+
if (!isTranslationActive || !targetLanguage || !message.trim().length) return message
|
|
95
|
+
|
|
96
|
+
const response = await this.api.translateTextFx({
|
|
97
|
+
text: [message],
|
|
98
|
+
targetLanguage,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
response.data.translations.map(({ translatedText }) =>
|
|
103
|
+
decodeHTMLEntities(translatedText),
|
|
104
|
+
)?.[0] ?? ''
|
|
105
|
+
)
|
|
106
|
+
},
|
|
107
|
+
),
|
|
108
|
+
})
|
|
109
|
+
|
|
80
110
|
sample({
|
|
81
111
|
clock: this.translateAllMessagesFx.doneData,
|
|
82
112
|
filter: (_, translatedMessages) => !!translatedMessages.length,
|
|
@@ -5,28 +5,52 @@ export type GetAlternativesPayload = {
|
|
|
5
5
|
assignmentClassGrade: number
|
|
6
6
|
} | null
|
|
7
7
|
|
|
8
|
+
export type AlternativesOptions = {
|
|
9
|
+
default: ChatAnswer[]
|
|
10
|
+
hints: ChatAnswer[]
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
export type GetAlternativesResponse = {
|
|
9
14
|
chatAccess?: boolean
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
isOpenChatEnabled?: boolean
|
|
16
|
+
version: string
|
|
17
|
+
options: AlternativesOptions
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type SendMessagePayload = {
|
|
21
|
+
problemDescription?: string
|
|
22
|
+
correctAnswer?: string | string[]
|
|
23
|
+
answerOptions?: string[]
|
|
24
|
+
altText?: string
|
|
25
|
+
language?: string
|
|
26
|
+
message: string
|
|
27
|
+
conversationId?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type SendMessageResponse = {
|
|
31
|
+
message: string
|
|
32
|
+
conversationId?: string | null
|
|
14
33
|
}
|
|
15
34
|
|
|
16
35
|
export type PostMessagePayload = {
|
|
17
36
|
language: string
|
|
18
37
|
problemAnswer: string[]
|
|
38
|
+
problemDescription: string
|
|
19
39
|
answer?: string | string[]
|
|
20
|
-
|
|
40
|
+
answerOptions?: string[]
|
|
21
41
|
imageAltText?: string
|
|
22
42
|
imageCdnId?: string
|
|
43
|
+
freeTextMessage?: string
|
|
44
|
+
conversationId?: string | null
|
|
23
45
|
}
|
|
24
46
|
|
|
25
47
|
export type PostMessageResponse = {
|
|
26
48
|
message: string
|
|
27
49
|
options: ChatAnswer[]
|
|
28
|
-
endMessage?: boolean
|
|
29
50
|
threadId: string
|
|
51
|
+
endMessage?: boolean
|
|
52
|
+
conversationId?: string | null
|
|
53
|
+
errorStrokeIds?: string[]
|
|
30
54
|
}
|
|
31
55
|
|
|
32
56
|
export type GoogleTranslatePayload = {
|
|
@@ -71,6 +95,7 @@ export type ChatHintPayload = {
|
|
|
71
95
|
|
|
72
96
|
export type ChatHintResponse = {
|
|
73
97
|
message: string
|
|
98
|
+
conversationId?: string | null
|
|
74
99
|
errorStrokeIds?: string[]
|
|
75
100
|
}
|
|
76
101
|
export type ErrorSpottingPayload = {
|
|
@@ -12,9 +12,11 @@ import {
|
|
|
12
12
|
GoogleTranslateResponse,
|
|
13
13
|
PostMessagePayload,
|
|
14
14
|
PostMessageResponse,
|
|
15
|
+
SendMessagePayload,
|
|
16
|
+
SendMessageResponse,
|
|
15
17
|
} from './api.types'
|
|
16
18
|
import { ExtendWithOptional } from '../../../lib/helpers/types'
|
|
17
|
-
import { ChatAnswer, ConversationMessage, FullStrokeData } from './units.types'
|
|
19
|
+
import { ChatAnswer, ChatItem, ConversationMessage, FullStrokeData } from './units.types'
|
|
18
20
|
|
|
19
21
|
export type ChatbotMessages = {
|
|
20
22
|
error: ConversationMessage
|
|
@@ -25,6 +27,7 @@ export type ChatbotMessages = {
|
|
|
25
27
|
|
|
26
28
|
export type ChatbotApiRequests = {
|
|
27
29
|
getAlternatives: (props: GetAlternativesPayload) => Promise<GetAlternativesResponse>
|
|
30
|
+
sendMessage: (props: SendMessagePayload) => Promise<SendMessageResponse>
|
|
28
31
|
postMessage: (props: PostMessagePayload) => Promise<PostMessageResponse>
|
|
29
32
|
postTranslateText: (props: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>
|
|
30
33
|
postTextToSpeech: (props: GoogleText2SpeechPayload) => Promise<GoogleText2SpeechResponse>
|
|
@@ -50,11 +53,14 @@ export type ChatbotModelProps = {
|
|
|
50
53
|
export type SendHelpParams = {
|
|
51
54
|
message: string
|
|
52
55
|
translatedMessage?: string
|
|
56
|
+
isFreeText?: boolean
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
export type SendHelpProps = SendHelpParams & {
|
|
56
60
|
key: string
|
|
57
61
|
context: ChatbotContext | null
|
|
62
|
+
cache: Record<string, ChatItem>
|
|
63
|
+
isFreeText?: boolean
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
export type SetHintMessageProps = {
|
|
@@ -108,7 +114,34 @@ export type ChatbotContext = {
|
|
|
108
114
|
problem: string
|
|
109
115
|
problemAnswer: string[]
|
|
110
116
|
answer?: string | string[]
|
|
117
|
+
answerOptions?: string[]
|
|
111
118
|
translationTargetLanguage: string
|
|
112
119
|
imageDescription?: string
|
|
113
|
-
|
|
120
|
+
imageCdnId?: string
|
|
114
121
|
}
|
|
122
|
+
|
|
123
|
+
export type ReinitConversationProps = {
|
|
124
|
+
key: string
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export enum ChatRequestType {
|
|
128
|
+
Freetext = 'sendMessage',
|
|
129
|
+
Hint = 'getHint',
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
type FreeTextWithConversationId = {
|
|
133
|
+
type: ChatRequestType.Freetext
|
|
134
|
+
data: Pick<SendMessagePayload, 'message' | 'conversationId'>
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type FreeTextNewConversation = {
|
|
138
|
+
type: ChatRequestType.Freetext
|
|
139
|
+
data: SendMessagePayload
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export type HintRequest = {
|
|
143
|
+
type: ChatRequestType.Hint
|
|
144
|
+
data: ChatHintPayload
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export type ChatRequestPayload = FreeTextWithConversationId | FreeTextNewConversation | HintRequest
|
|
@@ -34,3 +34,9 @@ export type TranslateRequestProps<List extends Record<string, string[]>> = {
|
|
|
34
34
|
textList: List
|
|
35
35
|
targetLanguage: string
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
export type TranslateSingleMessageFxParams = {
|
|
39
|
+
message: string
|
|
40
|
+
targetLanguage: string | null
|
|
41
|
+
isTranslationActive: boolean
|
|
42
|
+
}
|
|
@@ -3,6 +3,8 @@ import React from 'react'
|
|
|
3
3
|
import { COLORS, HeadingVariants, IS_WEB, SPACING, Typography } from '@magmamath/react-native-ui'
|
|
4
4
|
import { useUnit } from 'effector-react'
|
|
5
5
|
import { $localization } from '../../../shared/translation'
|
|
6
|
+
import { MessageBlock } from './MessageBlock'
|
|
7
|
+
import { LavaIcon } from './LavaIcon'
|
|
6
8
|
import { ExampleSolutionModalParams } from '../types'
|
|
7
9
|
import { QuestionSection } from './QuestionSection'
|
|
8
10
|
import { SolutionSection } from './SolutionSection'
|
|
@@ -38,6 +40,8 @@ export const ExampleSolutionModalContent = ({
|
|
|
38
40
|
/>
|
|
39
41
|
<SolutionSection status={status} answer={result?.answer} />
|
|
40
42
|
</View>
|
|
43
|
+
<MessageBlock status={status} style={styles.messageBlock} />
|
|
44
|
+
<LavaIcon status={status} style={styles.lavaIconContainer} />
|
|
41
45
|
</View>
|
|
42
46
|
)
|
|
43
47
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ExcitedLavaIcon } from '../../../shared/icons/ExcitedLavaIcon'
|
|
3
|
+
import { LavaIconInGlasses } from '../../../shared/icons'
|
|
4
|
+
import Animated, { FadeIn, useAnimatedStyle, withTiming } from 'react-native-reanimated'
|
|
5
|
+
import { StyleProp, ViewStyle } from 'react-native'
|
|
6
|
+
import { ExampleSolutionStatuses } from '../constants'
|
|
7
|
+
|
|
8
|
+
const LAVA_ICON_HEIGHT = 112
|
|
9
|
+
|
|
10
|
+
type LavaIconProps = {
|
|
11
|
+
status: ExampleSolutionStatuses
|
|
12
|
+
style?: StyleProp<ViewStyle>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const LavaIcon = ({ status, style }: LavaIconProps) => {
|
|
16
|
+
const opacityAnimation = useAnimatedStyle(() => {
|
|
17
|
+
return {
|
|
18
|
+
opacity: withTiming(status === ExampleSolutionStatuses.LOADING ? 1 : 0, { duration: 500 }),
|
|
19
|
+
}
|
|
20
|
+
}, [status])
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<Animated.View style={[style, opacityAnimation]}>
|
|
25
|
+
<LavaIconInGlasses height={112} />
|
|
26
|
+
</Animated.View>
|
|
27
|
+
|
|
28
|
+
{status !== ExampleSolutionStatuses.LOADING && (
|
|
29
|
+
<Animated.View style={style} entering={FadeIn}>
|
|
30
|
+
<ExcitedLavaIcon height={LAVA_ICON_HEIGHT} />
|
|
31
|
+
</Animated.View>
|
|
32
|
+
)}
|
|
33
|
+
</>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { StyleProp, StyleSheet, ViewStyle } from 'react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { COLORS, SPACING, Typography } from '@magmamath/react-native-ui'
|
|
4
|
+
import { useUnit } from 'effector-react'
|
|
5
|
+
import { $localization } from '../../../shared/translation'
|
|
6
|
+
import Animated, {
|
|
7
|
+
LinearTransition,
|
|
8
|
+
useAnimatedStyle,
|
|
9
|
+
withDelay,
|
|
10
|
+
withTiming,
|
|
11
|
+
} from 'react-native-reanimated'
|
|
12
|
+
import { ExampleSolutionStatuses } from '../constants'
|
|
13
|
+
|
|
14
|
+
type MessageBlockProps = {
|
|
15
|
+
status: ExampleSolutionStatuses
|
|
16
|
+
style?: StyleProp<ViewStyle>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const MessageBlock = ({ status, style }: MessageBlockProps) => {
|
|
20
|
+
const localization = useUnit($localization)
|
|
21
|
+
|
|
22
|
+
const opacityAnimation = useAnimatedStyle(() => {
|
|
23
|
+
return {
|
|
24
|
+
opacity: withDelay(
|
|
25
|
+
2000,
|
|
26
|
+
withTiming(status === ExampleSolutionStatuses.LOADING ? 1 : 0, { duration: 350 }),
|
|
27
|
+
),
|
|
28
|
+
}
|
|
29
|
+
}, [status])
|
|
30
|
+
|
|
31
|
+
if (status === ExampleSolutionStatuses.CACHE) return null
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Animated.View
|
|
35
|
+
layout={LinearTransition.duration(250)}
|
|
36
|
+
style={[styles.container, opacityAnimation, style]}
|
|
37
|
+
>
|
|
38
|
+
<Typography variant={'small'} numberOfLines={1}>
|
|
39
|
+
{status === ExampleSolutionStatuses.LOADING
|
|
40
|
+
? localization.exampleSolution.letMeThink
|
|
41
|
+
: localization.exampleSolution.aha}
|
|
42
|
+
</Typography>
|
|
43
|
+
</Animated.View>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const styles = StyleSheet.create({
|
|
48
|
+
container: {
|
|
49
|
+
padding: SPACING[200],
|
|
50
|
+
backgroundColor: COLORS.NEUTRAL_3,
|
|
51
|
+
height: 44,
|
|
52
|
+
borderRadius: 12,
|
|
53
|
+
borderBottomRightRadius: 2,
|
|
54
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
55
|
+
borderColor: COLORS.NEUTRAL_5,
|
|
56
|
+
|
|
57
|
+
shadowColor: COLORS.NEUTRAL_10,
|
|
58
|
+
shadowOffset: {
|
|
59
|
+
width: 0,
|
|
60
|
+
height: 1,
|
|
61
|
+
},
|
|
62
|
+
shadowOpacity: 0.2,
|
|
63
|
+
shadowRadius: 1,
|
|
64
|
+
|
|
65
|
+
elevation: 3,
|
|
66
|
+
},
|
|
67
|
+
})
|
|
@@ -4,12 +4,14 @@ import { KeyboardKeys } from '../../lib/constants'
|
|
|
4
4
|
|
|
5
5
|
export const useKeyDownListener = (
|
|
6
6
|
callback: (event: KeyboardEvent) => void,
|
|
7
|
+
enabled = true,
|
|
7
8
|
overrideKeys = [KeyboardKeys.ENTER],
|
|
8
9
|
) => {
|
|
9
10
|
const callbackRef = useRef(callback)
|
|
10
11
|
callbackRef.current = callback
|
|
11
12
|
|
|
12
13
|
useEffect(() => {
|
|
14
|
+
if (!enabled) return
|
|
13
15
|
const eventHandler = (event: KeyboardEvent) => {
|
|
14
16
|
if (overrideKeys.includes(event.key as KeyboardKeys)) {
|
|
15
17
|
event.preventDefault()
|
|
@@ -23,5 +25,5 @@ export const useKeyDownListener = (
|
|
|
23
25
|
return () => {
|
|
24
26
|
document.removeEventListener('keydown', eventHandler, true)
|
|
25
27
|
}
|
|
26
|
-
}, [])
|
|
28
|
+
}, [enabled])
|
|
27
29
|
}
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
"time.yearsAgo": "years ago",
|
|
14
14
|
"chat": {
|
|
15
15
|
"anotherHint": "Give me another hint",
|
|
16
|
-
"giveHint": "
|
|
16
|
+
"giveHint": "I need a hint",
|
|
17
17
|
"answerAgain": "Answer again to get another hint!",
|
|
18
18
|
"errorMessage": "Something went wrong! Try again",
|
|
19
19
|
"howCanIHelp": "Hi! Do you want help?",
|
|
20
|
-
"showError": "Show error"
|
|
20
|
+
"showError": "Show error",
|
|
21
|
+
"inputPlaceholder": "Type..."
|
|
21
22
|
},
|
|
22
23
|
"gifCelebrations": {
|
|
23
24
|
"greatStart": "Great start!",
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
"time.yearsAgo": "years ago",
|
|
14
14
|
"chat": {
|
|
15
15
|
"anotherHint": "Give me another hint",
|
|
16
|
-
"giveHint": "
|
|
16
|
+
"giveHint": "I need a hint",
|
|
17
17
|
"answerAgain": "Answer again to get another hint!",
|
|
18
18
|
"errorMessage": "Something went wrong! Try again",
|
|
19
19
|
"howCanIHelp": "Hi! Do you want help?",
|
|
20
|
-
"showError": "Show error"
|
|
20
|
+
"showError": "Show error",
|
|
21
|
+
"inputPlaceholder": "Type..."
|
|
21
22
|
},
|
|
22
23
|
"gifCelebrations": {
|
|
23
24
|
"greatStart": "Great start!",
|