@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
@@ -2,32 +2,30 @@ import { attach, createEffect, createEvent, EventCallable, restore, sample, Stor
2
2
  import {
3
3
  AddTranslationToAlternativesProps,
4
4
  TranslateBatchFxProps,
5
- ApplyTranslationProps,
5
+ TranslateMessageFxProps,
6
6
  TranslateRequestProps,
7
7
  } from '../types/translation.types'
8
- import { ChatbotContext, ChatbotMessages } from '../types/model.types'
8
+ import { ChatbotContext, ChatbotMessages, ConversationMessage } from '../types/model.types'
9
9
  import { GetAlternativesResponse } from '../types/api.types'
10
10
  import { decodeHTMLEntities } from '../helpers'
11
- import { ChatbotAPI } from './ChatbotApi'
11
+ import { ChatbotAPI } from './api'
12
+ import { EntityFieldStore } from '../../../lib/effector/createEntityFieldStore'
12
13
  import {
13
14
  addTranslationsToAlternative,
14
15
  addTranslationToOptions,
15
16
  getOptionsForTranslation,
16
17
  } from './translation.helpers'
17
18
 
18
- import { ChatsCacheModel } from './ChatsCacheModel'
19
- import { ConversationMessage } from '../types/units.types'
20
-
21
19
  type ChatbotTranslationProps = {
22
20
  api: ChatbotAPI
23
21
  $key: Store<string>
24
22
  defaultMessages: ChatbotMessages
23
+ messagesModel: EntityFieldStore<ConversationMessage[]>
25
24
  $context: Store<ChatbotContext | null>
26
25
  alternativesModel: {
27
26
  set: EventCallable<GetAlternativesResponse | null>
28
27
  $store: Store<GetAlternativesResponse | null>
29
28
  }
30
- chats: ChatsCacheModel
31
29
  }
32
30
 
33
31
  export class ChatbotTranslation {
@@ -35,54 +33,39 @@ export class ChatbotTranslation {
35
33
  private readonly $key
36
34
  private readonly $context
37
35
  private readonly defaultMessages
36
+ private readonly messagesModel
38
37
  private readonly alternativesModel
39
38
 
40
39
  readonly setIsTranslated = createEvent<boolean>()
41
40
  readonly $isTranslated = restore(this.setIsTranslated, false)
42
41
 
43
- public readonly translateAllMessagesFx
44
- public readonly applyTranslationFx
42
+ readonly translateAllMessagesFx
45
43
 
46
44
  constructor({
47
45
  api,
48
46
  $key,
49
47
  defaultMessages,
48
+ messagesModel,
50
49
  alternativesModel,
51
50
  $context,
52
- chats,
53
51
  }: ChatbotTranslationProps) {
54
52
  this.api = api
55
53
  this.$key = $key
56
54
  this.$context = $context
57
55
  this.defaultMessages = defaultMessages
56
+ this.messagesModel = messagesModel
58
57
  this.alternativesModel = alternativesModel
59
58
 
60
- this.applyTranslationFx = attach({
61
- source: [this.$isTranslated, this.$context],
62
- mapParams: (messages: ConversationMessage[], [isTranslationActive, context]) => ({
63
- messages,
64
- targetLanguage: context?.translationTargetLanguage ?? '',
65
- isTranslationActive,
66
- }),
67
- effect: this.translateMessagesFx,
68
- })
69
-
70
59
  this.translateAllMessagesFx = attach({
71
- source: [this.$key, chats.$data, this.alternativesModel.$store, this.$context],
72
- mapParams: (_: void, [key, chats, alternatives, context]) => ({
60
+ source: [this.$key, this.messagesModel.$state, this.alternativesModel.$store, this.$context],
61
+ mapParams: (_: void, [key, messages, alternatives, context]) => ({
73
62
  targetLanguage: context?.translationTargetLanguage ?? '',
74
- messages: chats[key]?.messages ?? [],
63
+ messages: messages[key] ?? [],
75
64
  alternatives,
76
65
  }),
77
66
  effect: this.translateBatchFx,
78
67
  })
79
-
80
- sample({
81
- clock: this.translateAllMessagesFx.doneData,
82
- source: [this.$key] as const,
83
- fn: ([key], translatedMessages) => ({ key, data: { messages: translatedMessages } }),
84
- target: chats.update,
85
- })
68
+ this.initTranslationSamples()
86
69
  }
87
70
 
88
71
  private shouldSkipTranslation(messages: ConversationMessage[]) {
@@ -100,6 +83,15 @@ export class ChatbotTranslation {
100
83
  return false
101
84
  }
102
85
 
86
+ private initTranslationSamples() {
87
+ sample({
88
+ clock: this.translateAllMessagesFx.doneData,
89
+ source: [this.$key] as const,
90
+ fn: ([key], translatedMessages) => ({ key, data: translatedMessages }),
91
+ target: this.messagesModel.setField,
92
+ })
93
+ }
94
+
103
95
  private async translateRequest<List extends Record<string, string[]>>({
104
96
  textList,
105
97
  targetLanguage,
@@ -175,13 +167,11 @@ export class ChatbotTranslation {
175
167
  },
176
168
  )
177
169
 
178
- private readonly translateMessagesFx = createEffect(
170
+ public readonly translateMessagesFx = createEffect(
179
171
  async ({
180
172
  messages,
181
173
  targetLanguage,
182
- isTranslationActive,
183
- }: ApplyTranslationProps): Promise<ConversationMessage[]> => {
184
- if (!isTranslationActive || !targetLanguage) return messages
174
+ }: TranslateMessageFxProps): Promise<ConversationMessage[]> => {
185
175
  const text = messages
186
176
  .map(({ options, message }) => {
187
177
  return [message, ...options.map(({ text }) => text)]
@@ -1,4 +1,8 @@
1
- import { ChatAnswer, FullStrokeData, Stroke } from './units.types'
1
+ export type ChatAnswer = {
2
+ text: string
3
+ promptKey: string
4
+ translatedText?: string
5
+ }
2
6
 
3
7
  export type GetAlternativesPayload = {
4
8
  municipalityId: string
@@ -17,15 +21,16 @@ export type PostMessagePayload = {
17
21
  language: string
18
22
  problemAnswer: string[]
19
23
  answer?: string | string[]
24
+ threadId?: string | null
20
25
  problem: string
21
26
  imageAltText?: string
22
27
  }
23
28
 
24
29
  export type PostMessageResponse = {
25
30
  message: string
31
+ threadId: string
26
32
  options: ChatAnswer[]
27
33
  endMessage?: boolean
28
- threadId: string
29
34
  }
30
35
 
31
36
  export type GoogleTranslatePayload = {
@@ -56,6 +61,11 @@ export type GoogleText2SpeechPayload = {
56
61
 
57
62
  export type GoogleText2SpeechResponse = string | undefined | { audioContent?: string }
58
63
 
64
+ export type Stroke = {
65
+ x: number[]
66
+ y: number[]
67
+ }
68
+
59
69
  export type ChatHintPayload = {
60
70
  problemDescription: string
61
71
  correctAnswer: string[]
@@ -69,13 +79,3 @@ export type ChatHintPayload = {
69
79
  export type ChatHintResponse = {
70
80
  message: string
71
81
  }
72
- export type ErrorSpottingPayload = {
73
- strokes: FullStrokeData[]
74
- problemDescription: string
75
- correctAnswer: string[]
76
- userAnswer: string | string[]
77
- hint: string
78
- }
79
- export type ErrorSpottingResponse = {
80
- highlightedStrokeIds: string[]
81
- }
@@ -1,20 +1,27 @@
1
1
  import type { Store } from 'effector'
2
2
  import {
3
- ChatHintPayload,
4
- ChatHintResponse,
5
- ErrorSpottingPayload,
6
- ErrorSpottingResponse,
7
- GetAlternativesPayload,
8
3
  GetAlternativesResponse,
9
- GoogleText2SpeechPayload,
10
- GoogleText2SpeechResponse,
11
- GoogleTranslatePayload,
12
- GoogleTranslateResponse,
13
4
  PostMessagePayload,
14
5
  PostMessageResponse,
6
+ GoogleTranslatePayload,
7
+ GoogleTranslateResponse,
8
+ GoogleText2SpeechPayload,
9
+ GoogleText2SpeechResponse,
10
+ ChatAnswer,
11
+ GetAlternativesPayload,
12
+ Stroke,
15
13
  } from './api.types'
16
14
  import { ExtendWithOptional } from '../../../lib/helpers/types'
17
- import { ChatAnswer, ConversationMessage, FullStrokeData } from './units.types'
15
+
16
+ export type ConversationMessage = {
17
+ id: string
18
+ message: string
19
+ threadId: string
20
+ options: ChatAnswer[]
21
+ isOwnMessage: boolean
22
+ translatedMessage?: string
23
+ endMessage?: boolean
24
+ }
18
25
 
19
26
  export type ChatbotMessages = {
20
27
  error: ConversationMessage
@@ -23,20 +30,15 @@ export type ChatbotMessages = {
23
30
  anotherHintOption: ChatAnswer
24
31
  }
25
32
 
26
- export type ChatbotApiRequests = {
27
- getAlternatives: (props: GetAlternativesPayload) => Promise<GetAlternativesResponse>
28
- postMessage: (props: PostMessagePayload) => Promise<PostMessageResponse>
29
- postTranslateText: (props: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>
30
- postTextToSpeech: (props: GoogleText2SpeechPayload) => Promise<GoogleText2SpeechResponse>
31
- spotError: (props: ErrorSpottingPayload) => Promise<ErrorSpottingResponse>
32
- }
33
-
34
33
  export type ChatbotModelProps = {
35
34
  $key?: Store<string>
36
- api: Omit<ChatbotApiRequests, 'postMessage'> & {
37
- requestHint: (props: ChatHintPayload) => Promise<ChatHintResponse>
35
+ api: {
36
+ getAlternatives: (props: GetAlternativesPayload) => Promise<GetAlternativesResponse>
37
+ postMessage: (props: PostMessagePayload) => Promise<PostMessageResponse>
38
+ postTranslateText: (props: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>
39
+ postTextToSpeech: (props: GoogleText2SpeechPayload) => Promise<GoogleText2SpeechResponse>
38
40
  }
39
- threadMessagesLimit?: number
41
+ messages: ChatbotMessages
40
42
  }
41
43
 
42
44
  export type SendHelpParams = {
@@ -46,6 +48,8 @@ export type SendHelpParams = {
46
48
 
47
49
  export type SendHelpProps = SendHelpParams & {
48
50
  key: string
51
+ isTranslated: boolean
52
+ threadId: string
49
53
  context: ChatbotContext | null
50
54
  }
51
55
 
@@ -67,19 +71,16 @@ export enum MessageVariant {
67
71
  RECEIVED = 'received',
68
72
  }
69
73
 
70
- export type CreateMessageResponse = ExtendWithOptional<
71
- Omit<PostMessageResponse, 'threadId'>,
72
- ConversationMessage
73
- >
74
-
75
- type GetVisibleStrokesResponse = {
76
- strokes: FullStrokeData[]
77
- validationKey: string
74
+ export type ChatbotRenderer = {
75
+ message: string
76
+ variant: MessageVariant
77
+ withTextToSpeech: boolean
78
78
  }
79
79
 
80
+ export type CreateMessageResponse = ExtendWithOptional<PostMessageResponse, ConversationMessage>
81
+
80
82
  export type IChatDrawBoardAdapter = {
81
- $strokesValidationKey: Store<string | null>
82
- getVisibleStrokes(): Promise<GetVisibleStrokesResponse | null>
83
+ getVisibleStrokes(): Promise<Stroke[] | null>
83
84
  }
84
85
 
85
86
  export type ChatbotContext = {
@@ -1,27 +1,24 @@
1
- import { ConversationMessage } from './units.types'
1
+ import { AUDIO_CONFIG, DEFAULT_VOICE } from '../constants'
2
2
 
3
3
  export enum AudioStatus {
4
- PLAYING = 'playing',
5
- STOPPED = 'stopped',
6
- PAUSED = 'paused',
4
+ PLAYING = 'playing',
5
+ STOPPED = 'stopped',
6
+ PAUSED = 'paused',
7
7
  }
8
8
 
9
9
  export type AudioProvider = {
10
- play: (audioPath: string, onPlaybackComplete: () => void) => Promise<void>
11
- pause: () => void
12
- resume: () => void
13
- stop: () => void
10
+ play: (audioPath: string, onPlaybackComplete: () => void) => Promise<void>
11
+ pause: () => void
12
+ resume: () => void
13
+ stop: () => void
14
14
  }
15
15
 
16
16
  export type PlayTextToSpeechProps = {
17
- message: ConversationMessage
18
- isTranslated: boolean
19
- }
20
-
21
- export type T2SState = {
22
- status: AudioStatus
23
- disabled: boolean
24
- isActive: boolean
25
- isLoading: boolean
26
- isEnabled: boolean
17
+ text: string
18
+ messageId: string
19
+ isTranslated: boolean
20
+ config?: {
21
+ voice?: typeof DEFAULT_VOICE
22
+ audioConfig?: typeof AUDIO_CONFIG
23
+ }
27
24
  }
@@ -1,5 +1,5 @@
1
+ import { ConversationMessage } from './model.types'
1
2
  import { GetAlternativesResponse } from './api.types'
2
- import { ConversationMessage } from './units.types'
3
3
 
4
4
  export type TranslateBatchFxProps = {
5
5
  messages: ConversationMessage[]
@@ -7,10 +7,9 @@ export type TranslateBatchFxProps = {
7
7
  alternatives: GetAlternativesResponse | null
8
8
  }
9
9
 
10
- export type ApplyTranslationProps = {
10
+ export type TranslateMessageFxProps = {
11
11
  messages: ConversationMessage[]
12
12
  targetLanguage: string
13
- isTranslationActive: boolean
14
13
  }
15
14
 
16
15
  export type AddTranslationToAlternativesProps = {
@@ -64,8 +64,6 @@ export const AnimatedCard = memo(
64
64
  const statsOpacity = useSharedValue(OPACITY.initial)
65
65
  const delaySv = useSharedValue(0)
66
66
 
67
- const starOffsetLeft = gbdAmount > 9 ? 70 : 55
68
-
69
67
  const animatedCardStyle = useAnimatedStyle(() => {
70
68
  const progress = interpolate(
71
69
  statsOpacity.value,
@@ -194,7 +192,7 @@ export const AnimatedCard = memo(
194
192
 
195
193
  <Animated.View style={[styles.statsWrapper, animatedStatsStyle]}>
196
194
  {variant === AnimatedCardVariant.GOOD_DRAWING && (
197
- <View style={[styles.starContainer, { left: starOffsetLeft }]}>
195
+ <View style={styles.starContainer}>
198
196
  <SparkIcon size={20} color={VARIANT_COLORS[variant].initial} />
199
197
  <View style={styles.starCircle} />
200
198
  <SparkIcon size={12} color={VARIANT_COLORS[variant].initial} />
@@ -283,6 +281,7 @@ const styles = StyleSheet.create({
283
281
  },
284
282
  starContainer: {
285
283
  position: 'absolute',
284
+ left: 70,
286
285
  top: 10,
287
286
  },
288
287
  starCircle: {
@@ -1,5 +1,6 @@
1
1
  import React, { useEffect } from 'react'
2
2
  import { StyleSheet } from 'react-native'
3
+
3
4
  import Animated, {
4
5
  useSharedValue,
5
6
  withDelay,
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { useFeaturesLocalization, setFeaturesLocalization, Locale } from './shared/translation'
2
+ export type { LocalizationConfig } from './shared/translation'
2
3
  export { generateRandomId } from './lib/helpers/helpers'
3
4
  export * from './features/chatbot'
4
5
  export * from './features/feedback'
@@ -1,4 +1,4 @@
1
- import { createEvent, createStore, Event } from 'effector'
1
+ import { createEvent, createStore } from 'effector'
2
2
 
3
3
  type UpdateField<T> = {
4
4
  key: string
@@ -19,14 +19,6 @@ export class EntityFieldStore<T> {
19
19
  return { ...state, [key]: data }
20
20
  })
21
21
  .reset(this.reset)
22
-
23
- public on<EV>(
24
- event: Event<EV>,
25
- fn: (state: Record<string, T>, payload: EV) => Record<string, T> | void,
26
- ) {
27
- this.$state.on(event, fn)
28
- return this
29
- }
30
22
  }
31
23
 
32
24
  export function createEntityFieldStore<T>() {
@@ -10,12 +10,5 @@
10
10
  "time.monthAgo": "month ago",
11
11
  "time.monthsAgo": "months ago",
12
12
  "time.yearAgo": "year ago",
13
- "time.yearsAgo": "years ago",
14
- "chat": {
15
- "anotherHint": "Give me another hint",
16
- "answerAgain": "Answer again to get another hint!",
17
- "errorMessage": "Sorry, I can't help with this issue at the moment 😔.",
18
- "howCanIHelp": "Hi! Do you want help?",
19
- "showError": "Show error"
20
- }
13
+ "time.yearsAgo": "years ago"
21
14
  }
@@ -10,12 +10,5 @@
10
10
  "time.monthAgo": "month ago",
11
11
  "time.monthsAgo": "months ago",
12
12
  "time.yearAgo": "year ago",
13
- "time.yearsAgo": "years ago",
14
- "chat": {
15
- "anotherHint": "Give me another hint",
16
- "answerAgain": "Answer again to get another hint!",
17
- "errorMessage": "Sorry, I can't help with this issue at the moment 😔.",
18
- "howCanIHelp": "Hi! Do you want help?",
19
- "showError": "Show error"
20
- }
13
+ "time.yearsAgo": "years ago"
21
14
  }
@@ -10,12 +10,5 @@
10
10
  "time.monthAgo": "månad sedan",
11
11
  "time.monthsAgo": "månader sedan",
12
12
  "time.yearAgo": "år sedan",
13
- "time.yearsAgo": "år sedan",
14
- "chat": {
15
- "anotherHint": "Ge mig en ledtråd",
16
- "answerAgain": "Svara igen för att få en till ledtråd!",
17
- "errorMessage": "Tyvärr kan jag inte hjälpa dig just nu 😔.",
18
- "howCanIHelp": "Hej! Hur kan jag hjälpa dig?",
19
- "showError": "Visa fel"
20
- }
13
+ "time.yearsAgo": "år sedan"
21
14
  }
@@ -1,11 +1,8 @@
1
- import { StyleProp, ViewStyle } from 'react-native'
2
-
3
1
  export type IconProps = {
4
- color?: string
5
- className?: string
6
- size?: number
7
- strokeWidth?: string
8
- width?: number
9
- height?: number
10
- style?: StyleProp<ViewStyle>
2
+ color?: string
3
+ className?: string
4
+ size?: number
5
+ strokeWidth?: string
6
+ width?: number
7
+ height?: number
11
8
  }
@@ -1,7 +1,7 @@
1
1
  import { Locale } from './types'
2
- import EN from './localization/en.json'
3
- import GB from './localization/gb.json'
4
- import SW from './localization/sw.json'
2
+ import EN from '../../lib/localization/en.json'
3
+ import GB from '../../lib/localization/gb.json'
4
+ import SW from '../../lib/localization/sw.json'
5
5
 
6
6
  export const LOCALIZATION_CONFIGS = {
7
7
  [Locale.EN]: EN,
@@ -1,23 +1,6 @@
1
1
  import { LOCALIZATION_CONFIGS } from './constants'
2
2
  import { $localization, setLocalization } from './model'
3
- import { GetText, TranslationKeys, Translations } from './types'
4
-
5
- export function getTranslation(config: Translations, key: TranslationKeys) {
6
- const rawTranslation = config?.[key as keyof Translations]
7
- if (typeof rawTranslation === 'string' || !key.includes('.')) {
8
- return rawTranslation as string
9
- }
10
- const keys = key.split('.')
11
- let translation = config
12
- for (const k of keys) {
13
- if (translation[k as keyof Translations] === undefined) return key
14
- translation = translation[k as keyof Translations] as any
15
- }
16
- if (typeof translation === 'string') {
17
- return translation
18
- }
19
- return key
20
- }
3
+ import { GetText, LocalizationConfig, TranslationKeys } from './types'
21
4
 
22
5
  export const getSubstitutedString = (str: string, substitutions: Record<string, string> = {}) => {
23
6
  const substitutionsArray = Object.entries(substitutions)
@@ -35,13 +18,17 @@ export const getSubstitutedString = (str: string, substitutions: Record<string,
35
18
  export const getText: GetText = (key: TranslationKeys, args = null) => {
36
19
  const config = $localization.getState()
37
20
 
38
- const translation = getTranslation(config, key)
39
- if (args) return getSubstitutedString(translation, args)
40
- return translation
21
+ const translation = config?.[key]
22
+
23
+ if (translation && args) {
24
+ return getSubstitutedString(translation, args)
25
+ }
26
+
27
+ return translation ?? key
41
28
  }
42
29
 
43
30
  export const setFeaturesLocalization = (
44
- generator: ((config: typeof LOCALIZATION_CONFIGS) => Translations) | Translations,
31
+ generator: ((config: typeof LOCALIZATION_CONFIGS) => LocalizationConfig) | LocalizationConfig,
45
32
  ) => {
46
33
  setLocalization(generator)
47
34
  }
@@ -1,24 +1,28 @@
1
1
  import { useUnit } from 'effector-react'
2
2
  import { $localization, setLocalization } from './model'
3
- import { GetText, Translations } from './types'
3
+ import { GetText, LocalizationConfig } from './types'
4
4
  import { useEffect } from 'react'
5
5
  import { LOCALIZATION_CONFIGS } from './constants'
6
- import { getSubstitutedString, getTranslation } from './helpers'
6
+ import { getSubstitutedString } from './helpers'
7
7
 
8
8
  export const useText = (): GetText => {
9
- const config = useUnit($localization)
9
+ const config = useUnit($localization) as LocalizationConfig
10
10
 
11
- return (key, args = null) => {
12
- const translation = getTranslation(config, key)
13
- if (args) return getSubstitutedString(translation, args)
14
- return translation
15
- }
11
+ return (key, args = null) => {
12
+ const translation = config?.[key]
13
+
14
+ if (translation && args) {
15
+ return getSubstitutedString(translation, args)
16
+ }
17
+
18
+ return translation ?? key
19
+ }
16
20
  }
17
21
 
18
22
  export const useFeaturesLocalization = (
19
- generator: ((config: typeof LOCALIZATION_CONFIGS) => Translations) | Translations,
23
+ generator: ((config: typeof LOCALIZATION_CONFIGS) => LocalizationConfig) | LocalizationConfig,
20
24
  ) => {
21
- useEffect(() => {
22
- setLocalization(generator)
23
- }, [generator])
25
+ useEffect(() => {
26
+ setLocalization(generator)
27
+ }, [generator])
24
28
  }
@@ -2,3 +2,4 @@ export { useFeaturesLocalization, useText } from './hooks'
2
2
  export { setFeaturesLocalization, getText as t } from './helpers'
3
3
  export { $localization, setLocalization } from './model'
4
4
  export { Locale } from './types'
5
+ export type { LocalizationConfig } from './types'
@@ -1,15 +1,15 @@
1
1
  import { createEvent, createStore } from 'effector'
2
- import { Locale, Translations } from './types'
2
+ import { Locale, LocalizationConfig } from './types'
3
3
  import { LOCALIZATION_CONFIGS } from './constants'
4
4
 
5
5
  export const setLocalization = createEvent<
6
- Translations | ((config: typeof LOCALIZATION_CONFIGS) => Translations)
6
+ LocalizationConfig | ((config: typeof LOCALIZATION_CONFIGS) => LocalizationConfig)
7
7
  >()
8
8
 
9
- export const $localization = createStore<Translations>(LOCALIZATION_CONFIGS[Locale.EN]).on(
10
- setLocalization,
11
- (state, payload) => {
12
- if (typeof payload === 'function') return payload(LOCALIZATION_CONFIGS)
13
- return payload
14
- },
9
+ export const $localization = createStore<LocalizationConfig>(LOCALIZATION_CONFIGS[Locale.EN]).on(
10
+ setLocalization,
11
+ (state, payload) => {
12
+ if (typeof payload === 'function') return payload(LOCALIZATION_CONFIGS)
13
+ if (state.locale !== payload.locale) return payload
14
+ },
15
15
  )
@@ -1,12 +1,12 @@
1
- import enTranslations from './localization/en.json'
2
- import swTranslations from './localization/sw.json'
3
- import gbTranslations from './localization/gb.json'
4
- import { RetrieveKeys } from '../../lib/types/keys'
5
- import { ISValidTranslation } from './validation.types'
1
+ import enTranslations from '../../lib/localization/en.json'
6
2
 
7
3
  export type Translations = typeof enTranslations
8
- export type TranslationKeys = RetrieveKeys<Translations>
9
- export type GetText = (key: TranslationKeys, args?: Record<string, string> | null) => string
4
+ export type TranslationKeys = keyof Translations
5
+
6
+ export type GetText = <T extends TranslationKeys>(
7
+ key: T,
8
+ args?: Record<string, string> | null,
9
+ ) => Translations[T]
10
10
 
11
11
  export enum Locale {
12
12
  EN = 'en-SE',
@@ -14,7 +14,4 @@ export enum Locale {
14
14
  GB = 'en-GB',
15
15
  }
16
16
 
17
- // Validation of translations, do not remove
18
- type ISValidEN = ISValidTranslation<Translations>
19
- type ISValidSW = ISValidTranslation<typeof swTranslations>
20
- type ISValidGB = ISValidTranslation<typeof gbTranslations>
17
+ export type LocalizationConfig = Record<string, string>