@magmamath/students-features 0.5.0 → 0.5.1-rc-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.
Files changed (414) hide show
  1. package/dist/commonjs/features/celebrations/config.js +4 -4
  2. package/dist/commonjs/features/celebrations/config.js.map +1 -1
  3. package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js +1 -2
  4. package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
  5. package/dist/commonjs/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
  6. package/dist/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.js +47 -30
  7. package/dist/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.js.map +1 -1
  8. package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js +42 -22
  9. package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
  10. package/dist/commonjs/features/chatbot/components/ChatMessage/SentMessage.js +14 -11
  11. package/dist/commonjs/features/chatbot/components/ChatMessage/SentMessage.js.map +1 -1
  12. package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js +32 -17
  13. package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
  14. package/dist/commonjs/features/chatbot/components/Chatbot.js +7 -5
  15. package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
  16. package/dist/commonjs/features/chatbot/index.js +7 -0
  17. package/dist/commonjs/features/chatbot/index.js.map +1 -1
  18. package/dist/commonjs/features/chatbot/model/{ChatBotThreadManager.js → ChatBotMessageHandler.js} +22 -44
  19. package/dist/commonjs/features/chatbot/model/ChatBotMessageHandler.js.map +1 -0
  20. package/dist/commonjs/features/chatbot/model/ChatBotModel.js +125 -146
  21. package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
  22. package/dist/commonjs/features/chatbot/model/DefaultMessageCreator.js +12 -12
  23. package/dist/commonjs/features/chatbot/model/DefaultMessageCreator.js.map +1 -1
  24. package/dist/commonjs/features/chatbot/model/ThreadItem.js +8 -16
  25. package/dist/commonjs/features/chatbot/model/ThreadItem.js.map +1 -1
  26. package/dist/commonjs/features/chatbot/model/{ChatbotApi.js → api.js} +1 -2
  27. package/dist/commonjs/features/chatbot/model/api.js.map +1 -0
  28. package/dist/commonjs/features/chatbot/model/constants.js.map +1 -1
  29. package/dist/commonjs/features/chatbot/model/messagesHelper.js +7 -7
  30. package/dist/commonjs/features/chatbot/model/messagesHelper.js.map +1 -1
  31. package/dist/commonjs/features/chatbot/model/t2s.js +13 -18
  32. package/dist/commonjs/features/chatbot/model/t2s.js.map +1 -1
  33. package/dist/commonjs/features/chatbot/model/translation.helpers.js.map +1 -1
  34. package/dist/commonjs/features/chatbot/model/translation.js +19 -28
  35. package/dist/commonjs/features/chatbot/model/translation.js.map +1 -1
  36. package/dist/commonjs/features/chatbot/types/api.types.js +0 -4
  37. package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
  38. package/dist/commonjs/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js +2 -4
  39. package/dist/commonjs/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js.map +1 -1
  40. package/dist/commonjs/features/endOfAssignment/ui/PracticeButtonGroup.js.map +1 -1
  41. package/dist/commonjs/index.js.map +1 -1
  42. package/dist/commonjs/lib/effector/createEntityFieldStore.js +0 -4
  43. package/dist/commonjs/lib/effector/createEntityFieldStore.js.map +1 -1
  44. package/{src/shared/translation → dist/commonjs/lib}/localization/en.json +1 -8
  45. package/dist/{module/shared/translation → commonjs/lib}/localization/gb.json +1 -8
  46. package/dist/commonjs/{shared/translation → lib}/localization/sw.json +1 -8
  47. package/dist/commonjs/shared/icons/icon.types.js +0 -4
  48. package/dist/commonjs/shared/translation/constants.js +3 -3
  49. package/dist/commonjs/shared/translation/constants.js.map +1 -1
  50. package/dist/commonjs/shared/translation/helpers.js +6 -22
  51. package/dist/commonjs/shared/translation/helpers.js.map +1 -1
  52. package/dist/commonjs/shared/translation/hooks.js +5 -3
  53. package/dist/commonjs/shared/translation/hooks.js.map +1 -1
  54. package/dist/commonjs/shared/translation/model.js +1 -1
  55. package/dist/commonjs/shared/translation/model.js.map +1 -1
  56. package/dist/commonjs/shared/translation/types.js +1 -1
  57. package/dist/commonjs/shared/translation/types.js.map +1 -1
  58. package/dist/module/features/celebrations/config.js +4 -4
  59. package/dist/module/features/celebrations/config.js.map +1 -1
  60. package/dist/module/features/chatbot/components/Alternatives/Alternatives.js +1 -2
  61. package/dist/module/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
  62. package/dist/module/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
  63. package/dist/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.js +48 -31
  64. package/dist/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.js.map +1 -1
  65. package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js +43 -23
  66. package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
  67. package/dist/module/features/chatbot/components/ChatMessage/SentMessage.js +13 -11
  68. package/dist/module/features/chatbot/components/ChatMessage/SentMessage.js.map +1 -1
  69. package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js +32 -17
  70. package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
  71. package/dist/module/features/chatbot/components/Chatbot.js +8 -6
  72. package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
  73. package/dist/module/features/chatbot/index.js +1 -0
  74. package/dist/module/features/chatbot/index.js.map +1 -1
  75. package/dist/module/features/chatbot/model/{ChatBotThreadManager.js → ChatBotMessageHandler.js} +20 -42
  76. package/dist/module/features/chatbot/model/ChatBotMessageHandler.js.map +1 -0
  77. package/dist/module/features/chatbot/model/ChatBotModel.js +126 -147
  78. package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
  79. package/dist/module/features/chatbot/model/DefaultMessageCreator.js +12 -12
  80. package/dist/module/features/chatbot/model/DefaultMessageCreator.js.map +1 -1
  81. package/dist/module/features/chatbot/model/ThreadItem.js +8 -16
  82. package/dist/module/features/chatbot/model/ThreadItem.js.map +1 -1
  83. package/dist/module/features/chatbot/model/{ChatbotApi.js → api.js} +1 -2
  84. package/dist/module/features/chatbot/model/api.js.map +1 -0
  85. package/dist/module/features/chatbot/model/constants.js.map +1 -1
  86. package/dist/module/features/chatbot/model/messagesHelper.js +7 -7
  87. package/dist/module/features/chatbot/model/messagesHelper.js.map +1 -1
  88. package/dist/module/features/chatbot/model/t2s.js +14 -19
  89. package/dist/module/features/chatbot/model/t2s.js.map +1 -1
  90. package/dist/module/features/chatbot/model/translation.helpers.js.map +1 -1
  91. package/dist/module/features/chatbot/model/translation.js +19 -28
  92. package/dist/module/features/chatbot/model/translation.js.map +1 -1
  93. package/dist/module/features/chatbot/types/api.types.js +0 -2
  94. package/dist/module/features/chatbot/types/model.types.js.map +1 -1
  95. package/dist/module/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js +2 -4
  96. package/dist/module/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js.map +1 -1
  97. package/dist/module/features/endOfAssignment/ui/PracticeButtonGroup.js.map +1 -1
  98. package/dist/module/index.js.map +1 -1
  99. package/dist/module/lib/effector/createEntityFieldStore.js +0 -4
  100. package/dist/module/lib/effector/createEntityFieldStore.js.map +1 -1
  101. package/dist/module/{shared/translation → lib}/localization/en.json +1 -8
  102. package/dist/{commonjs/shared/translation → module/lib}/localization/gb.json +1 -8
  103. package/dist/module/{shared/translation → lib}/localization/sw.json +1 -8
  104. package/dist/module/shared/icons/icon.types.js +0 -2
  105. package/dist/module/shared/translation/constants.js +3 -3
  106. package/dist/module/shared/translation/constants.js.map +1 -1
  107. package/dist/module/shared/translation/helpers.js +5 -19
  108. package/dist/module/shared/translation/helpers.js.map +1 -1
  109. package/dist/module/shared/translation/hooks.js +6 -4
  110. package/dist/module/shared/translation/hooks.js.map +1 -1
  111. package/dist/module/shared/translation/model.js +1 -1
  112. package/dist/module/shared/translation/model.js.map +1 -1
  113. package/dist/module/shared/translation/types.js +0 -2
  114. package/dist/module/shared/translation/types.js.map +1 -1
  115. package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts +3 -1
  116. package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -1
  117. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts +10 -7
  118. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
  119. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts +7 -5
  120. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts.map +1 -1
  121. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +1 -1
  122. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -1
  123. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/SentMessage.d.ts +1 -1
  124. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/SentMessage.d.ts.map +1 -1
  125. package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts +10 -2
  126. package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -1
  127. package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts +5 -2
  128. package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts.map +1 -1
  129. package/dist/typescript/commonjs/features/chatbot/index.d.ts +3 -4
  130. package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -1
  131. package/dist/typescript/commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts +31 -0
  132. package/dist/typescript/commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts.map +1 -0
  133. package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +18 -24
  134. package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
  135. package/dist/typescript/commonjs/features/chatbot/model/DefaultMessageCreator.d.ts +3 -5
  136. package/dist/typescript/commonjs/features/chatbot/model/DefaultMessageCreator.d.ts.map +1 -1
  137. package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts +7 -13
  138. package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts.map +1 -1
  139. package/dist/typescript/commonjs/features/chatbot/model/{ChatbotApi.d.ts → api.d.ts} +3 -4
  140. package/dist/typescript/commonjs/features/chatbot/model/api.d.ts.map +1 -0
  141. package/dist/typescript/commonjs/features/chatbot/model/constants.d.ts.map +1 -1
  142. package/dist/typescript/commonjs/features/chatbot/model/messagesHelper.d.ts +5 -7
  143. package/dist/typescript/commonjs/features/chatbot/model/messagesHelper.d.ts.map +1 -1
  144. package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts +6 -16
  145. package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts.map +1 -1
  146. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts +9 -8
  147. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts.map +1 -1
  148. package/dist/typescript/commonjs/features/chatbot/model/translation.helpers.d.ts +1 -2
  149. package/dist/typescript/commonjs/features/chatbot/model/translation.helpers.d.ts.map +1 -1
  150. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +11 -12
  151. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -1
  152. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +24 -19
  153. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
  154. package/dist/typescript/commonjs/features/chatbot/types/t2s.types.d.ts +7 -9
  155. package/dist/typescript/commonjs/features/chatbot/types/t2s.types.d.ts.map +1 -1
  156. package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts +2 -3
  157. package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts.map +1 -1
  158. package/dist/typescript/commonjs/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.d.ts.map +1 -1
  159. package/dist/typescript/commonjs/features/endOfAssignment/ui/PracticeButtonGroup.d.ts.map +1 -1
  160. package/dist/typescript/commonjs/index.d.ts +1 -0
  161. package/dist/typescript/commonjs/index.d.ts.map +1 -1
  162. package/dist/typescript/commonjs/lib/effector/createEntityFieldStore.d.ts +0 -2
  163. package/dist/typescript/commonjs/lib/effector/createEntityFieldStore.d.ts.map +1 -1
  164. package/dist/typescript/commonjs/shared/icons/icon.types.d.ts +0 -2
  165. package/dist/typescript/commonjs/shared/icons/icon.types.d.ts.map +1 -1
  166. package/dist/typescript/commonjs/shared/translation/constants.d.ts +0 -21
  167. package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
  168. package/dist/typescript/commonjs/shared/translation/helpers.d.ts +2 -3
  169. package/dist/typescript/commonjs/shared/translation/helpers.d.ts.map +1 -1
  170. package/dist/typescript/commonjs/shared/translation/hooks.d.ts +2 -2
  171. package/dist/typescript/commonjs/shared/translation/hooks.d.ts.map +1 -1
  172. package/dist/typescript/commonjs/shared/translation/index.d.ts +1 -0
  173. package/dist/typescript/commonjs/shared/translation/index.d.ts.map +1 -1
  174. package/dist/typescript/commonjs/shared/translation/model.d.ts +3 -43
  175. package/dist/typescript/commonjs/shared/translation/model.d.ts.map +1 -1
  176. package/dist/typescript/commonjs/shared/translation/types.d.ts +4 -4
  177. package/dist/typescript/commonjs/shared/translation/types.d.ts.map +1 -1
  178. package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts +3 -1
  179. package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -1
  180. package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts +10 -7
  181. package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
  182. package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts +7 -5
  183. package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts.map +1 -1
  184. package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +1 -1
  185. package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -1
  186. package/dist/typescript/module/features/chatbot/components/ChatMessage/SentMessage.d.ts +1 -1
  187. package/dist/typescript/module/features/chatbot/components/ChatMessage/SentMessage.d.ts.map +1 -1
  188. package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts +10 -2
  189. package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -1
  190. package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts +5 -2
  191. package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts.map +1 -1
  192. package/dist/typescript/module/features/chatbot/index.d.ts +3 -4
  193. package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -1
  194. package/dist/typescript/module/features/chatbot/model/ChatBotMessageHandler.d.ts +31 -0
  195. package/dist/typescript/module/features/chatbot/model/ChatBotMessageHandler.d.ts.map +1 -0
  196. package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +18 -24
  197. package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
  198. package/dist/typescript/module/features/chatbot/model/DefaultMessageCreator.d.ts +3 -5
  199. package/dist/typescript/module/features/chatbot/model/DefaultMessageCreator.d.ts.map +1 -1
  200. package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts +7 -13
  201. package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts.map +1 -1
  202. package/dist/typescript/module/features/chatbot/model/{ChatbotApi.d.ts → api.d.ts} +3 -4
  203. package/dist/typescript/module/features/chatbot/model/api.d.ts.map +1 -0
  204. package/dist/typescript/module/features/chatbot/model/constants.d.ts.map +1 -1
  205. package/dist/typescript/module/features/chatbot/model/messagesHelper.d.ts +5 -7
  206. package/dist/typescript/module/features/chatbot/model/messagesHelper.d.ts.map +1 -1
  207. package/dist/typescript/module/features/chatbot/model/t2s.d.ts +6 -16
  208. package/dist/typescript/module/features/chatbot/model/t2s.d.ts.map +1 -1
  209. package/dist/typescript/module/features/chatbot/model/translation.d.ts +9 -8
  210. package/dist/typescript/module/features/chatbot/model/translation.d.ts.map +1 -1
  211. package/dist/typescript/module/features/chatbot/model/translation.helpers.d.ts +1 -2
  212. package/dist/typescript/module/features/chatbot/model/translation.helpers.d.ts.map +1 -1
  213. package/dist/typescript/module/features/chatbot/types/api.types.d.ts +11 -12
  214. package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -1
  215. package/dist/typescript/module/features/chatbot/types/model.types.d.ts +24 -19
  216. package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
  217. package/dist/typescript/module/features/chatbot/types/t2s.types.d.ts +7 -9
  218. package/dist/typescript/module/features/chatbot/types/t2s.types.d.ts.map +1 -1
  219. package/dist/typescript/module/features/chatbot/types/translation.types.d.ts +2 -3
  220. package/dist/typescript/module/features/chatbot/types/translation.types.d.ts.map +1 -1
  221. package/dist/typescript/module/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.d.ts.map +1 -1
  222. package/dist/typescript/module/features/endOfAssignment/ui/PracticeButtonGroup.d.ts.map +1 -1
  223. package/dist/typescript/module/index.d.ts +1 -0
  224. package/dist/typescript/module/index.d.ts.map +1 -1
  225. package/dist/typescript/module/lib/effector/createEntityFieldStore.d.ts +0 -2
  226. package/dist/typescript/module/lib/effector/createEntityFieldStore.d.ts.map +1 -1
  227. package/dist/typescript/module/shared/icons/icon.types.d.ts +0 -2
  228. package/dist/typescript/module/shared/icons/icon.types.d.ts.map +1 -1
  229. package/dist/typescript/module/shared/translation/constants.d.ts +0 -21
  230. package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
  231. package/dist/typescript/module/shared/translation/helpers.d.ts +2 -3
  232. package/dist/typescript/module/shared/translation/helpers.d.ts.map +1 -1
  233. package/dist/typescript/module/shared/translation/hooks.d.ts +2 -2
  234. package/dist/typescript/module/shared/translation/hooks.d.ts.map +1 -1
  235. package/dist/typescript/module/shared/translation/index.d.ts +1 -0
  236. package/dist/typescript/module/shared/translation/index.d.ts.map +1 -1
  237. package/dist/typescript/module/shared/translation/model.d.ts +3 -43
  238. package/dist/typescript/module/shared/translation/model.d.ts.map +1 -1
  239. package/dist/typescript/module/shared/translation/types.d.ts +4 -4
  240. package/dist/typescript/module/shared/translation/types.d.ts.map +1 -1
  241. package/package.json +2 -2
  242. package/src/features/celebrations/config.ts +4 -4
  243. package/src/features/chatbot/components/Alternatives/Alternatives.tsx +4 -2
  244. package/src/features/chatbot/components/ChatMessage/ChatMessage.tsx +10 -7
  245. package/src/features/chatbot/components/ChatMessage/MessageTextToSpeech.tsx +51 -34
  246. package/src/features/chatbot/components/ChatMessage/ReceivedMessage.tsx +40 -15
  247. package/src/features/chatbot/components/ChatMessage/SentMessage.tsx +10 -9
  248. package/src/features/chatbot/components/ChatMessages/ChatbotMessages.tsx +34 -17
  249. package/src/features/chatbot/components/Chatbot.tsx +11 -5
  250. package/src/features/chatbot/index.ts +4 -3
  251. package/src/features/chatbot/model/{ChatBotThreadManager.ts → ChatBotMessageHandler.ts} +27 -53
  252. package/src/features/chatbot/model/ChatBotModel.ts +149 -151
  253. package/src/features/chatbot/model/DefaultMessageCreator.ts +16 -17
  254. package/src/features/chatbot/model/ThreadItem.ts +10 -15
  255. package/src/features/chatbot/model/{ChatbotApi.ts → api.ts} +2 -5
  256. package/src/features/chatbot/model/constants.ts +0 -2
  257. package/src/features/chatbot/model/messagesHelper.ts +7 -12
  258. package/src/features/chatbot/model/t2s.ts +13 -28
  259. package/src/features/chatbot/model/translation.helpers.ts +1 -2
  260. package/src/features/chatbot/model/translation.ts +24 -34
  261. package/src/features/chatbot/types/api.types.ts +12 -12
  262. package/src/features/chatbot/types/model.types.ts +32 -31
  263. package/src/features/chatbot/types/t2s.types.ts +15 -18
  264. package/src/features/chatbot/types/translation.types.ts +2 -3
  265. package/src/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.tsx +2 -3
  266. package/src/features/endOfAssignment/ui/PracticeButtonGroup.tsx +1 -0
  267. package/src/index.ts +1 -0
  268. package/src/lib/effector/createEntityFieldStore.ts +1 -9
  269. package/{dist/commonjs/shared/translation → src/lib}/localization/en.json +1 -8
  270. package/src/{shared/translation → lib}/localization/gb.json +1 -8
  271. package/src/{shared/translation → lib}/localization/sw.json +1 -8
  272. package/src/shared/icons/icon.types.ts +6 -9
  273. package/src/shared/translation/constants.ts +3 -3
  274. package/src/shared/translation/helpers.ts +9 -22
  275. package/src/shared/translation/hooks.ts +16 -12
  276. package/src/shared/translation/index.ts +1 -0
  277. package/src/shared/translation/model.ts +8 -8
  278. package/src/shared/translation/types.ts +8 -11
  279. package/dist/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.js +0 -44
  280. package/dist/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.js.map +0 -1
  281. package/dist/commonjs/features/chatbot/components/ChatMessage/MessageContent.js +0 -62
  282. package/dist/commonjs/features/chatbot/components/ChatMessage/MessageContent.js.map +0 -1
  283. package/dist/commonjs/features/chatbot/components/ChatMessage/helpers.js +0 -13
  284. package/dist/commonjs/features/chatbot/components/ChatMessage/helpers.js.map +0 -1
  285. package/dist/commonjs/features/chatbot/context/ChatBotModelContext.js +0 -17
  286. package/dist/commonjs/features/chatbot/context/ChatBotModelContext.js.map +0 -1
  287. package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.js +0 -57
  288. package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.js.map +0 -1
  289. package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.js +0 -130
  290. package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.js.map +0 -1
  291. package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js.map +0 -1
  292. package/dist/commonjs/features/chatbot/model/ChatBoxTextManager.js +0 -22
  293. package/dist/commonjs/features/chatbot/model/ChatBoxTextManager.js.map +0 -1
  294. package/dist/commonjs/features/chatbot/model/ChatbotApi.js.map +0 -1
  295. package/dist/commonjs/features/chatbot/model/ChatsCacheModel.js +0 -110
  296. package/dist/commonjs/features/chatbot/model/ChatsCacheModel.js.map +0 -1
  297. package/dist/commonjs/features/chatbot/types/units.types.js +0 -2
  298. package/dist/commonjs/features/chatbot/types/units.types.js.map +0 -1
  299. package/dist/commonjs/lib/effector/withEvent.js +0 -13
  300. package/dist/commonjs/lib/effector/withEvent.js.map +0 -1
  301. package/dist/commonjs/lib/types/keys.js +0 -2
  302. package/dist/commonjs/lib/types/keys.js.map +0 -1
  303. package/dist/commonjs/shared/icons/HighlighterIcon.js +0 -36
  304. package/dist/commonjs/shared/icons/HighlighterIcon.js.map +0 -1
  305. package/dist/commonjs/shared/icons/StopIcon.js +0 -33
  306. package/dist/commonjs/shared/icons/StopIcon.js.map +0 -1
  307. package/dist/commonjs/shared/translation/validation.types.js +0 -6
  308. package/dist/commonjs/shared/translation/validation.types.js.map +0 -1
  309. package/dist/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.js +0 -38
  310. package/dist/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.js.map +0 -1
  311. package/dist/module/features/chatbot/components/ChatMessage/MessageContent.js +0 -57
  312. package/dist/module/features/chatbot/components/ChatMessage/MessageContent.js.map +0 -1
  313. package/dist/module/features/chatbot/components/ChatMessage/helpers.js +0 -9
  314. package/dist/module/features/chatbot/components/ChatMessage/helpers.js.map +0 -1
  315. package/dist/module/features/chatbot/context/ChatBotModelContext.js +0 -12
  316. package/dist/module/features/chatbot/context/ChatBotModelContext.js.map +0 -1
  317. package/dist/module/features/chatbot/errorSpotting/ErrorSpottingButton.js +0 -51
  318. package/dist/module/features/chatbot/errorSpotting/ErrorSpottingButton.js.map +0 -1
  319. package/dist/module/features/chatbot/errorSpotting/ErrorSpottingModel.js +0 -125
  320. package/dist/module/features/chatbot/errorSpotting/ErrorSpottingModel.js.map +0 -1
  321. package/dist/module/features/chatbot/model/ChatBotThreadManager.js.map +0 -1
  322. package/dist/module/features/chatbot/model/ChatBoxTextManager.js +0 -17
  323. package/dist/module/features/chatbot/model/ChatBoxTextManager.js.map +0 -1
  324. package/dist/module/features/chatbot/model/ChatbotApi.js.map +0 -1
  325. package/dist/module/features/chatbot/model/ChatsCacheModel.js +0 -104
  326. package/dist/module/features/chatbot/model/ChatsCacheModel.js.map +0 -1
  327. package/dist/module/features/chatbot/types/units.types.js +0 -2
  328. package/dist/module/features/chatbot/types/units.types.js.map +0 -1
  329. package/dist/module/lib/effector/withEvent.js +0 -9
  330. package/dist/module/lib/effector/withEvent.js.map +0 -1
  331. package/dist/module/lib/types/keys.js +0 -2
  332. package/dist/module/lib/types/keys.js.map +0 -1
  333. package/dist/module/shared/icons/HighlighterIcon.js +0 -29
  334. package/dist/module/shared/icons/HighlighterIcon.js.map +0 -1
  335. package/dist/module/shared/icons/StopIcon.js +0 -26
  336. package/dist/module/shared/icons/StopIcon.js.map +0 -1
  337. package/dist/module/shared/translation/validation.types.js +0 -4
  338. package/dist/module/shared/translation/validation.types.js.map +0 -1
  339. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts +0 -10
  340. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts.map +0 -1
  341. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageContent.d.ts +0 -11
  342. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageContent.d.ts.map +0 -1
  343. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/helpers.d.ts +0 -4
  344. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/helpers.d.ts.map +0 -1
  345. package/dist/typescript/commonjs/features/chatbot/context/ChatBotModelContext.d.ts +0 -4
  346. package/dist/typescript/commonjs/features/chatbot/context/ChatBotModelContext.d.ts.map +0 -1
  347. package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts +0 -8
  348. package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts.map +0 -1
  349. package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts +0 -35
  350. package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts.map +0 -1
  351. package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts +0 -33
  352. package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts.map +0 -1
  353. package/dist/typescript/commonjs/features/chatbot/model/ChatBoxTextManager.d.ts +0 -6
  354. package/dist/typescript/commonjs/features/chatbot/model/ChatBoxTextManager.d.ts.map +0 -1
  355. package/dist/typescript/commonjs/features/chatbot/model/ChatbotApi.d.ts.map +0 -1
  356. package/dist/typescript/commonjs/features/chatbot/model/ChatsCacheModel.d.ts +0 -27
  357. package/dist/typescript/commonjs/features/chatbot/model/ChatsCacheModel.d.ts.map +0 -1
  358. package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts +0 -34
  359. package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts.map +0 -1
  360. package/dist/typescript/commonjs/lib/effector/withEvent.d.ts +0 -2
  361. package/dist/typescript/commonjs/lib/effector/withEvent.d.ts.map +0 -1
  362. package/dist/typescript/commonjs/lib/types/keys.d.ts +0 -8
  363. package/dist/typescript/commonjs/lib/types/keys.d.ts.map +0 -1
  364. package/dist/typescript/commonjs/shared/icons/HighlighterIcon.d.ts +0 -4
  365. package/dist/typescript/commonjs/shared/icons/HighlighterIcon.d.ts.map +0 -1
  366. package/dist/typescript/commonjs/shared/icons/StopIcon.d.ts +0 -4
  367. package/dist/typescript/commonjs/shared/icons/StopIcon.d.ts.map +0 -1
  368. package/dist/typescript/commonjs/shared/translation/validation.types.d.ts +0 -17
  369. package/dist/typescript/commonjs/shared/translation/validation.types.d.ts.map +0 -1
  370. package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts +0 -10
  371. package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts.map +0 -1
  372. package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageContent.d.ts +0 -11
  373. package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageContent.d.ts.map +0 -1
  374. package/dist/typescript/module/features/chatbot/components/ChatMessage/helpers.d.ts +0 -4
  375. package/dist/typescript/module/features/chatbot/components/ChatMessage/helpers.d.ts.map +0 -1
  376. package/dist/typescript/module/features/chatbot/context/ChatBotModelContext.d.ts +0 -4
  377. package/dist/typescript/module/features/chatbot/context/ChatBotModelContext.d.ts.map +0 -1
  378. package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts +0 -8
  379. package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts.map +0 -1
  380. package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts +0 -35
  381. package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts.map +0 -1
  382. package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts +0 -33
  383. package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts.map +0 -1
  384. package/dist/typescript/module/features/chatbot/model/ChatBoxTextManager.d.ts +0 -6
  385. package/dist/typescript/module/features/chatbot/model/ChatBoxTextManager.d.ts.map +0 -1
  386. package/dist/typescript/module/features/chatbot/model/ChatbotApi.d.ts.map +0 -1
  387. package/dist/typescript/module/features/chatbot/model/ChatsCacheModel.d.ts +0 -27
  388. package/dist/typescript/module/features/chatbot/model/ChatsCacheModel.d.ts.map +0 -1
  389. package/dist/typescript/module/features/chatbot/types/units.types.d.ts +0 -34
  390. package/dist/typescript/module/features/chatbot/types/units.types.d.ts.map +0 -1
  391. package/dist/typescript/module/lib/effector/withEvent.d.ts +0 -2
  392. package/dist/typescript/module/lib/effector/withEvent.d.ts.map +0 -1
  393. package/dist/typescript/module/lib/types/keys.d.ts +0 -8
  394. package/dist/typescript/module/lib/types/keys.d.ts.map +0 -1
  395. package/dist/typescript/module/shared/icons/HighlighterIcon.d.ts +0 -4
  396. package/dist/typescript/module/shared/icons/HighlighterIcon.d.ts.map +0 -1
  397. package/dist/typescript/module/shared/icons/StopIcon.d.ts +0 -4
  398. package/dist/typescript/module/shared/icons/StopIcon.d.ts.map +0 -1
  399. package/dist/typescript/module/shared/translation/validation.types.d.ts +0 -17
  400. package/dist/typescript/module/shared/translation/validation.types.d.ts.map +0 -1
  401. package/src/features/chatbot/components/ChatMessage/MessageButtonsBlock.tsx +0 -38
  402. package/src/features/chatbot/components/ChatMessage/MessageContent.tsx +0 -52
  403. package/src/features/chatbot/components/ChatMessage/helpers.ts +0 -9
  404. package/src/features/chatbot/context/ChatBotModelContext.ts +0 -14
  405. package/src/features/chatbot/errorSpotting/ErrorSpottingButton.tsx +0 -53
  406. package/src/features/chatbot/errorSpotting/ErrorSpottingModel.ts +0 -150
  407. package/src/features/chatbot/model/ChatBoxTextManager.ts +0 -18
  408. package/src/features/chatbot/model/ChatsCacheModel.ts +0 -95
  409. package/src/features/chatbot/types/units.types.ts +0 -37
  410. package/src/lib/effector/withEvent.ts +0 -7
  411. package/src/lib/types/keys.ts +0 -18
  412. package/src/shared/icons/HighlighterIcon.tsx +0 -21
  413. package/src/shared/icons/StopIcon.tsx +0 -17
  414. package/src/shared/translation/validation.types.ts +0 -26
