@magmamath/students-features 0.6.10 → 0.6.11-rc.1
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 +4 -1
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js +27 -24
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js +8 -3
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/SentMessage.js +11 -8
- package/dist/commonjs/features/chatbot/components/ChatMessage/SentMessage.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js +21 -13
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.js +2 -1
- package/dist/commonjs/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBoxTextManager.js +2 -1
- package/dist/commonjs/features/chatbot/model/ChatBoxTextManager.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
- package/dist/commonjs/shared/translation/localization/ca.json +2 -1
- package/dist/commonjs/shared/translation/localization/en.json +2 -1
- package/dist/commonjs/shared/translation/localization/gb.json +2 -1
- package/dist/commonjs/shared/translation/localization/sct.json +2 -1
- package/dist/commonjs/shared/translation/localization/sw.json +2 -1
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js +4 -1
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js +29 -27
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js +8 -3
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/SentMessage.js +11 -8
- package/dist/module/features/chatbot/components/ChatMessage/SentMessage.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js +21 -13
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
- package/dist/module/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.js +3 -3
- package/dist/module/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBotModel.js +1 -1
- package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBoxTextManager.js +2 -1
- package/dist/module/features/chatbot/model/ChatBoxTextManager.js.map +1 -1
- package/dist/module/features/chatbot/types/model.types.js.map +1 -1
- package/dist/module/shared/translation/localization/ca.json +2 -1
- package/dist/module/shared/translation/localization/en.json +2 -1
- package/dist/module/shared/translation/localization/gb.json +2 -1
- package/dist/module/shared/translation/localization/sct.json +2 -1
- package/dist/module/shared/translation/localization/sw.json +2 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts +2 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts +2 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageLoader.d.ts +5 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/SentMessage.d.ts +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/SentMessage.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBoxTextManager.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +2 -0
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/constants.d.ts +5 -0
- package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/model.d.ts +2 -0
- package/dist/typescript/commonjs/shared/translation/model.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts +2 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts +2 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageLoader.d.ts +5 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/SentMessage.d.ts +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/SentMessage.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBoxTextManager.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts +2 -0
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/constants.d.ts +5 -0
- package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/model.d.ts +2 -0
- package/dist/typescript/module/shared/translation/model.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/chatbot/components/Alternatives/Alternatives.tsx +4 -0
- package/src/features/chatbot/components/Alternatives/HelpRequestOption.tsx +28 -29
- package/src/features/chatbot/components/ChatMessage/ChatMessage.tsx +3 -0
- package/src/features/chatbot/components/ChatMessage/MessageLoader.tsx +9 -3
- package/src/features/chatbot/components/ChatMessage/SentMessage.tsx +16 -13
- package/src/features/chatbot/components/ChatMessages/ChatbotMessages.tsx +33 -17
- package/src/features/chatbot/components/ThreeDotsLoader/ThreeDotsLoader.tsx +7 -10
- package/src/features/chatbot/model/ChatBotModel.ts +3 -1
- package/src/features/chatbot/model/ChatBoxTextManager.ts +1 -0
- package/src/features/chatbot/types/model.types.ts +2 -0
- package/src/shared/translation/localization/ca.json +2 -1
- package/src/shared/translation/localization/en.json +2 -1
- package/src/shared/translation/localization/gb.json +2 -1
- package/src/shared/translation/localization/sct.json +2 -1
- package/src/shared/translation/localization/sw.json +2 -1
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { StyleSheet, Text, View } from 'react-native'
|
|
3
|
+
import { BORDER_RADIUS, COLORS, FONT_FAMILY, SPACING } from '@magmamath/react-native-ui'
|
|
4
|
+
|
|
3
5
|
import { VariantProps } from './ChatMessage'
|
|
4
6
|
|
|
5
|
-
export const SentMessage = React.memo(
|
|
6
|
-
|
|
7
|
+
export const SentMessage = React.memo(
|
|
8
|
+
({ message, isTranslated, backgroundColor = COLORS.PRIMARY_BLUE }: VariantProps) => {
|
|
9
|
+
const text = isTranslated ? message.translatedMessage : message.message
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
11
|
+
return (
|
|
12
|
+
<View style={[styles.container, { backgroundColor }]}>
|
|
13
|
+
<Text style={styles.text}>{text}</Text>
|
|
14
|
+
</View>
|
|
15
|
+
)
|
|
16
|
+
},
|
|
17
|
+
)
|
|
14
18
|
|
|
15
19
|
const styles = StyleSheet.create({
|
|
16
20
|
container: {
|
|
17
21
|
alignSelf: 'flex-end',
|
|
18
22
|
maxWidth: 305,
|
|
19
|
-
padding:
|
|
20
|
-
borderRadius:
|
|
23
|
+
padding: SPACING[200],
|
|
24
|
+
borderRadius: BORDER_RADIUS[200],
|
|
21
25
|
borderBottomRightRadius: 0,
|
|
22
|
-
backgroundColor: '#55ABE0',
|
|
23
26
|
},
|
|
24
27
|
text: {
|
|
25
28
|
fontSize: 20,
|
|
26
29
|
fontWeight: 400,
|
|
27
|
-
fontFamily:
|
|
28
|
-
color:
|
|
30
|
+
fontFamily: FONT_FAMILY.buenosAires,
|
|
31
|
+
color: COLORS.NEUTRAL_1,
|
|
29
32
|
},
|
|
30
33
|
})
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { useRef } from 'react'
|
|
2
2
|
import { Platform, ScrollView, StyleSheet, useWindowDimensions, View } from 'react-native'
|
|
3
3
|
import { useStoreMap, useUnit } from 'effector-react'
|
|
4
|
+
import { COLORS } from '@magmamath/react-native-ui'
|
|
5
|
+
|
|
4
6
|
import { ChatbotModel } from '../../model/ChatBotModel'
|
|
5
7
|
import { ChatMessage } from '../ChatMessage/ChatMessage'
|
|
6
8
|
import { MessageLoader } from '../ChatMessage/MessageLoader'
|
|
@@ -34,6 +36,7 @@ export const ChatbotMessages = ({
|
|
|
34
36
|
const currentPlayingId = useUnit(model.t2s.$currentPlayingId)
|
|
35
37
|
const isTranslated = useUnit(model.translation.$isTranslated)
|
|
36
38
|
const audioStatus = useUnit(model.t2s.$status)
|
|
39
|
+
const context = useUnit(model.$context)
|
|
37
40
|
|
|
38
41
|
const messages = useStoreMap(model.$currentChatData, ({ messages }) => messages)
|
|
39
42
|
const lastMessageId = messages.at(-1)?.id
|
|
@@ -60,24 +63,37 @@ export const ChatbotMessages = ({
|
|
|
60
63
|
>
|
|
61
64
|
{isOpen && (
|
|
62
65
|
<View style={styles.gap}>
|
|
63
|
-
{messages.map((message) =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
variant={message.isOwnMessage ? MessageVariant.SENT : MessageVariant.RECEIVED}
|
|
70
|
-
t2sState={{
|
|
71
|
-
isEnabled: isTextToSpeechEnabled && !message.isOwnMessage,
|
|
72
|
-
isActive: message.id === currentPlayingId,
|
|
73
|
-
isLoading: isTextToSpeechPending,
|
|
74
|
-
status: audioStatus,
|
|
75
|
-
disabled: isTextToSpeechPending,
|
|
76
|
-
}}
|
|
77
|
-
/>
|
|
78
|
-
))}
|
|
66
|
+
{messages.map((message) => {
|
|
67
|
+
const backgroundColor = message.isOwnMessage
|
|
68
|
+
? context?.isPracticeMode
|
|
69
|
+
? COLORS.PRIMARY_YELLOW
|
|
70
|
+
: COLORS.PRIMARY_BLUE
|
|
71
|
+
: COLORS.NEUTRAL_3
|
|
79
72
|
|
|
80
|
-
|
|
73
|
+
return (
|
|
74
|
+
<ChatMessage
|
|
75
|
+
key={message.id}
|
|
76
|
+
isTranslated={isTranslated}
|
|
77
|
+
withIcon={!message.isOwnMessage && message.id === lastMessageId}
|
|
78
|
+
message={message}
|
|
79
|
+
variant={message.isOwnMessage ? MessageVariant.SENT : MessageVariant.RECEIVED}
|
|
80
|
+
backgroundColor={backgroundColor}
|
|
81
|
+
t2sState={{
|
|
82
|
+
isEnabled: isTextToSpeechEnabled && !message.isOwnMessage,
|
|
83
|
+
isActive: message.id === currentPlayingId,
|
|
84
|
+
isLoading: isTextToSpeechPending,
|
|
85
|
+
status: audioStatus,
|
|
86
|
+
disabled: isTextToSpeechPending,
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
)
|
|
90
|
+
})}
|
|
91
|
+
|
|
92
|
+
{isHelpRequestPending && (
|
|
93
|
+
<MessageLoader
|
|
94
|
+
dotsColor={context?.isPracticeMode ? COLORS.PRIMARY_YELLOW : COLORS.PRIMARY_BLUE}
|
|
95
|
+
/>
|
|
96
|
+
)}
|
|
81
97
|
</View>
|
|
82
98
|
)}
|
|
83
99
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { useEffect, useMemo } from 'react'
|
|
1
|
+
import React, { useEffect, useMemo } from 'react'
|
|
3
2
|
import { View, Animated, StyleSheet, Platform } from 'react-native'
|
|
4
3
|
|
|
4
|
+
import { COLORS } from '@magmamath/react-native-ui'
|
|
5
|
+
|
|
5
6
|
type ChatLoaderProps = {
|
|
6
7
|
dotsCount?: number
|
|
7
8
|
animationDuration?: number
|
|
@@ -11,12 +12,12 @@ type ChatLoaderProps = {
|
|
|
11
12
|
export const ThreeDotsLoader = ({
|
|
12
13
|
dotsCount = 3,
|
|
13
14
|
animationDuration = 250,
|
|
14
|
-
backgroundColor =
|
|
15
|
+
backgroundColor = COLORS.PRIMARY_BLUE,
|
|
15
16
|
}: ChatLoaderProps) => {
|
|
16
17
|
const isWeb = Platform.OS === 'web'
|
|
17
18
|
const animations = useMemo(
|
|
18
19
|
() => [...Array(dotsCount)].map(() => new Animated.Value(0)),
|
|
19
|
-
[dotsCount]
|
|
20
|
+
[dotsCount],
|
|
20
21
|
)
|
|
21
22
|
|
|
22
23
|
useEffect(() => {
|
|
@@ -33,7 +34,7 @@ export const ThreeDotsLoader = ({
|
|
|
33
34
|
duration: animationDuration,
|
|
34
35
|
useNativeDriver: !isWeb,
|
|
35
36
|
}),
|
|
36
|
-
])
|
|
37
|
+
]),
|
|
37
38
|
)
|
|
38
39
|
|
|
39
40
|
Animated.loop(Animated.parallel(animationsArray)).start()
|
|
@@ -50,11 +51,7 @@ export const ThreeDotsLoader = ({
|
|
|
50
51
|
return (
|
|
51
52
|
<Animated.View
|
|
52
53
|
key={index}
|
|
53
|
-
style={[
|
|
54
|
-
styles.dot,
|
|
55
|
-
{ transform: [{ translateY }] },
|
|
56
|
-
{ backgroundColor },
|
|
57
|
-
]}
|
|
54
|
+
style={[styles.dot, { transform: [{ translateY }] }, { backgroundColor }]}
|
|
58
55
|
/>
|
|
59
56
|
)
|
|
60
57
|
})}
|
|
@@ -163,7 +163,9 @@ export class ChatbotModel {
|
|
|
163
163
|
messagesHelper.createAnswer(response, { isInitial: thread?.history.length === 1 }),
|
|
164
164
|
]
|
|
165
165
|
if (response.endMessage) {
|
|
166
|
-
|
|
166
|
+
context.isPracticeMode
|
|
167
|
+
? messages.push(messagesHelper.createLast(this.defaultMessages.hintsLimitReached))
|
|
168
|
+
: messages.push(messagesHelper.createLast(this.defaultMessages.endMessage))
|
|
167
169
|
}
|
|
168
170
|
const translatedMessages = await this.translation.applyTranslationFx(messages)
|
|
169
171
|
|
|
@@ -16,5 +16,6 @@ export class ChatBotTextManager {
|
|
|
16
16
|
start: this.messagesCreator.createMessage('chat.howCanIHelp'),
|
|
17
17
|
endMessage: this.messagesCreator.createMessage('chat.answerAgain'),
|
|
18
18
|
anotherHintOption: this.messagesCreator.createOption('chat.anotherHint'),
|
|
19
|
+
hintsLimitReached: this.messagesCreator.createMessage('chat.hintsLimitReached'),
|
|
19
20
|
}
|
|
20
21
|
}
|
|
@@ -21,6 +21,7 @@ export type ChatbotMessages = {
|
|
|
21
21
|
start: ConversationMessage
|
|
22
22
|
endMessage: ConversationMessage
|
|
23
23
|
anotherHintOption: ChatAnswer
|
|
24
|
+
hintsLimitReached: ConversationMessage
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export type ChatbotApiRequests = {
|
|
@@ -104,4 +105,5 @@ export type ChatbotContext = {
|
|
|
104
105
|
answer?: string | string[]
|
|
105
106
|
translationTargetLanguage: string
|
|
106
107
|
imageDescription?: string
|
|
108
|
+
isPracticeMode?: boolean
|
|
107
109
|
}
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"answerAgain": "Answer again to get another hint!",
|
|
18
18
|
"errorMessage": "Something went wrong! Try again",
|
|
19
19
|
"howCanIHelp": "Hi! Do you want help?",
|
|
20
|
-
"showError": "Show error"
|
|
20
|
+
"showError": "Show error",
|
|
21
|
+
"hintsLimitReached": "I cannot give any more hints."
|
|
21
22
|
},
|
|
22
23
|
"gifCelebrations": {
|
|
23
24
|
"greatStart": "Great start!",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"answerAgain": "Answer again to get another hint!",
|
|
18
18
|
"errorMessage": "Something went wrong! Try again",
|
|
19
19
|
"howCanIHelp": "Hi! Do you want help?",
|
|
20
|
-
"showError": "Show error"
|
|
20
|
+
"showError": "Show error",
|
|
21
|
+
"hintsLimitReached": "I cannot give any more hints."
|
|
21
22
|
},
|
|
22
23
|
"gifCelebrations": {
|
|
23
24
|
"greatStart": "Great start!",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"answerAgain": "Answer again to get another hint!",
|
|
18
18
|
"errorMessage": "Something went wrong! Try again",
|
|
19
19
|
"howCanIHelp": "Hi! Do you want help?",
|
|
20
|
-
"showError": "Show error"
|
|
20
|
+
"showError": "Show error",
|
|
21
|
+
"hintsLimitReached": "I cannot give any more hints."
|
|
21
22
|
},
|
|
22
23
|
"gifCelebrations": {
|
|
23
24
|
"greatStart": "Great start!",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"answerAgain": "Answer again to get another hint!",
|
|
18
18
|
"errorMessage": "Something went wrong! Try again",
|
|
19
19
|
"howCanIHelp": "Hi! Do you want help?",
|
|
20
|
-
"showError": "Show error"
|
|
20
|
+
"showError": "Show error",
|
|
21
|
+
"hintsLimitReached": "I cannot give any more hints."
|
|
21
22
|
},
|
|
22
23
|
"gifCelebrations": {
|
|
23
24
|
"greatStart": "Great start!",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"answerAgain": "Svara igen för att få en till ledtråd!",
|
|
18
18
|
"errorMessage": "Något gick snett! Försök igen",
|
|
19
19
|
"howCanIHelp": "Hej! Hur kan jag hjälpa dig?",
|
|
20
|
-
"showError": "Visa fel"
|
|
20
|
+
"showError": "Visa fel",
|
|
21
|
+
"hintsLimitReached": "Jag kan inte ge några fler ledtrådar."
|
|
21
22
|
},
|
|
22
23
|
"gifCelebrations": {
|
|
23
24
|
"greatStart": "Bra start!",
|