@magmamath/students-features 0.6.14-rc.9 → 0.6.14
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 +11 -8
- 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 +48 -28
- 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/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 +11 -8
- 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 +50 -30
- 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/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/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/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 +15 -9
- package/src/features/exampleSolution/components/QuestionSection.tsx +11 -7
- package/src/features/exampleSolution/components/SolutionSection.tsx +61 -28
- package/src/features/exampleSolution/model/ExampleSolution.model.ts +5 -2
- package/src/features/exampleSolution/types.ts +2 -1
- 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
package/dist/typescript/module/features/exampleSolution/components/ExampleSolutionModalContent.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ExampleSolutionModalParams } from '../types';
|
|
3
|
-
|
|
3
|
+
type ExampleSolutionModalContentProps = {
|
|
4
|
+
params: ExampleSolutionModalParams;
|
|
5
|
+
};
|
|
6
|
+
export declare const ExampleSolutionModalContent: ({ params: { model, payload, cacheKey }, }: ExampleSolutionModalContentProps) => React.JSX.Element;
|
|
7
|
+
export {};
|
|
4
8
|
//# sourceMappingURL=ExampleSolutionModalContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleSolutionModalContent.d.ts","sourceRoot":"","sources":["../../../../../../src/features/exampleSolution/components/ExampleSolutionModalContent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAA;AAKrD,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"ExampleSolutionModalContent.d.ts","sourceRoot":"","sources":["../../../../../../src/features/exampleSolution/components/ExampleSolutionModalContent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAA;AAKrD,KAAK,gCAAgC,GAAG;IACtC,MAAM,EAAE,0BAA0B,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,2BAA2B,8CAErC,gCAAgC,sBAqBlC,CAAA"}
|
|
@@ -3,7 +3,8 @@ import { ExampleSolutionStatuses } from '../constants';
|
|
|
3
3
|
type QuestionSectionProps = {
|
|
4
4
|
question?: string;
|
|
5
5
|
status: ExampleSolutionStatuses;
|
|
6
|
+
renderKatexComponent: (katexString: string) => React.ReactNode;
|
|
6
7
|
};
|
|
7
|
-
export declare const QuestionSection: ({ question, status }: QuestionSectionProps) => React.JSX.Element;
|
|
8
|
+
export declare const QuestionSection: ({ question, status, renderKatexComponent, }: QuestionSectionProps) => React.JSX.Element;
|
|
8
9
|
export {};
|
|
9
10
|
//# sourceMappingURL=QuestionSection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuestionSection.d.ts","sourceRoot":"","sources":["../../../../../../src/features/exampleSolution/components/QuestionSection.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAEtD,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"QuestionSection.d.ts","sourceRoot":"","sources":["../../../../../../src/features/exampleSolution/components/QuestionSection.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAEtD,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,uBAAuB,CAAA;IAC/B,oBAAoB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAA;CAC/D,CAAA;AAED,eAAO,MAAM,eAAe,gDAIzB,oBAAoB,sBAWtB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolutionSection.d.ts","sourceRoot":"","sources":["../../../../../../src/features/exampleSolution/components/SolutionSection.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAGtD,KAAK,oBAAoB,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,uBAAuB,CAAA;CAChC,CAAA;
|
|
1
|
+
{"version":3,"file":"SolutionSection.d.ts","sourceRoot":"","sources":["../../../../../../src/features/exampleSolution/components/SolutionSection.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAGtD,KAAK,oBAAoB,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,uBAAuB,CAAA;CAChC,CAAA;AAUD,eAAO,MAAM,eAAe,uBAAwB,oBAAoB,sBA+CvE,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExampleSolutionModelProps } from '../types';
|
|
2
2
|
import { ExampleSolutionsApi } from './ExampleSolutionApi';
|
|
3
3
|
import { ExampleSolutionCache } from './ExampleSolutionCache';
|
|
4
4
|
export declare class ExampleSolutionModel {
|
|
5
5
|
readonly api: ExampleSolutionsApi;
|
|
6
6
|
readonly cache: ExampleSolutionCache;
|
|
7
|
-
|
|
7
|
+
readonly renderKatexComponent: (katexString: string) => React.ReactNode;
|
|
8
|
+
constructor({ api, errorHandler, renderKatexComponent }: ExampleSolutionModelProps);
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=ExampleSolution.model.d.ts.map
|
package/dist/typescript/module/features/exampleSolution/model/ExampleSolution.model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleSolution.model.d.ts","sourceRoot":"","sources":["../../../../../../src/features/exampleSolution/model/ExampleSolution.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,qBAAa,oBAAoB;IAC/B,SAAgB,GAAG,sBAAA;IACnB,SAAgB,KAAK,uBAA6B;
|
|
1
|
+
{"version":3,"file":"ExampleSolution.model.d.ts","sourceRoot":"","sources":["../../../../../../src/features/exampleSolution/model/ExampleSolution.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,qBAAa,oBAAoB;IAC/B,SAAgB,GAAG,sBAAA;IACnB,SAAgB,KAAK,uBAA6B;IAElD,SAAgB,oBAAoB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAA;gBAElE,EAAE,GAAG,EAAE,YAAY,EAAE,oBAAoB,EAAE,EAAE,yBAAyB;CAInF"}
|
|
@@ -14,9 +14,10 @@ export type ExampleSolutionApiRequests = {
|
|
|
14
14
|
generateExampleSolution: (body: ExampleSolutionPayload) => Promise<ExampleSolutionResponse>;
|
|
15
15
|
};
|
|
16
16
|
export type ExampleSolutionErrorHandler = (errorMessage: string) => void;
|
|
17
|
-
export type
|
|
17
|
+
export type ExampleSolutionModelProps = {
|
|
18
18
|
api: ExampleSolutionApiRequests;
|
|
19
19
|
errorHandler?: ExampleSolutionErrorHandler;
|
|
20
|
+
renderKatexComponent: (katexString: string) => React.ReactNode;
|
|
20
21
|
};
|
|
21
22
|
export type ExampleSolutionModalParams = {
|
|
22
23
|
cacheKey: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/features/exampleSolution/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAEpE,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AACD,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AACD,MAAM,MAAM,0BAA0B,GAAG;IACvC,uBAAuB,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAA;CAC5F,CAAA;AACD,MAAM,MAAM,2BAA2B,GAAG,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;AACxE,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,0BAA0B,CAAA;IAC/B,YAAY,CAAC,EAAE,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/features/exampleSolution/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAEpE,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AACD,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AACD,MAAM,MAAM,0BAA0B,GAAG;IACvC,uBAAuB,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAA;CAC5F,CAAA;AACD,MAAM,MAAM,2BAA2B,GAAG,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;AACxE,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,0BAA0B,CAAA;IAC/B,YAAY,CAAC,EAAE,2BAA2B,CAAA;IAC1C,oBAAoB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAA;CAC/D,CAAA;AACD,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,sBAAsB,CAAA;IAC/B,KAAK,EAAE,oBAAoB,CAAA;CAC5B,CAAA"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, View } from 'react-native'
|
|
3
|
+
import { useStoreMap, useUnit } from 'effector-react'
|
|
4
|
+
|
|
5
|
+
import { HelpRequestOption } from './HelpRequestOption'
|
|
6
|
+
import { useChatModel } from '../../context/ChatBotModelContext'
|
|
7
|
+
import { ColorScheme } from '../../types/style.types'
|
|
8
|
+
import { CONTROLS_COLORS_MAP } from '../../constants'
|
|
9
|
+
|
|
10
|
+
type AlternativesProps = {
|
|
11
|
+
onPressAlternative: (message: string, translatedMessage?: string) => void
|
|
12
|
+
hasMessages: boolean
|
|
13
|
+
isHintFeedback: boolean
|
|
14
|
+
colorScheme?: ColorScheme
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const Alternatives = ({
|
|
18
|
+
onPressAlternative,
|
|
19
|
+
hasMessages,
|
|
20
|
+
isHintFeedback,
|
|
21
|
+
colorScheme = ColorScheme.Blue,
|
|
22
|
+
}: AlternativesProps) => {
|
|
23
|
+
const model = useChatModel()
|
|
24
|
+
const isTranslated = useUnit(model.translation.$isTranslated)
|
|
25
|
+
const alternatives = useUnit(model.$alternatives)
|
|
26
|
+
const isTranslationPending = useUnit(model.translation.translateAllMessagesFx.pending)
|
|
27
|
+
const lastMessageOptions = useStoreMap(model.$currentChatData, ({ messages }) => {
|
|
28
|
+
const lastMessage = messages.at(-1)
|
|
29
|
+
return lastMessage?.options ?? []
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const options = (() => {
|
|
33
|
+
if (hasMessages) return lastMessageOptions
|
|
34
|
+
if (isHintFeedback) return alternatives?.options.hints ?? []
|
|
35
|
+
return alternatives?.options.default ?? []
|
|
36
|
+
})()
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<View style={styles.container}>
|
|
40
|
+
{options.map(({ text, translatedText }, index) => (
|
|
41
|
+
<HelpRequestOption
|
|
42
|
+
key={index}
|
|
43
|
+
onPress={() => onPressAlternative(text, translatedText)}
|
|
44
|
+
message={isTranslated ? (translatedText as string) : text}
|
|
45
|
+
disabled={isTranslationPending}
|
|
46
|
+
hoverColor={CONTROLS_COLORS_MAP[colorScheme].hover}
|
|
47
|
+
/>
|
|
48
|
+
))}
|
|
49
|
+
</View>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const styles = StyleSheet.create({
|
|
54
|
+
container: {
|
|
55
|
+
flex: 1,
|
|
56
|
+
width: 305,
|
|
57
|
+
marginVertical: 8,
|
|
58
|
+
gap: 8,
|
|
59
|
+
},
|
|
60
|
+
})
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { Animated, Pressable, StyleSheet } from 'react-native'
|
|
3
|
+
import { COLORS, FONT_FAMILY, SPACING } from '@magmamath/react-native-ui'
|
|
4
|
+
import { ArrowRightIcon } from '../../../../shared/icons/ArrowRightIcon'
|
|
5
|
+
|
|
6
|
+
type HelpRequestOptionProps = {
|
|
7
|
+
onPress: () => void
|
|
8
|
+
message: string
|
|
9
|
+
disabled: boolean
|
|
10
|
+
hoverColor?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const HelpRequestOption = ({
|
|
14
|
+
onPress,
|
|
15
|
+
message,
|
|
16
|
+
disabled = false,
|
|
17
|
+
hoverColor = COLORS.PRIMARY_BLUE,
|
|
18
|
+
}: HelpRequestOptionProps) => {
|
|
19
|
+
const [isHovered, setIsHovered] = useState(false)
|
|
20
|
+
const hoverAnim = useRef(new Animated.Value(0)).current
|
|
21
|
+
|
|
22
|
+
const backgroundColor = hoverAnim.interpolate({
|
|
23
|
+
inputRange: [0, 1],
|
|
24
|
+
outputRange: [COLORS.NEUTRAL_1, hoverColor],
|
|
25
|
+
})
|
|
26
|
+
const textColor = hoverAnim.interpolate({
|
|
27
|
+
inputRange: [0, 1],
|
|
28
|
+
outputRange: [COLORS.NEUTRAL_10, COLORS.NEUTRAL_1],
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
Animated.timing(hoverAnim, {
|
|
33
|
+
toValue: isHovered ? 1 : 0,
|
|
34
|
+
duration: 200,
|
|
35
|
+
useNativeDriver: false,
|
|
36
|
+
}).start()
|
|
37
|
+
}, [isHovered, hoverAnim])
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Pressable
|
|
41
|
+
onHoverIn={() => setIsHovered(true)}
|
|
42
|
+
onHoverOut={() => setIsHovered(false)}
|
|
43
|
+
onPress={onPress}
|
|
44
|
+
style={styles.button}
|
|
45
|
+
disabled={disabled}
|
|
46
|
+
accessibilityState={{ disabled }}
|
|
47
|
+
accessibilityRole="button"
|
|
48
|
+
>
|
|
49
|
+
<Animated.View
|
|
50
|
+
style={[styles.textWrapper, { backgroundColor, borderColor: backgroundColor }]}
|
|
51
|
+
>
|
|
52
|
+
<Animated.Text numberOfLines={1} style={[styles.text, { color: textColor }]}>
|
|
53
|
+
{message}
|
|
54
|
+
</Animated.Text>
|
|
55
|
+
<ArrowRightIcon color={isHovered ? COLORS.NEUTRAL_1 : COLORS.NEUTRAL_10} />
|
|
56
|
+
</Animated.View>
|
|
57
|
+
</Pressable>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const styles = StyleSheet.create({
|
|
62
|
+
button: {
|
|
63
|
+
flexDirection: 'row',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'space-between',
|
|
66
|
+
width: '100%',
|
|
67
|
+
},
|
|
68
|
+
text: {
|
|
69
|
+
fontSize: 20,
|
|
70
|
+
fontWeight: 400,
|
|
71
|
+
fontFamily: FONT_FAMILY.buenosAires,
|
|
72
|
+
color: COLORS.NEUTRAL_10,
|
|
73
|
+
},
|
|
74
|
+
textWrapper: {
|
|
75
|
+
flex: 1,
|
|
76
|
+
flexDirection: 'row',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
justifyContent: 'space-between',
|
|
79
|
+
maxWidth: 305,
|
|
80
|
+
paddingHorizontal: SPACING[400],
|
|
81
|
+
paddingVertical: SPACING[200],
|
|
82
|
+
borderWidth: 1,
|
|
83
|
+
borderRadius: 48,
|
|
84
|
+
elevation: 3,
|
|
85
|
+
shadowColor: '#333',
|
|
86
|
+
shadowOffset: { width: 0, height: 1 },
|
|
87
|
+
shadowOpacity: 0.25,
|
|
88
|
+
shadowRadius: 3,
|
|
89
|
+
backgroundColor: COLORS.NEUTRAL_1,
|
|
90
|
+
},
|
|
91
|
+
})
|
|
@@ -6,7 +6,6 @@ import { ChatbotIcon } from '../../../../shared/icons/ChatbotIcon'
|
|
|
6
6
|
import { ThreeDotsLoader } from '../ThreeDotsLoader/ThreeDotsLoader'
|
|
7
7
|
import { CONTROLS_COLORS_MAP } from '../../constants'
|
|
8
8
|
import { ColorScheme } from '../../types/style.types'
|
|
9
|
-
import { LavaIconInGlasses } from '@magmamath/students-features'
|
|
10
9
|
|
|
11
10
|
type MessageLoaderProps = {
|
|
12
11
|
colorScheme?: ColorScheme
|
|
@@ -15,7 +14,7 @@ type MessageLoaderProps = {
|
|
|
15
14
|
export const MessageLoader = ({ colorScheme = ColorScheme.Blue }: MessageLoaderProps) => (
|
|
16
15
|
<View style={styles.container}>
|
|
17
16
|
<View style={styles.icon}>
|
|
18
|
-
<
|
|
17
|
+
<ChatbotIcon width={60} height={80} />
|
|
19
18
|
</View>
|
|
20
19
|
<View style={styles.loader}>
|
|
21
20
|
<ThreeDotsLoader backgroundColor={CONTROLS_COLORS_MAP[colorScheme].background} />
|
|
@@ -28,13 +27,10 @@ const styles = StyleSheet.create({
|
|
|
28
27
|
flexDirection: 'row',
|
|
29
28
|
width: 327,
|
|
30
29
|
alignItems: 'flex-end',
|
|
31
|
-
paddingLeft:70
|
|
32
30
|
},
|
|
33
31
|
icon: {
|
|
34
|
-
position: 'absolute',
|
|
35
|
-
zIndex:1,
|
|
36
32
|
alignSelf: 'flex-end',
|
|
37
|
-
|
|
33
|
+
marginRight: 8,
|
|
38
34
|
},
|
|
39
35
|
loader: {
|
|
40
36
|
flex: 1,
|
|
@@ -5,16 +5,14 @@ import { useStoreMap, useUnit } from 'effector-react'
|
|
|
5
5
|
import { ChatbotModel } from '../../model/ChatBotModel'
|
|
6
6
|
import { ChatMessage } from '../ChatMessage/ChatMessage'
|
|
7
7
|
import { MessageLoader } from '../ChatMessage/MessageLoader'
|
|
8
|
-
import {
|
|
8
|
+
import { Alternatives } from '../Alternatives/Alternatives'
|
|
9
9
|
import { MessageVariant } from '../../types/model.types'
|
|
10
10
|
import { ColorScheme } from '../../types/style.types'
|
|
11
|
-
import { ChatInputMode } from '../../types/units.types'
|
|
12
11
|
|
|
13
12
|
type ChatbotMessagesProps = {
|
|
14
13
|
model: ChatbotModel
|
|
15
14
|
isHintFeedback: boolean
|
|
16
15
|
isTextToSpeechEnabled: boolean
|
|
17
|
-
inputMode: ChatInputMode
|
|
18
16
|
colorScheme?: ColorScheme
|
|
19
17
|
}
|
|
20
18
|
|
|
@@ -24,11 +22,10 @@ const BOTTOM_OFFSET = Platform.select({
|
|
|
24
22
|
default: 294,
|
|
25
23
|
})
|
|
26
24
|
|
|
27
|
-
export const
|
|
25
|
+
export const ChatbotMessages = ({
|
|
28
26
|
model,
|
|
29
27
|
isHintFeedback,
|
|
30
28
|
isTextToSpeechEnabled,
|
|
31
|
-
inputMode,
|
|
32
29
|
colorScheme = ColorScheme.Blue,
|
|
33
30
|
}: ChatbotMessagesProps) => {
|
|
34
31
|
const dimensions = useWindowDimensions()
|
|
@@ -48,8 +45,8 @@ export const Chat = ({
|
|
|
48
45
|
|
|
49
46
|
const MAX_HEIGHT = dimensions.height - TOOLBAR_HEIGHT - BOTTOM_OFFSET
|
|
50
47
|
|
|
51
|
-
const askChatForHelp = (message: string, translatedMessage?: string
|
|
52
|
-
void model.sendHelpRequestFx({ message, translatedMessage
|
|
48
|
+
const askChatForHelp = (message: string, translatedMessage?: string) => {
|
|
49
|
+
void model.sendHelpRequestFx({ message, translatedMessage })
|
|
53
50
|
}
|
|
54
51
|
|
|
55
52
|
return (
|
|
@@ -91,13 +88,12 @@ export const Chat = ({
|
|
|
91
88
|
</View>
|
|
92
89
|
)}
|
|
93
90
|
|
|
94
|
-
{isOpen && (
|
|
95
|
-
<
|
|
91
|
+
{!isHelpRequestPending && isOpen && (
|
|
92
|
+
<Alternatives
|
|
96
93
|
onPressAlternative={askChatForHelp}
|
|
97
94
|
hasMessages={messages.length > 1}
|
|
98
95
|
isHintFeedback={isHintFeedback}
|
|
99
96
|
colorScheme={colorScheme}
|
|
100
|
-
inputMode={inputMode}
|
|
101
97
|
/>
|
|
102
98
|
)}
|
|
103
99
|
</ScrollView>
|
|
@@ -2,13 +2,11 @@ import React, { ComponentType, PropsWithChildren } from 'react'
|
|
|
2
2
|
import { useStoreMap, useUnit } from 'effector-react'
|
|
3
3
|
|
|
4
4
|
import { ChatbotModel } from '../model/ChatBotModel'
|
|
5
|
-
import {
|
|
5
|
+
import { ChatbotMessages } from './ChatMessages/ChatbotMessages'
|
|
6
6
|
import { ChatControls } from './ChatControls/ChatControls'
|
|
7
7
|
import { AUDIO_CONFIG, DEFAULT_VOICE } from '../constants'
|
|
8
8
|
import { ChatBotModelContext } from '../context/ChatBotModelContext'
|
|
9
9
|
import { ColorScheme } from '../types/style.types'
|
|
10
|
-
import { ChatInputMode } from '../types/units.types'
|
|
11
|
-
import { IS_MOBILE } from '@magmamath/react-native-ui'
|
|
12
10
|
|
|
13
11
|
type ChatbotProps = {
|
|
14
12
|
model: ChatbotModel
|
|
@@ -18,7 +16,6 @@ type ChatbotProps = {
|
|
|
18
16
|
voice: typeof DEFAULT_VOICE
|
|
19
17
|
audioConfig: typeof AUDIO_CONFIG
|
|
20
18
|
}
|
|
21
|
-
inputMode?: ChatInputMode
|
|
22
19
|
ButtonWrapper: ComponentType<PropsWithChildren>
|
|
23
20
|
iconSize?: { width: number; height: number } // TODO: use number instead
|
|
24
21
|
colorScheme?: ColorScheme
|
|
@@ -46,12 +43,11 @@ export const Chatbot = ({
|
|
|
46
43
|
|
|
47
44
|
return (
|
|
48
45
|
<ChatBotModelContext.Provider value={model}>
|
|
49
|
-
<
|
|
46
|
+
<ChatbotMessages
|
|
50
47
|
model={model}
|
|
51
48
|
colorScheme={colorScheme}
|
|
52
49
|
isHintFeedback={isHintFeedback}
|
|
53
50
|
isTextToSpeechEnabled={isTextToSpeechEnabled}
|
|
54
|
-
inputMode={alternatives?.isOpenChatEnabled ? ChatInputMode.FreeText : ChatInputMode.Option}
|
|
55
51
|
/>
|
|
56
52
|
|
|
57
53
|
<ChatControls
|
|
@@ -2,7 +2,6 @@ import { ButtonColor, COLORS } from '@magmamath/react-native-ui'
|
|
|
2
2
|
import { Platform } from 'react-native'
|
|
3
3
|
import { MessageVariant } from './types/model.types'
|
|
4
4
|
import { ColorScheme } from './types/style.types'
|
|
5
|
-
import { ANIMATION_DURATION } from '../gifCelebrations/constants'
|
|
6
5
|
|
|
7
6
|
export const AUDIO_CONFIG = {
|
|
8
7
|
audioEncoding: 'LINEAR16',
|
|
@@ -45,24 +44,20 @@ export const MESSAGE_COLORS_MAP = {
|
|
|
45
44
|
[ColorScheme.Blue]: {
|
|
46
45
|
[MessageVariant.RECEIVED]: {
|
|
47
46
|
background: COLORS.NEUTRAL_3,
|
|
48
|
-
border: COLORS.NEUTRAL_3,
|
|
49
47
|
icon: ButtonColor.BLUE,
|
|
50
48
|
},
|
|
51
49
|
[MessageVariant.SENT]: {
|
|
52
50
|
background: COLORS.PRIMARY_BLUE,
|
|
53
|
-
border: COLORS.PRIMARY_BLUE,
|
|
54
51
|
icon: ButtonColor.BLUE,
|
|
55
52
|
},
|
|
56
53
|
},
|
|
57
54
|
[ColorScheme.Yellow]: {
|
|
58
55
|
[MessageVariant.RECEIVED]: {
|
|
59
56
|
background: COLORS.NEUTRAL_3,
|
|
60
|
-
border: COLORS.NEUTRAL_3,
|
|
61
57
|
icon: ButtonColor.YELLOW,
|
|
62
58
|
},
|
|
63
59
|
[MessageVariant.SENT]: {
|
|
64
60
|
background: COLORS.PRIMARY_YELLOW,
|
|
65
|
-
border: COLORS.PRIMARY_YELLOW,
|
|
66
61
|
icon: ButtonColor.YELLOW,
|
|
67
62
|
},
|
|
68
63
|
},
|
|
@@ -78,5 +73,3 @@ export const CONTROLS_COLORS_MAP = {
|
|
|
78
73
|
background: COLORS.PRIMARY_YELLOW,
|
|
79
74
|
},
|
|
80
75
|
}
|
|
81
|
-
|
|
82
|
-
export const HOVER_ANIMATION_DURATION = 200
|
|
@@ -9,7 +9,5 @@ export {
|
|
|
9
9
|
export type { PostMessageResponse } from './types/api.types'
|
|
10
10
|
export { DefaultMessagesCreator } from './model/DefaultMessageCreator'
|
|
11
11
|
export type { ChatAnswer } from './types/units.types'
|
|
12
|
-
export { ChatInputMode } from './types/units.types'
|
|
13
|
-
|
|
14
12
|
export type { ConversationMessage } from './types/units.types'
|
|
15
13
|
export { ColorScheme } from './types/style.types'
|
|
@@ -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
|
}
|