@magmamath/students-features 0.6.14-rc.2 → 0.6.14-rc.21

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 (274) hide show
  1. package/dist/commonjs/features/chatbot/components/{ChatMessages/ChatbotMessages.js → Chat/Chat.js} +8 -15
  2. package/dist/commonjs/features/chatbot/components/Chat/Chat.js.map +1 -0
  3. package/dist/commonjs/features/chatbot/components/ChatInput/ChatInput.js +74 -0
  4. package/dist/commonjs/features/chatbot/components/ChatInput/ChatInput.js.map +1 -0
  5. package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js +144 -0
  6. package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -0
  7. package/dist/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.js +135 -0
  8. package/dist/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.js.map +1 -0
  9. package/dist/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js +77 -0
  10. package/dist/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js.map +1 -0
  11. package/dist/commonjs/features/chatbot/components/{Alternatives/InputButton.js → ChatInput/freeText/SendMessageButton.js} +26 -17
  12. package/dist/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.js.map +1 -0
  13. package/dist/commonjs/features/chatbot/components/Chatbot.js +2 -2
  14. package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
  15. package/dist/commonjs/features/chatbot/constants.js +2 -1
  16. package/dist/commonjs/features/chatbot/constants.js.map +1 -1
  17. package/dist/commonjs/features/chatbot/index.js +7 -0
  18. package/dist/commonjs/features/chatbot/index.js.map +1 -1
  19. package/dist/commonjs/features/chatbot/model/ChatBotModel.js +44 -8
  20. package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
  21. package/dist/commonjs/features/chatbot/model/ChatBotTextInput.js +16 -0
  22. package/dist/commonjs/features/chatbot/model/ChatBotTextInput.js.map +1 -0
  23. package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js +44 -11
  24. package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
  25. package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
  26. package/dist/commonjs/features/chatbot/types/types.js +2 -0
  27. package/dist/commonjs/features/chatbot/types/types.js.map +1 -0
  28. package/dist/commonjs/features/chatbot/types/units.types.js +10 -0
  29. package/dist/commonjs/features/chatbot/types/units.types.js.map +1 -1
  30. package/dist/commonjs/features/exampleSolution/ExampleSolutionModal.js +1 -3
  31. package/dist/commonjs/features/exampleSolution/ExampleSolutionModal.js.map +1 -1
  32. package/dist/commonjs/features/exampleSolution/assets/grid.webp +0 -0
  33. package/dist/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.js +18 -11
  34. package/dist/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.js.map +1 -1
  35. package/dist/commonjs/features/exampleSolution/components/QuestionSection.js +7 -7
  36. package/dist/commonjs/features/exampleSolution/components/QuestionSection.js.map +1 -1
  37. package/dist/commonjs/features/exampleSolution/components/SolutionSection.js +55 -29
  38. package/dist/commonjs/features/exampleSolution/components/SolutionSection.js.map +1 -1
  39. package/dist/commonjs/features/exampleSolution/model/ExampleSolution.model.js +3 -1
  40. package/dist/commonjs/features/exampleSolution/model/ExampleSolution.model.js.map +1 -1
  41. package/dist/commonjs/features/formulaSheet/components/FormulaSheet.js +5 -4
  42. package/dist/commonjs/features/formulaSheet/components/FormulaSheet.js.map +1 -1
  43. package/dist/commonjs/shared/hooks/useKeyDownListener.js +3 -2
  44. package/dist/commonjs/shared/hooks/useKeyDownListener.js.map +1 -1
  45. package/dist/commonjs/shared/translation/localization/ca.json +2 -1
  46. package/dist/commonjs/shared/translation/localization/en.json +3 -2
  47. package/dist/commonjs/shared/translation/localization/gb.json +2 -1
  48. package/dist/commonjs/shared/translation/localization/sct.json +2 -1
  49. package/dist/commonjs/shared/translation/localization/sw.json +3 -2
  50. package/dist/module/features/chatbot/components/{ChatMessages/ChatbotMessages.js → Chat/Chat.js} +6 -13
  51. package/dist/module/features/chatbot/components/Chat/Chat.js.map +1 -0
  52. package/dist/module/features/chatbot/components/ChatInput/ChatInput.js +67 -0
  53. package/dist/module/features/chatbot/components/ChatInput/ChatInput.js.map +1 -0
  54. package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js +138 -0
  55. package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -0
  56. package/dist/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.js +128 -0
  57. package/dist/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.js.map +1 -0
  58. package/dist/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js +71 -0
  59. package/dist/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.js.map +1 -0
  60. package/dist/module/features/chatbot/components/{Alternatives/InputButton.js → ChatInput/freeText/SendMessageButton.js} +25 -16
  61. package/dist/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.js.map +1 -0
  62. package/dist/module/features/chatbot/components/Chatbot.js +2 -2
  63. package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
  64. package/dist/module/features/chatbot/constants.js +1 -0
  65. package/dist/module/features/chatbot/constants.js.map +1 -1
  66. package/dist/module/features/chatbot/index.js +1 -0
  67. package/dist/module/features/chatbot/index.js.map +1 -1
  68. package/dist/module/features/chatbot/model/ChatBotModel.js +44 -8
  69. package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
  70. package/dist/module/features/chatbot/model/ChatBotTextInput.js +11 -0
  71. package/dist/module/features/chatbot/model/ChatBotTextInput.js.map +1 -0
  72. package/dist/module/features/chatbot/model/ChatBotThreadManager.js +44 -11
  73. package/dist/module/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
  74. package/dist/module/features/chatbot/types/model.types.js.map +1 -1
  75. package/dist/module/features/chatbot/types/types.js +2 -0
  76. package/dist/module/features/chatbot/types/types.js.map +1 -0
  77. package/dist/module/features/chatbot/types/units.types.js +6 -0
  78. package/dist/module/features/chatbot/types/units.types.js.map +1 -1
  79. package/dist/module/features/exampleSolution/ExampleSolutionModal.js +1 -3
  80. package/dist/module/features/exampleSolution/ExampleSolutionModal.js.map +1 -1
  81. package/dist/module/features/exampleSolution/assets/grid.webp +0 -0
  82. package/dist/module/features/exampleSolution/components/ExampleSolutionModalContent.js +19 -12
  83. package/dist/module/features/exampleSolution/components/ExampleSolutionModalContent.js.map +1 -1
  84. package/dist/module/features/exampleSolution/components/QuestionSection.js +9 -9
  85. package/dist/module/features/exampleSolution/components/QuestionSection.js.map +1 -1
  86. package/dist/module/features/exampleSolution/components/SolutionSection.js +57 -31
  87. package/dist/module/features/exampleSolution/components/SolutionSection.js.map +1 -1
  88. package/dist/module/features/exampleSolution/model/ExampleSolution.model.js +3 -1
  89. package/dist/module/features/exampleSolution/model/ExampleSolution.model.js.map +1 -1
  90. package/dist/module/features/formulaSheet/components/FormulaSheet.js +5 -4
  91. package/dist/module/features/formulaSheet/components/FormulaSheet.js.map +1 -1
  92. package/dist/module/shared/hooks/useKeyDownListener.js +3 -2
  93. package/dist/module/shared/hooks/useKeyDownListener.js.map +1 -1
  94. package/dist/module/shared/translation/localization/ca.json +2 -1
  95. package/dist/module/shared/translation/localization/en.json +3 -2
  96. package/dist/module/shared/translation/localization/gb.json +2 -1
  97. package/dist/module/shared/translation/localization/sct.json +2 -1
  98. package/dist/module/shared/translation/localization/sw.json +3 -2
  99. package/dist/typescript/commonjs/features/chatbot/components/{ChatMessages/ChatbotMessages.d.ts → Chat/Chat.d.ts} +3 -3
  100. package/dist/typescript/commonjs/features/chatbot/components/Chat/Chat.d.ts.map +1 -0
  101. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/ChatInput.d.ts +9 -0
  102. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/ChatInput.d.ts.map +1 -0
  103. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/RequestHintButton.d.ts +16 -0
  104. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -0
  105. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts +16 -0
  106. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts.map +1 -0
  107. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts +11 -0
  108. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts.map +1 -0
  109. package/dist/typescript/{module/features/chatbot/components/Alternatives/InputButton.d.ts → commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts} +2 -2
  110. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts.map +1 -0
  111. package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts +2 -0
  112. package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts.map +1 -1
  113. package/dist/typescript/commonjs/features/chatbot/constants.d.ts +1 -0
  114. package/dist/typescript/commonjs/features/chatbot/constants.d.ts.map +1 -1
  115. package/dist/typescript/commonjs/features/chatbot/index.d.ts +1 -0
  116. package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -1
  117. package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +5 -6
  118. package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
  119. package/dist/typescript/commonjs/features/chatbot/model/ChatBotTextInput.d.ts +8 -0
  120. package/dist/typescript/commonjs/features/chatbot/model/ChatBotTextInput.d.ts.map +1 -0
  121. package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts +3 -2
  122. package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -1
  123. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts +1 -1
  124. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts.map +1 -1
  125. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +23 -1
  126. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -1
  127. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +11 -2
  128. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
  129. package/dist/typescript/commonjs/features/chatbot/types/types.d.ts +1 -0
  130. package/dist/typescript/commonjs/features/chatbot/types/types.d.ts.map +1 -0
  131. package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts +5 -0
  132. package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts.map +1 -1
  133. package/dist/typescript/commonjs/features/exampleSolution/ExampleSolutionModal.d.ts.map +1 -1
  134. package/dist/typescript/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.d.ts +5 -1
  135. package/dist/typescript/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +1 -1
  136. package/dist/typescript/commonjs/features/exampleSolution/components/QuestionSection.d.ts +2 -1
  137. package/dist/typescript/commonjs/features/exampleSolution/components/QuestionSection.d.ts.map +1 -1
  138. package/dist/typescript/commonjs/features/exampleSolution/components/SolutionSection.d.ts.map +1 -1
  139. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolution.model.d.ts +3 -2
  140. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolution.model.d.ts.map +1 -1
  141. package/dist/typescript/commonjs/features/exampleSolution/types.d.ts +2 -1
  142. package/dist/typescript/commonjs/features/exampleSolution/types.d.ts.map +1 -1
  143. package/dist/typescript/commonjs/features/formulaSheet/components/FormulaSheet.d.ts.map +1 -1
  144. package/dist/typescript/commonjs/shared/hooks/useKeyDownListener.d.ts +1 -1
  145. package/dist/typescript/commonjs/shared/hooks/useKeyDownListener.d.ts.map +1 -1
  146. package/dist/typescript/commonjs/shared/hooks/useKeyboard.d.ts +1 -1
  147. package/dist/typescript/commonjs/shared/hooks/useKeyboard.d.ts.map +1 -1
  148. package/dist/typescript/commonjs/shared/translation/constants.d.ts +5 -0
  149. package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
  150. package/dist/typescript/commonjs/shared/translation/model.d.ts +2 -0
  151. package/dist/typescript/commonjs/shared/translation/model.d.ts.map +1 -1
  152. package/dist/typescript/module/features/chatbot/components/{ChatMessages/ChatbotMessages.d.ts → Chat/Chat.d.ts} +3 -3
  153. package/dist/typescript/module/features/chatbot/components/Chat/Chat.d.ts.map +1 -0
  154. package/dist/typescript/module/features/chatbot/components/ChatInput/ChatInput.d.ts +9 -0
  155. package/dist/typescript/module/features/chatbot/components/ChatInput/ChatInput.d.ts.map +1 -0
  156. package/dist/typescript/module/features/chatbot/components/ChatInput/RequestHintButton.d.ts +16 -0
  157. package/dist/typescript/module/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -0
  158. package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts +16 -0
  159. package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/ChatTextInput.d.ts.map +1 -0
  160. package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts +11 -0
  161. package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.d.ts.map +1 -0
  162. package/dist/typescript/{commonjs/features/chatbot/components/Alternatives/InputButton.d.ts → module/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts} +2 -2
  163. package/dist/typescript/module/features/chatbot/components/ChatInput/freeText/SendMessageButton.d.ts.map +1 -0
  164. package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts +2 -0
  165. package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts.map +1 -1
  166. package/dist/typescript/module/features/chatbot/constants.d.ts +1 -0
  167. package/dist/typescript/module/features/chatbot/constants.d.ts.map +1 -1
  168. package/dist/typescript/module/features/chatbot/index.d.ts +1 -0
  169. package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -1
  170. package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +5 -6
  171. package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
  172. package/dist/typescript/module/features/chatbot/model/ChatBotTextInput.d.ts +8 -0
  173. package/dist/typescript/module/features/chatbot/model/ChatBotTextInput.d.ts.map +1 -0
  174. package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts +3 -2
  175. package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -1
  176. package/dist/typescript/module/features/chatbot/model/translation.d.ts +1 -1
  177. package/dist/typescript/module/features/chatbot/model/translation.d.ts.map +1 -1
  178. package/dist/typescript/module/features/chatbot/types/api.types.d.ts +23 -1
  179. package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -1
  180. package/dist/typescript/module/features/chatbot/types/model.types.d.ts +11 -2
  181. package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
  182. package/dist/typescript/module/features/chatbot/types/types.d.ts +1 -0
  183. package/dist/typescript/module/features/chatbot/types/types.d.ts.map +1 -0
  184. package/dist/typescript/module/features/chatbot/types/units.types.d.ts +5 -0
  185. package/dist/typescript/module/features/chatbot/types/units.types.d.ts.map +1 -1
  186. package/dist/typescript/module/features/exampleSolution/ExampleSolutionModal.d.ts.map +1 -1
  187. package/dist/typescript/module/features/exampleSolution/components/ExampleSolutionModalContent.d.ts +5 -1
  188. package/dist/typescript/module/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +1 -1
  189. package/dist/typescript/module/features/exampleSolution/components/QuestionSection.d.ts +2 -1
  190. package/dist/typescript/module/features/exampleSolution/components/QuestionSection.d.ts.map +1 -1
  191. package/dist/typescript/module/features/exampleSolution/components/SolutionSection.d.ts.map +1 -1
  192. package/dist/typescript/module/features/exampleSolution/model/ExampleSolution.model.d.ts +3 -2
  193. package/dist/typescript/module/features/exampleSolution/model/ExampleSolution.model.d.ts.map +1 -1
  194. package/dist/typescript/module/features/exampleSolution/types.d.ts +2 -1
  195. package/dist/typescript/module/features/exampleSolution/types.d.ts.map +1 -1
  196. package/dist/typescript/module/features/formulaSheet/components/FormulaSheet.d.ts.map +1 -1
  197. package/dist/typescript/module/shared/hooks/useKeyDownListener.d.ts +1 -1
  198. package/dist/typescript/module/shared/hooks/useKeyDownListener.d.ts.map +1 -1
  199. package/dist/typescript/module/shared/hooks/useKeyboard.d.ts +1 -1
  200. package/dist/typescript/module/shared/hooks/useKeyboard.d.ts.map +1 -1
  201. package/dist/typescript/module/shared/translation/constants.d.ts +5 -0
  202. package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
  203. package/dist/typescript/module/shared/translation/model.d.ts +2 -0
  204. package/dist/typescript/module/shared/translation/model.d.ts.map +1 -1
  205. package/package.json +2 -2
  206. package/src/features/chatbot/components/{ChatMessages/ChatbotMessages.tsx → Chat/Chat.tsx} +12 -17
  207. package/src/features/chatbot/components/ChatInput/ChatInput.tsx +83 -0
  208. package/src/features/chatbot/components/ChatInput/RequestHintButton.tsx +156 -0
  209. package/src/features/chatbot/components/ChatInput/freeText/ChatTextInput.tsx +153 -0
  210. package/src/features/chatbot/components/ChatInput/freeText/FreeTextInputBlock.tsx +83 -0
  211. package/src/features/chatbot/components/{Alternatives/InputButton.tsx → ChatInput/freeText/SendMessageButton.tsx} +37 -16
  212. package/src/features/chatbot/components/Chatbot.tsx +4 -2
  213. package/src/features/chatbot/constants.ts +3 -0
  214. package/src/features/chatbot/index.ts +2 -0
  215. package/src/features/chatbot/model/ChatBotModel.ts +67 -33
  216. package/src/features/chatbot/model/ChatBotTextInput.ts +10 -0
  217. package/src/features/chatbot/model/ChatBotThreadManager.ts +35 -9
  218. package/src/features/chatbot/model/translation.ts +1 -1
  219. package/src/features/chatbot/types/api.types.ts +25 -1
  220. package/src/features/chatbot/types/model.types.ts +16 -1
  221. package/src/features/chatbot/types/types.ts +0 -0
  222. package/src/features/chatbot/types/units.types.ts +6 -0
  223. package/src/features/exampleSolution/ExampleSolutionModal.tsx +1 -7
  224. package/src/features/exampleSolution/assets/grid.webp +0 -0
  225. package/src/features/exampleSolution/components/ExampleSolutionModalContent.tsx +24 -12
  226. package/src/features/exampleSolution/components/QuestionSection.tsx +11 -7
  227. package/src/features/exampleSolution/components/SolutionSection.tsx +72 -29
  228. package/src/features/exampleSolution/model/ExampleSolution.model.ts +5 -2
  229. package/src/features/exampleSolution/types.ts +2 -1
  230. package/src/features/formulaSheet/components/FormulaSheet.tsx +6 -4
  231. package/src/shared/hooks/useKeyDownListener.ts +3 -1
  232. package/src/shared/translation/localization/ca.json +2 -1
  233. package/src/shared/translation/localization/en.json +3 -2
  234. package/src/shared/translation/localization/gb.json +2 -1
  235. package/src/shared/translation/localization/sct.json +2 -1
  236. package/src/shared/translation/localization/sw.json +3 -2
  237. package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js +0 -111
  238. package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js.map +0 -1
  239. package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js +0 -208
  240. package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js.map +0 -1
  241. package/dist/commonjs/features/chatbot/components/Alternatives/InputButton.js.map +0 -1
  242. package/dist/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.js +0 -157
  243. package/dist/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.js.map +0 -1
  244. package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +0 -1
  245. package/dist/commonjs/features/exampleSolution/assets/grid.png +0 -0
  246. package/dist/module/features/chatbot/components/Alternatives/Alternatives.js +0 -105
  247. package/dist/module/features/chatbot/components/Alternatives/Alternatives.js.map +0 -1
  248. package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js +0 -200
  249. package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js.map +0 -1
  250. package/dist/module/features/chatbot/components/Alternatives/InputButton.js.map +0 -1
  251. package/dist/module/features/chatbot/components/Alternatives/InputWithHintRow.js +0 -150
  252. package/dist/module/features/chatbot/components/Alternatives/InputWithHintRow.js.map +0 -1
  253. package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +0 -1
  254. package/dist/module/features/exampleSolution/assets/grid.png +0 -0
  255. package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts +0 -11
  256. package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts.map +0 -1
  257. package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts +0 -13
  258. package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +0 -1
  259. package/dist/typescript/commonjs/features/chatbot/components/Alternatives/InputButton.d.ts.map +0 -1
  260. package/dist/typescript/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.d.ts +0 -11
  261. package/dist/typescript/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.d.ts.map +0 -1
  262. package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +0 -1
  263. package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts +0 -11
  264. package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts.map +0 -1
  265. package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts +0 -13
  266. package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +0 -1
  267. package/dist/typescript/module/features/chatbot/components/Alternatives/InputButton.d.ts.map +0 -1
  268. package/dist/typescript/module/features/chatbot/components/Alternatives/InputWithHintRow.d.ts +0 -11
  269. package/dist/typescript/module/features/chatbot/components/Alternatives/InputWithHintRow.d.ts.map +0 -1
  270. package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +0 -1
  271. package/src/features/chatbot/components/Alternatives/Alternatives.tsx +0 -135
  272. package/src/features/chatbot/components/Alternatives/HelpRequestOption.tsx +0 -214
  273. package/src/features/chatbot/components/Alternatives/InputWithHintRow.tsx +0 -160
  274. package/src/features/exampleSolution/assets/grid.png +0 -0
