@magmamath/students-features 0.6.14-rc.2 → 0.6.14-rc.21
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/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 +135 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js +77 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/{Alternatives/InputButton.js → ChatInput/freeText/SendMessageButton.js} +26 -17
- package/dist/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.js.map +1 -0
- 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 +2 -1
- package/dist/commonjs/features/chatbot/constants.js.map +1 -1
- package/dist/commonjs/features/chatbot/index.js +7 -0
- package/dist/commonjs/features/chatbot/index.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js +44 -8
- 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 +44 -11
- package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/types.js +2 -0
- package/dist/commonjs/features/chatbot/types/types.js.map +1 -0
- 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/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 +18 -11
- 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 +5 -4
- package/dist/commonjs/features/formulaSheet/components/FormulaSheet.js.map +1 -1
- package/dist/commonjs/shared/hooks/useKeyDownListener.js +3 -2
- package/dist/commonjs/shared/hooks/useKeyDownListener.js.map +1 -1
- package/dist/commonjs/shared/translation/localization/ca.json +2 -1
- package/dist/commonjs/shared/translation/localization/en.json +3 -2
- package/dist/commonjs/shared/translation/localization/gb.json +2 -1
- package/dist/commonjs/shared/translation/localization/sct.json +2 -1
- 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/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 +128 -0
- package/dist/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js +71 -0
- package/dist/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js.map +1 -0
- package/dist/module/features/chatbot/components/{Alternatives/InputButton.js → ChatInput/freeText/SendMessageButton.js} +25 -16
- package/dist/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.js.map +1 -0
- 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 +1 -0
- package/dist/module/features/chatbot/constants.js.map +1 -1
- package/dist/module/features/chatbot/index.js +1 -0
- package/dist/module/features/chatbot/index.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBotModel.js +44 -8
- 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 +44 -11
- package/dist/module/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
- package/dist/module/features/chatbot/types/model.types.js.map +1 -1
- package/dist/module/features/chatbot/types/types.js +2 -0
- package/dist/module/features/chatbot/types/types.js.map +1 -0
- 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/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 +19 -12
- 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 +5 -4
- package/dist/module/features/formulaSheet/components/FormulaSheet.js.map +1 -1
- package/dist/module/shared/hooks/useKeyDownListener.js +3 -2
- package/dist/module/shared/hooks/useKeyDownListener.js.map +1 -1
- package/dist/module/shared/translation/localization/ca.json +2 -1
- package/dist/module/shared/translation/localization/en.json +3 -2
- package/dist/module/shared/translation/localization/gb.json +2 -1
- package/dist/module/shared/translation/localization/sct.json +2 -1
- package/dist/module/shared/translation/localization/sw.json +3 -2
- package/dist/typescript/commonjs/features/chatbot/components/{ChatMessages/ChatbotMessages.d.ts → 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/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/{module/features/chatbot/components/Alternatives/InputButton.d.ts → commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts} +2 -2
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts +2 -0
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts +1 -0
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/index.d.ts +1 -0
- 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/commonjs/features/chatbot/model/translation.d.ts +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +23 -1
- 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 +11 -2
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/types.d.ts +1 -0
- package/dist/typescript/commonjs/features/chatbot/types/types.d.ts.map +1 -0
- 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/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/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/module/features/chatbot/components/{ChatMessages/ChatbotMessages.d.ts → 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/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/{commonjs/features/chatbot/components/Alternatives/InputButton.d.ts → module/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts} +2 -2
- package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts +2 -0
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/constants.d.ts +1 -0
- package/dist/typescript/module/features/chatbot/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/index.d.ts +1 -0
- 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/module/features/chatbot/model/translation.d.ts +1 -1
- package/dist/typescript/module/features/chatbot/model/translation.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts +23 -1
- 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 +11 -2
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/types.d.ts +1 -0
- package/dist/typescript/module/features/chatbot/types/types.d.ts.map +1 -0
- 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/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/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 +2 -2
- package/src/features/chatbot/components/{ChatMessages/ChatbotMessages.tsx → Chat/Chat.tsx} +12 -17
- package/src/features/chatbot/components/ChatInput/ChatInput.tsx +83 -0
- package/src/features/chatbot/components/ChatInput/RequestHintButton.tsx +156 -0
- package/src/features/chatbot/components/ChatInput/freeText/ChatTextInput.tsx +153 -0
- package/src/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.tsx +83 -0
- package/src/features/chatbot/components/{Alternatives/InputButton.tsx → ChatInput/freeText/SendMessageButton.tsx} +37 -16
- package/src/features/chatbot/components/Chatbot.tsx +4 -2
- package/src/features/chatbot/constants.ts +3 -0
- package/src/features/chatbot/index.ts +2 -0
- package/src/features/chatbot/model/ChatBotModel.ts +67 -33
- package/src/features/chatbot/model/ChatBotTextInput.ts +10 -0
- package/src/features/chatbot/model/ChatBotThreadManager.ts +35 -9
- package/src/features/chatbot/model/translation.ts +1 -1
- package/src/features/chatbot/types/api.types.ts +25 -1
- package/src/features/chatbot/types/model.types.ts +16 -1
- package/src/features/chatbot/types/types.ts +0 -0
- package/src/features/chatbot/types/units.types.ts +6 -0
- package/src/features/exampleSolution/ExampleSolutionModal.tsx +1 -7
- package/src/features/exampleSolution/assets/grid.webp +0 -0
- package/src/features/exampleSolution/components/ExampleSolutionModalContent.tsx +24 -12
- 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 +6 -4
- package/src/shared/hooks/useKeyDownListener.ts +3 -1
- package/src/shared/translation/localization/ca.json +2 -1
- package/src/shared/translation/localization/en.json +3 -2
- package/src/shared/translation/localization/gb.json +2 -1
- package/src/shared/translation/localization/sct.json +2 -1
- package/src/shared/translation/localization/sw.json +3 -2
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js +0 -111
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js +0 -208
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/Alternatives/InputButton.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.js +0 -157
- package/dist/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +0 -1
- package/dist/commonjs/features/exampleSolution/assets/grid.png +0 -0
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js +0 -105
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js.map +0 -1
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js +0 -200
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js.map +0 -1
- package/dist/module/features/chatbot/components/Alternatives/InputButton.js.map +0 -1
- package/dist/module/features/chatbot/components/Alternatives/InputWithHintRow.js +0 -150
- package/dist/module/features/chatbot/components/Alternatives/InputWithHintRow.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +0 -1
- package/dist/module/features/exampleSolution/assets/grid.png +0 -0
- 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 -13
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/InputButton.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.d.ts +0 -11
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.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 -13
- package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/InputButton.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/InputWithHintRow.d.ts +0 -11
- package/dist/typescript/module/features/chatbot/components/Alternatives/InputWithHintRow.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +0 -1
- package/src/features/chatbot/components/Alternatives/Alternatives.tsx +0 -135
- package/src/features/chatbot/components/Alternatives/HelpRequestOption.tsx +0 -214
- package/src/features/chatbot/components/Alternatives/InputWithHintRow.tsx +0 -160
- package/src/features/exampleSolution/assets/grid.png +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { attach, combine, createEffect, createEvent, restore, sample, type Store } from 'effector'
|
|
2
|
+
import { IS_WEB } from '@magmamath/react-native-ui'
|
|
2
3
|
import {
|
|
3
4
|
ChatbotContext,
|
|
4
5
|
ChatbotModelProps,
|
|
5
6
|
IChatDrawBoardAdapter,
|
|
7
|
+
ReinitConversationProps,
|
|
6
8
|
SendHelpParams,
|
|
7
9
|
SendHelpProps,
|
|
8
10
|
SetHintMessageProps,
|
|
@@ -17,14 +19,11 @@ import { messagesHelper } from './messagesHelper'
|
|
|
17
19
|
import { ChatBotThreadManager } from './ChatBotThreadManager'
|
|
18
20
|
import { ChatsCacheModel, defaultChatData } from './ChatsCacheModel'
|
|
19
21
|
import { ErrorSpottingModel } from '../errorSpotting/ErrorSpottingModel'
|
|
22
|
+
import { ChatBotTextInput } from './ChatBotTextInput'
|
|
20
23
|
import { withEvent } from '../../../lib/effector/withEvent'
|
|
21
24
|
import { ChatBotTextManager } from './ChatBoxTextManager'
|
|
22
25
|
import { ControlledSample } from '../../../lib/effector/ControlledSample'
|
|
23
26
|
|
|
24
|
-
type ReinitConversationProps = {
|
|
25
|
-
key: string
|
|
26
|
-
}
|
|
27
|
-
|
|
28
27
|
export class ChatbotModel {
|
|
29
28
|
public readonly textManager = new ChatBotTextManager()
|
|
30
29
|
private readonly defaultMessages = this.textManager.messages
|
|
@@ -37,6 +36,7 @@ export class ChatbotModel {
|
|
|
37
36
|
public readonly translation: ChatbotTranslation
|
|
38
37
|
public readonly t2s: ChatTextToSpeechModel
|
|
39
38
|
public readonly errorSpotting: ErrorSpottingModel
|
|
39
|
+
public readonly textInput = new ChatBotTextInput()
|
|
40
40
|
|
|
41
41
|
private readonly setCurrentKey = createEvent<string>()
|
|
42
42
|
public readonly $currentKey = restore(this.setCurrentKey, '')
|
|
@@ -46,7 +46,7 @@ export class ChatbotModel {
|
|
|
46
46
|
|
|
47
47
|
readonly resetAlternatives = createEvent()
|
|
48
48
|
readonly setAlternatives = createEvent<GetAlternativesResponse | null>()
|
|
49
|
-
readonly $alternatives
|
|
49
|
+
readonly $alternatives
|
|
50
50
|
|
|
51
51
|
readonly setIsOpen = createEvent<boolean>()
|
|
52
52
|
readonly toggleOpen = createEvent()
|
|
@@ -72,7 +72,7 @@ export class ChatbotModel {
|
|
|
72
72
|
constructor({ api, $key, threadMessagesLimit, settings = {} }: ChatbotModelProps) {
|
|
73
73
|
this.api = new ChatbotAPI({ ...api, postMessage: this.threadManager.postMessage })
|
|
74
74
|
|
|
75
|
-
this.threadManager.setApi({ getHint: api.requestHint })
|
|
75
|
+
this.threadManager.setApi({ getHint: api.requestHint, sendMessage: api.sendMessage })
|
|
76
76
|
if (threadMessagesLimit) {
|
|
77
77
|
this.threadManager.setMessagesLimit(threadMessagesLimit)
|
|
78
78
|
}
|
|
@@ -122,6 +122,11 @@ export class ChatbotModel {
|
|
|
122
122
|
target: this.cache.update,
|
|
123
123
|
})
|
|
124
124
|
|
|
125
|
+
sample({
|
|
126
|
+
clock: this.resetAlternatives,
|
|
127
|
+
target: this.textInput.reset
|
|
128
|
+
})
|
|
129
|
+
|
|
125
130
|
if (settings.closeOnKeyChange) {
|
|
126
131
|
sample({
|
|
127
132
|
clock: this.$currentKey.updates,
|
|
@@ -154,42 +159,69 @@ export class ChatbotModel {
|
|
|
154
159
|
},
|
|
155
160
|
),
|
|
156
161
|
})
|
|
162
|
+
|
|
163
|
+
this.$alternatives.updates.watch((alternatives) => {
|
|
164
|
+
// Use short text for another hint option if openChatEnabled
|
|
165
|
+
if (alternatives?.chatAccess && alternatives?.isOpenChatEnabled && IS_WEB) {
|
|
166
|
+
this.textManager.update((creator) => ({
|
|
167
|
+
anotherHintOption: creator.createOption('chat.giveHint'),
|
|
168
|
+
}))
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
|
|
157
173
|
}
|
|
158
174
|
|
|
159
175
|
private createSendHelpRequestFx() {
|
|
160
176
|
const effect = attach({
|
|
161
|
-
source: [this.$currentKey, this.$context],
|
|
162
|
-
mapParams: (params: SendHelpParams, [key, context]) => ({
|
|
177
|
+
source: [this.$currentKey, this.$context, this.cache.$data],
|
|
178
|
+
mapParams: (params: SendHelpParams, [key, context, cache]) => ({
|
|
163
179
|
message: params.message,
|
|
164
180
|
translatedMessage: params.translatedMessage,
|
|
181
|
+
isFreeText: params.isFreeText,
|
|
182
|
+
cache,
|
|
165
183
|
context,
|
|
166
184
|
key,
|
|
167
185
|
}),
|
|
168
|
-
effect: createEffect(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
186
|
+
effect: createEffect(
|
|
187
|
+
async ({ message, translatedMessage, key, context, isFreeText, cache }: SendHelpProps) => {
|
|
188
|
+
if (!context) throw new Error('Trying to send message in chat without context')
|
|
189
|
+
this.setLastMessageKey(key)
|
|
190
|
+
this.cache.addMessages(key, {
|
|
191
|
+
messages: [messagesHelper.createOwn({ message, translatedMessage })],
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
const response = await this.api.postMessageFx({
|
|
195
|
+
answer: context.answer,
|
|
196
|
+
answerOptions: context.answerOptions,
|
|
197
|
+
problemDescription: context.problem,
|
|
198
|
+
problemAnswer: context.problemAnswer,
|
|
199
|
+
language: context.language,
|
|
200
|
+
imageAltText: context.imageDescription,
|
|
201
|
+
imageCdnId: context.imageCdnId,
|
|
202
|
+
conversationId: cache[key].conversationId,
|
|
203
|
+
...(isFreeText && { freeTextMessage: message }),
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
const thread = this.threadManager.get(key)
|
|
207
|
+
const messages = [
|
|
208
|
+
messagesHelper.createAnswer(response, { isInitial: thread?.history.length === 1 }),
|
|
209
|
+
]
|
|
210
|
+
if (response.endMessage) {
|
|
211
|
+
messages.push(messagesHelper.createLast(this.defaultMessages.endMessage))
|
|
212
|
+
}
|
|
213
|
+
const translatedMessages = await this.translation.applyTranslationFx(messages)
|
|
214
|
+
|
|
215
|
+
this.cache.addMessages(key, {
|
|
216
|
+
messages: translatedMessages,
|
|
217
|
+
thread,
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
if (response.conversationId) {
|
|
221
|
+
this.cache.update({ key, data: { conversationId: response.conversationId } })
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
),
|
|
193
225
|
})
|
|
194
226
|
|
|
195
227
|
sample({
|
|
@@ -273,6 +305,7 @@ export class ChatbotModel {
|
|
|
273
305
|
this.api.postMessageFx.controller.abort()
|
|
274
306
|
this.removeLastMessage()
|
|
275
307
|
}
|
|
308
|
+
this.textInput.reset()
|
|
276
309
|
this.errorSpotting.abortPendingRequest()
|
|
277
310
|
|
|
278
311
|
this.t2s.stop()
|
|
@@ -286,6 +319,7 @@ export class ChatbotModel {
|
|
|
286
319
|
this.resetAlternatives()
|
|
287
320
|
this.threadManager.reset()
|
|
288
321
|
this.errorSpotting.reset()
|
|
322
|
+
this.textInput.reset()
|
|
289
323
|
})
|
|
290
324
|
|
|
291
325
|
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,15 @@ import {
|
|
|
4
4
|
ChatHintResponse,
|
|
5
5
|
PostMessagePayload,
|
|
6
6
|
PostMessageResponse,
|
|
7
|
+
SendMessagePayload,
|
|
8
|
+
SendMessageResponse,
|
|
7
9
|
} from '../types/api.types'
|
|
8
10
|
import { ChatbotMessages, IChatDrawBoardAdapter } from '../types/model.types'
|
|
9
11
|
import { CHAT_BOT_MODEL_DEFAULTS } from './constants'
|
|
10
12
|
|
|
11
13
|
type ThreadManagerApi = {
|
|
12
14
|
getHint: (props: ChatHintPayload) => Promise<ChatHintResponse>
|
|
15
|
+
sendMessage: (props: SendMessagePayload) => Promise<SendMessageResponse>
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
type ChatBotThreadManagerProps = {
|
|
@@ -65,10 +68,14 @@ export class ChatBotThreadManager {
|
|
|
65
68
|
|
|
66
69
|
public readonly postMessage = async ({
|
|
67
70
|
problemAnswer,
|
|
68
|
-
|
|
71
|
+
problemDescription,
|
|
69
72
|
answer,
|
|
73
|
+
answerOptions,
|
|
70
74
|
language,
|
|
71
75
|
imageAltText,
|
|
76
|
+
imageCdnId,
|
|
77
|
+
freeTextMessage,
|
|
78
|
+
conversationId,
|
|
72
79
|
}: PostMessagePayload): Promise<PostMessageResponse> => {
|
|
73
80
|
if (!this.api) {
|
|
74
81
|
throw new Error(
|
|
@@ -77,14 +84,32 @@ export class ChatBotThreadManager {
|
|
|
77
84
|
}
|
|
78
85
|
const threadItem = await this.getThreadItem()
|
|
79
86
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
let result
|
|
88
|
+
|
|
89
|
+
if (freeTextMessage) {
|
|
90
|
+
const payload = conversationId
|
|
91
|
+
? { conversationId, message: freeTextMessage }
|
|
92
|
+
: {
|
|
93
|
+
message: freeTextMessage,
|
|
94
|
+
problemDescription,
|
|
95
|
+
correctAnswer: problemAnswer,
|
|
96
|
+
language,
|
|
97
|
+
...(imageCdnId && { imageCdnId }),
|
|
98
|
+
...(imageAltText && { altText: imageAltText }),
|
|
99
|
+
...(!!answerOptions?.length && { answerOptions }),
|
|
100
|
+
}
|
|
101
|
+
result = await this.api.sendMessage(payload)
|
|
102
|
+
} else {
|
|
103
|
+
result = await this.api.getHint({
|
|
104
|
+
...threadItem.getNextHintProps(),
|
|
105
|
+
correctAnswer: problemAnswer,
|
|
106
|
+
problemDescription,
|
|
107
|
+
userAnswer: answer,
|
|
108
|
+
language,
|
|
109
|
+
...(imageCdnId && { imageCdnId }),
|
|
110
|
+
...(imageAltText && { imageAltText }),
|
|
111
|
+
})
|
|
112
|
+
}
|
|
88
113
|
|
|
89
114
|
threadItem.history.push(result.message)
|
|
90
115
|
const nextOptions =
|
|
@@ -95,6 +120,7 @@ export class ChatBotThreadManager {
|
|
|
95
120
|
options: nextOptions,
|
|
96
121
|
endMessage: !nextOptions.length,
|
|
97
122
|
threadId: threadItem.id,
|
|
123
|
+
conversationId: result?.conversationId ?? null,
|
|
98
124
|
}
|
|
99
125
|
}
|
|
100
126
|
|
|
@@ -12,21 +12,43 @@ export type AlternativesOptions = {
|
|
|
12
12
|
|
|
13
13
|
export type GetAlternativesResponse = {
|
|
14
14
|
chatAccess?: boolean
|
|
15
|
+
isOpenChatEnabled?: boolean
|
|
16
|
+
version: string
|
|
15
17
|
options: AlternativesOptions
|
|
16
18
|
}
|
|
17
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
|
|
33
|
+
}
|
|
34
|
+
|
|
18
35
|
export type PostMessagePayload = {
|
|
19
36
|
language: string
|
|
20
37
|
problemAnswer: string[]
|
|
38
|
+
problemDescription: string
|
|
21
39
|
answer?: string | string[]
|
|
22
|
-
|
|
40
|
+
answerOptions?: string[]
|
|
23
41
|
imageAltText?: string
|
|
42
|
+
imageCdnId?: string
|
|
43
|
+
freeTextMessage?: string
|
|
44
|
+
conversationId?: string | null
|
|
24
45
|
}
|
|
25
46
|
|
|
26
47
|
export type PostMessageResponse = {
|
|
27
48
|
message: string
|
|
28
49
|
options: ChatAnswer[]
|
|
29
50
|
endMessage?: boolean
|
|
51
|
+
conversationId?: string | null
|
|
30
52
|
threadId: string
|
|
31
53
|
}
|
|
32
54
|
|
|
@@ -66,11 +88,13 @@ export type ChatHintPayload = {
|
|
|
66
88
|
previousHint?: string
|
|
67
89
|
language: string
|
|
68
90
|
imageAltText?: string
|
|
91
|
+
imageCdnId?: string
|
|
69
92
|
drawBoardText?: string
|
|
70
93
|
}
|
|
71
94
|
|
|
72
95
|
export type ChatHintResponse = {
|
|
73
96
|
message: string
|
|
97
|
+
conversationId?: string | null
|
|
74
98
|
}
|
|
75
99
|
export type ErrorSpottingPayload = {
|
|
76
100
|
strokes: FullStrokeData[]
|
|
@@ -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>
|
|
@@ -47,11 +50,14 @@ export type ChatbotModelProps = {
|
|
|
47
50
|
export type SendHelpParams = {
|
|
48
51
|
message: string
|
|
49
52
|
translatedMessage?: string
|
|
53
|
+
isFreeText?: boolean
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
export type SendHelpProps = SendHelpParams & {
|
|
53
57
|
key: string
|
|
54
58
|
context: ChatbotContext | null
|
|
59
|
+
cache: Record<string, ChatItem>
|
|
60
|
+
isFreeText?: boolean
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
export type SetHintMessageProps = {
|
|
@@ -105,6 +111,15 @@ export type ChatbotContext = {
|
|
|
105
111
|
problem: string
|
|
106
112
|
problemAnswer: string[]
|
|
107
113
|
answer?: string | string[]
|
|
114
|
+
answerOptions?: string[]
|
|
108
115
|
translationTargetLanguage: string
|
|
109
116
|
imageDescription?: string
|
|
117
|
+
imageCdnId?: string
|
|
110
118
|
}
|
|
119
|
+
|
|
120
|
+
export type ReinitConversationProps = {
|
|
121
|
+
key: string
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
File without changes
|
|
@@ -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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StyleSheet, View } from 'react-native'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { COLORS, HeadingVariants, SPACING, Typography } from '@magmamath/react-native-ui'
|
|
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
6
|
import { MessageBlock } from './MessageBlock'
|
|
@@ -10,21 +10,34 @@ 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
|
+
|
|
17
|
+
const CONTAINER_HEIGHT = 593
|
|
18
|
+
|
|
13
19
|
export const ExampleSolutionModalContent = ({
|
|
14
|
-
model,
|
|
15
|
-
|
|
16
|
-
cacheKey,
|
|
17
|
-
}: ExampleSolutionModalParams) => {
|
|
20
|
+
params: { model, payload, cacheKey },
|
|
21
|
+
}: ExampleSolutionModalContentProps) => {
|
|
18
22
|
const { result, status } = useExampleSolution({ model, payload, cacheKey })
|
|
19
23
|
const localization = useUnit($localization)
|
|
20
24
|
|
|
21
25
|
return (
|
|
22
|
-
<View
|
|
26
|
+
<View
|
|
27
|
+
style={[
|
|
28
|
+
styles.container,
|
|
29
|
+
IS_WEB ? { maxHeight: CONTAINER_HEIGHT } : { height: CONTAINER_HEIGHT },
|
|
30
|
+
]}
|
|
31
|
+
>
|
|
23
32
|
<Typography align="center" variant={HeadingVariants.H2} style={{ color: COLORS.NEUTRAL_9 }}>
|
|
24
33
|
{localization.exampleSolution.exampleSolution}
|
|
25
34
|
</Typography>
|
|
26
35
|
<View style={styles.content}>
|
|
27
|
-
<QuestionSection
|
|
36
|
+
<QuestionSection
|
|
37
|
+
status={status}
|
|
38
|
+
question={result?.question}
|
|
39
|
+
renderKatexComponent={model.renderKatexComponent}
|
|
40
|
+
/>
|
|
28
41
|
<SolutionSection status={status} answer={result?.answer} />
|
|
29
42
|
</View>
|
|
30
43
|
<MessageBlock status={status} style={styles.messageBlock} />
|
|
@@ -36,7 +49,6 @@ export const ExampleSolutionModalContent = ({
|
|
|
36
49
|
const styles = StyleSheet.create({
|
|
37
50
|
container: {
|
|
38
51
|
width: 880,
|
|
39
|
-
height: 593,
|
|
40
52
|
},
|
|
41
53
|
content: {
|
|
42
54
|
flex: 1,
|
|
@@ -53,8 +65,8 @@ const styles = StyleSheet.create({
|
|
|
53
65
|
},
|
|
54
66
|
lavaIconContainer: {
|
|
55
67
|
position: 'absolute',
|
|
56
|
-
bottom: -
|
|
57
|
-
right: -
|
|
68
|
+
bottom: -24,
|
|
69
|
+
right: -26,
|
|
58
70
|
},
|
|
59
71
|
loaderContainer: {
|
|
60
72
|
paddingTop: 34,
|
|
@@ -65,7 +77,7 @@ const styles = StyleSheet.create({
|
|
|
65
77
|
},
|
|
66
78
|
messageBlock: {
|
|
67
79
|
position: 'absolute',
|
|
68
|
-
right:
|
|
69
|
-
bottom: -
|
|
80
|
+
right: 58,
|
|
81
|
+
bottom: -12,
|
|
70
82
|
},
|
|
71
83
|
})
|
|
@@ -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
|
})
|