@@ -1,17 +0,0 @@
1
- import enTranslations from './localization/en.json';
2
- import swTranslations from './localization/sw.json';
3
- import gbTranslations from './localization/gb.json';
4
- type Extends<T, U> = T extends U ? true : false;
5
- type ExtendsAll<Candidate, Types extends unknown[]> = Types extends [infer Head, ...infer Tail] ? Extends<Candidate, Head> extends true ? ExtendsAll<Candidate, Tail> : false : true;
6
- type FindDominantType<Types extends unknown[]> = Types extends [
7
- infer First,
8
- ...infer Rest extends unknown[]
9
- ] ? ExtendsAll<First, Rest> extends true ? First : FindDominantType<Rest> : never;
10
- type DominantTranslation = FindDominantType<[
11
- typeof enTranslations,
12
- typeof swTranslations,
13
- typeof gbTranslations
14
- ]>;
15
- export type ISValidTranslation<T extends DominantTranslation> = T;
16
- export {};
17
- //# sourceMappingURL=validation.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.types.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/validation.types.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,wBAAwB,CAAA;AACnD,OAAO,cAAc,MAAM,wBAAwB,CAAA;AACnD,OAAO,cAAc,MAAM,wBAAwB,CAAA;AAEnD,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,GAAG,KAAK,CAAA;AAE/C,KAAK,UAAU,CAAC,SAAS,EAAE,KAAK,SAAS,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,MAAM,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GAC3F,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,GACnC,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,GAC3B,KAAK,GACP,IAAI,CAAA;AAER,KAAK,gBAAgB,CAAC,KAAK,SAAS,OAAO,EAAE,IAAI,KAAK,SAAS;IAC7D,MAAM,KAAK;IACX,GAAG,MAAM,IAAI,SAAS,OAAO,EAAE;CAChC,GACG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,IAAI,GAClC,KAAK,GACL,gBAAgB,CAAC,IAAI,CAAC,GACxB,KAAK,CAAA;AAET,KAAK,mBAAmB,GAAG,gBAAgB,CACzC;IAAC,OAAO,cAAc;IAAE,OAAO,cAAc;IAAE,OAAO,cAAc;CAAC,CACtE,CAAA;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,mBAAmB,IAAI,CAAC,CAAA"}
@@ -1,38 +0,0 @@
1
- import React from 'react'
2
- import { StyleSheet, View } from 'react-native'
3
- import { ErrorSpottingButton } from '../../errorSpotting/ErrorSpottingButton'
4
- import { MessageTextToSpeech } from './MessageTextToSpeech'
5
- import { ConversationMessage } from '../../types/units.types'
6
- import { IS_WEB } from '@magmamath/react-native-ui'
7
- import { T2SState } from '../../types/t2s.types'
8
-
9
- type MessageButtonsBlockProps = {
10
- t2sState: T2SState
11
- message: ConversationMessage
12
- }
13
-
14
- export const MessageButtonsBlock = ({ t2sState, message }: MessageButtonsBlockProps) => {
15
- if (!t2sState.isEnabled && !message.isInitial) return null
16
-
17
- return (
18
- <View style={styles.container}>
19
- {!!message.isInitial && <ErrorSpottingButton contextMessage={message} />}
20
- {t2sState.isEnabled && <MessageTextToSpeech state={t2sState} message={message} />}
21
- </View>
22
- )
23
- }
24
-
25
- const styles = StyleSheet.create({
26
- container: {
27
- flexDirection: 'row',
28
- gap: 8,
29
- marginLeft: 'auto',
30
- ...(IS_WEB
31
- ? { float: 'right' }
32
- : {
33
- position: 'absolute',
34
- bottom: 8,
35
- right: 8,
36
- }),
37
- },
38
- })
@@ -1,52 +0,0 @@
1
- import { ConversationMessage } from '../../types/units.types'
2
- import { T2SState } from '../../types/t2s.types'
3
- import { Platform, StyleSheet, Text, View } from 'react-native'
4
- import { MessageButtonsBlock } from './MessageButtonsBlock'
5
- import { getSpacerSize } from './helpers'
6
- import React from 'react'
7
-
8
- type MessageContentProps = {
9
- text: string
10
- message: ConversationMessage
11
- t2sState: T2SState
12
- }
13
-
14
- const MessageContentWeb = ({ message, text, t2sState }: MessageContentProps) => {
15
- return (
16
- <Text style={styles.messageText}>
17
- {text}
18
- <MessageButtonsBlock message={message} t2sState={t2sState} />
19
- </Text>
20
- )
21
- }
22
-
23
- const MessageContentMobile = ({ message, text, t2sState }: MessageContentProps) => {
24
- return (
25
- <>
26
- <Text style={[styles.messageText, styles.mobileMessageText]}>
27
- {text}
28
- <View style={{ width: getSpacerSize(message, t2sState) }} />
29
- </Text>
30
- <MessageButtonsBlock message={message} t2sState={t2sState} />
31
- </>
32
- )
33
- }
34
-
35
- export const MessageContent = Platform.select({
36
- web: MessageContentWeb,
37
- default: MessageContentMobile,
38
- })
39
-
40
- const styles = StyleSheet.create({
41
- messageText: {
42
- flex: 1,
43
- fontSize: 20,
44
- fontWeight: 400,
45
- fontFamily: 'Buenos Aires',
46
- color: '#33334D',
47
- width: '100%',
48
- },
49
- mobileMessageText: {
50
- lineHeight: 27,
51
- },
52
- })
@@ -1,9 +0,0 @@
1
- import { ConversationMessage } from '../../types/units.types'
2
- import { T2SState } from '../../types/t2s.types'
3
-
4
- export function getSpacerSize(message: ConversationMessage, t2sState: T2SState) {
5
- if (!t2sState.isEnabled && !message.isInitial) return 0
6
- if (t2sState.isEnabled && message.isInitial) return 164
7
- if (t2sState.isEnabled) return 34
8
- return 133
9
- }
@@ -1,14 +0,0 @@
1
- import { createContext, useContext } from 'react'
2
- import { ChatbotModel } from '../model/ChatBotModel'
3
-
4
- export const ChatBotModelContext = createContext<ChatbotModel | null>(null)
5
-
6
- export function useChatModel() {
7
- const model = useContext(ChatBotModelContext)
8
- if (!model) {
9
- throw new Error(
10
- 'Something went wrong, you are probably trying to use component that is supposed to be inside ChatBotContext.Provider',
11
- )
12
- }
13
- return model
14
- }
@@ -1,53 +0,0 @@
1
- import React from 'react'
2
- import { Button, COLORS, StopIcon } from '@magmamath/react-native-ui'
3
- import { useChatModel } from '../context/ChatBotModelContext'
4
- import { useStoreMap, useUnit } from 'effector-react'
5
- import { StyleSheet } from 'react-native'
6
- import { HighlighterIcon } from '../../../shared/icons/HighlighterIcon'
7
- import { ConversationMessage } from '../types/units.types'
8
- import { useText } from '../../../shared/translation'
9
-
10
- type ErrorSpottingButtonProps = {
11
- contextMessage: ConversationMessage
12
- }
13
-
14
- export const ErrorSpottingButton = ({ contextMessage }: ErrorSpottingButtonProps) => {
15
- const t = useText()
16
- const model = useChatModel()
17
- const activeErrorSpotting = useUnit(model.errorSpotting.$activeData)
18
- const validationKey = useUnit(model.errorSpotting.$validationKey)
19
- const isLoading = useUnit(model.errorSpotting.$isLoading)
20
- const currentThread = useStoreMap(model.$currentChatData, (chatData) => chatData.currentThread)
21
-
22
- const threadId = contextMessage.threadId
23
- if (!currentThread?.strokes || (threadId && currentThread.id !== threadId)) {
24
- return null
25
- }
26
-
27
- const isActive = !!activeErrorSpotting?.isActive
28
- return (
29
- <Button
30
- style={buttonStyles}
31
- disabled={validationKey !== currentThread.strokesValidationKey}
32
- isActive={isActive}
33
- isLoading={isLoading}
34
- variant={'secondary'}
35
- colorScheme={'blue'}
36
- size={'small'}
37
- onPress={() => {
38
- if (isLoading) return
39
- model.errorSpotting.errorSpottingPressed({ message: contextMessage })
40
- }}
41
- icon={isActive ? <StopIcon color={COLORS.NEUTRAL_1} /> : <HighlighterIcon />}
42
- >
43
- {t('chat.showError')}
44
- </Button>
45
- )
46
- }
47
-
48
- const buttonStyles = StyleSheet.create({
49
- text: {
50
- textTransform: 'uppercase',
51
- paddingTop: 0.5,
52
- },
53
- })
@@ -1,150 +0,0 @@
1
- import { ChatbotAPI } from '../model/ChatbotApi'
2
- import { createEvent, createStore, sample, createEffect, Store } from 'effector'
3
- import { ChatItem, ConversationMessage } from '../types/units.types'
4
- import { ChatbotContext } from '../types/model.types'
5
-
6
- type ErrorSpottingProps = {
7
- api: ChatbotAPI
8
- $currentChatData: Store<ChatItem>
9
- $currentChatContext: Store<ChatbotContext | null>
10
- }
11
-
12
- type ActiveErrorSpottingData = {
13
- isActive: boolean
14
- isDisabled: boolean
15
- strokesIds: string[]
16
- validationKey: null | string
17
- }
18
-
19
- type ErrorSpottingReducerProps = {
20
- chatData: ChatItem
21
- activeSpotting: ActiveErrorSpottingData | null
22
- message: ConversationMessage
23
- context: ChatbotContext | null
24
- }
25
-
26
- const AUTO_CLOSE_TIMEOUT = 5000
27
-
28
- type ErrorSpottingPressedProps = {
29
- message: ConversationMessage
30
- }
31
-
32
- export class ErrorSpottingModel {
33
- private readonly api: ChatbotAPI
34
-
35
- public readonly errorSpottingPressed = createEvent<ErrorSpottingPressedProps>()
36
- private readonly activeDataChanged = createEvent<ActiveErrorSpottingData | null>()
37
- public readonly spottingHidden = createEvent()
38
-
39
- public readonly $validationKey = createStore<string | null>(null)
40
- public readonly $activeData = createStore<ActiveErrorSpottingData | null>(null)
41
- .on(this.activeDataChanged, (_, payload) => payload)
42
- .on(this.spottingHidden, (state) => {
43
- if (state) return { ...state, isActive: false }
44
- return null
45
- })
46
- .on(this.$validationKey, (state, payload) => {
47
- if (!state || payload === null) return state
48
- const isDisabled = payload !== state.validationKey
49
- return { ...state, isDisabled, isActive: isDisabled ? false : state.isActive }
50
- })
51
-
52
- public readonly $isLoading
53
-
54
- private closeTimeout: NodeJS.Timeout | null = null
55
-
56
- public constructor({ api, $currentChatData, $currentChatContext }: ErrorSpottingProps) {
57
- this.api = api
58
-
59
- this.$isLoading = api.spotErrorFx.pending
60
-
61
- this.$activeData.on($currentChatData, (state, payload) => {
62
- if (!state || state.validationKey !== payload.currentThread?.strokesValidationKey) return null
63
- })
64
-
65
- sample({
66
- clock: api.spotErrorFx.doneData,
67
- source: {
68
- chatData: $currentChatData,
69
- activeSpotting: this.$activeData,
70
- validationKey: this.$validationKey,
71
- },
72
- fn: (source, result) => {
73
- const key = source.chatData.currentThread?.strokesValidationKey || null
74
- const currentKey = source.validationKey
75
- const isDisabled = !!currentKey && currentKey !== key
76
- return {
77
- validationKey: key,
78
- strokesIds: result.highlightedStrokeIds,
79
- isActive: !isDisabled,
80
- isDisabled,
81
- }
82
- },
83
- target: this.$activeData,
84
- })
85
-
86
- sample({
87
- clock: this.errorSpottingPressed,
88
- source: {
89
- context: $currentChatContext,
90
- chatData: $currentChatData,
91
- activeSpotting: this.$activeData,
92
- },
93
- fn: (source, { message }) => ({ ...source, message }),
94
- target: createEffect(
95
- ({ chatData, activeSpotting, message, context }: ErrorSpottingReducerProps) => {
96
- if (!context) throw new Error('Trying to use error spotting in chat without context')
97
- if (!chatData.currentThread?.strokes) return
98
- if (!activeSpotting) {
99
- return this.api
100
- .spotErrorFx({
101
- strokes: chatData.currentThread.strokes,
102
- problemDescription: context.problem,
103
- correctAnswer: context.problemAnswer,
104
- userAnswer: context.answer ?? '',
105
- hint: message.message,
106
- })
107
- .then(() => {
108
- this.scheduleClose()
109
- })
110
- }
111
- this.activeDataChanged({ ...activeSpotting, isActive: !activeSpotting.isActive })
112
- this.scheduleClose()
113
- },
114
- ),
115
- })
116
-
117
- this.activeDataChanged.watch((spotting) => {
118
- if ((!spotting || !spotting.isActive) && this.closeTimeout) {
119
- clearTimeout(this.closeTimeout)
120
- this.closeTimeout = null
121
- }
122
- })
123
- }
124
-
125
- private scheduleClose() {
126
- if (this.closeTimeout) clearTimeout(this.closeTimeout)
127
- this.closeTimeout = setTimeout(() => {
128
- this.spottingHidden()
129
- this.closeTimeout = null
130
- }, AUTO_CLOSE_TIMEOUT)
131
- }
132
-
133
- public bindStrokesValidation($store: Store<string | null>) {
134
- sample({
135
- source: $store,
136
- target: this.$validationKey,
137
- })
138
- return this
139
- }
140
-
141
- public abortPendingRequest() {
142
- const isPending = this.api.spotErrorFx.pending.getState()
143
- if (isPending) this.api.spotErrorFx.controller.abort()
144
- }
145
-
146
- public reset() {
147
- this.activeDataChanged(null)
148
- this.abortPendingRequest()
149
- }
150
- }
@@ -1,18 +0,0 @@
1
- import { DefaultMessagesCreator } from './DefaultMessageCreator'
2
- import { TranslationKeys } from '../../../shared/translation/types'
3
- import { getText } from '../../../shared/translation/helpers'
4
- import { ChatbotMessages } from '../types/model.types'
5
- import { $localization } from '../../../shared/translation'
6
-
7
- export class ChatBotTextManager {
8
- private readonly messagesCreator = new DefaultMessagesCreator<TranslationKeys>({
9
- textGetter: getText,
10
- }).bindToLanguageChanged($localization.updates)
11
-
12
- public readonly messages: ChatbotMessages = {
13
- error: this.messagesCreator.createMessage('chat.errorMessage'),
14
- start: this.messagesCreator.createMessage('chat.howCanIHelp'),
15
- endMessage: this.messagesCreator.createMessage('chat.answerAgain'),
16
- anotherHintOption: this.messagesCreator.createOption('chat.anotherHint'),
17
- }
18
- }
@@ -1,95 +0,0 @@
1
- import { createEvent } from 'effector'
2
- import { createEntityFieldStore } from '../../../lib/effector'
3
- import { ChatAnswer, ChatItem, ConversationMessage } from '../types/units.types'
4
- import { ThreadItem } from './ThreadItem'
5
-
6
- type ReinitChatThreadSettings = {
7
- initialOption: ChatAnswer
8
- }
9
-
10
- type UpdateProps = {
11
- key: string
12
- data: Partial<ChatItem>
13
- }
14
-
15
- type AddMessagesProps = {
16
- messages: ConversationMessage[]
17
- thread?: ThreadItem | null
18
- }
19
-
20
- export function defaultChatData(props: Partial<ChatItem> = {}): ChatItem {
21
- return {
22
- messages: [],
23
- isAvailable: false,
24
- currentThread: null,
25
- ...props,
26
- }
27
- }
28
-
29
- export class ChatsCacheModel {
30
- public readonly update = createEvent<UpdateProps>()
31
- private readonly cache = createEntityFieldStore<ChatItem>().on(
32
- this.update,
33
- (state, { key, data }) => {
34
- const currentData = state[key] ?? defaultChatData()
35
- return { ...state, [key]: { ...currentData, ...data } }
36
- },
37
- )
38
-
39
- public readonly $data = this.cache.$state
40
- public readonly reset = this.cache.reset
41
-
42
- public disableChat(key: string) {
43
- this.cache.setField({
44
- key,
45
- fn: (current) =>
46
- current ? { ...current, isAvailable: false } : defaultChatData({ isAvailable: false }),
47
- })
48
- }
49
-
50
- public reinitChatThread(key: string, { initialOption }: ReinitChatThreadSettings) {
51
- this.cache.setField({
52
- key,
53
- fn: (current) => {
54
- if (!current || current.messages.length <= 1) return
55
- const copy = [...current.messages]
56
- while (copy.at(-1)?.endMessage) {
57
- copy.pop()
58
- }
59
- const lastMessage = copy.at(-1)
60
- if (!lastMessage) return
61
- copy.splice(copy.length - 1, 1, {
62
- ...lastMessage,
63
- options: [initialOption],
64
- })
65
- return { ...current, messages: copy }
66
- },
67
- })
68
- }
69
-
70
- public setSingleMessage(key: string, message: ConversationMessage) {
71
- this.cache.setField({
72
- key,
73
- fn: (current) => {
74
- if (!current || current.messages.length > 1) return
75
- return { ...current, messages: [message] }
76
- },
77
- })
78
- }
79
-
80
- public addMessages(key: string, { messages, thread = null }: AddMessagesProps) {
81
- this.cache.setField({
82
- key,
83
- fn: (current) => {
84
- if (!current) return defaultChatData({ messages, currentThread: thread })
85
- const result = { ...current, messages: [...current.messages, ...messages] }
86
- if (thread) result.currentThread = thread
87
- return result
88
- },
89
- })
90
- }
91
-
92
- public add(key: string, data: ChatItem) {
93
- this.cache.setField({ key, data })
94
- }
95
- }
@@ -1,37 +0,0 @@
1
- export type Stroke = {
2
- x: number[]
3
- y: number[]
4
- }
5
- export type FullStrokeData = Stroke & {
6
- id: string
7
- }
8
-
9
- export type IThreadItem = {
10
- id: string
11
- strokesValidationKey: string | null
12
- strokes: FullStrokeData[] | null
13
- history: string[]
14
- }
15
-
16
- export type ChatAnswer = {
17
- text: string
18
- promptKey: string
19
- translatedText?: string
20
- }
21
-
22
- export type ConversationMessage = {
23
- id: string
24
- message: string
25
- options: ChatAnswer[]
26
- isOwnMessage: boolean
27
- translatedMessage?: string
28
- endMessage?: boolean
29
- isInitial?: boolean
30
- threadId?: string
31
- }
32
-
33
- export type ChatItem = {
34
- messages: ConversationMessage[]
35
- isAvailable: boolean
36
- currentThread: IThreadItem | null
37
- }
@@ -1,7 +0,0 @@
1
- import { createEvent } from 'effector'
2
-
3
- export function withEvent<T = void>(cb: (props: T) => void) {
4
- const event = createEvent<T>()
5
- event.watch(cb)
6
- return event
7
- }
@@ -1,18 +0,0 @@
1
- type JoinKeys<K extends string, P extends string> = `${K}.${P}`
2
-
3
- type NestedKeys<T, Prefix extends string = ''> = T extends object
4
- ? T extends Array<any>
5
- ? never
6
- : {
7
- [K in keyof T & string]: T[K] extends object
8
- ?
9
- | JoinKeys<Prefix extends '' ? K : `${Prefix}.${K}`, NestedKeys<T[K], ''>>
10
- | (Prefix extends '' ? K : `${Prefix}.${K}`)
11
- : Prefix extends ''
12
- ? K
13
- : `${Prefix}.${K}`
14
- }[keyof T & string]
15
- : never
16
-
17
- type FlattenKeys<T> = T extends string ? T : never
18
- export type RetrieveKeys<T> = FlattenKeys<NestedKeys<T>>
@@ -1,21 +0,0 @@
1
- import React from 'react'
2
- import Svg, { Path } from 'react-native-svg'
3
- import { IconProps } from './icon.types'
4
- import { COLORS } from '@magmamath/react-native-ui'
5
-
6
- export function HighlighterIcon({ size = 17, color = COLORS.NEUTRAL_9, style }: IconProps) {
7
- return (
8
- <Svg style={style} width={size} height={size} viewBox="0 0 17 17" fill="none">
9
- <Path
10
- d="M6.02 1.557a.596.596 0 011.108 0l.42 1.067c.06.153.182.275.336.335l1.066.42a.596.596 0 010 1.109l-1.066.42a.596.596 0 00-.336.336l-.42 1.066a.596.596 0 01-1.109 0L5.6 5.244a.596.596 0 00-.336-.336l-1.066-.42a.596.596 0 010-1.108l1.066-.42a.596.596 0 00.336-.336l.42-1.067z"
11
- fill={color}
12
- />
13
- <Path
14
- fillRule="evenodd"
15
- clipRule="evenodd"
16
- d="M8.843 3.338l-.974.73-2.11 1.583.26.66a.596.596 0 001.109 0l.42-1.067a.596.596 0 01.336-.336l1.066-.42a.596.596 0 000-1.108l-.107-.042zm.67-.502c.497.346.665.964.506 1.495l.476-.357 2.868 2.868-3.636 4.849-4.08-4.08.38-.286a1.316 1.316 0 01-.705-.74l-.185-.468-.898.674a.95.95 0 00-.33 1.065 1.75 1.75 0 00-.2.53l-.602 3.016-1.752 1.752a.95.95 0 00.297 1.545l1.83.784a1.35 1.35 0 001.487-.286l.966-.966 3.016-.604c.187-.037.366-.105.53-.199a.95.95 0 001.065-.33l5.445-7.26a2.25 2.25 0 00-.209-2.94L14.44 1.554a2.25 2.25 0 00-2.941-.209l-1.986 1.49zm3.866-.22a.75.75 0 00-.98-.07l-.692.519 2.565 2.565.52-.692a.75.75 0 00-.07-.98l-1.343-1.342zM3.797 12.832l-.807.808.99.425.525-.525-.708-.707zm2.015-.107l2.357-.47-3.086-3.087-.471 2.357 1.2 1.2z"
17
- fill={color}
18
- />
19
- </Svg>
20
- )
21
- }
@@ -1,17 +0,0 @@
1
- import React from 'react'
2
- import Svg, { Path } from 'react-native-svg'
3
- import { IconProps } from './icon.types'
4
- import { COLORS } from '@magmamath/react-native-ui'
5
-
6
- export function StopIcon({ size = 17, color = COLORS.NEUTRAL_9, style }: IconProps) {
7
- return (
8
- <Svg width={size} height={size} viewBox="0 0 17 17" fill="none" style={style}>
9
- <Path
10
- fillRule="evenodd"
11
- clipRule="evenodd"
12
- d="M1.759 2.996c0-.967.784-1.752 1.752-1.752h10.496c.967 0 1.752.785 1.752 1.752v10.496c0 .968-.785 1.752-1.752 1.752H3.51a1.752 1.752 0 01-1.752-1.752V2.996z"
13
- fill={color}
14
- />
15
- </Svg>
16
- )
17
- }
@@ -1,26 +0,0 @@
1
- import enTranslations from './localization/en.json'
2
- import swTranslations from './localization/sw.json'
3
- import gbTranslations from './localization/gb.json'
4
-
5
- type Extends<T, U> = T extends U ? true : false
6
-
7
- type ExtendsAll<Candidate, Types extends unknown[]> = Types extends [infer Head, ...infer Tail]
8
- ? Extends<Candidate, Head> extends true
9
- ? ExtendsAll<Candidate, Tail>
10
- : false
11
- : true
12
-
13
- type FindDominantType<Types extends unknown[]> = Types extends [
14
- infer First,
15
- ...infer Rest extends unknown[],
16
- ]
17
- ? ExtendsAll<First, Rest> extends true
18
- ? First
19
- : FindDominantType<Rest>
20
- : never
21
-
22
- type DominantTranslation = FindDominantType<
23
- [typeof enTranslations, typeof swTranslations, typeof gbTranslations]
24
- >
25
-
26
- export type ISValidTranslation<T extends DominantTranslation> = T