@@ -1,8 +1,10 @@
1
1
  import { attach, combine, createEffect, createEvent, restore, sample, type Store } from 'effector'
2
+ import { IS_WEB } from '@magmamath/react-native-ui'
2
3
  import {
3
4
  ChatbotContext,
4
5
  ChatbotModelProps,
5
6
  IChatDrawBoardAdapter,
7
+ ReinitConversationProps,
6
8
  SendHelpParams,
7
9
  SendHelpProps,
8
10
  SetHintMessageProps,
@@ -17,14 +19,11 @@ import { messagesHelper } from './messagesHelper'
17
19
  import { ChatBotThreadManager } from './ChatBotThreadManager'
18
20
  import { ChatsCacheModel, defaultChatData } from './ChatsCacheModel'
19
21
  import { ErrorSpottingModel } from '../errorSpotting/ErrorSpottingModel'
22
+ import { ChatBotTextInput } from './ChatBotTextInput'
20
23
  import { withEvent } from '../../../lib/effector/withEvent'
21
24
  import { ChatBotTextManager } from './ChatBoxTextManager'
22
25
  import { ControlledSample } from '../../../lib/effector/ControlledSample'
23
26
 
24
- type ReinitConversationProps = {
25
- key: string
26
- }
27
-
28
27
  export class ChatbotModel {
29
28
  public readonly textManager = new ChatBotTextManager()
30
29
  private readonly defaultMessages = this.textManager.messages
@@ -37,6 +36,7 @@ export class ChatbotModel {
37
36
  public readonly translation: ChatbotTranslation
38
37
  public readonly t2s: ChatTextToSpeechModel
39
38
  public readonly errorSpotting: ErrorSpottingModel
39
+ public readonly textInput = new ChatBotTextInput()
40
40
 
41
41
  private readonly setCurrentKey = createEvent<string>()
42
42
  public readonly $currentKey = restore(this.setCurrentKey, '')
@@ -46,7 +46,7 @@ export class ChatbotModel {
46
46
 
47
47
  readonly resetAlternatives = createEvent()
48
48
  readonly setAlternatives = createEvent<GetAlternativesResponse | null>()
49
- readonly $alternatives: Store<GetAlternativesResponse | null>
49
+ readonly $alternatives
50
50
 
51
51
  readonly setIsOpen = createEvent<boolean>()
52
52
  readonly toggleOpen = createEvent()
@@ -72,7 +72,7 @@ export class ChatbotModel {
72
72
  constructor({ api, $key, threadMessagesLimit, settings = {} }: ChatbotModelProps) {
73
73
  this.api = new ChatbotAPI({ ...api, postMessage: this.threadManager.postMessage })
74
74
 
75
- this.threadManager.setApi({ getHint: api.requestHint })
75
+ this.threadManager.setApi({ getHint: api.requestHint, sendMessage: api.sendMessage })
76
76
  if (threadMessagesLimit) {
77
77
  this.threadManager.setMessagesLimit(threadMessagesLimit)
78
78
  }
@@ -122,6 +122,11 @@ export class ChatbotModel {
122
122
  target: this.cache.update,
123
123
  })
124
124
 
125
+ sample({
126
+ clock: this.resetAlternatives,
127
+ target: this.textInput.reset
128
+ })
129
+
125
130
  if (settings.closeOnKeyChange) {
126
131
  sample({
127
132
  clock: this.$currentKey.updates,
@@ -154,42 +159,69 @@ export class ChatbotModel {
154
159
  },
155
160
  ),
156
161
  })
162
+
163
+ this.$alternatives.updates.watch((alternatives) => {
164
+ // Use short text for another hint option if openChatEnabled
165
+ if (alternatives?.chatAccess && alternatives?.isOpenChatEnabled && IS_WEB) {
166
+ this.textManager.update((creator) => ({
167
+ anotherHintOption: creator.createOption('chat.giveHint'),
168
+ }))
169
+ }
170
+ })
171
+
172
+
157
173
  }
158
174
 
159
175
  private createSendHelpRequestFx() {
160
176
  const effect = attach({
161
- source: [this.$currentKey, this.$context],
162
- mapParams: (params: SendHelpParams, [key, context]) => ({
177
+ source: [this.$currentKey, this.$context, this.cache.$data],
178
+ mapParams: (params: SendHelpParams, [key, context, cache]) => ({
163
179
  message: params.message,
164
180
  translatedMessage: params.translatedMessage,
181
+ isFreeText: params.isFreeText,
182
+ cache,
165
183
  context,
166
184
  key,
167
185
  }),
168
- effect: createEffect(async ({ message, translatedMessage, key, context }: SendHelpProps) => {
169
- if (!context) throw new Error('Trying to send message in chat without context')
170
- this.setLastMessageKey(key)
171
- this.cache.addMessages(key, {
172
- messages: [messagesHelper.createOwn({ message, translatedMessage })],
173
- })
174
-
175
- const response = await this.api.postMessageFx({
176
- problem: context.problem,
177
- language: context.language,
178
- problemAnswer: context.problemAnswer,
179
- answer: context.answer,
180
- imageAltText: context.imageDescription,
181
- })
182
- const thread = this.threadManager.get(key)
183
- const messages = [
184
- messagesHelper.createAnswer(response, { isInitial: thread?.history.length === 1 }),
185
- ]
186
- if (response.endMessage) {
187
- messages.push(messagesHelper.createLast(this.defaultMessages.endMessage))
188
- }
189
- const translatedMessages = await this.translation.applyTranslationFx(messages)
190
-
191
- this.cache.addMessages(key, { messages: translatedMessages, thread })
192
- }),
186
+ effect: createEffect(
187
+ async ({ message, translatedMessage, key, context, isFreeText, cache }: SendHelpProps) => {
188
+ if (!context) throw new Error('Trying to send message in chat without context')
189
+ this.setLastMessageKey(key)
190
+ this.cache.addMessages(key, {
191
+ messages: [messagesHelper.createOwn({ message, translatedMessage })],
192
+ })
193
+
194
+ const response = await this.api.postMessageFx({
195
+ answer: context.answer,
196
+ answerOptions: context.answerOptions,
197
+ problemDescription: context.problem,
198
+ problemAnswer: context.problemAnswer,
199
+ language: context.language,
200
+ imageAltText: context.imageDescription,
201
+ imageCdnId: context.imageCdnId,
202
+ conversationId: cache[key].conversationId,
203
+ ...(isFreeText && { freeTextMessage: message }),
204
+ })
205
+
206
+ const thread = this.threadManager.get(key)
207
+ const messages = [
208
+ messagesHelper.createAnswer(response, { isInitial: thread?.history.length === 1 }),
209
+ ]
210
+ if (response.endMessage) {
211
+ messages.push(messagesHelper.createLast(this.defaultMessages.endMessage))
212
+ }
213
+ const translatedMessages = await this.translation.applyTranslationFx(messages)
214
+
215
+ this.cache.addMessages(key, {
216
+ messages: translatedMessages,
217
+ thread,
218
+ })
219
+
220
+ if (response.conversationId) {
221
+ this.cache.update({ key, data: { conversationId: response.conversationId } })
222
+ }
223
+ },
224
+ ),
193
225
  })
194
226
 
195
227
  sample({
@@ -273,6 +305,7 @@ export class ChatbotModel {
273
305
  this.api.postMessageFx.controller.abort()
274
306
  this.removeLastMessage()
275
307
  }
308
+ this.textInput.reset()
276
309
  this.errorSpotting.abortPendingRequest()
277
310
 
278
311
  this.t2s.stop()
@@ -286,6 +319,7 @@ export class ChatbotModel {
286
319
  this.resetAlternatives()
287
320
  this.threadManager.reset()
288
321
  this.errorSpotting.reset()
322
+ this.textInput.reset()
289
323
  })
290
324
 
291
325
  public unbindKey() {
@@ -0,0 +1,10 @@
1
+ import { createEvent, restore } from 'effector'
2
+
3
+ export class ChatBotTextInput {
4
+ public readonly setValue = createEvent<string>()
5
+ public readonly setIsFocused = createEvent<boolean>()
6
+ public readonly reset = createEvent()
7
+
8
+ public readonly $value = restore(this.setValue, '').reset(this.reset)
9
+ public readonly $isFocused = restore(this.setIsFocused, false).reset(this.reset)
10
+ }
@@ -4,12 +4,15 @@ import {
4
4
  ChatHintResponse,
5
5
  PostMessagePayload,
6
6
  PostMessageResponse,
7
+ SendMessagePayload,
8
+ SendMessageResponse,
7
9
  } from '../types/api.types'
8
10
  import { ChatbotMessages, IChatDrawBoardAdapter } from '../types/model.types'
9
11
  import { CHAT_BOT_MODEL_DEFAULTS } from './constants'
10
12
 
11
13
  type ThreadManagerApi = {
12
14
  getHint: (props: ChatHintPayload) => Promise<ChatHintResponse>
15
+ sendMessage: (props: SendMessagePayload) => Promise<SendMessageResponse>
13
16
  }
14
17
 
15
18
  type ChatBotThreadManagerProps = {
@@ -65,10 +68,14 @@ export class ChatBotThreadManager {
65
68
 
66
69
  public readonly postMessage = async ({
67
70
  problemAnswer,
68
- problem,
71
+ problemDescription,
69
72
  answer,
73
+ answerOptions,
70
74
  language,
71
75
  imageAltText,
76
+ imageCdnId,
77
+ freeTextMessage,
78
+ conversationId,
72
79
  }: PostMessagePayload): Promise<PostMessageResponse> => {
73
80
  if (!this.api) {
74
81
  throw new Error(
@@ -77,14 +84,32 @@ export class ChatBotThreadManager {
77
84
  }
78
85
  const threadItem = await this.getThreadItem()
79
86
 
80
- const result = await this.api.getHint({
81
- ...threadItem.getNextHintProps(),
82
- correctAnswer: problemAnswer,
83
- problemDescription: problem,
84
- userAnswer: answer,
85
- language,
86
- imageAltText,
87
- })
87
+ let result
88
+
89
+ if (freeTextMessage) {
90
+ const payload = conversationId
91
+ ? { conversationId, message: freeTextMessage }
92
+ : {
93
+ message: freeTextMessage,
94
+ problemDescription,
95
+ correctAnswer: problemAnswer,
96
+ language,
97
+ ...(imageCdnId && { imageCdnId }),
98
+ ...(imageAltText && { altText: imageAltText }),
99
+ ...(!!answerOptions?.length && { answerOptions }),
100
+ }
101
+ result = await this.api.sendMessage(payload)
102
+ } else {
103
+ result = await this.api.getHint({
104
+ ...threadItem.getNextHintProps(),
105
+ correctAnswer: problemAnswer,
106
+ problemDescription,
107
+ userAnswer: answer,
108
+ language,
109
+ ...(imageCdnId && { imageCdnId }),
110
+ ...(imageAltText && { imageAltText }),
111
+ })
112
+ }
88
113
 
89
114
  threadItem.history.push(result.message)
90
115
  const nextOptions =
@@ -95,6 +120,7 @@ export class ChatBotThreadManager {
95
120
  options: nextOptions,
96
121
  endMessage: !nextOptions.length,
97
122
  threadId: threadItem.id,
123
+ conversationId: result?.conversationId ?? null,
98
124
  }
99
125
  }
100
126
 
@@ -31,7 +31,7 @@ type ChatbotTranslationProps = {
31
31
  }
32
32
 
33
33
  export class ChatbotTranslation {
34
- private readonly api
34
+ public readonly api
35
35
  private readonly $key
36
36
  private readonly $context
37
37
  private readonly defaultMessages
@@ -12,21 +12,43 @@ export type AlternativesOptions = {
12
12
 
13
13
  export type GetAlternativesResponse = {
14
14
  chatAccess?: boolean
15
+ isOpenChatEnabled?: boolean
16
+ version: string
15
17
  options: AlternativesOptions
16
18
  }
17
19
 
20
+ export type SendMessagePayload = {
21
+ problemDescription?: string
22
+ correctAnswer?: string | string[]
23
+ answerOptions?: string[]
24
+ altText?: string;
25
+ language?: string
26
+ message: string
27
+ conversationId?: string
28
+ }
29
+
30
+ export type SendMessageResponse = {
31
+ message: string
32
+ conversationId?: string | null
33
+ }
34
+
18
35
  export type PostMessagePayload = {
19
36
  language: string
20
37
  problemAnswer: string[]
38
+ problemDescription: string
21
39
  answer?: string | string[]
22
- problem: string
40
+ answerOptions?: string[]
23
41
  imageAltText?: string
42
+ imageCdnId?: string
43
+ freeTextMessage?: string
44
+ conversationId?: string | null
24
45
  }
25
46
 
26
47
  export type PostMessageResponse = {
27
48
  message: string
28
49
  options: ChatAnswer[]
29
50
  endMessage?: boolean
51
+ conversationId?: string | null
30
52
  threadId: string
31
53
  }
32
54
 
@@ -66,11 +88,13 @@ export type ChatHintPayload = {
66
88
  previousHint?: string
67
89
  language: string
68
90
  imageAltText?: string
91
+ imageCdnId?: string
69
92
  drawBoardText?: string
70
93
  }
71
94
 
72
95
  export type ChatHintResponse = {
73
96
  message: string
97
+ conversationId?: string | null
74
98
  }
75
99
  export type ErrorSpottingPayload = {
76
100
  strokes: FullStrokeData[]
@@ -12,9 +12,11 @@ import {
12
12
  GoogleTranslateResponse,
13
13
  PostMessagePayload,
14
14
  PostMessageResponse,
15
+ SendMessagePayload,
16
+ SendMessageResponse,
15
17
  } from './api.types'
16
18
  import { ExtendWithOptional } from '../../../lib/helpers/types'
17
- import { ChatAnswer, ConversationMessage, FullStrokeData } from './units.types'
19
+ import { ChatAnswer, ChatItem, ConversationMessage, FullStrokeData } from './units.types'
18
20
 
19
21
  export type ChatbotMessages = {
20
22
  error: ConversationMessage
@@ -25,6 +27,7 @@ export type ChatbotMessages = {
25
27
 
26
28
  export type ChatbotApiRequests = {
27
29
  getAlternatives: (props: GetAlternativesPayload) => Promise<GetAlternativesResponse>
30
+ sendMessage: (props: SendMessagePayload) => Promise<SendMessageResponse>
28
31
  postMessage: (props: PostMessagePayload) => Promise<PostMessageResponse>
29
32
  postTranslateText: (props: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>
30
33
  postTextToSpeech: (props: GoogleText2SpeechPayload) => Promise<GoogleText2SpeechResponse>
@@ -47,11 +50,14 @@ export type ChatbotModelProps = {
47
50
  export type SendHelpParams = {
48
51
  message: string
49
52
  translatedMessage?: string
53
+ isFreeText?: boolean
50
54
  }
51
55
 
52
56
  export type SendHelpProps = SendHelpParams & {
53
57
  key: string
54
58
  context: ChatbotContext | null
59
+ cache: Record<string, ChatItem>
60
+ isFreeText?: boolean
55
61
  }
56
62
 
57
63
  export type SetHintMessageProps = {
@@ -105,6 +111,15 @@ export type ChatbotContext = {
105
111
  problem: string
106
112
  problemAnswer: string[]
107
113
  answer?: string | string[]
114
+ answerOptions?: string[]
108
115
  translationTargetLanguage: string
109
116
  imageDescription?: string
117
+ imageCdnId?: string
110
118
  }
119
+
120
+ export type ReinitConversationProps = {
121
+ key: string
122
+ }
123
+
124
+
125
+
File without changes
@@ -34,4 +34,10 @@ export type ChatItem = {
34
34
  messages: ConversationMessage[]
35
35
  isAvailable: boolean
36
36
  currentThread: IThreadItem | null
37
+ conversationId?: string | null
38
+ }
39
+
40
+ export enum ChatInputMode {
41
+ FreeText = 1,
42
+ Option = 2,
37
43
  }
@@ -18,12 +18,6 @@ export const ExampleSolutionModal = ({
18
18
  container: { paddingHorizontal: SPACING[800] },
19
19
  }}
20
20
  onClose={closeModal}
21
- content={
22
- <ExampleSolutionModalContent
23
- model={params.model}
24
- payload={params.payload}
25
- cacheKey={params.cacheKey}
26
- />
27
- }
21
+ content={<ExampleSolutionModalContent params={params} />}
28
22
  />
29
23
  )
@@ -1,6 +1,6 @@
1
1
  import { StyleSheet, View } from 'react-native'
2
2
  import React from 'react'
3
- import { COLORS, HeadingVariants, SPACING, Typography } from '@magmamath/react-native-ui'
3
+ import { COLORS, HeadingVariants, IS_WEB, SPACING, Typography } from '@magmamath/react-native-ui'
4
4
  import { useUnit } from 'effector-react'
5
5
  import { $localization } from '../../../shared/translation'
6
6
  import { MessageBlock } from './MessageBlock'
@@ -10,21 +10,34 @@ import { QuestionSection } from './QuestionSection'
10
10
  import { SolutionSection } from './SolutionSection'
11
11
  import { useExampleSolution } from '../hooks/useExampleSolution'
12
12
 
13
+ type ExampleSolutionModalContentProps = {
14
+ params: ExampleSolutionModalParams
15
+ }
16
+
17
+ const CONTAINER_HEIGHT = 593
18
+
13
19
  export const ExampleSolutionModalContent = ({
14
- model,
15
- payload,
16
- cacheKey,
17
- }: ExampleSolutionModalParams) => {
20
+ params: { model, payload, cacheKey },
21
+ }: ExampleSolutionModalContentProps) => {
18
22
  const { result, status } = useExampleSolution({ model, payload, cacheKey })
19
23
  const localization = useUnit($localization)
20
24
 
21
25
  return (
22
- <View style={styles.container}>
26
+ <View
27
+ style={[
28
+ styles.container,
29
+ IS_WEB ? { maxHeight: CONTAINER_HEIGHT } : { height: CONTAINER_HEIGHT },
30
+ ]}
31
+ >
23
32
  <Typography align="center" variant={HeadingVariants.H2} style={{ color: COLORS.NEUTRAL_9 }}>
24
33
  {localization.exampleSolution.exampleSolution}
25
34
  </Typography>
26
35
  <View style={styles.content}>
27
- <QuestionSection status={status} question={result?.question} />
36
+ <QuestionSection
37
+ status={status}
38
+ question={result?.question}
39
+ renderKatexComponent={model.renderKatexComponent}
40
+ />
28
41
  <SolutionSection status={status} answer={result?.answer} />
29
42
  </View>
30
43
  <MessageBlock status={status} style={styles.messageBlock} />
@@ -36,7 +49,6 @@ export const ExampleSolutionModalContent = ({
36
49
  const styles = StyleSheet.create({
37
50
  container: {
38
51
  width: 880,
39
- height: 593,
40
52
  },
41
53
  content: {
42
54
  flex: 1,
@@ -53,8 +65,8 @@ const styles = StyleSheet.create({
53
65
  },
54
66
  lavaIconContainer: {
55
67
  position: 'absolute',
56
- bottom: -54,
57
- right: -50,
68
+ bottom: -24,
69
+ right: -26,
58
70
  },
59
71
  loaderContainer: {
60
72
  paddingTop: 34,
@@ -65,7 +77,7 @@ const styles = StyleSheet.create({
65
77
  },
66
78
  messageBlock: {
67
79
  position: 'absolute',
68
- right: 38,
69
- bottom: -22,
80
+ right: 58,
81
+ bottom: -12,
70
82
  },
71
83
  })
@@ -1,20 +1,23 @@
1
- import { StyleSheet, View, ScrollView } from 'react-native'
1
+ import { StyleSheet, View } from 'react-native'
2
2
  import React from 'react'
3
- import { COLORS, Loader, LoaderColor, SPACING, Typography } from '@magmamath/react-native-ui'
3
+ import { COLORS, Loader, LoaderColor, SPACING } from '@magmamath/react-native-ui'
4
4
  import Animated, { FadeOut } from 'react-native-reanimated'
5
5
  import { ExampleSolutionStatuses } from '../constants'
6
6
 
7
7
  type QuestionSectionProps = {
8
8
  question?: string
9
9
  status: ExampleSolutionStatuses
10
+ renderKatexComponent: (katexString: string) => React.ReactNode
10
11
  }
11
12
 
12
- export const QuestionSection = ({ question, status }: QuestionSectionProps) => {
13
+ export const QuestionSection = ({
14
+ question,
15
+ status,
16
+ renderKatexComponent,
17
+ }: QuestionSectionProps) => {
13
18
  return (
14
19
  <View style={styles.container}>
15
- <ScrollView style={styles.scrollView}>
16
- <Typography>{question}</Typography>
17
- </ScrollView>
20
+ {question && <View style={styles.katexContainer}>{renderKatexComponent(question)}</View>}
18
21
  {status === ExampleSolutionStatuses.LOADING && (
19
22
  <Animated.View exiting={FadeOut} style={styles.loaderContainer}>
20
23
  <Loader size="large" color={LoaderColor.BLUE} />
@@ -28,12 +31,13 @@ const styles = StyleSheet.create({
28
31
  container: {
29
32
  flex: 1,
30
33
  },
31
- scrollView: {
34
+ katexContainer: {
32
35
  flex: 1,
33
36
  },
34
37
  loaderContainer: {
35
38
  paddingTop: 34,
36
39
  position: 'absolute',
40
+ zIndex: 100,
37
41
  width: '100%',
38
42
  height: '100%',
39
43
  backgroundColor: COLORS.NEUTRAL_1,
@@ -1,69 +1,112 @@
1
- import { StyleSheet, View, Image, Text } from 'react-native'
1
+ import {
2
+ StyleSheet,
3
+ View,
4
+ Image,
5
+ ImageBackground,
6
+ ScrollView,
7
+ useWindowDimensions,
8
+ } from 'react-native'
2
9
  import React from 'react'
3
10
  import { COLORS, IS_WEB, SPACING } from '@magmamath/react-native-ui'
4
11
  import Animated, { FadeIn } from 'react-native-reanimated'
5
12
  import { ExampleSolutionStatuses } from '../constants'
6
- import gridImage from '../assets/grid.png'
13
+ import gridImage from '../assets/grid.webp'
7
14
 
8
15
  type SolutionSectionProps = {
9
16
  answer?: string
10
17
  status: ExampleSolutionStatuses
11
18
  }
12
19
 
20
+ const CONTAINER_SIZES = {
21
+ width: 489,
22
+ height: 543,
23
+ }
24
+ const BORDER_WIDTH = 1
25
+ const CONTAINER_HEIGHT_OFFSET = 160
26
+
13
27
  const gridImagePath = !IS_WEB ? Image.resolveAssetSource(gridImage).uri : gridImage
14
28
 
15
29
  export const SolutionSection = ({ answer, status }: SolutionSectionProps) => {
30
+ const { height } = useWindowDimensions()
31
+
16
32
  const shouldShowAnswer =
17
33
  answer &&
18
34
  (status === ExampleSolutionStatuses.DONE_DATA || status === ExampleSolutionStatuses.CACHE)
19
35
 
20
36
  return (
21
- <View style={styles.container}>
22
- <Image
23
- source={{ uri: gridImagePath }}
24
- style={[styles.gridImage, IS_WEB && styles.gridImageWeb]}
25
- />
26
- {shouldShowAnswer && (
27
- <Animated.ScrollView
28
- style={styles.solutionScroll}
29
- contentContainerStyle={styles.solutionScrollContent}
30
- entering={status === 'cache' ? undefined : FadeIn.delay(1000).duration(500)}
31
- >
32
- <Text style={styles.solutionText}>{answer}</Text>
33
- </Animated.ScrollView>
34
- )}
37
+ <View style={[styles.container, IS_WEB && { maxHeight: height - CONTAINER_HEIGHT_OFFSET }]}>
38
+ <ScrollView
39
+ style={styles.solutionScroll}
40
+ contentContainerStyle={styles.solutionScrollContent}
41
+ bounces
42
+ >
43
+ {IS_WEB ? (
44
+ <ImageBackground
45
+ resizeMode="repeat"
46
+ style={[styles.gridImageWeb]}
47
+ source={{ uri: gridImagePath }}
48
+ >
49
+ {shouldShowAnswer && (
50
+ <Animated.Text
51
+ entering={status === 'cache' ? undefined : FadeIn.delay(1000).duration(500)}
52
+ style={styles.solutionText}
53
+ >
54
+ {answer}
55
+ </Animated.Text>
56
+ )}
57
+ </ImageBackground>
58
+ ) : (
59
+ <>
60
+ <ImageBackground
61
+ resizeMode="repeat"
62
+ style={styles.gridImageRn}
63
+ source={{ uri: gridImagePath }}
64
+ />
65
+ {shouldShowAnswer && (
66
+ <Animated.Text
67
+ entering={status === 'cache' ? undefined : FadeIn.delay(1000).duration(500)}
68
+ style={styles.solutionText}
69
+ >
70
+ {answer}
71
+ </Animated.Text>
72
+ )}
73
+ </>
74
+ )}
75
+ </ScrollView>
35
76
  </View>
36
77
  )
37
78
  }
38
79
 
39
80
  const styles = StyleSheet.create({
40
81
  container: {
41
- width: 500,
82
+ width: CONTAINER_SIZES.width,
83
+ height: CONTAINER_SIZES.height,
42
84
  overflow: 'hidden',
43
85
  borderRadius: 8,
44
- borderWidth: 1,
86
+ borderWidth: BORDER_WIDTH,
45
87
  borderColor: COLORS.NEUTRAL_5,
46
88
  },
47
- gridImage: {
89
+ gridImageRn: {
90
+ top: -327,
48
91
  width: '100%',
49
- height: '100%',
50
- resizeMode: 'cover',
51
- aspectRatio: 28 / 8,
92
+ height: '150%',
93
+ position: 'absolute',
52
94
  },
53
95
  gridImageWeb: {
54
- transform: [{ scale: 3.5 }],
55
- },
56
- solutionScroll: {
57
- position: 'absolute',
58
96
  width: '100%',
59
97
  height: '100%',
60
98
  },
99
+ solutionScroll: {
100
+ flex: 1,
101
+ },
61
102
  solutionScrollContent: {
62
- paddingHorizontal: SPACING[800],
63
- paddingVertical: SPACING[400],
103
+ minHeight: CONTAINER_SIZES.height - BORDER_WIDTH * 2,
104
+ width: '100%',
64
105
  },
65
106
  solutionText: {
66
107
  fontFamily: 'PlaypenSans-Light',
67
- fontSize: 22,
108
+ fontSize: 28,
109
+ marginHorizontal: SPACING[800],
110
+ marginVertical: SPACING[400],
68
111
  },
69
112
  })