@databiosphere/findable-ui 49.0.0 → 49.2.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 (315) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +26 -0
  3. package/lib/common/ai/config/types.d.ts +22 -0
  4. package/lib/common/ai/config/types.js +1 -0
  5. package/lib/common/ai/constants.d.ts +3 -0
  6. package/lib/common/ai/constants.js +3 -0
  7. package/lib/components/Filter/components/FilterLabel/filterLabel.js +1 -1
  8. package/lib/components/Filter/components/FilterLabel/filterLabel.stories.d.ts +3 -0
  9. package/lib/components/Filter/components/FilterLabel/filterLabel.stories.js +5 -0
  10. package/lib/components/Filter/components/Filters/stories/constants.js +21 -1
  11. package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.styles.js +2 -0
  12. package/lib/components/Layout/components/Sidebar/components/SidebarTools/sidebarTools.styles.d.ts +4 -0
  13. package/lib/components/Layout/components/Sidebar/components/SidebarTools/sidebarTools.styles.js +4 -0
  14. package/lib/components/common/Chip/components/Beta/beta.d.ts +10 -0
  15. package/lib/components/common/Chip/components/Beta/beta.js +12 -0
  16. package/lib/components/common/Chip/components/Beta/beta.styles.d.ts +3 -0
  17. package/lib/components/common/Chip/components/Beta/beta.styles.js +14 -0
  18. package/lib/components/common/Chip/components/Beta/stories/beta.stories.d.ts +6 -0
  19. package/lib/components/common/Chip/components/Beta/stories/beta.stories.js +6 -0
  20. package/lib/components/common/CustomIcon/components/UpArrowIcon/upArrowIcon.d.ts +6 -0
  21. package/lib/components/common/CustomIcon/components/UpArrowIcon/upArrowIcon.js +8 -0
  22. package/lib/components/common/Tabs/tabs.js +1 -1
  23. package/lib/components/common/ToggleButtonGroup/provider/context.d.ts +2 -0
  24. package/lib/components/common/ToggleButtonGroup/provider/context.js +5 -0
  25. package/lib/components/common/ToggleButtonGroup/provider/hook.d.ts +7 -0
  26. package/lib/components/common/ToggleButtonGroup/provider/hook.js +9 -0
  27. package/lib/components/common/ToggleButtonGroup/provider/provider.d.ts +12 -0
  28. package/lib/components/common/ToggleButtonGroup/provider/provider.js +22 -0
  29. package/lib/components/common/ToggleButtonGroup/provider/types.d.ts +9 -0
  30. package/lib/components/common/ToggleButtonGroup/provider/types.js +1 -0
  31. package/lib/config/entities.d.ts +2 -0
  32. package/lib/hooks/ai/useAiRoutes/hook.d.ts +6 -0
  33. package/lib/hooks/ai/useAiRoutes/hook.js +18 -0
  34. package/lib/styles/common/mui/drawer.d.ts +9 -0
  35. package/lib/styles/common/mui/drawer.js +15 -0
  36. package/lib/styles/common/mui/inputBase.d.ts +13 -0
  37. package/lib/styles/common/mui/inputBase.js +25 -0
  38. package/lib/styles/common/mui/stack.d.ts +11 -0
  39. package/lib/styles/common/mui/stack.js +22 -0
  40. package/lib/tests/testIds.d.ts +3 -0
  41. package/lib/tests/testIds.js +3 -0
  42. package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.d.ts +6 -0
  43. package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.js +17 -0
  44. package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.styles.d.ts +6 -0
  45. package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.styles.js +23 -0
  46. package/lib/views/ExploreView/entityList/filters/filters.styles.d.ts +7 -0
  47. package/lib/views/ExploreView/entityList/filters/filters.styles.js +17 -0
  48. package/lib/views/ExploreView/exploreView.js +3 -2
  49. package/lib/views/ResearchView/assistant/assistant.d.ts +6 -0
  50. package/lib/views/ResearchView/assistant/assistant.js +16 -0
  51. package/lib/views/ResearchView/assistant/components/Drawer/drawer.d.ts +9 -0
  52. package/lib/views/ResearchView/assistant/components/Drawer/drawer.js +15 -0
  53. package/lib/views/ResearchView/assistant/components/Drawer/drawer.styles.d.ts +4 -0
  54. package/lib/views/ResearchView/assistant/components/Drawer/drawer.styles.js +21 -0
  55. package/lib/views/ResearchView/assistant/components/Drawer/types.d.ts +4 -0
  56. package/lib/views/ResearchView/assistant/components/Drawer/types.js +1 -0
  57. package/lib/views/ResearchView/assistant/components/Form/constants.d.ts +3 -0
  58. package/lib/views/ResearchView/assistant/components/Form/constants.js +3 -0
  59. package/lib/views/ResearchView/assistant/components/Form/form.d.ts +11 -0
  60. package/lib/views/ResearchView/assistant/components/Form/form.js +27 -0
  61. package/lib/views/ResearchView/assistant/components/Form/form.styles.d.ts +4 -0
  62. package/lib/views/ResearchView/assistant/components/Form/form.styles.js +7 -0
  63. package/lib/views/ResearchView/assistant/components/Form/types.d.ts +3 -0
  64. package/lib/views/ResearchView/assistant/components/Form/types.js +1 -0
  65. package/lib/views/ResearchView/assistant/components/Form/utils.d.ts +16 -0
  66. package/lib/views/ResearchView/assistant/components/Form/utils.js +41 -0
  67. package/lib/views/ResearchView/assistant/components/Input/constants.d.ts +2 -0
  68. package/lib/views/ResearchView/assistant/components/Input/constants.js +14 -0
  69. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/constants.d.ts +7 -0
  70. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/constants.js +7 -0
  71. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/hook.d.ts +6 -0
  72. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/hook.js +32 -0
  73. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/types.d.ts +8 -0
  74. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/types.js +1 -0
  75. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/utils.d.ts +32 -0
  76. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/utils.js +74 -0
  77. package/lib/views/ResearchView/assistant/components/Input/input.d.ts +9 -0
  78. package/lib/views/ResearchView/assistant/components/Input/input.js +19 -0
  79. package/lib/views/ResearchView/assistant/components/Input/input.styles.d.ts +8 -0
  80. package/lib/views/ResearchView/assistant/components/Input/input.styles.js +19 -0
  81. package/lib/views/ResearchView/assistant/components/Input/stories/input.stories.d.ts +6 -0
  82. package/lib/views/ResearchView/assistant/components/Input/stories/input.stories.js +11 -0
  83. package/lib/views/ResearchView/assistant/components/Input/types.d.ts +2 -0
  84. package/lib/views/ResearchView/assistant/components/Input/types.js +1 -0
  85. package/lib/views/ResearchView/assistant/components/Input/utils.d.ts +9 -0
  86. package/lib/views/ResearchView/assistant/components/Input/utils.js +25 -0
  87. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/assistantMessage.d.ts +9 -0
  88. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/assistantMessage.js +15 -0
  89. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/types.d.ts +4 -0
  90. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/types.js +1 -0
  91. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/utils.d.ts +13 -0
  92. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/utils.js +25 -0
  93. package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/errorMessage.d.ts +9 -0
  94. package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/errorMessage.js +12 -0
  95. package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/types.d.ts +4 -0
  96. package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/types.js +1 -0
  97. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.d.ts +3 -0
  98. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.js +10 -0
  99. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.styles.d.ts +3 -0
  100. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.styles.js +26 -0
  101. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/types.d.ts +5 -0
  102. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/types.js +1 -0
  103. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/promptMessage.d.ts +10 -0
  104. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/promptMessage.js +14 -0
  105. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/types.d.ts +5 -0
  106. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/types.js +1 -0
  107. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/types.d.ts +4 -0
  108. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/types.js +1 -0
  109. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/useMessage.styles.d.ts +5 -0
  110. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/useMessage.styles.js +10 -0
  111. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/userMessage.d.ts +9 -0
  112. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/userMessage.js +13 -0
  113. package/lib/views/ResearchView/assistant/components/Messages/hooks/UseScroll/hook.d.ts +8 -0
  114. package/lib/views/ResearchView/assistant/components/Messages/hooks/UseScroll/hook.js +20 -0
  115. package/lib/views/ResearchView/assistant/components/Messages/messages.d.ts +9 -0
  116. package/lib/views/ResearchView/assistant/components/Messages/messages.js +16 -0
  117. package/lib/views/ResearchView/assistant/components/Messages/messages.styles.d.ts +3 -0
  118. package/lib/views/ResearchView/assistant/components/Messages/messages.styles.js +9 -0
  119. package/lib/views/ResearchView/assistant/components/Messages/selector/messageSelector.d.ts +17 -0
  120. package/lib/views/ResearchView/assistant/components/Messages/selector/messageSelector.js +32 -0
  121. package/lib/views/ResearchView/assistant/components/Messages/selector/types.d.ts +5 -0
  122. package/lib/views/ResearchView/assistant/components/Messages/selector/types.js +1 -0
  123. package/lib/views/ResearchView/assistant/components/Messages/stories/args.d.ts +3 -0
  124. package/lib/views/ResearchView/assistant/components/Messages/stories/args.js +109 -0
  125. package/lib/views/ResearchView/assistant/components/Messages/stories/messages.stories.d.ts +6 -0
  126. package/lib/views/ResearchView/assistant/components/Messages/stories/messages.stories.js +14 -0
  127. package/lib/views/ResearchView/assistant/components/Messages/types.d.ts +4 -0
  128. package/lib/views/ResearchView/assistant/components/Messages/types.js +1 -0
  129. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/stories/toggleButtonGroup.stories.d.ts +6 -0
  130. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/stories/toggleButtonGroup.stories.js +12 -0
  131. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.d.ts +6 -0
  132. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.js +16 -0
  133. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.styles.d.ts +6 -0
  134. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.styles.js +20 -0
  135. package/lib/views/ResearchView/assistant/stories/args.d.ts +4 -0
  136. package/lib/views/ResearchView/assistant/stories/args.js +30 -0
  137. package/lib/views/ResearchView/assistant/stories/assistant.stories.d.ts +6 -0
  138. package/lib/views/ResearchView/assistant/stories/assistant.stories.js +23 -0
  139. package/lib/views/ResearchView/query/constants.d.ts +5 -0
  140. package/lib/views/ResearchView/query/constants.js +5 -0
  141. package/lib/views/ResearchView/query/fetch.d.ts +17 -0
  142. package/lib/views/ResearchView/query/fetch.js +44 -0
  143. package/lib/views/ResearchView/researchView.d.ts +10 -0
  144. package/lib/views/ResearchView/researchView.js +13 -0
  145. package/lib/views/ResearchView/state/actions/setError/action.d.ts +10 -0
  146. package/lib/views/ResearchView/state/actions/setError/action.js +17 -0
  147. package/lib/views/ResearchView/state/actions/setError/dispatch.d.ts +7 -0
  148. package/lib/views/ResearchView/state/actions/setError/dispatch.js +12 -0
  149. package/lib/views/ResearchView/state/actions/setError/types.d.ts +14 -0
  150. package/lib/views/ResearchView/state/actions/setError/types.js +1 -0
  151. package/lib/views/ResearchView/state/actions/setMessage/action.d.ts +10 -0
  152. package/lib/views/ResearchView/state/actions/setMessage/action.js +21 -0
  153. package/lib/views/ResearchView/state/actions/setMessage/dispatch.d.ts +7 -0
  154. package/lib/views/ResearchView/state/actions/setMessage/dispatch.js +12 -0
  155. package/lib/views/ResearchView/state/actions/setMessage/types.d.ts +15 -0
  156. package/lib/views/ResearchView/state/actions/setMessage/types.js +1 -0
  157. package/lib/views/ResearchView/state/actions/setQuery/action.d.ts +10 -0
  158. package/lib/views/ResearchView/state/actions/setQuery/action.js +17 -0
  159. package/lib/views/ResearchView/state/actions/setQuery/dispatch.d.ts +7 -0
  160. package/lib/views/ResearchView/state/actions/setQuery/dispatch.js +12 -0
  161. package/lib/views/ResearchView/state/actions/setQuery/types.d.ts +14 -0
  162. package/lib/views/ResearchView/state/actions/setQuery/types.js +1 -0
  163. package/lib/views/ResearchView/state/actions/setStatus/action.d.ts +10 -0
  164. package/lib/views/ResearchView/state/actions/setStatus/action.js +13 -0
  165. package/lib/views/ResearchView/state/actions/setStatus/dispatch.d.ts +7 -0
  166. package/lib/views/ResearchView/state/actions/setStatus/dispatch.js +12 -0
  167. package/lib/views/ResearchView/state/actions/setStatus/types.d.ts +14 -0
  168. package/lib/views/ResearchView/state/actions/setStatus/types.js +1 -0
  169. package/lib/views/ResearchView/state/actions/types.d.ts +17 -0
  170. package/lib/views/ResearchView/state/actions/types.js +10 -0
  171. package/lib/views/ResearchView/state/constants.d.ts +5 -0
  172. package/lib/views/ResearchView/state/constants.js +7 -0
  173. package/lib/views/ResearchView/state/context.d.ts +5 -0
  174. package/lib/views/ResearchView/state/context.js +9 -0
  175. package/lib/views/ResearchView/state/guards/guards.d.ts +33 -0
  176. package/lib/views/ResearchView/state/guards/guards.js +41 -0
  177. package/lib/views/ResearchView/state/hooks/UseChatDispatch/hook.d.ts +6 -0
  178. package/lib/views/ResearchView/state/hooks/UseChatDispatch/hook.js +26 -0
  179. package/lib/views/ResearchView/state/hooks/UseChatDispatch/types.d.ts +10 -0
  180. package/lib/views/ResearchView/state/hooks/UseChatDispatch/types.js +1 -0
  181. package/lib/views/ResearchView/state/hooks/UseChatReducer/hook.d.ts +8 -0
  182. package/lib/views/ResearchView/state/hooks/UseChatReducer/hook.js +12 -0
  183. package/lib/views/ResearchView/state/hooks/UseChatState/hook.d.ts +7 -0
  184. package/lib/views/ResearchView/state/hooks/UseChatState/hook.js +11 -0
  185. package/lib/views/ResearchView/state/initializer/initializer.d.ts +8 -0
  186. package/lib/views/ResearchView/state/initializer/initializer.js +22 -0
  187. package/lib/views/ResearchView/state/initializer/types.d.ts +2 -0
  188. package/lib/views/ResearchView/state/initializer/types.js +1 -0
  189. package/lib/views/ResearchView/state/provider.d.ts +19 -0
  190. package/lib/views/ResearchView/state/provider.js +20 -0
  191. package/lib/views/ResearchView/state/query/context.d.ts +5 -0
  192. package/lib/views/ResearchView/state/query/context.js +7 -0
  193. package/lib/views/ResearchView/state/query/hooks/UseQuery/hook.d.ts +6 -0
  194. package/lib/views/ResearchView/state/query/hooks/UseQuery/hook.js +9 -0
  195. package/lib/views/ResearchView/state/query/hooks/UseSubmit/hook.d.ts +7 -0
  196. package/lib/views/ResearchView/state/query/hooks/UseSubmit/hook.js +46 -0
  197. package/lib/views/ResearchView/state/query/provider.d.ts +13 -0
  198. package/lib/views/ResearchView/state/query/provider.js +15 -0
  199. package/lib/views/ResearchView/state/query/types.d.ts +24 -0
  200. package/lib/views/ResearchView/state/query/types.js +1 -0
  201. package/lib/views/ResearchView/state/reducer.d.ts +10 -0
  202. package/lib/views/ResearchView/state/reducer.js +32 -0
  203. package/lib/views/ResearchView/state/types.d.ts +125 -0
  204. package/lib/views/ResearchView/state/types.js +22 -0
  205. package/package.json +1 -1
  206. package/src/common/ai/config/types.ts +25 -0
  207. package/src/common/ai/constants.ts +3 -0
  208. package/src/components/Filter/components/FilterLabel/filterLabel.stories.tsx +6 -0
  209. package/src/components/Filter/components/FilterLabel/filterLabel.tsx +6 -1
  210. package/src/components/Filter/components/Filters/stories/constants.ts +25 -1
  211. package/src/components/Filter/components/SearchAllFilters/searchAllFilters.styles.ts +2 -0
  212. package/src/components/Layout/components/Sidebar/components/SidebarTools/sidebarTools.styles.ts +4 -0
  213. package/src/components/common/Chip/components/Beta/beta.styles.ts +15 -0
  214. package/src/components/common/Chip/components/Beta/beta.tsx +25 -0
  215. package/src/components/common/Chip/components/Beta/stories/beta.stories.tsx +12 -0
  216. package/src/components/common/CustomIcon/components/UpArrowIcon/upArrowIcon.tsx +21 -0
  217. package/src/components/common/Tabs/tabs.tsx +5 -1
  218. package/src/components/common/ToggleButtonGroup/provider/context.ts +9 -0
  219. package/src/components/common/ToggleButtonGroup/provider/hook.ts +16 -0
  220. package/src/components/common/ToggleButtonGroup/provider/provider.tsx +37 -0
  221. package/src/components/common/ToggleButtonGroup/provider/types.ts +17 -0
  222. package/src/config/entities.ts +2 -0
  223. package/src/hooks/ai/useAiRoutes/hook.ts +22 -0
  224. package/src/styles/common/mui/drawer.ts +24 -0
  225. package/src/styles/common/mui/inputBase.ts +38 -0
  226. package/src/styles/common/mui/stack.ts +33 -0
  227. package/src/tests/testIds.ts +3 -0
  228. package/src/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.styles.ts +25 -0
  229. package/src/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.tsx +35 -0
  230. package/src/views/ExploreView/entityList/filters/filters.styles.ts +19 -0
  231. package/src/views/ExploreView/exploreView.tsx +16 -12
  232. package/src/views/ResearchView/assistant/assistant.tsx +28 -0
  233. package/src/views/ResearchView/assistant/components/Drawer/drawer.styles.ts +24 -0
  234. package/src/views/ResearchView/assistant/components/Drawer/drawer.tsx +26 -0
  235. package/src/views/ResearchView/assistant/components/Drawer/types.ts +5 -0
  236. package/src/views/ResearchView/assistant/components/Form/constants.ts +3 -0
  237. package/src/views/ResearchView/assistant/components/Form/form.styles.ts +8 -0
  238. package/src/views/ResearchView/assistant/components/Form/form.tsx +40 -0
  239. package/src/views/ResearchView/assistant/components/Form/types.ts +9 -0
  240. package/src/views/ResearchView/assistant/components/Form/utils.ts +51 -0
  241. package/src/views/ResearchView/assistant/components/Input/constants.ts +16 -0
  242. package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/constants.ts +7 -0
  243. package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/hook.ts +45 -0
  244. package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/types.ts +10 -0
  245. package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/utils.ts +93 -0
  246. package/src/views/ResearchView/assistant/components/Input/input.styles.ts +21 -0
  247. package/src/views/ResearchView/assistant/components/Input/input.tsx +37 -0
  248. package/src/views/ResearchView/assistant/components/Input/stories/input.stories.tsx +21 -0
  249. package/src/views/ResearchView/assistant/components/Input/types.ts +3 -0
  250. package/src/views/ResearchView/assistant/components/Input/utils.ts +34 -0
  251. package/src/views/ResearchView/assistant/components/Messages/components/AssistantMessage/assistantMessage.tsx +49 -0
  252. package/src/views/ResearchView/assistant/components/Messages/components/AssistantMessage/types.ts +5 -0
  253. package/src/views/ResearchView/assistant/components/Messages/components/AssistantMessage/utils.ts +31 -0
  254. package/src/views/ResearchView/assistant/components/Messages/components/ErrorMessage/errorMessage.tsx +21 -0
  255. package/src/views/ResearchView/assistant/components/Messages/components/ErrorMessage/types.ts +5 -0
  256. package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.styles.ts +27 -0
  257. package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.tsx +31 -0
  258. package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/types.ts +6 -0
  259. package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/promptMessage.tsx +26 -0
  260. package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/types.ts +6 -0
  261. package/src/views/ResearchView/assistant/components/Messages/components/UserMessage/types.ts +5 -0
  262. package/src/views/ResearchView/assistant/components/Messages/components/UserMessage/useMessage.styles.ts +11 -0
  263. package/src/views/ResearchView/assistant/components/Messages/components/UserMessage/userMessage.tsx +21 -0
  264. package/src/views/ResearchView/assistant/components/Messages/hooks/UseScroll/hook.ts +25 -0
  265. package/src/views/ResearchView/assistant/components/Messages/messages.styles.ts +10 -0
  266. package/src/views/ResearchView/assistant/components/Messages/messages.tsx +29 -0
  267. package/src/views/ResearchView/assistant/components/Messages/selector/messageSelector.tsx +37 -0
  268. package/src/views/ResearchView/assistant/components/Messages/selector/types.ts +6 -0
  269. package/src/views/ResearchView/assistant/components/Messages/stories/args.ts +115 -0
  270. package/src/views/ResearchView/assistant/components/Messages/stories/messages.stories.tsx +24 -0
  271. package/src/views/ResearchView/assistant/components/Messages/types.ts +5 -0
  272. package/src/views/ResearchView/assistant/components/ToggleButtonGroup/stories/toggleButtonGroup.stories.tsx +22 -0
  273. package/src/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.styles.ts +22 -0
  274. package/src/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.tsx +34 -0
  275. package/src/views/ResearchView/assistant/stories/args.ts +36 -0
  276. package/src/views/ResearchView/assistant/stories/assistant.stories.tsx +39 -0
  277. package/src/views/ResearchView/query/constants.ts +5 -0
  278. package/src/views/ResearchView/query/fetch.ts +58 -0
  279. package/src/views/ResearchView/researchView.tsx +19 -0
  280. package/src/views/ResearchView/state/actions/setError/action.ts +22 -0
  281. package/src/views/ResearchView/state/actions/setError/dispatch.ts +14 -0
  282. package/src/views/ResearchView/state/actions/setError/types.ts +16 -0
  283. package/src/views/ResearchView/state/actions/setMessage/action.ts +26 -0
  284. package/src/views/ResearchView/state/actions/setMessage/dispatch.ts +14 -0
  285. package/src/views/ResearchView/state/actions/setMessage/types.ts +19 -0
  286. package/src/views/ResearchView/state/actions/setQuery/action.ts +22 -0
  287. package/src/views/ResearchView/state/actions/setQuery/dispatch.ts +14 -0
  288. package/src/views/ResearchView/state/actions/setQuery/types.ts +16 -0
  289. package/src/views/ResearchView/state/actions/setStatus/action.ts +19 -0
  290. package/src/views/ResearchView/state/actions/setStatus/dispatch.ts +14 -0
  291. package/src/views/ResearchView/state/actions/setStatus/types.ts +16 -0
  292. package/src/views/ResearchView/state/actions/types.ts +23 -0
  293. package/src/views/ResearchView/state/constants.ts +9 -0
  294. package/src/views/ResearchView/state/context.ts +11 -0
  295. package/src/views/ResearchView/state/guards/guards.ts +58 -0
  296. package/src/views/ResearchView/state/hooks/UseChatDispatch/hook.ts +46 -0
  297. package/src/views/ResearchView/state/hooks/UseChatDispatch/types.ts +11 -0
  298. package/src/views/ResearchView/state/hooks/UseChatReducer/hook.ts +15 -0
  299. package/src/views/ResearchView/state/hooks/UseChatState/hook.ts +14 -0
  300. package/src/views/ResearchView/state/initializer/initializer.ts +23 -0
  301. package/src/views/ResearchView/state/initializer/types.ts +3 -0
  302. package/src/views/ResearchView/state/provider.tsx +34 -0
  303. package/src/views/ResearchView/state/query/context.ts +9 -0
  304. package/src/views/ResearchView/state/query/hooks/UseQuery/hook.ts +11 -0
  305. package/src/views/ResearchView/state/query/hooks/UseSubmit/hook.ts +66 -0
  306. package/src/views/ResearchView/state/query/provider.tsx +27 -0
  307. package/src/views/ResearchView/state/query/types.ts +31 -0
  308. package/src/views/ResearchView/state/reducer.ts +34 -0
  309. package/src/views/ResearchView/state/types.ts +149 -0
  310. package/tests/research.assistantMessageUtils.test.ts +149 -0
  311. package/tests/research.chatState.test.ts +463 -0
  312. package/tests/research.fetchResponse.test.ts +164 -0
  313. package/tests/research.queryProvider.test.ts +321 -0
  314. package/tests/research.useKeyShortCuts.test.ts +254 -0
  315. package/tests/toggleButtonGroupProvider.test.tsx +125 -0
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from "@mui/material";
3
+ import { PALETTE } from "../../../../styles/common/constants/palette";
4
+ import { ChatProvider } from "../../state/provider";
5
+ import { Assistant } from "../assistant";
6
+ import { INITIAL_ARGS, INITIAL_CONFIG } from "./args";
7
+ import { ConfigProvider } from "../../../../providers/config";
8
+ const meta = {
9
+ component: Assistant,
10
+ decorators: [
11
+ (Story) => (_jsx(ConfigProvider, { config: INITIAL_CONFIG, children: _jsx(ChatProvider, { initialArgs: INITIAL_ARGS, url: "https://api.example.com", children: _jsx(Box, { sx: {
12
+ backgroundColor: PALETTE.COMMON_WHITE,
13
+ display: "flex",
14
+ flexDirection: "column",
15
+ height: "100vh",
16
+ minHeight: 0,
17
+ width: "412px",
18
+ }, children: _jsx(Story, {}) }) }) })),
19
+ ],
20
+ parameters: { layout: "none" },
21
+ };
22
+ export default meta;
23
+ export const Default = {};
@@ -0,0 +1,5 @@
1
+ export declare const ERROR_MESSAGE: {
2
+ readonly RATE_LIMITED: "You're sending too many requests. Please wait a moment.";
3
+ readonly REQUEST_FAILED: "Request failed";
4
+ readonly UNKNOWN: "An unknown error occurred.";
5
+ };
@@ -0,0 +1,5 @@
1
+ export const ERROR_MESSAGE = {
2
+ RATE_LIMITED: "You're sending too many requests. Please wait a moment.",
3
+ REQUEST_FAILED: "Request failed",
4
+ UNKNOWN: "An unknown error occurred.",
5
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Fetches a response from the given API URL.
3
+ * @param url - Request URL.
4
+ * @param query - Query to send.
5
+ * @param options - Fetch options.
6
+ * @param options.controller - AbortController.
7
+ * @param options.onError - Callback invoked on error.
8
+ * @param options.onSettled - Callback invoked when the request is settled (after success or error).
9
+ * @param options.onSuccess - Callback invoked with response data on success.
10
+ * @returns Promise that resolves when the request completes.
11
+ */
12
+ export declare function fetchResponse<T = unknown>(url: string, query: string, { controller, onError, onSettled, onSuccess, }: {
13
+ controller: AbortController;
14
+ onError: (error: Error) => void;
15
+ onSettled: () => void;
16
+ onSuccess: (data: T) => void;
17
+ }): Promise<T | undefined>;
@@ -0,0 +1,44 @@
1
+ import { ERROR_MESSAGE } from "./constants";
2
+ /**
3
+ * Fetches a response from the given API URL.
4
+ * @param url - Request URL.
5
+ * @param query - Query to send.
6
+ * @param options - Fetch options.
7
+ * @param options.controller - AbortController.
8
+ * @param options.onError - Callback invoked on error.
9
+ * @param options.onSettled - Callback invoked when the request is settled (after success or error).
10
+ * @param options.onSuccess - Callback invoked with response data on success.
11
+ * @returns Promise that resolves when the request completes.
12
+ */
13
+ export async function fetchResponse(url, query, { controller, onError, onSettled, onSuccess, }) {
14
+ const timeout = setTimeout(() => controller.abort(), 90_000);
15
+ try {
16
+ const res = await fetch(url, {
17
+ body: JSON.stringify({ query }),
18
+ headers: { "Content-Type": "application/json" },
19
+ method: "POST",
20
+ signal: controller.signal,
21
+ });
22
+ const { status } = res;
23
+ if (status === 429) {
24
+ onError(new Error(ERROR_MESSAGE.RATE_LIMITED));
25
+ return;
26
+ }
27
+ if (!res.ok)
28
+ throw new Error(`${ERROR_MESSAGE.REQUEST_FAILED} (${status})`);
29
+ const data = await res.json();
30
+ onSuccess(data);
31
+ }
32
+ catch (error) {
33
+ if (controller.signal.aborted)
34
+ return;
35
+ if (error instanceof Error)
36
+ onError(error);
37
+ else
38
+ onError(new Error(ERROR_MESSAGE.UNKNOWN));
39
+ }
40
+ finally {
41
+ clearTimeout(timeout);
42
+ onSettled();
43
+ }
44
+ }
@@ -0,0 +1,10 @@
1
+ import { JSX } from "react";
2
+ import { ChildrenProps } from "../../components/types";
3
+ /**
4
+ * Main view for the research assistant feature.
5
+ * Renders the assistant drawer and any related components.
6
+ * @param props - Component props.
7
+ * @param props.children - Children components to be rendered within the research view.
8
+ * @returns The research view component.
9
+ */
10
+ export declare const ResearchView: ({ children }: ChildrenProps) => JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment } from "react";
3
+ import { Assistant } from "./assistant/assistant";
4
+ /**
5
+ * Main view for the research assistant feature.
6
+ * Renders the assistant drawer and any related components.
7
+ * @param props - Component props.
8
+ * @param props.children - Children components to be rendered within the research view.
9
+ * @returns The research view component.
10
+ */
11
+ export const ResearchView = ({ children }) => {
12
+ return (_jsxs(Fragment, { children: [_jsx(Assistant, {}), children] }));
13
+ };
@@ -0,0 +1,10 @@
1
+ import { ChatState } from "../../types";
2
+ import { SetErrorPayload } from "./types";
3
+ /**
4
+ * Reducer action to set an error message in the chat.
5
+ *
6
+ * @param state - State.
7
+ * @param payload - Payload.
8
+ * @returns State.
9
+ */
10
+ export declare function setErrorAction(state: ChatState, payload: SetErrorPayload): ChatState;
@@ -0,0 +1,17 @@
1
+ import { MESSAGE_TYPE } from "../../types";
2
+ /**
3
+ * Reducer action to set an error message in the chat.
4
+ *
5
+ * @param state - State.
6
+ * @param payload - Payload.
7
+ * @returns State.
8
+ */
9
+ export function setErrorAction(state, payload) {
10
+ return {
11
+ ...state,
12
+ messages: [
13
+ ...state.messages,
14
+ { createdAt: Date.now(), error: payload.error, type: MESSAGE_TYPE.ERROR },
15
+ ],
16
+ };
17
+ }
@@ -0,0 +1,7 @@
1
+ import { SetErrorAction, SetErrorPayload } from "./types";
2
+ /**
3
+ * Action creator for setting an error message in the chat.
4
+ * @param payload - Payload.
5
+ * @returns Action with payload and action type.
6
+ */
7
+ export declare function setError(payload: SetErrorPayload): SetErrorAction;
@@ -0,0 +1,12 @@
1
+ import { ChatActionKind } from "../types";
2
+ /**
3
+ * Action creator for setting an error message in the chat.
4
+ * @param payload - Payload.
5
+ * @returns Action with payload and action type.
6
+ */
7
+ export function setError(payload) {
8
+ return {
9
+ payload,
10
+ type: ChatActionKind.SetError,
11
+ };
12
+ }
@@ -0,0 +1,14 @@
1
+ import { ChatActionKind } from "../types";
2
+ /**
3
+ * Action to set an error message in the chat.
4
+ */
5
+ export interface SetErrorAction {
6
+ payload: SetErrorPayload;
7
+ type: ChatActionKind.SetError;
8
+ }
9
+ /**
10
+ * Payload for the SetError action.
11
+ */
12
+ export interface SetErrorPayload {
13
+ error: string;
14
+ }
@@ -0,0 +1,10 @@
1
+ import { ChatState } from "../../types";
2
+ import { SetMessagePayload } from "./types";
3
+ /**
4
+ * Reducer action to set a message in the chat.
5
+ *
6
+ * @param state - State.
7
+ * @param payload - Payload.
8
+ * @returns State.
9
+ */
10
+ export declare function setMessageAction(state: ChatState, payload: SetMessagePayload): ChatState;
@@ -0,0 +1,21 @@
1
+ import { MESSAGE_TYPE } from "../../types";
2
+ /**
3
+ * Reducer action to set a message in the chat.
4
+ *
5
+ * @param state - State.
6
+ * @param payload - Payload.
7
+ * @returns State.
8
+ */
9
+ export function setMessageAction(state, payload) {
10
+ return {
11
+ ...state,
12
+ messages: [
13
+ ...state.messages,
14
+ {
15
+ createdAt: Date.now(),
16
+ response: payload.response,
17
+ type: MESSAGE_TYPE.ASSISTANT,
18
+ },
19
+ ],
20
+ };
21
+ }
@@ -0,0 +1,7 @@
1
+ import { SetMessageAction, SetMessagePayload } from "./types";
2
+ /**
3
+ * Action creator for setting a message in the chat.
4
+ * @param payload - Payload.
5
+ * @returns Action with payload and action type.
6
+ */
7
+ export declare function setMessage(payload: SetMessagePayload): SetMessageAction;
@@ -0,0 +1,12 @@
1
+ import { ChatActionKind } from "../types";
2
+ /**
3
+ * Action creator for setting a message in the chat.
4
+ * @param payload - Payload.
5
+ * @returns Action with payload and action type.
6
+ */
7
+ export function setMessage(payload) {
8
+ return {
9
+ payload,
10
+ type: ChatActionKind.SetMessage,
11
+ };
12
+ }
@@ -0,0 +1,15 @@
1
+ import { MessageResponse } from "../../types";
2
+ import { ChatActionKind } from "../types";
3
+ /**
4
+ * Action to set the message for a chat.
5
+ */
6
+ export interface SetMessageAction {
7
+ payload: SetMessagePayload;
8
+ type: ChatActionKind.SetMessage;
9
+ }
10
+ /**
11
+ * Payload for the SetMessage action.
12
+ */
13
+ export interface SetMessagePayload<R extends MessageResponse = MessageResponse> {
14
+ response: R;
15
+ }
@@ -0,0 +1,10 @@
1
+ import { ChatState } from "../../types";
2
+ import { SetQueryPayload } from "./types";
3
+ /**
4
+ * Reducer action to set a query in the chat.
5
+ *
6
+ * @param state - State.
7
+ * @param payload - Payload.
8
+ * @returns State.
9
+ */
10
+ export declare function setQueryAction(state: ChatState, payload: SetQueryPayload): ChatState;
@@ -0,0 +1,17 @@
1
+ import { MESSAGE_TYPE } from "../../types";
2
+ /**
3
+ * Reducer action to set a query in the chat.
4
+ *
5
+ * @param state - State.
6
+ * @param payload - Payload.
7
+ * @returns State.
8
+ */
9
+ export function setQueryAction(state, payload) {
10
+ return {
11
+ ...state,
12
+ messages: [
13
+ ...state.messages,
14
+ { createdAt: Date.now(), text: payload.query, type: MESSAGE_TYPE.USER },
15
+ ],
16
+ };
17
+ }
@@ -0,0 +1,7 @@
1
+ import { SetQueryAction, SetQueryPayload } from "./types";
2
+ /**
3
+ * Action creator for setting a query in the chat.
4
+ * @param payload - Payload.
5
+ * @returns Action with payload and action type.
6
+ */
7
+ export declare function setQuery(payload: SetQueryPayload): SetQueryAction;
@@ -0,0 +1,12 @@
1
+ import { ChatActionKind } from "../types";
2
+ /**
3
+ * Action creator for setting a query in the chat.
4
+ * @param payload - Payload.
5
+ * @returns Action with payload and action type.
6
+ */
7
+ export function setQuery(payload) {
8
+ return {
9
+ payload,
10
+ type: ChatActionKind.SetQuery,
11
+ };
12
+ }
@@ -0,0 +1,14 @@
1
+ import { ChatActionKind } from "../types";
2
+ /**
3
+ * Action to set the query for a chat.
4
+ */
5
+ export interface SetQueryAction {
6
+ payload: SetQueryPayload;
7
+ type: ChatActionKind.SetQuery;
8
+ }
9
+ /**
10
+ * Payload for the SetQuery action.
11
+ */
12
+ export interface SetQueryPayload {
13
+ query: string;
14
+ }
@@ -0,0 +1,10 @@
1
+ import { ChatState } from "../../types";
2
+ import { SetStatusPayload } from "./types";
3
+ /**
4
+ * Reducer action to set the loading status in the chat.
5
+ *
6
+ * @param state - State.
7
+ * @param payload - Payload.
8
+ * @returns State.
9
+ */
10
+ export declare function setStatusAction(state: ChatState, payload: SetStatusPayload): ChatState;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Reducer action to set the loading status in the chat.
3
+ *
4
+ * @param state - State.
5
+ * @param payload - Payload.
6
+ * @returns State.
7
+ */
8
+ export function setStatusAction(state, payload) {
9
+ return {
10
+ ...state,
11
+ status: { ...state.status, loading: payload.loading },
12
+ };
13
+ }
@@ -0,0 +1,7 @@
1
+ import { SetStatusAction, SetStatusPayload } from "./types";
2
+ /**
3
+ * Action creator for setting the loading status in the chat.
4
+ * @param payload - Payload.
5
+ * @returns Action with payload and action type.
6
+ */
7
+ export declare function setStatus(payload: SetStatusPayload): SetStatusAction;
@@ -0,0 +1,12 @@
1
+ import { ChatActionKind } from "../types";
2
+ /**
3
+ * Action creator for setting the loading status in the chat.
4
+ * @param payload - Payload.
5
+ * @returns Action with payload and action type.
6
+ */
7
+ export function setStatus(payload) {
8
+ return {
9
+ payload,
10
+ type: ChatActionKind.SetStatus,
11
+ };
12
+ }
@@ -0,0 +1,14 @@
1
+ import { ChatActionKind } from "../types";
2
+ /**
3
+ * Action to set the loading status for a chat.
4
+ */
5
+ export interface SetStatusAction {
6
+ payload: SetStatusPayload;
7
+ type: ChatActionKind.SetStatus;
8
+ }
9
+ /**
10
+ * Payload for the SetStatus action.
11
+ */
12
+ export interface SetStatusPayload {
13
+ loading: boolean;
14
+ }
@@ -0,0 +1,17 @@
1
+ import { SetErrorAction } from "./setError/types";
2
+ import { SetMessageAction } from "./setMessage/types";
3
+ import { SetQueryAction } from "./setQuery/types";
4
+ import { SetStatusAction } from "./setStatus/types";
5
+ /**
6
+ * Union of all Chat actions.
7
+ */
8
+ export type ChatAction = SetErrorAction | SetMessageAction | SetQueryAction | SetStatusAction;
9
+ /**
10
+ * Action kind identifiers for the Chat reducer.
11
+ */
12
+ export declare enum ChatActionKind {
13
+ SetError = "SET_ERROR",
14
+ SetMessage = "SET_MESSAGE",
15
+ SetQuery = "SET_QUERY",
16
+ SetStatus = "SET_STATUS"
17
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Action kind identifiers for the Chat reducer.
3
+ */
4
+ export var ChatActionKind;
5
+ (function (ChatActionKind) {
6
+ ChatActionKind["SetError"] = "SET_ERROR";
7
+ ChatActionKind["SetMessage"] = "SET_MESSAGE";
8
+ ChatActionKind["SetQuery"] = "SET_QUERY";
9
+ ChatActionKind["SetStatus"] = "SET_STATUS";
10
+ })(ChatActionKind || (ChatActionKind = {}));
@@ -0,0 +1,5 @@
1
+ import { ChatState } from "./types";
2
+ /**
3
+ * Initial state for the chat reducer.
4
+ */
5
+ export declare const INITIAL_STATE: ChatState;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Initial state for the chat reducer.
3
+ */
4
+ export const INITIAL_STATE = {
5
+ messages: [],
6
+ status: { loading: false },
7
+ };
@@ -0,0 +1,5 @@
1
+ import { ChatContextValue } from "./types";
2
+ /**
3
+ * Context for the Chat state provider.
4
+ */
5
+ export declare const ChatContext: import("react").Context<ChatContextValue>;
@@ -0,0 +1,9 @@
1
+ import { createContext } from "react";
2
+ import { INITIAL_STATE } from "./constants";
3
+ /**
4
+ * Context for the Chat state provider.
5
+ */
6
+ export const ChatContext = createContext({
7
+ dispatch: () => undefined,
8
+ state: INITIAL_STATE,
9
+ });
@@ -0,0 +1,33 @@
1
+ import { AssistantMessage, ErrorMessage, Message, MessageResponse, PromptMessage, UserMessage } from "../types";
2
+ /**
3
+ * Returns true if the message is an assistant message.
4
+ * @param message - Chat message.
5
+ * @returns True if the message is an assistant message.
6
+ */
7
+ export declare function isAssistantMessage<R extends MessageResponse = MessageResponse>(message: Message<R>): message is AssistantMessage<R>;
8
+ /**
9
+ * Returns true if the message is an error message.
10
+ * @param message - Chat message.
11
+ * @returns True if the message is an error message.
12
+ */
13
+ export declare function isErrorMessage(message: Message): message is ErrorMessage;
14
+ /**
15
+ * Returns true if the message is the initial prompt message.
16
+ * @param message - Chat message.
17
+ * @returns True if the message is the initial prompt message.
18
+ */
19
+ export declare function isInitialPromptMessage(message: Message): message is PromptMessage & {
20
+ initial: true;
21
+ };
22
+ /**
23
+ * Returns true if the message is a prompt message.
24
+ * @param message - Chat message.
25
+ * @returns True if the message is a prompt message.
26
+ */
27
+ export declare function isPromptMessage(message: Message): message is PromptMessage;
28
+ /**
29
+ * Returns true if the message is a user message.
30
+ * @param message - Chat message.
31
+ * @returns True if the message is a user message.
32
+ */
33
+ export declare function isUserMessage(message: Message): message is UserMessage;
@@ -0,0 +1,41 @@
1
+ import { MESSAGE_TYPE, } from "../types";
2
+ /**
3
+ * Returns true if the message is an assistant message.
4
+ * @param message - Chat message.
5
+ * @returns True if the message is an assistant message.
6
+ */
7
+ export function isAssistantMessage(message) {
8
+ return message.type === MESSAGE_TYPE.ASSISTANT;
9
+ }
10
+ /**
11
+ * Returns true if the message is an error message.
12
+ * @param message - Chat message.
13
+ * @returns True if the message is an error message.
14
+ */
15
+ export function isErrorMessage(message) {
16
+ return message.type === MESSAGE_TYPE.ERROR;
17
+ }
18
+ /**
19
+ * Returns true if the message is the initial prompt message.
20
+ * @param message - Chat message.
21
+ * @returns True if the message is the initial prompt message.
22
+ */
23
+ export function isInitialPromptMessage(message) {
24
+ return isPromptMessage(message) && message.initial === true;
25
+ }
26
+ /**
27
+ * Returns true if the message is a prompt message.
28
+ * @param message - Chat message.
29
+ * @returns True if the message is a prompt message.
30
+ */
31
+ export function isPromptMessage(message) {
32
+ return message.type === MESSAGE_TYPE.PROMPT;
33
+ }
34
+ /**
35
+ * Returns true if the message is a user message.
36
+ * @param message - Chat message.
37
+ * @returns True if the message is a user message.
38
+ */
39
+ export function isUserMessage(message) {
40
+ return message.type === MESSAGE_TYPE.USER;
41
+ }
@@ -0,0 +1,6 @@
1
+ import { UseChatDispatch } from "./types";
2
+ /**
3
+ * Hook to dispatch Chat actions.
4
+ * @returns Object containing action dispatch functions.
5
+ */
6
+ export declare const useChatDispatch: () => UseChatDispatch;
@@ -0,0 +1,26 @@
1
+ import { useCallback, useContext } from "react";
2
+ import { setError } from "../../actions/setError/dispatch";
3
+ import { setMessage } from "../../actions/setMessage/dispatch";
4
+ import { setQuery } from "../../actions/setQuery/dispatch";
5
+ import { setStatus } from "../../actions/setStatus/dispatch";
6
+ import { ChatContext } from "../../context";
7
+ /**
8
+ * Hook to dispatch Chat actions.
9
+ * @returns Object containing action dispatch functions.
10
+ */
11
+ export const useChatDispatch = () => {
12
+ const { dispatch } = useContext(ChatContext);
13
+ const onSetError = useCallback((error) => {
14
+ dispatch(setError({ error }));
15
+ }, [dispatch]);
16
+ const onSetMessage = useCallback((response) => {
17
+ dispatch(setMessage({ response }));
18
+ }, [dispatch]);
19
+ const onSetQuery = useCallback((query) => {
20
+ dispatch(setQuery({ query }));
21
+ }, [dispatch]);
22
+ const onSetStatus = useCallback((loading) => {
23
+ dispatch(setStatus({ loading }));
24
+ }, [dispatch]);
25
+ return { onSetError, onSetMessage, onSetQuery, onSetStatus };
26
+ };
@@ -0,0 +1,10 @@
1
+ import { MessageResponse } from "../../types";
2
+ /**
3
+ * Return type for the useChatDispatch hook.
4
+ */
5
+ export interface UseChatDispatch {
6
+ onSetError: (error: string) => void;
7
+ onSetMessage: <R extends MessageResponse>(response: R) => void;
8
+ onSetQuery: (query: string) => void;
9
+ onSetStatus: (loading: boolean) => void;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { InitialArgs } from "../../initializer/types";
2
+ import { ChatContextValue } from "../../types";
3
+ /**
4
+ * Hook that manages the chat reducer with initial state from config.
5
+ * @param initialArgs - Initial arguments for the chat state.
6
+ * @returns Chat context value with dispatch and state.
7
+ */
8
+ export declare const useChatReducer: (initialArgs?: InitialArgs) => ChatContextValue;
@@ -0,0 +1,12 @@
1
+ import { useReducer } from "react";
2
+ import { initializer } from "../../initializer/initializer";
3
+ import { chatReducer } from "../../reducer";
4
+ /**
5
+ * Hook that manages the chat reducer with initial state from config.
6
+ * @param initialArgs - Initial arguments for the chat state.
7
+ * @returns Chat context value with dispatch and state.
8
+ */
9
+ export const useChatReducer = (initialArgs) => {
10
+ const [state, dispatch] = useReducer(chatReducer, initialArgs, initializer);
11
+ return { dispatch, state };
12
+ };
@@ -0,0 +1,7 @@
1
+ import { ChatContextValue } from "../../types";
2
+ /**
3
+ * Hook to access Chat state.
4
+ *
5
+ * @returns Chat state.
6
+ */
7
+ export declare const useChatState: () => Pick<ChatContextValue, "state">;
@@ -0,0 +1,11 @@
1
+ import { useContext } from "react";
2
+ import { ChatContext } from "../../context";
3
+ /**
4
+ * Hook to access Chat state.
5
+ *
6
+ * @returns Chat state.
7
+ */
8
+ export const useChatState = () => {
9
+ const { state } = useContext(ChatContext);
10
+ return { state };
11
+ };