@magmamath/students-features 0.6.14-rc.9 → 0.6.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js +59 -0
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js +99 -0
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js +4 -7
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/{Chat/Chat.js → ChatMessages/ChatbotMessages.js} +9 -12
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/Chatbot.js +3 -5
- package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/commonjs/features/chatbot/constants.js +1 -6
- package/dist/commonjs/features/chatbot/constants.js.map +1 -1
- package/dist/commonjs/features/chatbot/index.js +0 -7
- package/dist/commonjs/features/chatbot/index.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js +3 -37
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js +10 -31
- package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatbotApi.js +0 -3
- package/dist/commonjs/features/chatbot/model/ChatbotApi.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/units.types.js +0 -10
- package/dist/commonjs/features/chatbot/types/units.types.js.map +1 -1
- package/dist/commonjs/features/exampleSolution/ExampleSolutionModal.js +1 -3
- package/dist/commonjs/features/exampleSolution/ExampleSolutionModal.js.map +1 -1
- package/dist/commonjs/features/exampleSolution/assets/grid.webp +0 -0
- package/dist/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.js +12 -9
- package/dist/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.js.map +1 -1
- package/dist/commonjs/features/exampleSolution/components/QuestionSection.js +7 -7
- package/dist/commonjs/features/exampleSolution/components/QuestionSection.js.map +1 -1
- package/dist/commonjs/features/exampleSolution/components/SolutionSection.js +55 -29
- package/dist/commonjs/features/exampleSolution/components/SolutionSection.js.map +1 -1
- package/dist/commonjs/features/exampleSolution/model/ExampleSolution.model.js +3 -1
- package/dist/commonjs/features/exampleSolution/model/ExampleSolution.model.js.map +1 -1
- package/dist/commonjs/features/formulaSheet/components/FormulaSheet.js +6 -4
- package/dist/commonjs/features/formulaSheet/components/FormulaSheet.js.map +1 -1
- package/dist/commonjs/shared/translation/localization/ca.json +1 -1
- package/dist/commonjs/shared/translation/localization/en.json +1 -1
- package/dist/commonjs/shared/translation/localization/gb.json +1 -1
- package/dist/commonjs/shared/translation/localization/sct.json +2 -2
- package/dist/commonjs/shared/translation/localization/sw.json +3 -3
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js +53 -0
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js.map +1 -0
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js +92 -0
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js +4 -7
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -1
- package/dist/module/features/chatbot/components/{Chat/Chat.js → ChatMessages/ChatbotMessages.js} +7 -10
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -0
- package/dist/module/features/chatbot/components/Chatbot.js +3 -5
- package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/module/features/chatbot/constants.js +0 -5
- package/dist/module/features/chatbot/constants.js.map +1 -1
- package/dist/module/features/chatbot/index.js +0 -1
- package/dist/module/features/chatbot/index.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBotModel.js +3 -37
- package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBotThreadManager.js +10 -31
- package/dist/module/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatbotApi.js +0 -3
- package/dist/module/features/chatbot/model/ChatbotApi.js.map +1 -1
- package/dist/module/features/chatbot/types/model.types.js.map +1 -1
- package/dist/module/features/chatbot/types/units.types.js +0 -6
- package/dist/module/features/chatbot/types/units.types.js.map +1 -1
- package/dist/module/features/exampleSolution/ExampleSolutionModal.js +1 -3
- package/dist/module/features/exampleSolution/ExampleSolutionModal.js.map +1 -1
- package/dist/module/features/exampleSolution/assets/grid.webp +0 -0
- package/dist/module/features/exampleSolution/components/ExampleSolutionModalContent.js +12 -9
- package/dist/module/features/exampleSolution/components/ExampleSolutionModalContent.js.map +1 -1
- package/dist/module/features/exampleSolution/components/QuestionSection.js +9 -9
- package/dist/module/features/exampleSolution/components/QuestionSection.js.map +1 -1
- package/dist/module/features/exampleSolution/components/SolutionSection.js +57 -31
- package/dist/module/features/exampleSolution/components/SolutionSection.js.map +1 -1
- package/dist/module/features/exampleSolution/model/ExampleSolution.model.js +3 -1
- package/dist/module/features/exampleSolution/model/ExampleSolution.model.js.map +1 -1
- package/dist/module/features/formulaSheet/components/FormulaSheet.js +6 -4
- package/dist/module/features/formulaSheet/components/FormulaSheet.js.map +1 -1
- package/dist/module/shared/translation/localization/ca.json +1 -1
- package/dist/module/shared/translation/localization/en.json +1 -1
- package/dist/module/shared/translation/localization/gb.json +1 -1
- package/dist/module/shared/translation/localization/sct.json +2 -2
- package/dist/module/shared/translation/localization/sw.json +3 -3
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts +11 -0
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts +10 -0
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -1
- package/dist/typescript/{module/features/chatbot/components/Chat/Chat.d.ts → commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts} +2 -4
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts +0 -2
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts +0 -5
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/index.d.ts +0 -1
- package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +1 -5
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts +2 -5
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatbotApi.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +4 -21
- 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 +1 -10
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts +0 -18
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/exampleSolution/ExampleSolutionModal.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.d.ts +5 -1
- package/dist/typescript/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/exampleSolution/components/QuestionSection.d.ts +2 -1
- package/dist/typescript/commonjs/features/exampleSolution/components/QuestionSection.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/exampleSolution/components/SolutionSection.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolution.model.d.ts +3 -2
- package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolution.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/exampleSolution/types.d.ts +2 -1
- package/dist/typescript/commonjs/features/exampleSolution/types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/formulaSheet/components/FormulaSheet.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts +11 -0
- package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts +10 -0
- package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -1
- package/dist/typescript/{commonjs/features/chatbot/components/Chat/Chat.d.ts → module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts} +2 -4
- package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts +0 -2
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/constants.d.ts +0 -5
- package/dist/typescript/module/features/chatbot/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/index.d.ts +0 -1
- package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +1 -5
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts +2 -5
- package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatbotApi.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts +4 -21
- 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 +1 -10
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts +0 -18
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts.map +1 -1
- package/dist/typescript/module/features/exampleSolution/ExampleSolutionModal.d.ts.map +1 -1
- package/dist/typescript/module/features/exampleSolution/components/ExampleSolutionModalContent.d.ts +5 -1
- package/dist/typescript/module/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +1 -1
- package/dist/typescript/module/features/exampleSolution/components/QuestionSection.d.ts +2 -1
- package/dist/typescript/module/features/exampleSolution/components/QuestionSection.d.ts.map +1 -1
- package/dist/typescript/module/features/exampleSolution/components/SolutionSection.d.ts.map +1 -1
- package/dist/typescript/module/features/exampleSolution/model/ExampleSolution.model.d.ts +3 -2
- package/dist/typescript/module/features/exampleSolution/model/ExampleSolution.model.d.ts.map +1 -1
- package/dist/typescript/module/features/exampleSolution/types.d.ts +2 -1
- package/dist/typescript/module/features/exampleSolution/types.d.ts.map +1 -1
- package/dist/typescript/module/features/formulaSheet/components/FormulaSheet.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/chatbot/components/Alternatives/Alternatives.tsx +60 -0
- package/src/features/chatbot/components/Alternatives/HelpRequestOption.tsx +91 -0
- package/src/features/chatbot/components/ChatMessage/MessageLoader.tsx +2 -6
- package/src/features/chatbot/components/{Chat/Chat.tsx → ChatMessages/ChatbotMessages.tsx} +6 -10
- package/src/features/chatbot/components/Chatbot.tsx +2 -6
- package/src/features/chatbot/constants.ts +0 -7
- package/src/features/chatbot/index.ts +0 -2
- package/src/features/chatbot/model/ChatBotModel.ts +27 -71
- package/src/features/chatbot/model/ChatBotThreadManager.ts +9 -38
- package/src/features/chatbot/model/ChatbotApi.ts +0 -2
- package/src/features/chatbot/types/api.types.ts +4 -24
- package/src/features/chatbot/types/model.types.ts +0 -15
- package/src/features/chatbot/types/units.types.ts +0 -22
- package/src/features/exampleSolution/ExampleSolutionModal.tsx +1 -7
- package/src/features/exampleSolution/assets/grid.webp +0 -0
- package/src/features/exampleSolution/components/ExampleSolutionModalContent.tsx +16 -10
- package/src/features/exampleSolution/components/QuestionSection.tsx +11 -7
- package/src/features/exampleSolution/components/SolutionSection.tsx +72 -29
- package/src/features/exampleSolution/model/ExampleSolution.model.ts +5 -2
- package/src/features/exampleSolution/types.ts +2 -1
- package/src/features/formulaSheet/components/FormulaSheet.tsx +7 -4
- package/src/shared/translation/localization/ca.json +1 -1
- package/src/shared/translation/localization/en.json +1 -1
- package/src/shared/translation/localization/gb.json +1 -1
- package/src/shared/translation/localization/sct.json +2 -2
- package/src/shared/translation/localization/sw.json +3 -3
- package/dist/commonjs/features/chatbot/components/Chat/Chat.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/ChatInput.js +0 -53
- package/dist/commonjs/features/chatbot/components/ChatInput/ChatInput.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/InputOption.js +0 -39
- package/dist/commonjs/features/chatbot/components/ChatInput/InputOption.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/InputOptionWithTextArea.js +0 -38
- package/dist/commonjs/features/chatbot/components/ChatInput/InputOptionWithTextArea.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js +0 -140
- package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.js +0 -142
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js +0 -44
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.js +0 -105
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.js.map +0 -1
- package/dist/commonjs/features/exampleSolution/assets/grid.png +0 -0
- package/dist/module/features/chatbot/components/Chat/Chat.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatInput/ChatInput.js +0 -47
- package/dist/module/features/chatbot/components/ChatInput/ChatInput.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatInput/InputOption.js +0 -34
- package/dist/module/features/chatbot/components/ChatInput/InputOption.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatInput/InputOptionWithTextArea.js +0 -32
- package/dist/module/features/chatbot/components/ChatInput/InputOptionWithTextArea.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js +0 -132
- package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.js +0 -134
- package/dist/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js +0 -38
- package/dist/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.js +0 -97
- package/dist/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.js.map +0 -1
- package/dist/module/features/exampleSolution/assets/grid.png +0 -0
- package/dist/typescript/commonjs/features/chatbot/components/Chat/Chat.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/ChatInput.d.ts +0 -4
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/ChatInput.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/InputOption.d.ts +0 -4
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/InputOption.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/InputOptionWithTextArea.d.ts +0 -4
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/InputOptionWithTextArea.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/RequestHintButton.d.ts +0 -18
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts +0 -10
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts +0 -11
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts +0 -10
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/Chat/Chat.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatInput/ChatInput.d.ts +0 -4
- package/dist/typescript/module/features/chatbot/components/ChatInput/ChatInput.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatInput/InputOption.d.ts +0 -4
- package/dist/typescript/module/features/chatbot/components/ChatInput/InputOption.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatInput/InputOptionWithTextArea.d.ts +0 -4
- package/dist/typescript/module/features/chatbot/components/ChatInput/InputOptionWithTextArea.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatInput/RequestHintButton.d.ts +0 -18
- package/dist/typescript/module/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts +0 -10
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts +0 -11
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts +0 -10
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts.map +0 -1
- package/src/features/chatbot/components/ChatInput/ChatInput.tsx +0 -56
- package/src/features/chatbot/components/ChatInput/InputOption.tsx +0 -29
- package/src/features/chatbot/components/ChatInput/InputOptionWithTextArea.tsx +0 -27
- package/src/features/chatbot/components/ChatInput/RequestHintButton.tsx +0 -160
- package/src/features/chatbot/components/ChatInput/freeText/ChatTextInput.tsx +0 -133
- package/src/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.tsx +0 -42
- package/src/features/chatbot/components/ChatInput/freeText/SendMessageButton.tsx +0 -110
- package/src/features/exampleSolution/assets/grid.png +0 -0
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
IChatDrawBoardAdapter,
|
|
6
6
|
SendHelpParams,
|
|
7
7
|
SendHelpProps,
|
|
8
|
-
SendMessageProps,
|
|
9
8
|
SetHintMessageProps,
|
|
10
9
|
StartConversationFxData,
|
|
11
10
|
StartConversationProps,
|
|
@@ -21,9 +20,6 @@ import { ErrorSpottingModel } from '../errorSpotting/ErrorSpottingModel'
|
|
|
21
20
|
import { withEvent } from '../../../lib/effector/withEvent'
|
|
22
21
|
import { ChatBotTextManager } from './ChatBoxTextManager'
|
|
23
22
|
import { ControlledSample } from '../../../lib/effector/ControlledSample'
|
|
24
|
-
import { DefaultMessagesCreator } from './DefaultMessageCreator'
|
|
25
|
-
import { t } from '../../../shared/translation'
|
|
26
|
-
import { IS_WEB } from '@magmamath/react-native-ui'
|
|
27
23
|
|
|
28
24
|
type ReinitConversationProps = {
|
|
29
25
|
key: string
|
|
@@ -50,19 +46,12 @@ export class ChatbotModel {
|
|
|
50
46
|
|
|
51
47
|
readonly resetAlternatives = createEvent()
|
|
52
48
|
readonly setAlternatives = createEvent<GetAlternativesResponse | null>()
|
|
53
|
-
readonly $alternatives
|
|
49
|
+
readonly $alternatives: Store<GetAlternativesResponse | null>
|
|
54
50
|
|
|
55
51
|
readonly setIsOpen = createEvent<boolean>()
|
|
56
52
|
readonly toggleOpen = createEvent()
|
|
57
53
|
readonly $isOpen = restore(this.setIsOpen, false).on(this.toggleOpen, (isOpen) => !isOpen)
|
|
58
54
|
|
|
59
|
-
readonly setIsTextInputFocused = createEvent<boolean>()
|
|
60
|
-
readonly $isTextInputFocused = restore(this.setIsTextInputFocused, false).reset(
|
|
61
|
-
this.resetAlternatives,
|
|
62
|
-
)
|
|
63
|
-
readonly setTextInputValue = createEvent<string>()
|
|
64
|
-
readonly $textInputValue = restore(this.setTextInputValue, '').reset(this.resetAlternatives)
|
|
65
|
-
|
|
66
55
|
public readonly removeLastMessage = createEvent()
|
|
67
56
|
private readonly setLastMessageKey = createEvent<string>()
|
|
68
57
|
public readonly $lastMessageKey = restore(this.setLastMessageKey, null)
|
|
@@ -83,7 +72,7 @@ export class ChatbotModel {
|
|
|
83
72
|
constructor({ api, $key, threadMessagesLimit, settings = {} }: ChatbotModelProps) {
|
|
84
73
|
this.api = new ChatbotAPI({ ...api, postMessage: this.threadManager.postMessage })
|
|
85
74
|
|
|
86
|
-
this.threadManager.setApi({ getHint: api.requestHint
|
|
75
|
+
this.threadManager.setApi({ getHint: api.requestHint })
|
|
87
76
|
if (threadMessagesLimit) {
|
|
88
77
|
this.threadManager.setMessagesLimit(threadMessagesLimit)
|
|
89
78
|
}
|
|
@@ -119,29 +108,6 @@ export class ChatbotModel {
|
|
|
119
108
|
target: [this.t2s.reset, this.errorSpotting.spottingHidden],
|
|
120
109
|
})
|
|
121
110
|
|
|
122
|
-
// sample({
|
|
123
|
-
// source: { alternatives: this.$alternatives },
|
|
124
|
-
// // filter: ({ alternatives }) => !!alternatives && alternatives.isOpenChatEnabled && IS_WEB,
|
|
125
|
-
// target: createEffect(() => {
|
|
126
|
-
// this.textManager.update((creator) => ({
|
|
127
|
-
// anotherHintOption: creator.createMessagÏe(t('chat.giveHint')),
|
|
128
|
-
// }))
|
|
129
|
-
// }),
|
|
130
|
-
// })
|
|
131
|
-
|
|
132
|
-
// // Update default "another hint" option from alternatives when they arrive
|
|
133
|
-
// this.$alternatives.updates.watch((alternatives) => {
|
|
134
|
-
// const dynamicOption = alternatives?.options?.default?.[0]
|
|
135
|
-
// if (dynamicOption) {
|
|
136
|
-
// this.textManager.update(() => ({ anotherHintOption: dynamicOption }))
|
|
137
|
-
// }
|
|
138
|
-
// })
|
|
139
|
-
//
|
|
140
|
-
// // Restore default texts when alternatives are reset
|
|
141
|
-
// this.resetAlternatives.watch(() => {
|
|
142
|
-
// this.textManager.restore()
|
|
143
|
-
// })
|
|
144
|
-
|
|
145
111
|
sample({
|
|
146
112
|
clock: this.removeLastMessage,
|
|
147
113
|
source: [this.$lastMessageKey, this.cache.$data] as const,
|
|
@@ -196,42 +162,34 @@ export class ChatbotModel {
|
|
|
196
162
|
mapParams: (params: SendHelpParams, [key, context]) => ({
|
|
197
163
|
message: params.message,
|
|
198
164
|
translatedMessage: params.translatedMessage,
|
|
199
|
-
isFreeText: params.isFreeText,
|
|
200
165
|
context,
|
|
201
166
|
key,
|
|
202
167
|
}),
|
|
203
|
-
effect: createEffect(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.cache.addMessages(key, {
|
|
230
|
-
messages: translatedMessages,
|
|
231
|
-
thread,
|
|
232
|
-
})
|
|
233
|
-
},
|
|
234
|
-
),
|
|
168
|
+
effect: createEffect(async ({ message, translatedMessage, key, context }: SendHelpProps) => {
|
|
169
|
+
if (!context) throw new Error('Trying to send message in chat without context')
|
|
170
|
+
this.setLastMessageKey(key)
|
|
171
|
+
this.cache.addMessages(key, {
|
|
172
|
+
messages: [messagesHelper.createOwn({ message, translatedMessage })],
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
const response = await this.api.postMessageFx({
|
|
176
|
+
problem: context.problem,
|
|
177
|
+
language: context.language,
|
|
178
|
+
problemAnswer: context.problemAnswer,
|
|
179
|
+
answer: context.answer,
|
|
180
|
+
imageAltText: context.imageDescription,
|
|
181
|
+
})
|
|
182
|
+
const thread = this.threadManager.get(key)
|
|
183
|
+
const messages = [
|
|
184
|
+
messagesHelper.createAnswer(response, { isInitial: thread?.history.length === 1 }),
|
|
185
|
+
]
|
|
186
|
+
if (response.endMessage) {
|
|
187
|
+
messages.push(messagesHelper.createLast(this.defaultMessages.endMessage))
|
|
188
|
+
}
|
|
189
|
+
const translatedMessages = await this.translation.applyTranslationFx(messages)
|
|
190
|
+
|
|
191
|
+
this.cache.addMessages(key, { messages: translatedMessages, thread })
|
|
192
|
+
}),
|
|
235
193
|
})
|
|
236
194
|
|
|
237
195
|
sample({
|
|
@@ -315,8 +273,6 @@ export class ChatbotModel {
|
|
|
315
273
|
this.api.postMessageFx.controller.abort()
|
|
316
274
|
this.removeLastMessage()
|
|
317
275
|
}
|
|
318
|
-
this.setIsTextInputFocused(false)
|
|
319
|
-
this.setTextInputValue('')
|
|
320
276
|
this.errorSpotting.abortPendingRequest()
|
|
321
277
|
|
|
322
278
|
this.t2s.stop()
|
|
@@ -4,18 +4,12 @@ import {
|
|
|
4
4
|
ChatHintResponse,
|
|
5
5
|
PostMessagePayload,
|
|
6
6
|
PostMessageResponse,
|
|
7
|
-
SendMessagePayload,
|
|
8
|
-
SendMessageResponse,
|
|
9
7
|
} from '../types/api.types'
|
|
10
|
-
import {
|
|
11
|
-
ChatbotMessages,
|
|
12
|
-
IChatDrawBoardAdapter,
|
|
13
|
-
} from '../types/model.types'
|
|
8
|
+
import { ChatbotMessages, IChatDrawBoardAdapter } from '../types/model.types'
|
|
14
9
|
import { CHAT_BOT_MODEL_DEFAULTS } from './constants'
|
|
15
10
|
|
|
16
11
|
type ThreadManagerApi = {
|
|
17
12
|
getHint: (props: ChatHintPayload) => Promise<ChatHintResponse>
|
|
18
|
-
sendMessage: (props: SendMessagePayload) => Promise<SendMessageResponse>
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
type ChatBotThreadManagerProps = {
|
|
@@ -32,7 +26,6 @@ export class ChatBotThreadManager {
|
|
|
32
26
|
|
|
33
27
|
private messagesLimit
|
|
34
28
|
private currentKey = ''
|
|
35
|
-
private currentConversationId: null | string = null
|
|
36
29
|
|
|
37
30
|
private readonly defaultMessages
|
|
38
31
|
|
|
@@ -76,7 +69,6 @@ export class ChatBotThreadManager {
|
|
|
76
69
|
answer,
|
|
77
70
|
language,
|
|
78
71
|
imageAltText,
|
|
79
|
-
message,
|
|
80
72
|
}: PostMessagePayload): Promise<PostMessageResponse> => {
|
|
81
73
|
if (!this.api) {
|
|
82
74
|
throw new Error(
|
|
@@ -85,28 +77,14 @@ export class ChatBotThreadManager {
|
|
|
85
77
|
}
|
|
86
78
|
const threadItem = await this.getThreadItem()
|
|
87
79
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
conversationId: this.currentConversationId ?? '',
|
|
97
|
-
})
|
|
98
|
-
//@ts-ignore
|
|
99
|
-
this.conversationId = result?.conversationId ?? null
|
|
100
|
-
} else {
|
|
101
|
-
result = await this.api.getHint({
|
|
102
|
-
...threadItem.getNextHintProps(),
|
|
103
|
-
correctAnswer: problemAnswer,
|
|
104
|
-
problemDescription: problem,
|
|
105
|
-
userAnswer: answer,
|
|
106
|
-
language,
|
|
107
|
-
imageAltText,
|
|
108
|
-
})
|
|
109
|
-
}
|
|
80
|
+
const result = await this.api.getHint({
|
|
81
|
+
...threadItem.getNextHintProps(),
|
|
82
|
+
correctAnswer: problemAnswer,
|
|
83
|
+
problemDescription: problem,
|
|
84
|
+
userAnswer: answer,
|
|
85
|
+
language,
|
|
86
|
+
imageAltText,
|
|
87
|
+
})
|
|
110
88
|
|
|
111
89
|
threadItem.history.push(result.message)
|
|
112
90
|
const nextOptions =
|
|
@@ -117,8 +95,6 @@ export class ChatBotThreadManager {
|
|
|
117
95
|
options: nextOptions,
|
|
118
96
|
endMessage: !nextOptions.length,
|
|
119
97
|
threadId: threadItem.id,
|
|
120
|
-
//@ts-ignore
|
|
121
|
-
conversationId: result?.conversationId ?? null,
|
|
122
98
|
}
|
|
123
99
|
}
|
|
124
100
|
|
|
@@ -128,7 +104,6 @@ export class ChatBotThreadManager {
|
|
|
128
104
|
|
|
129
105
|
public reset(key?: string) {
|
|
130
106
|
if (typeof key === 'string') {
|
|
131
|
-
this.currentConversationId = null
|
|
132
107
|
this.threads.delete(key)
|
|
133
108
|
return
|
|
134
109
|
}
|
|
@@ -147,8 +122,4 @@ export class ChatBotThreadManager {
|
|
|
147
122
|
public setCurrentKey(key: string) {
|
|
148
123
|
this.currentKey = key
|
|
149
124
|
}
|
|
150
|
-
|
|
151
|
-
public setCurrentConversationId(id: string) {
|
|
152
|
-
this.currentConversationId = id
|
|
153
|
-
}
|
|
154
125
|
}
|
|
@@ -9,12 +9,10 @@ export class ChatbotAPI {
|
|
|
9
9
|
public readonly getAlternativesFx
|
|
10
10
|
public readonly translateTextFx
|
|
11
11
|
public readonly textToSpeechTextFx
|
|
12
|
-
// public readonly sendMessageFx
|
|
13
12
|
|
|
14
13
|
public readonly spotErrorFx
|
|
15
14
|
|
|
16
15
|
constructor(api: ChatbotApiRequests) {
|
|
17
|
-
// this.sendMessageFx = createControllerEffect(api.sendMessage)
|
|
18
16
|
this.spotErrorFx = createControllerEffect(api.spotError)
|
|
19
17
|
this.postMessageFx = createControllerEffect(api.postMessage)
|
|
20
18
|
this.getAlternativesFx = createEffect(api.getAlternatives)
|
|
@@ -5,31 +5,12 @@ export type GetAlternativesPayload = {
|
|
|
5
5
|
assignmentClassGrade: number
|
|
6
6
|
} | null
|
|
7
7
|
|
|
8
|
-
export type AlternativesOptions = {
|
|
9
|
-
default: ChatAnswer[]
|
|
10
|
-
hints: ChatAnswer[]
|
|
11
|
-
}
|
|
12
|
-
|
|
13
8
|
export type GetAlternativesResponse = {
|
|
14
9
|
chatAccess?: boolean
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
10
|
+
options: {
|
|
11
|
+
default: ChatAnswer[]
|
|
12
|
+
hints: ChatAnswer[]
|
|
13
|
+
}
|
|
33
14
|
}
|
|
34
15
|
|
|
35
16
|
export type PostMessagePayload = {
|
|
@@ -38,7 +19,6 @@ export type PostMessagePayload = {
|
|
|
38
19
|
answer?: string | string[]
|
|
39
20
|
problem: string
|
|
40
21
|
imageAltText?: string
|
|
41
|
-
message?: string
|
|
42
22
|
}
|
|
43
23
|
|
|
44
24
|
export type PostMessageResponse = {
|
|
@@ -12,8 +12,6 @@ import {
|
|
|
12
12
|
GoogleTranslateResponse,
|
|
13
13
|
PostMessagePayload,
|
|
14
14
|
PostMessageResponse,
|
|
15
|
-
SendMessagePayload,
|
|
16
|
-
SendMessageResponse,
|
|
17
15
|
} from './api.types'
|
|
18
16
|
import { ExtendWithOptional } from '../../../lib/helpers/types'
|
|
19
17
|
import { ChatAnswer, ConversationMessage, FullStrokeData } from './units.types'
|
|
@@ -27,7 +25,6 @@ export type ChatbotMessages = {
|
|
|
27
25
|
|
|
28
26
|
export type ChatbotApiRequests = {
|
|
29
27
|
getAlternatives: (props: GetAlternativesPayload) => Promise<GetAlternativesResponse>
|
|
30
|
-
sendMessage: (props: SendMessagePayload) => Promise<SendMessageResponse>
|
|
31
28
|
postMessage: (props: PostMessagePayload) => Promise<PostMessageResponse>
|
|
32
29
|
postTranslateText: (props: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>
|
|
33
30
|
postTextToSpeech: (props: GoogleText2SpeechPayload) => Promise<GoogleText2SpeechResponse>
|
|
@@ -50,20 +47,11 @@ export type ChatbotModelProps = {
|
|
|
50
47
|
export type SendHelpParams = {
|
|
51
48
|
message: string
|
|
52
49
|
translatedMessage?: string
|
|
53
|
-
isFreeText?: boolean
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
export type SendHelpProps = SendHelpParams & {
|
|
57
53
|
key: string
|
|
58
54
|
context: ChatbotContext | null
|
|
59
|
-
isFreeText?: boolean
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type SendMessageProps = SendHelpParams & {
|
|
63
|
-
key: string
|
|
64
|
-
context: ChatbotContext | null
|
|
65
|
-
conversationId?: string
|
|
66
|
-
message: string
|
|
67
55
|
}
|
|
68
56
|
|
|
69
57
|
export type SetHintMessageProps = {
|
|
@@ -120,6 +108,3 @@ export type ChatbotContext = {
|
|
|
120
108
|
translationTargetLanguage: string
|
|
121
109
|
imageDescription?: string
|
|
122
110
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ColorScheme } from './style.types'
|
|
2
|
-
|
|
3
1
|
export type Stroke = {
|
|
4
2
|
x: number[]
|
|
5
3
|
y: number[]
|
|
@@ -37,23 +35,3 @@ export type ChatItem = {
|
|
|
37
35
|
isAvailable: boolean
|
|
38
36
|
currentThread: IThreadItem | null
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
export type ChatInputAreaProps = {
|
|
42
|
-
onPressAlternative: (message: string, translatedMessage?: string) => void
|
|
43
|
-
hasMessages: boolean
|
|
44
|
-
isHintFeedback: boolean
|
|
45
|
-
inputMode: ChatInputMode
|
|
46
|
-
colorScheme?: ColorScheme
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export enum ChatInputMode {
|
|
50
|
-
FreeText = 1,
|
|
51
|
-
Option = 2,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export type ChatInputProps = {
|
|
55
|
-
message: string
|
|
56
|
-
disabled: boolean
|
|
57
|
-
onPress: () => void
|
|
58
|
-
colorScheme: ColorScheme
|
|
59
|
-
}
|
|
@@ -18,12 +18,6 @@ export const ExampleSolutionModal = ({
|
|
|
18
18
|
container: { paddingHorizontal: SPACING[800] },
|
|
19
19
|
}}
|
|
20
20
|
onClose={closeModal}
|
|
21
|
-
content={
|
|
22
|
-
<ExampleSolutionModalContent
|
|
23
|
-
model={params.model}
|
|
24
|
-
payload={params.payload}
|
|
25
|
-
cacheKey={params.cacheKey}
|
|
26
|
-
/>
|
|
27
|
-
}
|
|
21
|
+
content={<ExampleSolutionModalContent params={params} />}
|
|
28
22
|
/>
|
|
29
23
|
)
|
|
Binary file
|
|
@@ -10,11 +10,13 @@ import { QuestionSection } from './QuestionSection'
|
|
|
10
10
|
import { SolutionSection } from './SolutionSection'
|
|
11
11
|
import { useExampleSolution } from '../hooks/useExampleSolution'
|
|
12
12
|
|
|
13
|
+
type ExampleSolutionModalContentProps = {
|
|
14
|
+
params: ExampleSolutionModalParams
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
export const ExampleSolutionModalContent = ({
|
|
14
|
-
model,
|
|
15
|
-
|
|
16
|
-
cacheKey,
|
|
17
|
-
}: ExampleSolutionModalParams) => {
|
|
18
|
+
params: { model, payload, cacheKey },
|
|
19
|
+
}: ExampleSolutionModalContentProps) => {
|
|
18
20
|
const { result, status } = useExampleSolution({ model, payload, cacheKey })
|
|
19
21
|
const localization = useUnit($localization)
|
|
20
22
|
|
|
@@ -24,7 +26,11 @@ export const ExampleSolutionModalContent = ({
|
|
|
24
26
|
{localization.exampleSolution.exampleSolution}
|
|
25
27
|
</Typography>
|
|
26
28
|
<View style={styles.content}>
|
|
27
|
-
<QuestionSection
|
|
29
|
+
<QuestionSection
|
|
30
|
+
status={status}
|
|
31
|
+
question={result?.question}
|
|
32
|
+
renderKatexComponent={model.renderKatexComponent}
|
|
33
|
+
/>
|
|
28
34
|
<SolutionSection status={status} answer={result?.answer} />
|
|
29
35
|
</View>
|
|
30
36
|
<MessageBlock status={status} style={styles.messageBlock} />
|
|
@@ -36,7 +42,7 @@ export const ExampleSolutionModalContent = ({
|
|
|
36
42
|
const styles = StyleSheet.create({
|
|
37
43
|
container: {
|
|
38
44
|
width: 880,
|
|
39
|
-
|
|
45
|
+
maxHeight: 593,
|
|
40
46
|
},
|
|
41
47
|
content: {
|
|
42
48
|
flex: 1,
|
|
@@ -53,8 +59,8 @@ const styles = StyleSheet.create({
|
|
|
53
59
|
},
|
|
54
60
|
lavaIconContainer: {
|
|
55
61
|
position: 'absolute',
|
|
56
|
-
bottom: -
|
|
57
|
-
right: -
|
|
62
|
+
bottom: -24,
|
|
63
|
+
right: -26,
|
|
58
64
|
},
|
|
59
65
|
loaderContainer: {
|
|
60
66
|
paddingTop: 34,
|
|
@@ -65,7 +71,7 @@ const styles = StyleSheet.create({
|
|
|
65
71
|
},
|
|
66
72
|
messageBlock: {
|
|
67
73
|
position: 'absolute',
|
|
68
|
-
right:
|
|
69
|
-
bottom: -
|
|
74
|
+
right: 58,
|
|
75
|
+
bottom: -12,
|
|
70
76
|
},
|
|
71
77
|
})
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import { StyleSheet, View
|
|
1
|
+
import { StyleSheet, View } from 'react-native'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { COLORS, Loader, LoaderColor, SPACING
|
|
3
|
+
import { COLORS, Loader, LoaderColor, SPACING } from '@magmamath/react-native-ui'
|
|
4
4
|
import Animated, { FadeOut } from 'react-native-reanimated'
|
|
5
5
|
import { ExampleSolutionStatuses } from '../constants'
|
|
6
6
|
|
|
7
7
|
type QuestionSectionProps = {
|
|
8
8
|
question?: string
|
|
9
9
|
status: ExampleSolutionStatuses
|
|
10
|
+
renderKatexComponent: (katexString: string) => React.ReactNode
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export const QuestionSection = ({
|
|
13
|
+
export const QuestionSection = ({
|
|
14
|
+
question,
|
|
15
|
+
status,
|
|
16
|
+
renderKatexComponent,
|
|
17
|
+
}: QuestionSectionProps) => {
|
|
13
18
|
return (
|
|
14
19
|
<View style={styles.container}>
|
|
15
|
-
<
|
|
16
|
-
<Typography>{question}</Typography>
|
|
17
|
-
</ScrollView>
|
|
20
|
+
{question && <View style={styles.katexContainer}>{renderKatexComponent(question)}</View>}
|
|
18
21
|
{status === ExampleSolutionStatuses.LOADING && (
|
|
19
22
|
<Animated.View exiting={FadeOut} style={styles.loaderContainer}>
|
|
20
23
|
<Loader size="large" color={LoaderColor.BLUE} />
|
|
@@ -28,12 +31,13 @@ const styles = StyleSheet.create({
|
|
|
28
31
|
container: {
|
|
29
32
|
flex: 1,
|
|
30
33
|
},
|
|
31
|
-
|
|
34
|
+
katexContainer: {
|
|
32
35
|
flex: 1,
|
|
33
36
|
},
|
|
34
37
|
loaderContainer: {
|
|
35
38
|
paddingTop: 34,
|
|
36
39
|
position: 'absolute',
|
|
40
|
+
zIndex: 100,
|
|
37
41
|
width: '100%',
|
|
38
42
|
height: '100%',
|
|
39
43
|
backgroundColor: COLORS.NEUTRAL_1,
|
|
@@ -1,69 +1,112 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
StyleSheet,
|
|
3
|
+
View,
|
|
4
|
+
Image,
|
|
5
|
+
ImageBackground,
|
|
6
|
+
ScrollView,
|
|
7
|
+
useWindowDimensions,
|
|
8
|
+
} from 'react-native'
|
|
2
9
|
import React from 'react'
|
|
3
10
|
import { COLORS, IS_WEB, SPACING } from '@magmamath/react-native-ui'
|
|
4
11
|
import Animated, { FadeIn } from 'react-native-reanimated'
|
|
5
12
|
import { ExampleSolutionStatuses } from '../constants'
|
|
6
|
-
import gridImage from '../assets/grid.
|
|
13
|
+
import gridImage from '../assets/grid.webp'
|
|
7
14
|
|
|
8
15
|
type SolutionSectionProps = {
|
|
9
16
|
answer?: string
|
|
10
17
|
status: ExampleSolutionStatuses
|
|
11
18
|
}
|
|
12
19
|
|
|
20
|
+
const CONTAINER_SIZES = {
|
|
21
|
+
width: 489,
|
|
22
|
+
height: 543,
|
|
23
|
+
}
|
|
24
|
+
const BORDER_WIDTH = 1
|
|
25
|
+
const CONTAINER_HEIGHT_OFFSET = 160
|
|
26
|
+
|
|
13
27
|
const gridImagePath = !IS_WEB ? Image.resolveAssetSource(gridImage).uri : gridImage
|
|
14
28
|
|
|
15
29
|
export const SolutionSection = ({ answer, status }: SolutionSectionProps) => {
|
|
30
|
+
const { height } = useWindowDimensions()
|
|
31
|
+
|
|
16
32
|
const shouldShowAnswer =
|
|
17
33
|
answer &&
|
|
18
34
|
(status === ExampleSolutionStatuses.DONE_DATA || status === ExampleSolutionStatuses.CACHE)
|
|
19
35
|
|
|
20
36
|
return (
|
|
21
|
-
<View style={styles.container}>
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
<View style={[styles.container, IS_WEB && { maxHeight: height - CONTAINER_HEIGHT_OFFSET }]}>
|
|
38
|
+
<ScrollView
|
|
39
|
+
style={styles.solutionScroll}
|
|
40
|
+
contentContainerStyle={styles.solutionScrollContent}
|
|
41
|
+
bounces
|
|
42
|
+
>
|
|
43
|
+
{IS_WEB ? (
|
|
44
|
+
<ImageBackground
|
|
45
|
+
resizeMode="repeat"
|
|
46
|
+
style={[styles.gridImageWeb]}
|
|
47
|
+
source={{ uri: gridImagePath }}
|
|
48
|
+
>
|
|
49
|
+
{shouldShowAnswer && (
|
|
50
|
+
<Animated.Text
|
|
51
|
+
entering={status === 'cache' ? undefined : FadeIn.delay(1000).duration(500)}
|
|
52
|
+
style={styles.solutionText}
|
|
53
|
+
>
|
|
54
|
+
{answer}
|
|
55
|
+
</Animated.Text>
|
|
56
|
+
)}
|
|
57
|
+
</ImageBackground>
|
|
58
|
+
) : (
|
|
59
|
+
<>
|
|
60
|
+
<ImageBackground
|
|
61
|
+
resizeMode="repeat"
|
|
62
|
+
style={styles.gridImageRn}
|
|
63
|
+
source={{ uri: gridImagePath }}
|
|
64
|
+
/>
|
|
65
|
+
{shouldShowAnswer && (
|
|
66
|
+
<Animated.Text
|
|
67
|
+
entering={status === 'cache' ? undefined : FadeIn.delay(1000).duration(500)}
|
|
68
|
+
style={styles.solutionText}
|
|
69
|
+
>
|
|
70
|
+
{answer}
|
|
71
|
+
</Animated.Text>
|
|
72
|
+
)}
|
|
73
|
+
</>
|
|
74
|
+
)}
|
|
75
|
+
</ScrollView>
|
|
35
76
|
</View>
|
|
36
77
|
)
|
|
37
78
|
}
|
|
38
79
|
|
|
39
80
|
const styles = StyleSheet.create({
|
|
40
81
|
container: {
|
|
41
|
-
width:
|
|
82
|
+
width: CONTAINER_SIZES.width,
|
|
83
|
+
height: CONTAINER_SIZES.height,
|
|
42
84
|
overflow: 'hidden',
|
|
43
85
|
borderRadius: 8,
|
|
44
|
-
borderWidth:
|
|
86
|
+
borderWidth: BORDER_WIDTH,
|
|
45
87
|
borderColor: COLORS.NEUTRAL_5,
|
|
46
88
|
},
|
|
47
|
-
|
|
89
|
+
gridImageRn: {
|
|
90
|
+
top: -327,
|
|
48
91
|
width: '100%',
|
|
49
|
-
height: '
|
|
50
|
-
|
|
51
|
-
aspectRatio: 28 / 8,
|
|
92
|
+
height: '150%',
|
|
93
|
+
position: 'absolute',
|
|
52
94
|
},
|
|
53
95
|
gridImageWeb: {
|
|
54
|
-
transform: [{ scale: 3.5 }],
|
|
55
|
-
},
|
|
56
|
-
solutionScroll: {
|
|
57
|
-
position: 'absolute',
|
|
58
96
|
width: '100%',
|
|
59
97
|
height: '100%',
|
|
60
98
|
},
|
|
99
|
+
solutionScroll: {
|
|
100
|
+
flex: 1,
|
|
101
|
+
},
|
|
61
102
|
solutionScrollContent: {
|
|
62
|
-
|
|
63
|
-
|
|
103
|
+
minHeight: CONTAINER_SIZES.height - BORDER_WIDTH * 2,
|
|
104
|
+
width: '100%',
|
|
64
105
|
},
|
|
65
106
|
solutionText: {
|
|
66
107
|
fontFamily: 'PlaypenSans-Light',
|
|
67
|
-
fontSize:
|
|
108
|
+
fontSize: 28,
|
|
109
|
+
marginHorizontal: SPACING[800],
|
|
110
|
+
marginVertical: SPACING[400],
|
|
68
111
|
},
|
|
69
112
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExampleSolutionModelProps } from '../types'
|
|
2
2
|
import { ExampleSolutionsApi } from './ExampleSolutionApi'
|
|
3
3
|
import { ExampleSolutionCache } from './ExampleSolutionCache'
|
|
4
4
|
|
|
@@ -6,7 +6,10 @@ export class ExampleSolutionModel {
|
|
|
6
6
|
public readonly api
|
|
7
7
|
public readonly cache = new ExampleSolutionCache()
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
public readonly renderKatexComponent: (katexString: string) => React.ReactNode
|
|
10
|
+
|
|
11
|
+
constructor({ api, errorHandler, renderKatexComponent }: ExampleSolutionModelProps) {
|
|
10
12
|
this.api = new ExampleSolutionsApi({ api, errorHandler })
|
|
13
|
+
this.renderKatexComponent = renderKatexComponent
|
|
11
14
|
}
|
|
12
15
|
}
|
|
@@ -15,9 +15,10 @@ export type ExampleSolutionApiRequests = {
|
|
|
15
15
|
generateExampleSolution: (body: ExampleSolutionPayload) => Promise<ExampleSolutionResponse>
|
|
16
16
|
}
|
|
17
17
|
export type ExampleSolutionErrorHandler = (errorMessage: string) => void
|
|
18
|
-
export type
|
|
18
|
+
export type ExampleSolutionModelProps = {
|
|
19
19
|
api: ExampleSolutionApiRequests
|
|
20
20
|
errorHandler?: ExampleSolutionErrorHandler
|
|
21
|
+
renderKatexComponent: (katexString: string) => React.ReactNode
|
|
21
22
|
}
|
|
22
23
|
export type ExampleSolutionModalParams = {
|
|
23
24
|
cacheKey: string
|