@magmamath/students-features 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js +60 -0
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js +96 -0
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js +97 -0
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/ChatMessage.js +27 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js +56 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.js +88 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js +87 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/SentMessage.js +43 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/SentMessage.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js +130 -0
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/Chatbot.js +69 -0
- package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.js +65 -0
- package/dist/commonjs/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.js.map +1 -0
- package/dist/commonjs/features/chatbot/constants.js +31 -0
- package/dist/commonjs/features/chatbot/constants.js.map +1 -0
- package/dist/commonjs/features/chatbot/helpers.js +12 -0
- package/dist/commonjs/features/chatbot/helpers.js.map +1 -0
- package/dist/commonjs/features/chatbot/index.js +34 -0
- package/dist/commonjs/features/chatbot/index.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/api.js +18 -0
- package/dist/commonjs/features/chatbot/model/api.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/model.js +244 -0
- package/dist/commonjs/features/chatbot/model/model.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/t2s.js +104 -0
- package/dist/commonjs/features/chatbot/model/t2s.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/translation.js +203 -0
- package/dist/commonjs/features/chatbot/model/translation.js.map +1 -0
- package/dist/commonjs/features/chatbot/types/api.types.js +2 -0
- package/dist/commonjs/features/chatbot/types/api.types.js.map +1 -0
- package/dist/commonjs/features/chatbot/types/model.types.js +12 -0
- package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -0
- package/dist/commonjs/features/chatbot/types/t2s.types.js +13 -0
- package/dist/commonjs/features/chatbot/types/t2s.types.js.map +1 -0
- package/dist/commonjs/features/chatbot/types/translation.types.js +6 -0
- package/dist/commonjs/features/chatbot/types/translation.types.js.map +1 -0
- package/dist/commonjs/index.js +42 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/lib/createFeature/createFeature.js +28 -0
- package/dist/commonjs/lib/createFeature/createFeature.js.map +1 -0
- package/dist/commonjs/lib/effector/createControllerEffect.js +51 -0
- package/dist/commonjs/lib/effector/createControllerEffect.js.map +1 -0
- package/dist/commonjs/lib/effector/createEntityFieldStore.js +42 -0
- package/dist/commonjs/lib/effector/createEntityFieldStore.js.map +1 -0
- package/dist/commonjs/lib/effector/index.js +20 -0
- package/dist/commonjs/lib/effector/index.js.map +1 -0
- package/dist/commonjs/lib/helpers/helpers.js +9 -0
- package/dist/commonjs/lib/helpers/helpers.js.map +1 -0
- package/dist/commonjs/lib/localization/en.json +2 -0
- package/dist/commonjs/lib/localization/gb.json +2 -0
- package/dist/commonjs/lib/localization/sw.json +2 -0
- package/dist/commonjs/shared/hooks/useDebounce.js +21 -0
- package/dist/commonjs/shared/hooks/useDebounce.js.map +1 -0
- package/dist/commonjs/shared/icons/ArrowRightIcon.js +30 -0
- package/dist/commonjs/shared/icons/ArrowRightIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/ChatbotIcon.js +148 -0
- package/dist/commonjs/shared/icons/ChatbotIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/CloseIcon.js +28 -0
- package/dist/commonjs/shared/icons/CloseIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/GlobeIcon.js +30 -0
- package/dist/commonjs/shared/icons/GlobeIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/PauseIcon.js +32 -0
- package/dist/commonjs/shared/icons/PauseIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/PlayIcon.js +32 -0
- package/dist/commonjs/shared/icons/PlayIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/SpeakerIcon.js +37 -0
- package/dist/commonjs/shared/icons/SpeakerIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/icon.types.js +2 -0
- package/dist/commonjs/shared/icons/icon.types.js.map +1 -0
- package/dist/commonjs/shared/translation/constants.js +17 -0
- package/dist/commonjs/shared/translation/constants.js.map +1 -0
- package/dist/commonjs/shared/translation/helpers.js +31 -0
- package/dist/commonjs/shared/translation/helpers.js.map +1 -0
- package/dist/commonjs/shared/translation/hooks.js +28 -0
- package/dist/commonjs/shared/translation/hooks.js.map +1 -0
- package/dist/commonjs/shared/translation/index.js +52 -0
- package/dist/commonjs/shared/translation/index.js.map +1 -0
- package/dist/commonjs/shared/translation/model.js +15 -0
- package/dist/commonjs/shared/translation/model.js.map +1 -0
- package/dist/commonjs/shared/translation/types.js +13 -0
- package/dist/commonjs/shared/translation/types.js.map +1 -0
- package/dist/commonjs/types/types.d.js +2 -0
- package/dist/commonjs/types/types.d.js.map +1 -0
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js +54 -0
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js.map +1 -0
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js +90 -0
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js +91 -0
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatMessage/ChatMessage.js +21 -0
- package/dist/module/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js +50 -0
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.js +82 -0
- package/dist/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js +81 -0
- package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatMessage/SentMessage.js +37 -0
- package/dist/module/features/chatbot/components/ChatMessage/SentMessage.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js +123 -0
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -0
- package/dist/module/features/chatbot/components/Chatbot.js +63 -0
- package/dist/module/features/chatbot/components/Chatbot.js.map +1 -0
- package/dist/module/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.js +59 -0
- package/dist/module/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.js.map +1 -0
- package/dist/module/features/chatbot/constants.js +27 -0
- package/dist/module/features/chatbot/constants.js.map +1 -0
- package/dist/module/features/chatbot/helpers.js +7 -0
- package/dist/module/features/chatbot/helpers.js.map +1 -0
- package/dist/module/features/chatbot/index.js +7 -0
- package/dist/module/features/chatbot/index.js.map +1 -0
- package/dist/module/features/chatbot/model/api.js +13 -0
- package/dist/module/features/chatbot/model/api.js.map +1 -0
- package/dist/module/features/chatbot/model/model.js +239 -0
- package/dist/module/features/chatbot/model/model.js.map +1 -0
- package/dist/module/features/chatbot/model/t2s.js +99 -0
- package/dist/module/features/chatbot/model/t2s.js.map +1 -0
- package/dist/module/features/chatbot/model/translation.js +198 -0
- package/dist/module/features/chatbot/model/translation.js.map +1 -0
- package/dist/module/features/chatbot/types/api.types.js +2 -0
- package/dist/module/features/chatbot/types/api.types.js.map +1 -0
- package/dist/module/features/chatbot/types/model.types.js +8 -0
- package/dist/module/features/chatbot/types/model.types.js.map +1 -0
- package/dist/module/features/chatbot/types/t2s.types.js +9 -0
- package/dist/module/features/chatbot/types/t2s.types.js.map +1 -0
- package/dist/module/features/chatbot/types/translation.types.js +4 -0
- package/dist/module/features/chatbot/types/translation.types.js.map +1 -0
- package/dist/module/index.js +5 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/lib/createFeature/createFeature.js +22 -0
- package/dist/module/lib/createFeature/createFeature.js.map +1 -0
- package/dist/module/lib/effector/createControllerEffect.js +45 -0
- package/dist/module/lib/effector/createControllerEffect.js.map +1 -0
- package/dist/module/lib/effector/createEntityFieldStore.js +38 -0
- package/dist/module/lib/effector/createEntityFieldStore.js.map +1 -0
- package/dist/module/lib/effector/index.js +5 -0
- package/dist/module/lib/effector/index.js.map +1 -0
- package/dist/module/lib/helpers/helpers.js +4 -0
- package/dist/module/lib/helpers/helpers.js.map +1 -0
- package/dist/module/lib/localization/en.json +2 -0
- package/dist/module/lib/localization/gb.json +2 -0
- package/dist/module/lib/localization/sw.json +2 -0
- package/dist/module/shared/hooks/useDebounce.js +16 -0
- package/dist/module/shared/hooks/useDebounce.js.map +1 -0
- package/dist/module/shared/icons/ArrowRightIcon.js +22 -0
- package/dist/module/shared/icons/ArrowRightIcon.js.map +1 -0
- package/dist/module/shared/icons/ChatbotIcon.js +140 -0
- package/dist/module/shared/icons/ChatbotIcon.js.map +1 -0
- package/dist/module/shared/icons/CloseIcon.js +20 -0
- package/dist/module/shared/icons/CloseIcon.js.map +1 -0
- package/dist/module/shared/icons/GlobeIcon.js +22 -0
- package/dist/module/shared/icons/GlobeIcon.js.map +1 -0
- package/dist/module/shared/icons/PauseIcon.js +24 -0
- package/dist/module/shared/icons/PauseIcon.js.map +1 -0
- package/dist/module/shared/icons/PlayIcon.js +24 -0
- package/dist/module/shared/icons/PlayIcon.js.map +1 -0
- package/dist/module/shared/icons/SpeakerIcon.js +29 -0
- package/dist/module/shared/icons/SpeakerIcon.js.map +1 -0
- package/dist/module/shared/icons/icon.types.js +2 -0
- package/dist/module/shared/icons/icon.types.js.map +1 -0
- package/dist/module/shared/translation/constants.js +12 -0
- package/dist/module/shared/translation/constants.js.map +1 -0
- package/dist/module/shared/translation/helpers.js +24 -0
- package/dist/module/shared/translation/helpers.js.map +1 -0
- package/dist/module/shared/translation/hooks.js +22 -0
- package/dist/module/shared/translation/hooks.js.map +1 -0
- package/dist/module/shared/translation/index.js +7 -0
- package/dist/module/shared/translation/index.js.map +1 -0
- package/dist/module/shared/translation/model.js +11 -0
- package/dist/module/shared/translation/model.js.map +1 -0
- package/dist/module/shared/translation/types.js +9 -0
- package/dist/module/shared/translation/types.js.map +1 -0
- package/dist/module/types/types.d.js +2 -0
- package/dist/module/types/types.d.js.map +1 -0
- 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 +9 -0
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts +14 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts +17 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageLoader.d.ts +3 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts +12 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +4 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/SentMessage.d.ts +4 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/SentMessage.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts +21 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts +25 -0
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.d.ts +9 -0
- package/dist/typescript/commonjs/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts +21 -0
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/helpers.d.ts +2 -0
- package/dist/typescript/commonjs/features/chatbot/helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/index.d.ts +5 -0
- package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/model/api.d.ts +12 -0
- package/dist/typescript/commonjs/features/chatbot/model/api.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/model/model.d.ts +73 -0
- package/dist/typescript/commonjs/features/chatbot/model/model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts +18 -0
- package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts +22 -0
- package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +60 -0
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +64 -0
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/types/t2s.types.d.ts +22 -0
- package/dist/typescript/commonjs/features/chatbot/types/t2s.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts +23 -0
- package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/index.d.ts +4 -0
- package/dist/typescript/commonjs/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/createFeature/createFeature.d.ts +7 -0
- package/dist/typescript/commonjs/lib/createFeature/createFeature.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/effector/createControllerEffect.d.ts +16 -0
- package/dist/typescript/commonjs/lib/effector/createControllerEffect.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/effector/createEntityFieldStore.d.ts +16 -0
- package/dist/typescript/commonjs/lib/effector/createEntityFieldStore.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/effector/index.d.ts +3 -0
- package/dist/typescript/commonjs/lib/effector/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/helpers/helpers.d.ts +2 -0
- package/dist/typescript/commonjs/lib/helpers/helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/package.json +1 -0
- package/dist/typescript/commonjs/shared/hooks/useDebounce.d.ts +2 -0
- package/dist/typescript/commonjs/shared/hooks/useDebounce.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/ArrowRightIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/ArrowRightIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/ChatbotIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/ChatbotIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/CloseIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/CloseIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/GlobeIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/GlobeIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/PauseIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/PauseIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/PlayIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/PlayIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/SpeakerIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/SpeakerIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/icon.types.d.ts +9 -0
- package/dist/typescript/commonjs/shared/icons/icon.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/translation/constants.d.ts +6 -0
- package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/translation/helpers.d.ts +6 -0
- package/dist/typescript/commonjs/shared/translation/helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/translation/hooks.d.ts +5 -0
- package/dist/typescript/commonjs/shared/translation/hooks.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/translation/index.d.ts +6 -0
- package/dist/typescript/commonjs/shared/translation/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/translation/model.d.ts +5 -0
- package/dist/typescript/commonjs/shared/translation/model.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/translation/types.d.ts +8 -0
- package/dist/typescript/commonjs/shared/translation/types.d.ts.map +1 -0
- 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 +9 -0
- package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts +14 -0
- package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts +17 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageLoader.d.ts +3 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts +12 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +4 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/SentMessage.d.ts +4 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/SentMessage.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts +21 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts +25 -0
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.d.ts +9 -0
- package/dist/typescript/module/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/constants.d.ts +21 -0
- package/dist/typescript/module/features/chatbot/constants.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/helpers.d.ts +2 -0
- package/dist/typescript/module/features/chatbot/helpers.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/index.d.ts +5 -0
- package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/model/api.d.ts +12 -0
- package/dist/typescript/module/features/chatbot/model/api.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/model/model.d.ts +73 -0
- package/dist/typescript/module/features/chatbot/model/model.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/model/t2s.d.ts +18 -0
- package/dist/typescript/module/features/chatbot/model/t2s.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/model/translation.d.ts +22 -0
- package/dist/typescript/module/features/chatbot/model/translation.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts +60 -0
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts +64 -0
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/types/t2s.types.d.ts +22 -0
- package/dist/typescript/module/features/chatbot/types/t2s.types.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/types/translation.types.d.ts +23 -0
- package/dist/typescript/module/features/chatbot/types/translation.types.d.ts.map +1 -0
- package/dist/typescript/module/index.d.ts +4 -0
- package/dist/typescript/module/index.d.ts.map +1 -0
- package/dist/typescript/module/lib/createFeature/createFeature.d.ts +7 -0
- package/dist/typescript/module/lib/createFeature/createFeature.d.ts.map +1 -0
- package/dist/typescript/module/lib/effector/createControllerEffect.d.ts +16 -0
- package/dist/typescript/module/lib/effector/createControllerEffect.d.ts.map +1 -0
- package/dist/typescript/module/lib/effector/createEntityFieldStore.d.ts +16 -0
- package/dist/typescript/module/lib/effector/createEntityFieldStore.d.ts.map +1 -0
- package/dist/typescript/module/lib/effector/index.d.ts +3 -0
- package/dist/typescript/module/lib/effector/index.d.ts.map +1 -0
- package/dist/typescript/module/lib/helpers/helpers.d.ts +2 -0
- package/dist/typescript/module/lib/helpers/helpers.d.ts.map +1 -0
- package/dist/typescript/module/package.json +1 -0
- package/dist/typescript/module/shared/hooks/useDebounce.d.ts +2 -0
- package/dist/typescript/module/shared/hooks/useDebounce.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/ArrowRightIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/ArrowRightIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/ChatbotIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/ChatbotIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/CloseIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/CloseIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/GlobeIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/GlobeIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/PauseIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/PauseIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/PlayIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/PlayIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/SpeakerIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/SpeakerIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/icon.types.d.ts +9 -0
- package/dist/typescript/module/shared/icons/icon.types.d.ts.map +1 -0
- package/dist/typescript/module/shared/translation/constants.d.ts +6 -0
- package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -0
- package/dist/typescript/module/shared/translation/helpers.d.ts +6 -0
- package/dist/typescript/module/shared/translation/helpers.d.ts.map +1 -0
- package/dist/typescript/module/shared/translation/hooks.d.ts +5 -0
- package/dist/typescript/module/shared/translation/hooks.d.ts.map +1 -0
- package/dist/typescript/module/shared/translation/index.d.ts +6 -0
- package/dist/typescript/module/shared/translation/index.d.ts.map +1 -0
- package/dist/typescript/module/shared/translation/model.d.ts +5 -0
- package/dist/typescript/module/shared/translation/model.d.ts.map +1 -0
- package/dist/typescript/module/shared/translation/types.d.ts +8 -0
- package/dist/typescript/module/shared/translation/types.d.ts.map +1 -0
- package/package.json +73 -0
- package/src/features/chatbot/components/Alternatives/Alternatives.tsx +64 -0
- package/src/features/chatbot/components/Alternatives/HelpRequestOption.tsx +92 -0
- package/src/features/chatbot/components/ChatControls/ChatControls.tsx +103 -0
- package/src/features/chatbot/components/ChatMessage/ChatMessage.tsx +28 -0
- package/src/features/chatbot/components/ChatMessage/MessageLoader.tsx +42 -0
- package/src/features/chatbot/components/ChatMessage/MessageTextToSpeech.tsx +78 -0
- package/src/features/chatbot/components/ChatMessage/ReceivedMessage.tsx +73 -0
- package/src/features/chatbot/components/ChatMessage/SentMessage.tsx +31 -0
- package/src/features/chatbot/components/ChatMessages/ChatbotMessages.tsx +148 -0
- package/src/features/chatbot/components/Chatbot.tsx +92 -0
- package/src/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.tsx +77 -0
- package/src/features/chatbot/constants.ts +30 -0
- package/src/features/chatbot/helpers.ts +4 -0
- package/src/features/chatbot/index.ts +4 -0
- package/src/features/chatbot/model/api.ts +28 -0
- package/src/features/chatbot/model/model.ts +277 -0
- package/src/features/chatbot/model/t2s.ts +107 -0
- package/src/features/chatbot/model/translation.ts +231 -0
- package/src/features/chatbot/types/api.types.ts +59 -0
- package/src/features/chatbot/types/model.types.ts +73 -0
- package/src/features/chatbot/types/t2s.types.ts +24 -0
- package/src/features/chatbot/types/translation.types.ts +23 -0
- package/src/index.ts +3 -0
- package/src/lib/createFeature/createFeature.tsx +21 -0
- package/src/lib/effector/createControllerEffect.ts +66 -0
- package/src/lib/effector/createEntityFieldStore.ts +43 -0
- package/src/lib/effector/index.ts +2 -0
- package/src/lib/helpers/helpers.ts +2 -0
- package/src/lib/localization/en.json +2 -0
- package/src/lib/localization/gb.json +2 -0
- package/src/lib/localization/sw.json +2 -0
- package/src/shared/hooks/useDebounce.ts +17 -0
- package/src/shared/icons/ArrowRightIcon.tsx +14 -0
- package/src/shared/icons/ChatbotIcon.tsx +109 -0
- package/src/shared/icons/CloseIcon.tsx +12 -0
- package/src/shared/icons/GlobeIcon.tsx +14 -0
- package/src/shared/icons/PauseIcon.tsx +16 -0
- package/src/shared/icons/PlayIcon.tsx +16 -0
- package/src/shared/icons/SpeakerIcon.tsx +22 -0
- package/src/shared/icons/icon.types.ts +8 -0
- package/src/shared/translation/constants.ts +10 -0
- package/src/shared/translation/helpers.ts +34 -0
- package/src/shared/translation/hooks.ts +28 -0
- package/src/shared/translation/index.ts +5 -0
- package/src/shared/translation/model.ts +15 -0
- package/src/shared/translation/types.ts +9 -0
- package/src/types/types.d.ts +4 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { useEffect, useRef, useState } from 'react'
|
|
3
|
+
import { Animated, Platform, Pressable, StyleSheet } from 'react-native'
|
|
4
|
+
import { ArrowRightIcon } from '../../../../shared/icons/ArrowRightIcon'
|
|
5
|
+
|
|
6
|
+
const transitionColor = (isHovered: boolean, value: Animated.Value) =>
|
|
7
|
+
Animated.timing(value, {
|
|
8
|
+
toValue: isHovered ? 1 : 0,
|
|
9
|
+
duration: 200,
|
|
10
|
+
useNativeDriver: Platform.OS !== 'web',
|
|
11
|
+
}).start()
|
|
12
|
+
|
|
13
|
+
type HelpRequestOptionProps = {
|
|
14
|
+
onPress: () => void
|
|
15
|
+
message: string
|
|
16
|
+
disabled: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const HelpRequestOption = ({
|
|
20
|
+
onPress,
|
|
21
|
+
message,
|
|
22
|
+
disabled = false,
|
|
23
|
+
}: HelpRequestOptionProps) => {
|
|
24
|
+
const [isHovered, setIsHovered] = useState(false)
|
|
25
|
+
|
|
26
|
+
const backgroundColor = useRef(new Animated.Value(0)).current
|
|
27
|
+
const backgroundInterpolation = backgroundColor.interpolate({
|
|
28
|
+
inputRange: [0, 1],
|
|
29
|
+
outputRange: ['#FFFFFF', '#55ABE0'],
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const textColor = useRef(new Animated.Value(0)).current
|
|
33
|
+
const textInterpolation = textColor.interpolate({
|
|
34
|
+
inputRange: [0, 1],
|
|
35
|
+
outputRange: ['#33334D', '#FFFFFF'],
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
transitionColor(isHovered, backgroundColor)
|
|
40
|
+
transitionColor(isHovered, textColor)
|
|
41
|
+
}, [isHovered])
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Pressable
|
|
45
|
+
onHoverIn={() => setIsHovered(true)}
|
|
46
|
+
onHoverOut={() => setIsHovered(false)}
|
|
47
|
+
onPress={onPress}
|
|
48
|
+
style={styles.button}
|
|
49
|
+
disabled={disabled}
|
|
50
|
+
>
|
|
51
|
+
<Animated.View style={[styles.textWrapper, { backgroundColor: backgroundInterpolation }]}>
|
|
52
|
+
<Animated.Text numberOfLines={1} style={[styles.text, { color: textInterpolation }]}>
|
|
53
|
+
{message}
|
|
54
|
+
</Animated.Text>
|
|
55
|
+
<ArrowRightIcon color={isHovered ? '#FFFFFF' : '#33334D'} />
|
|
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: 'Buenos Aires',
|
|
72
|
+
color: '#33334D',
|
|
73
|
+
},
|
|
74
|
+
textWrapper: {
|
|
75
|
+
flex: 1,
|
|
76
|
+
flexDirection: 'row',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
justifyContent: 'space-between',
|
|
79
|
+
maxWidth: 305,
|
|
80
|
+
paddingHorizontal: 16,
|
|
81
|
+
paddingVertical: 8,
|
|
82
|
+
borderWidth: 1,
|
|
83
|
+
borderRadius: 48,
|
|
84
|
+
borderColor: '#55ABE0',
|
|
85
|
+
elevation: 3,
|
|
86
|
+
shadowColor: '#333',
|
|
87
|
+
shadowOffset: { width: 0, height: 1 },
|
|
88
|
+
shadowOpacity: 0.25,
|
|
89
|
+
shadowRadius: 3,
|
|
90
|
+
backgroundColor: '#FFFFFF',
|
|
91
|
+
},
|
|
92
|
+
})
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ComponentType, PropsWithChildren } from 'react'
|
|
3
|
+
import { ActivityIndicator, Pressable, StyleSheet, View } from 'react-native'
|
|
4
|
+
import { Button } from '@magmamath/react-native-ui'
|
|
5
|
+
import { useUnit } from 'effector-react'
|
|
6
|
+
import { ChatbotModel } from '../../model/model'
|
|
7
|
+
import { ChatbotIcon } from '../../../../shared/icons/ChatbotIcon'
|
|
8
|
+
import { GlobeIcon } from '../../../../shared/icons/GlobeIcon'
|
|
9
|
+
import { CloseIcon } from '../../../../shared/icons/CloseIcon'
|
|
10
|
+
|
|
11
|
+
type ChatControlsProps = {
|
|
12
|
+
model: ChatbotModel
|
|
13
|
+
onPressTranslate: () => void
|
|
14
|
+
onPressChatIcon: () => void
|
|
15
|
+
onPressClose: () => void
|
|
16
|
+
isTranslationEnabled: boolean
|
|
17
|
+
ButtonWrapper: ComponentType<PropsWithChildren>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const ChatControls = ({
|
|
21
|
+
model,
|
|
22
|
+
onPressTranslate,
|
|
23
|
+
onPressChatIcon,
|
|
24
|
+
onPressClose,
|
|
25
|
+
isTranslationEnabled,
|
|
26
|
+
ButtonWrapper,
|
|
27
|
+
}: ChatControlsProps) => {
|
|
28
|
+
const isOpen = useUnit(model.$isOpen)
|
|
29
|
+
const isTranslated = useUnit(model.translation.$isTranslated)
|
|
30
|
+
const isTranslationPending = useUnit(model.translation.translateBatchFx.pending)
|
|
31
|
+
const isHelpRequestPending = useUnit(model.sendHelpRequestFx.pending)
|
|
32
|
+
|
|
33
|
+
if (isOpen) {
|
|
34
|
+
const backgroundColor = isTranslated ? '#55ABE0' : '#FFF'
|
|
35
|
+
const fillColor = isTranslated ? '#FFF' : '#4D4D63'
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View style={styles.container}>
|
|
39
|
+
{isTranslationEnabled && (
|
|
40
|
+
<Pressable
|
|
41
|
+
onPress={onPressTranslate}
|
|
42
|
+
disabled={isHelpRequestPending || isTranslationPending}
|
|
43
|
+
style={[styles.buttonTranslate, { backgroundColor }]}
|
|
44
|
+
>
|
|
45
|
+
{isTranslationPending ? <ActivityIndicator /> : <GlobeIcon color={fillColor} />}
|
|
46
|
+
</Pressable>
|
|
47
|
+
)}
|
|
48
|
+
|
|
49
|
+
<Button
|
|
50
|
+
onPress={onPressClose}
|
|
51
|
+
style={{
|
|
52
|
+
container: styles.buttonClose,
|
|
53
|
+
button: {
|
|
54
|
+
backgroundColor: '#FFF',
|
|
55
|
+
},
|
|
56
|
+
}}
|
|
57
|
+
raiseLevel={5}
|
|
58
|
+
>
|
|
59
|
+
<CloseIcon />
|
|
60
|
+
</Button>
|
|
61
|
+
</View>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<View style={styles.container}>
|
|
67
|
+
<ButtonWrapper>
|
|
68
|
+
<Pressable onPress={onPressChatIcon}>
|
|
69
|
+
<ChatbotIcon />
|
|
70
|
+
</Pressable>
|
|
71
|
+
</ButtonWrapper>
|
|
72
|
+
</View>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const styles = StyleSheet.create({
|
|
77
|
+
container: {
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
justifyContent: 'flex-end',
|
|
80
|
+
flexDirection: 'row',
|
|
81
|
+
height: 60,
|
|
82
|
+
gap: 8,
|
|
83
|
+
},
|
|
84
|
+
buttonClose: {
|
|
85
|
+
width: 50,
|
|
86
|
+
height: 50,
|
|
87
|
+
},
|
|
88
|
+
buttonTranslate: {
|
|
89
|
+
alignItems: 'center',
|
|
90
|
+
justifyContent: 'center',
|
|
91
|
+
width: 36,
|
|
92
|
+
height: 36,
|
|
93
|
+
borderRadius: 32,
|
|
94
|
+
borderWidth: 1,
|
|
95
|
+
borderColor: '#F2F2F4',
|
|
96
|
+
shadowColor: '#333333',
|
|
97
|
+
shadowOffset: { width: 0, height: 1 },
|
|
98
|
+
shadowOpacity: 0.25,
|
|
99
|
+
shadowRadius: 3,
|
|
100
|
+
elevation: 3,
|
|
101
|
+
backgroundColor: '#FFF',
|
|
102
|
+
},
|
|
103
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { ComponentType, ReactNode } from 'react'
|
|
2
|
+
import { ReceivedMessage } from './ReceivedMessage'
|
|
3
|
+
import { SentMessage } from './SentMessage'
|
|
4
|
+
import { AudioStatus } from '../../types/t2s.types'
|
|
5
|
+
import { MessageVariant, ChatbotRenderer } from '../../types/model.types'
|
|
6
|
+
|
|
7
|
+
type ChatMessageProps = {
|
|
8
|
+
variant: MessageVariant
|
|
9
|
+
message: string
|
|
10
|
+
onPressTextToSpeech: () => void
|
|
11
|
+
isTextToSpeechPending: boolean
|
|
12
|
+
isActive: boolean
|
|
13
|
+
withTextToSpeech?: boolean
|
|
14
|
+
audioStatus: AudioStatus
|
|
15
|
+
renderer?: (props: ChatbotRenderer) => ReactNode
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type VariantProps = Omit<ChatMessageProps, 'variant'>
|
|
19
|
+
|
|
20
|
+
const variantsMap: Record<MessageVariant, ComponentType<VariantProps>> = {
|
|
21
|
+
[MessageVariant.SENT]: SentMessage,
|
|
22
|
+
[MessageVariant.RECEIVED]: ReceivedMessage,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const ChatMessage = ({ variant, ...props }: ChatMessageProps) => {
|
|
26
|
+
const Component = variantsMap[variant]
|
|
27
|
+
return <Component {...props} />
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, View } from 'react-native'
|
|
3
|
+
import { ChatbotIcon } from '../../../../shared/icons/ChatbotIcon'
|
|
4
|
+
import { ThreeDotsLoader } from '../ThreeDotsLoader/ThreeDotsLoader'
|
|
5
|
+
|
|
6
|
+
export const MessageLoader = () => (
|
|
7
|
+
<View style={styles.container}>
|
|
8
|
+
<View style={styles.icon}>
|
|
9
|
+
<ChatbotIcon width={38} height={38} />
|
|
10
|
+
</View>
|
|
11
|
+
<View style={styles.loader}>
|
|
12
|
+
<ThreeDotsLoader />
|
|
13
|
+
</View>
|
|
14
|
+
</View>
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
const styles = StyleSheet.create({
|
|
18
|
+
container: {
|
|
19
|
+
flexDirection: 'row',
|
|
20
|
+
width: 305,
|
|
21
|
+
},
|
|
22
|
+
icon: {
|
|
23
|
+
alignSelf: 'flex-end',
|
|
24
|
+
marginRight: 8,
|
|
25
|
+
},
|
|
26
|
+
loader: {
|
|
27
|
+
flex: 1,
|
|
28
|
+
flexDirection: 'row',
|
|
29
|
+
alignItems: 'flex-start',
|
|
30
|
+
maxWidth: 70,
|
|
31
|
+
padding: 8,
|
|
32
|
+
paddingTop: 15,
|
|
33
|
+
shadowColor: '#333333',
|
|
34
|
+
shadowOffset: { width: 0, height: 1 },
|
|
35
|
+
shadowOpacity: 0.25,
|
|
36
|
+
shadowRadius: 3,
|
|
37
|
+
elevation: 3,
|
|
38
|
+
borderRadius: 8,
|
|
39
|
+
borderBottomLeftRadius: 0,
|
|
40
|
+
backgroundColor: '#F2F2F4',
|
|
41
|
+
},
|
|
42
|
+
})
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ActivityIndicator, Pressable, StyleSheet, TouchableOpacity } from 'react-native'
|
|
3
|
+
import { SpeakerIcon } from '../../../../shared/icons/SpeakerIcon'
|
|
4
|
+
import { PlayIcon } from '../../../../shared/icons/PlayIcon'
|
|
5
|
+
import { PauseIcon } from '../../../../shared/icons/PauseIcon'
|
|
6
|
+
import { AudioStatus } from '../../types/t2s.types'
|
|
7
|
+
|
|
8
|
+
type TextToSpeechIconProps = {
|
|
9
|
+
status: AudioStatus
|
|
10
|
+
isLoading: boolean
|
|
11
|
+
isActive: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const TextToSpeechIcon = ({ status, isActive, isLoading }: TextToSpeechIconProps) => {
|
|
15
|
+
if (isLoading && isActive) {
|
|
16
|
+
return <ActivityIndicator />
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!isActive) {
|
|
20
|
+
return <SpeakerIcon color={isActive ? '#55ABE0' : undefined} />
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (status === 'playing') return <PauseIcon color="#FFF" />
|
|
24
|
+
if (status === 'paused') return <PlayIcon color="#FFF" />
|
|
25
|
+
return <SpeakerIcon color={isActive ? '#55ABE0' : undefined} />
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type MessageTextToSpeechProps = {
|
|
29
|
+
status: AudioStatus
|
|
30
|
+
disabled: boolean
|
|
31
|
+
isActive: boolean
|
|
32
|
+
isLoading: boolean
|
|
33
|
+
onPress: () => void
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const MessageTextToSpeech = ({
|
|
37
|
+
status,
|
|
38
|
+
disabled,
|
|
39
|
+
isActive,
|
|
40
|
+
isLoading,
|
|
41
|
+
onPress,
|
|
42
|
+
}: MessageTextToSpeechProps) => (
|
|
43
|
+
<TouchableOpacity style={styles.container} onPress={onPress}>
|
|
44
|
+
<Pressable
|
|
45
|
+
disabled={disabled}
|
|
46
|
+
onPress={onPress}
|
|
47
|
+
style={[styles.button, { backgroundColor: isActive && !isLoading ? '#55ABE0' : '#FFF' }]}
|
|
48
|
+
>
|
|
49
|
+
<TextToSpeechIcon isActive={isActive} isLoading={isLoading} status={status} />
|
|
50
|
+
</Pressable>
|
|
51
|
+
</TouchableOpacity>
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
const styles = StyleSheet.create({
|
|
55
|
+
container: {
|
|
56
|
+
alignSelf: 'flex-end',
|
|
57
|
+
justifyContent: 'flex-end',
|
|
58
|
+
width: 45,
|
|
59
|
+
height: '100%',
|
|
60
|
+
},
|
|
61
|
+
button: {
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
justifyContent: 'center',
|
|
64
|
+
width: 28,
|
|
65
|
+
height: 28,
|
|
66
|
+
padding: 1,
|
|
67
|
+
marginLeft: 'auto',
|
|
68
|
+
shadowColor: '#333',
|
|
69
|
+
shadowOffset: { width: 0, height: 1 },
|
|
70
|
+
shadowOpacity: 0.25,
|
|
71
|
+
shadowRadius: 3,
|
|
72
|
+
elevation: 3,
|
|
73
|
+
borderRadius: 6,
|
|
74
|
+
borderColor: '#F2F2F4',
|
|
75
|
+
borderWidth: 0.5,
|
|
76
|
+
backgroundColor: '#FFF',
|
|
77
|
+
},
|
|
78
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native'
|
|
3
|
+
import { VariantProps } from './ChatMessage'
|
|
4
|
+
import { ChatbotIcon } from '../../../../shared/icons/ChatbotIcon'
|
|
5
|
+
import { MessageTextToSpeech } from './MessageTextToSpeech'
|
|
6
|
+
import { MessageVariant } from '../../types/model.types'
|
|
7
|
+
|
|
8
|
+
export const ReceivedMessage = ({
|
|
9
|
+
message,
|
|
10
|
+
onPressTextToSpeech,
|
|
11
|
+
isTextToSpeechPending,
|
|
12
|
+
isActive,
|
|
13
|
+
audioStatus,
|
|
14
|
+
renderer,
|
|
15
|
+
withTextToSpeech = true,
|
|
16
|
+
}: VariantProps) => (
|
|
17
|
+
<View style={styles.container}>
|
|
18
|
+
<View style={styles.icon}>
|
|
19
|
+
<ChatbotIcon width={38} height={38} />
|
|
20
|
+
</View>
|
|
21
|
+
|
|
22
|
+
<View style={styles.message}>
|
|
23
|
+
<Text style={[styles.messageText, { width: withTextToSpeech ? 240 : 305 }]}>
|
|
24
|
+
{renderer
|
|
25
|
+
? renderer({ message, variant: MessageVariant.RECEIVED, withTextToSpeech })
|
|
26
|
+
: message}
|
|
27
|
+
</Text>
|
|
28
|
+
{withTextToSpeech && (
|
|
29
|
+
<MessageTextToSpeech
|
|
30
|
+
isActive={isActive}
|
|
31
|
+
isLoading={isTextToSpeechPending}
|
|
32
|
+
onPress={onPressTextToSpeech}
|
|
33
|
+
disabled={isTextToSpeechPending}
|
|
34
|
+
status={audioStatus}
|
|
35
|
+
/>
|
|
36
|
+
)}
|
|
37
|
+
</View>
|
|
38
|
+
</View>
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
container: {
|
|
43
|
+
flex: 1,
|
|
44
|
+
flexDirection: 'row',
|
|
45
|
+
maxWidth: 350,
|
|
46
|
+
width: 350,
|
|
47
|
+
},
|
|
48
|
+
icon: {
|
|
49
|
+
alignSelf: 'flex-end',
|
|
50
|
+
marginRight: 8,
|
|
51
|
+
},
|
|
52
|
+
message: {
|
|
53
|
+
flex: 1,
|
|
54
|
+
flexDirection: 'row',
|
|
55
|
+
maxWidth: 305,
|
|
56
|
+
padding: 8,
|
|
57
|
+
shadowColor: '#333',
|
|
58
|
+
shadowOffset: { width: 0, height: 1 },
|
|
59
|
+
shadowOpacity: 0.25,
|
|
60
|
+
shadowRadius: 3,
|
|
61
|
+
elevation: 3,
|
|
62
|
+
borderRadius: 8,
|
|
63
|
+
borderBottomLeftRadius: 0,
|
|
64
|
+
backgroundColor: '#F2F2F4',
|
|
65
|
+
},
|
|
66
|
+
messageText: {
|
|
67
|
+
flex: 1,
|
|
68
|
+
fontSize: 20,
|
|
69
|
+
fontWeight: 400,
|
|
70
|
+
fontFamily: 'Buenos Aires',
|
|
71
|
+
color: '#33334D',
|
|
72
|
+
},
|
|
73
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native'
|
|
3
|
+
import { VariantProps } from './ChatMessage'
|
|
4
|
+
import { MessageVariant } from '../../types/model.types'
|
|
5
|
+
|
|
6
|
+
export const SentMessage = ({ message, renderer }: VariantProps) => (
|
|
7
|
+
<View style={styles.container}>
|
|
8
|
+
<Text style={styles.text}>
|
|
9
|
+
{renderer
|
|
10
|
+
? renderer({ message, variant: MessageVariant.SENT, withTextToSpeech: false })
|
|
11
|
+
: message}
|
|
12
|
+
</Text>
|
|
13
|
+
</View>
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
const styles = StyleSheet.create({
|
|
17
|
+
container: {
|
|
18
|
+
alignSelf: 'flex-end',
|
|
19
|
+
maxWidth: 305,
|
|
20
|
+
padding: 8,
|
|
21
|
+
borderRadius: 8,
|
|
22
|
+
borderBottomRightRadius: 0,
|
|
23
|
+
backgroundColor: '#55ABE0',
|
|
24
|
+
},
|
|
25
|
+
text: {
|
|
26
|
+
fontSize: 20,
|
|
27
|
+
fontWeight: 400,
|
|
28
|
+
fontFamily: 'Buenos Aires',
|
|
29
|
+
color: '#FFF',
|
|
30
|
+
},
|
|
31
|
+
})
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React, { ReactNode, useRef } from 'react'
|
|
2
|
+
import { Platform, ScrollView, StyleSheet, useWindowDimensions, View } from 'react-native'
|
|
3
|
+
import { useStoreMap, useUnit } from 'effector-react'
|
|
4
|
+
import { ChatbotModel } from '../../model/model'
|
|
5
|
+
import { ChatMessage } from '../ChatMessage/ChatMessage'
|
|
6
|
+
import { MessageLoader } from '../ChatMessage/MessageLoader'
|
|
7
|
+
import { Alternatives } from '../Alternatives/Alternatives'
|
|
8
|
+
import { PostMessagePayload } from '../../types/api.types'
|
|
9
|
+
import { AUDIO_CONFIG, DEFAULT_VOICE, TEXT_TO_SPEECH_CONFIG } from '../../constants'
|
|
10
|
+
import { MessageVariant, ChatbotRenderer } from '../../types/model.types'
|
|
11
|
+
|
|
12
|
+
type ChatbotMessagesProps = {
|
|
13
|
+
model: ChatbotModel
|
|
14
|
+
isHintFeedback: boolean
|
|
15
|
+
sendHelpRequestPayload: Omit<PostMessagePayload, 'type'>
|
|
16
|
+
translationTargetLanguage: string
|
|
17
|
+
sanitizeSpeechInput: (speech: string) => string
|
|
18
|
+
isTextToSpeechEnabled: boolean
|
|
19
|
+
textToSpeechConfig?: {
|
|
20
|
+
voice: typeof DEFAULT_VOICE
|
|
21
|
+
audioConfig: typeof AUDIO_CONFIG
|
|
22
|
+
}
|
|
23
|
+
renderer?: (props: ChatbotRenderer) => ReactNode
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const TOOLBAR_HEIGHT = 140
|
|
27
|
+
const BOTTOM_OFFSET = Platform.OS === 'web' ? 250 : 284
|
|
28
|
+
|
|
29
|
+
export const ChatbotMessages = ({
|
|
30
|
+
model,
|
|
31
|
+
isHintFeedback,
|
|
32
|
+
sendHelpRequestPayload,
|
|
33
|
+
translationTargetLanguage,
|
|
34
|
+
sanitizeSpeechInput,
|
|
35
|
+
isTextToSpeechEnabled,
|
|
36
|
+
textToSpeechConfig,
|
|
37
|
+
renderer,
|
|
38
|
+
}: ChatbotMessagesProps) => {
|
|
39
|
+
const dimensions = useWindowDimensions()
|
|
40
|
+
const ref = useRef<ScrollView>(null)
|
|
41
|
+
const assignmentId = useUnit(model.credits.$assignmentId)
|
|
42
|
+
const exerciseId = useUnit(model.credits.$exerciseId)
|
|
43
|
+
const isOpen = useUnit(model.$isOpen)
|
|
44
|
+
|
|
45
|
+
const isHelpRequestPending = useUnit(model.sendHelpRequestFx.pending)
|
|
46
|
+
const isTextToSpeechPending = useUnit(model.api.textToSpeechTextFx.pending)
|
|
47
|
+
|
|
48
|
+
const currentPlayingId = useUnit(model.t2s.$currentPlayingId)
|
|
49
|
+
const isTranslated = useUnit(model.translation.$isTranslated)
|
|
50
|
+
const audioStatus = useUnit(model.t2s.$status)
|
|
51
|
+
|
|
52
|
+
const MAX_HEIGHT = dimensions.height - TOOLBAR_HEIGHT - BOTTOM_OFFSET
|
|
53
|
+
|
|
54
|
+
const messages = useStoreMap({
|
|
55
|
+
store: model.messages.$state,
|
|
56
|
+
keys: [assignmentId, exerciseId],
|
|
57
|
+
fn: state => state[assignmentId]?.[exerciseId]?.messages ?? [],
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const playTextToSpeech = (id: string, message: string, translatedMessage?: string) => {
|
|
61
|
+
if (isTranslated) {
|
|
62
|
+
model.t2s.play({
|
|
63
|
+
text: sanitizeSpeechInput(translatedMessage as string),
|
|
64
|
+
messageId: id,
|
|
65
|
+
isTranslated: true,
|
|
66
|
+
config: textToSpeechConfig ?? TEXT_TO_SPEECH_CONFIG,
|
|
67
|
+
})
|
|
68
|
+
} else {
|
|
69
|
+
model.t2s.play({
|
|
70
|
+
text: sanitizeSpeechInput(message),
|
|
71
|
+
messageId: id,
|
|
72
|
+
isTranslated: false,
|
|
73
|
+
config: textToSpeechConfig ?? TEXT_TO_SPEECH_CONFIG,
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const askChatForHelp = (message: string, promptKey: string, translatedMessage?: string) => {
|
|
79
|
+
model.sendHelpRequestFx({
|
|
80
|
+
payload: { ...sendHelpRequestPayload, type: promptKey },
|
|
81
|
+
message,
|
|
82
|
+
translatedMessage,
|
|
83
|
+
translationTargetLanguage,
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<View style={[styles.container, { maxHeight: MAX_HEIGHT }]}>
|
|
89
|
+
<ScrollView
|
|
90
|
+
ref={ref}
|
|
91
|
+
contentContainerStyle={styles.list}
|
|
92
|
+
onContentSizeChange={(_, height) => {
|
|
93
|
+
ref.current?.scrollToEnd()
|
|
94
|
+
|
|
95
|
+
if (height >= MAX_HEIGHT) {
|
|
96
|
+
model.setScrollActive(true)
|
|
97
|
+
}
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
{isOpen && (
|
|
101
|
+
<View style={styles.gap}>
|
|
102
|
+
{messages.map(({ id, message, translatedMessage, isOwnMessage }) => (
|
|
103
|
+
<ChatMessage
|
|
104
|
+
key={id}
|
|
105
|
+
message={isTranslated ? (translatedMessage as string) : message}
|
|
106
|
+
renderer={renderer}
|
|
107
|
+
audioStatus={audioStatus}
|
|
108
|
+
onPressTextToSpeech={() => playTextToSpeech(id, message, translatedMessage)}
|
|
109
|
+
isActive={id === currentPlayingId}
|
|
110
|
+
isTextToSpeechPending={isTextToSpeechPending}
|
|
111
|
+
variant={isOwnMessage ? MessageVariant.SENT : MessageVariant.RECEIVED}
|
|
112
|
+
withTextToSpeech={isTextToSpeechEnabled && !isOwnMessage}
|
|
113
|
+
/>
|
|
114
|
+
))}
|
|
115
|
+
|
|
116
|
+
{isHelpRequestPending && <MessageLoader />}
|
|
117
|
+
</View>
|
|
118
|
+
)}
|
|
119
|
+
|
|
120
|
+
{!isHelpRequestPending && isOpen && (
|
|
121
|
+
<Alternatives
|
|
122
|
+
model={model}
|
|
123
|
+
onPressAlternative={askChatForHelp}
|
|
124
|
+
hasMessages={messages.length > 1}
|
|
125
|
+
isHintFeedback={isHintFeedback}
|
|
126
|
+
/>
|
|
127
|
+
)}
|
|
128
|
+
</ScrollView>
|
|
129
|
+
</View>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const styles = StyleSheet.create({
|
|
134
|
+
container: {
|
|
135
|
+
flex: 1,
|
|
136
|
+
alignItems: 'flex-end',
|
|
137
|
+
width: 350,
|
|
138
|
+
height: '100%',
|
|
139
|
+
},
|
|
140
|
+
list: {
|
|
141
|
+
alignItems: 'flex-end',
|
|
142
|
+
paddingVertical: 2,
|
|
143
|
+
},
|
|
144
|
+
gap: {
|
|
145
|
+
flex: 1,
|
|
146
|
+
gap: 8,
|
|
147
|
+
},
|
|
148
|
+
})
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ComponentType, PropsWithChildren, ReactNode, useEffect } from 'react'
|
|
2
|
+
import { useStoreMap, useUnit } from 'effector-react'
|
|
3
|
+
|
|
4
|
+
import { ChatbotModel } from '../model/model'
|
|
5
|
+
import { ChatbotMessages } from './ChatMessages/ChatbotMessages'
|
|
6
|
+
import { ChatControls } from './ChatControls/ChatControls'
|
|
7
|
+
import { PostMessagePayload } from '../types/api.types'
|
|
8
|
+
import { AUDIO_CONFIG, DEFAULT_VOICE } from '../constants'
|
|
9
|
+
import { ChatbotRenderer } from '../types/model.types'
|
|
10
|
+
import React from 'react'
|
|
11
|
+
|
|
12
|
+
type ChatbotProps = {
|
|
13
|
+
model: ChatbotModel
|
|
14
|
+
translationTargetLanguage: string
|
|
15
|
+
isEnabled: boolean
|
|
16
|
+
isHintFeedback: boolean
|
|
17
|
+
sendHelpRequestPayload: Omit<PostMessagePayload, 'type'>
|
|
18
|
+
sanitizeSpeechInput: (speech: string) => string
|
|
19
|
+
isTextToSpeechEnabled: boolean
|
|
20
|
+
isTranslationEnabled: boolean
|
|
21
|
+
textToSpeechConfig?: {
|
|
22
|
+
voice: typeof DEFAULT_VOICE
|
|
23
|
+
audioConfig: typeof AUDIO_CONFIG
|
|
24
|
+
}
|
|
25
|
+
ButtonWrapper: ComponentType<PropsWithChildren>
|
|
26
|
+
renderer?: (props: ChatbotRenderer) => ReactNode
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Chatbot = ({
|
|
30
|
+
model,
|
|
31
|
+
translationTargetLanguage,
|
|
32
|
+
isEnabled,
|
|
33
|
+
isHintFeedback,
|
|
34
|
+
sendHelpRequestPayload,
|
|
35
|
+
sanitizeSpeechInput,
|
|
36
|
+
isTextToSpeechEnabled = false,
|
|
37
|
+
textToSpeechConfig,
|
|
38
|
+
isTranslationEnabled,
|
|
39
|
+
renderer,
|
|
40
|
+
ButtonWrapper,
|
|
41
|
+
}: ChatbotProps) => {
|
|
42
|
+
const assignmentId = useUnit(model.credits.$assignmentId)
|
|
43
|
+
const exerciseId = useUnit(model.credits.$exerciseId)
|
|
44
|
+
const alternatives = useUnit(model.$alternatives)
|
|
45
|
+
|
|
46
|
+
const isAvailable = useStoreMap({
|
|
47
|
+
store: model.availableChats.$state,
|
|
48
|
+
keys: [assignmentId, exerciseId],
|
|
49
|
+
fn: (state) => !!state[assignmentId]?.[exerciseId]?.isAvailable,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const translateMessages = () => {
|
|
53
|
+
model.translation.translateBatchFx({
|
|
54
|
+
targetLanguage: translationTargetLanguage,
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const openChat = () => model.setIsOpen(true)
|
|
59
|
+
const closeChat = () => model.setIsOpen(false)
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!alternatives) model.api.getAlternativesFx()
|
|
63
|
+
}, [alternatives, model])
|
|
64
|
+
|
|
65
|
+
if (!isEnabled || !isAvailable) {
|
|
66
|
+
return null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<>
|
|
71
|
+
<ChatbotMessages
|
|
72
|
+
model={model}
|
|
73
|
+
renderer={renderer}
|
|
74
|
+
sendHelpRequestPayload={sendHelpRequestPayload}
|
|
75
|
+
translationTargetLanguage={translationTargetLanguage}
|
|
76
|
+
isHintFeedback={isHintFeedback}
|
|
77
|
+
sanitizeSpeechInput={sanitizeSpeechInput}
|
|
78
|
+
isTextToSpeechEnabled={isTextToSpeechEnabled}
|
|
79
|
+
textToSpeechConfig={textToSpeechConfig}
|
|
80
|
+
/>
|
|
81
|
+
|
|
82
|
+
<ChatControls
|
|
83
|
+
model={model}
|
|
84
|
+
onPressTranslate={translateMessages}
|
|
85
|
+
onPressChatIcon={openChat}
|
|
86
|
+
onPressClose={closeChat}
|
|
87
|
+
isTranslationEnabled={isTranslationEnabled}
|
|
88
|
+
ButtonWrapper={ButtonWrapper}
|
|
89
|
+
/>
|
|
90
|
+
</>
|
|
91
|
+
)
|
|
92
|
+
}
|