@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
@@ -11,7 +11,6 @@ import { SearchAllFilters } from "../../components/Filter/components/SearchAllFi
11
11
  import { SURFACE_TYPE } from "../../components/Filter/components/surfaces/types";
12
12
  import { Index as IndexView } from "../../components/Index/index";
13
13
  import { SidebarLabel } from "../../components/Layout/components/Sidebar/components/SidebarLabel/sidebarLabel";
14
- import { SidebarTools } from "../../components/Layout/components/Sidebar/components/SidebarTools/sidebarTools.styles";
15
14
  import { Sidebar } from "../../components/Layout/components/Sidebar/sidebar";
16
15
  import { useStateSyncManager } from "../../hooks/stateSyncManager/hook";
17
16
  import { useBreakpoint } from "../../hooks/useBreakpoint";
@@ -26,6 +25,8 @@ import { SELECT_CATEGORY_KEY } from "../../providers/exploreState/constants";
26
25
  import { TEST_IDS } from "../../tests/testIds";
27
26
  import { useUpdateFilterSort } from "./hooks/UseUpdateFilterSort/hook";
28
27
  import { buildStateSyncManagerContext } from "./utils";
28
+ import { StyledGrid, StyledStack } from "./entityList/filters/filters.styles";
29
+ import { ToggleButtonGroup } from "./entityList/filters/components/ToggleButtonGroup/toggleButtonGroup";
29
30
  export const ExploreView = (props) => {
30
31
  const { mdDown } = useBreakpoint();
31
32
  const { config, entityConfig } = useConfig(); // Get app level config.
@@ -99,7 +100,7 @@ export const ExploreView = (props) => {
99
100
  });
100
101
  }
101
102
  }, [entityListType, exploreDispatch]);
102
- return (_jsxs(DrawerProvider, { children: [categoryViews && !!categoryViews.length && (_jsxs(Sidebar, { children: [_jsxs(SidebarTools, { "data-testid": TEST_IDS.FILTER_CONTROLS, children: [_jsx(SidebarLabel, { label: "Filters" }), _jsxs(Stack, { direction: "row", gap: 4, children: [_jsx(ClearAllFilters, {}), _jsx(FilterSort, { enabled: filterSortEnabled, filterSort: filterSort, onFilterSortChange: onFilterSortChange })] }), _jsx(SearchAllFilters, { categoryViews: categoryViews, onFilter: onFilterChange.bind(null, true), surfaceType: mdDown ? SURFACE_TYPE.POPPER_DRAWER : SURFACE_TYPE.POPPER_MENU })] }), _jsx(Filters, { categoryFilters: categoryFilters, onFilter: onFilterChange.bind(null, false), surfaceType: mdDown ? SURFACE_TYPE.DRAWER : SURFACE_TYPE.MENU, trackFilterOpened: trackingConfig?.trackFilterOpened })] })), _jsx(IndexView, { className: props.className, categoryFilters: categoryFilters, entityListType: entityListType, entityName: label, loading: loading })] }));
103
+ return (_jsxs(DrawerProvider, { children: [categoryViews && !!categoryViews.length && (_jsxs(Sidebar, { children: [_jsx(ToggleButtonGroup, {}), _jsxs(StyledStack, { children: [_jsxs(StyledGrid, { "data-testid": TEST_IDS.FILTER_CONTROLS, children: [_jsx(SidebarLabel, { label: "Filters" }), _jsxs(Stack, { direction: "row", gap: 4, children: [_jsx(ClearAllFilters, {}), _jsx(FilterSort, { enabled: filterSortEnabled, filterSort: filterSort, onFilterSortChange: onFilterSortChange })] })] }), _jsx(SearchAllFilters, { categoryViews: categoryViews, onFilter: onFilterChange.bind(null, true), surfaceType: mdDown ? SURFACE_TYPE.POPPER_DRAWER : SURFACE_TYPE.POPPER_MENU })] }), _jsx(Filters, { categoryFilters: categoryFilters, onFilter: onFilterChange.bind(null, false), surfaceType: mdDown ? SURFACE_TYPE.DRAWER : SURFACE_TYPE.MENU, trackFilterOpened: trackingConfig?.trackFilterOpened })] })), _jsx(IndexView, { className: props.className, categoryFilters: categoryFilters, entityListType: entityListType, entityName: label, loading: loading })] }));
103
104
  };
104
105
  /**
105
106
  * Builds the category views into category views grouped by the given category group configuration.
@@ -0,0 +1,6 @@
1
+ import { JSX } from "react";
2
+ /**
3
+ * Renders the research assistant drawer.
4
+ * @returns The assistant drawer.
5
+ */
6
+ export declare const Assistant: () => JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useChatState } from "../state/hooks/UseChatState/hook";
3
+ import { Form } from "./components/Form/form";
4
+ import { Input } from "./components/Input/input";
5
+ import { getPlaceholder } from "./components/Input/utils";
6
+ import { Messages } from "./components/Messages/messages";
7
+ import { Drawer } from "./components/Drawer/drawer";
8
+ import { ToggleButtonGroup } from "./components/ToggleButtonGroup/toggleButtonGroup";
9
+ /**
10
+ * Renders the research assistant drawer.
11
+ * @returns The assistant drawer.
12
+ */
13
+ export const Assistant = () => {
14
+ const { state } = useChatState();
15
+ return (_jsxs(Drawer, { children: [_jsx(ToggleButtonGroup, {}), _jsxs(Form, { status: state.status, children: [_jsx(Messages, { state: state }), _jsx(Input, { disabled: state.status.loading, placeholder: getPlaceholder(state) })] })] }));
16
+ };
@@ -0,0 +1,9 @@
1
+ import { JSX } from "react";
2
+ import { DrawerProps } from "./types";
3
+ /**
4
+ * Renders the drawer component for the research assistant.
5
+ * @param props - Component props.
6
+ * @param props.children - Children.
7
+ * @returns The drawer component.
8
+ */
9
+ export declare const Drawer: ({ children }: DrawerProps) => JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { TEST_IDS } from "../../../../../tests/testIds";
3
+ import { StyledDrawer } from "./drawer.styles";
4
+ import { useLayoutSpacing } from "../../../../../hooks/UseLayoutSpacing/hook";
5
+ import { DRAWER_PROPS } from "../../../../../styles/common/mui/drawer";
6
+ /**
7
+ * Renders the drawer component for the research assistant.
8
+ * @param props - Component props.
9
+ * @param props.children - Children.
10
+ * @returns The drawer component.
11
+ */
12
+ export const Drawer = ({ children }) => {
13
+ const { spacing } = useLayoutSpacing();
14
+ return (_jsx(StyledDrawer, { "data-testid": TEST_IDS.RESEARCH_PANEL, open: true, variant: DRAWER_PROPS.VARIANT.PERSISTENT, ...spacing, children: children }));
15
+ };
@@ -0,0 +1,4 @@
1
+ import { LayoutSpacing } from "../../../../../hooks/UseLayoutSpacing/types";
2
+ export declare const StyledDrawer: import("@emotion/styled").StyledComponent<import("@mui/material").DrawerProps & {
3
+ theme?: import("@emotion/react").Theme;
4
+ } & LayoutSpacing, {}, {}>;
@@ -0,0 +1,21 @@
1
+ import styled from "@emotion/styled";
2
+ import { Drawer } from "@mui/material";
3
+ import { PALETTE } from "../../../../../styles/common/constants/palette";
4
+ export const StyledDrawer = styled(Drawer, {
5
+ shouldForwardProp(prop) {
6
+ return prop !== "bottom" && prop !== "top";
7
+ },
8
+ }) `
9
+ height: 100%;
10
+ max-height: 100dvh;
11
+ width: 412px;
12
+ z-index: 0;
13
+
14
+ > .MuiPaper-root {
15
+ background-color: ${PALETTE.COMMON_WHITE};
16
+ border-right: 1px solid ${PALETTE.SMOKE_MAIN};
17
+ padding-top: ${({ top }) => top}px;
18
+ position: relative;
19
+ width: inherit;
20
+ }
21
+ `;
@@ -0,0 +1,4 @@
1
+ import { ReactNode } from "react";
2
+ export interface DrawerProps {
3
+ children: ReactNode;
4
+ }
@@ -0,0 +1,3 @@
1
+ export declare const FIELD_NAME: {
2
+ AI_PROMPT: string;
3
+ };
@@ -0,0 +1,3 @@
1
+ export const FIELD_NAME = {
2
+ AI_PROMPT: "ai-prompt",
3
+ };
@@ -0,0 +1,11 @@
1
+ import { JSX } from "react";
2
+ import { FormProps } from "./types";
3
+ /**
4
+ * Renders the research form.
5
+ * @param props - Component props.
6
+ * @param props.children - Form children.
7
+ * @param props.className - Class name for styling.
8
+ * @param props.status - Form status.
9
+ * @returns The research form container element.
10
+ */
11
+ export declare const Form: ({ children, className, status, }: FormProps) => JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { TEST_IDS } from "../../../../../tests/testIds";
3
+ import { useQuery } from "../../../state/query/hooks/UseQuery/hook";
4
+ import { FIELD_NAME } from "./constants";
5
+ import { StyledForm } from "./form.styles";
6
+ import { getPayload } from "./utils";
7
+ /**
8
+ * Renders the research form.
9
+ * @param props - Component props.
10
+ * @param props.children - Form children.
11
+ * @param props.className - Class name for styling.
12
+ * @param props.status - Form status.
13
+ * @returns The research form container element.
14
+ */
15
+ export const Form = ({ children, className, status, }) => {
16
+ const { onSubmit } = useQuery();
17
+ return (_jsx(StyledForm, { className: className, "data-testid": TEST_IDS.RESEARCH_FORM, onSubmit: async (e) => {
18
+ await onSubmit(e, getPayload(e), {
19
+ onSettled: (form) => {
20
+ const input = form.elements.namedItem(FIELD_NAME.AI_PROMPT);
21
+ if (input instanceof HTMLElement)
22
+ input.focus();
23
+ },
24
+ status,
25
+ });
26
+ }, children: children }));
27
+ };
@@ -0,0 +1,4 @@
1
+ export declare const StyledForm: import("@emotion/styled").StyledComponent<{
2
+ theme?: import("@emotion/react").Theme;
3
+ as?: React.ElementType;
4
+ }, import("react").DetailedHTMLProps<import("react").FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, {}>;
@@ -0,0 +1,7 @@
1
+ import styled from "@emotion/styled";
2
+ export const StyledForm = styled.form `
3
+ display: flex;
4
+ flex-direction: column;
5
+ height: 100%;
6
+ min-height: 0;
7
+ `;
@@ -0,0 +1,3 @@
1
+ import { BaseComponentProps, ChildrenProps } from "../../../../../components/types";
2
+ import { ChatState } from "../../../state/types";
3
+ export type FormProps = BaseComponentProps & ChildrenProps & Pick<ChatState, "status">;
@@ -0,0 +1,16 @@
1
+ import { FormEvent } from "react";
2
+ import { OnSubmitPayload } from "../../../state/query/types";
3
+ /**
4
+ * Extracts and trims form values from a form element.
5
+ * @param form - Form element.
6
+ * @returns An object mapping form field names to their trimmed string values.
7
+ */
8
+ export declare const getFormValues: (form: HTMLFormElement) => Record<string, string>;
9
+ /**
10
+ * Returns the payload for the query form submission.
11
+ * If the submitter has a data-query attribute (e.g. a suggestion chip), uses that as the query.
12
+ * Otherwise, falls back to the form input value.
13
+ * @param e - Form event.
14
+ * @returns The payload object containing the query value.
15
+ */
16
+ export declare const getPayload: (e: FormEvent<HTMLFormElement>) => OnSubmitPayload;
@@ -0,0 +1,41 @@
1
+ import { FIELD_NAME } from "./constants";
2
+ /**
3
+ * Extracts and trims form values from a form element.
4
+ * @param form - Form element.
5
+ * @returns An object mapping form field names to their trimmed string values.
6
+ */
7
+ export const getFormValues = (form) => {
8
+ const formData = new FormData(form);
9
+ const values = {};
10
+ formData.forEach((value, key) => {
11
+ values[key] = value.toString().trim();
12
+ });
13
+ return values;
14
+ };
15
+ /**
16
+ * Returns the payload for the query form submission.
17
+ * If the submitter has a data-query attribute (e.g. a suggestion chip), uses that as the query.
18
+ * Otherwise, falls back to the form input value.
19
+ * @param e - Form event.
20
+ * @returns The payload object containing the query value.
21
+ */
22
+ export const getPayload = (e) => {
23
+ // Check for a query from the submitter's data-query attribute first
24
+ const query = getSubmitterQuery(e);
25
+ // The onSubmit handler will ignore empty queries which acts as a safeguard against empty data-query values.
26
+ if (query !== undefined)
27
+ return { query };
28
+ // If no submitter query, fall back to form values
29
+ const formValues = getFormValues(e.currentTarget);
30
+ return { query: formValues[FIELD_NAME.AI_PROMPT] || "" };
31
+ };
32
+ /**
33
+ * Returns the query from the form submitter's data-query attribute, if present.
34
+ * @param e - Form event.
35
+ * @returns The query string, or undefined if the submitter has no data-query.
36
+ */
37
+ function getSubmitterQuery(e) {
38
+ const submitter = e.nativeEvent.submitter;
39
+ // We should expect a defined value here if the submitter is a data-query element, but we trim it just in case.
40
+ return submitter?.dataset.query?.trim();
41
+ }
@@ -0,0 +1,2 @@
1
+ import { InputBaseProps } from "@mui/material";
2
+ export declare const INPUT_BASE_PROPS: InputBaseProps;
@@ -0,0 +1,14 @@
1
+ import { INPUT_BASE_PROPS as MUI_INPUT_BASE_PROPS } from "../../../../../styles/common/mui/inputBase";
2
+ import { FIELD_NAME } from "../Form/constants";
3
+ export const INPUT_BASE_PROPS = {
4
+ autoFocus: true,
5
+ color: MUI_INPUT_BASE_PROPS.COLOR.PRIMARY,
6
+ fullWidth: true,
7
+ inputProps: { autoComplete: "off", spellCheck: false },
8
+ margin: MUI_INPUT_BASE_PROPS.MARGIN.DENSE,
9
+ maxRows: 4,
10
+ minRows: 1,
11
+ multiline: true,
12
+ name: FIELD_NAME.AI_PROMPT,
13
+ placeholder: "Ask anything",
14
+ };
@@ -0,0 +1,7 @@
1
+ export declare const KEY: {
2
+ readonly ARROW_DOWN: "ArrowDown";
3
+ readonly ARROW_UP: "ArrowUp";
4
+ readonly ENTER: "Enter";
5
+ readonly ESCAPE: "Escape";
6
+ readonly TAB: "Tab";
7
+ };
@@ -0,0 +1,7 @@
1
+ export const KEY = {
2
+ ARROW_DOWN: "ArrowDown",
3
+ ARROW_UP: "ArrowUp",
4
+ ENTER: "Enter",
5
+ ESCAPE: "Escape",
6
+ TAB: "Tab",
7
+ };
@@ -0,0 +1,6 @@
1
+ import { UseKeyShortCutsProps } from "./types";
2
+ /**
3
+ * Provides a keydown handler that implements keyboard shortcuts for the assistant input.
4
+ * @returns An object containing the onKeyDown handler.
5
+ */
6
+ export declare const useKeyShortCuts: () => UseKeyShortCutsProps;
@@ -0,0 +1,32 @@
1
+ import { useCallback, useEffect, useRef } from "react";
2
+ import { useChatState } from "../../../../../state/hooks/UseChatState/hook";
3
+ import { KEY } from "./constants";
4
+ import { getHistory, handleArrowKey, handleEnterKey, handleEscapeKey, handleTabKey, } from "./utils";
5
+ /**
6
+ * Provides a keydown handler that implements keyboard shortcuts for the assistant input.
7
+ * @returns An object containing the onKeyDown handler.
8
+ */
9
+ export const useKeyShortCuts = () => {
10
+ const { state } = useChatState();
11
+ const { messages } = state;
12
+ const history = getHistory(messages);
13
+ const draftRef = useRef("");
14
+ const historyIndexRef = useRef(-1);
15
+ useEffect(() => {
16
+ // Resets history navigation when messages change.
17
+ draftRef.current = "";
18
+ historyIndexRef.current = -1;
19
+ }, [messages]);
20
+ const onKeyDown = useCallback((e) => {
21
+ const refs = { draftRef, historyIndexRef };
22
+ if (e.key === KEY.ENTER)
23
+ return handleEnterKey(e);
24
+ if (e.key === KEY.ESCAPE)
25
+ return handleEscapeKey(e, refs);
26
+ if (e.key === KEY.ARROW_UP || e.key === KEY.ARROW_DOWN)
27
+ return handleArrowKey(e, history, refs);
28
+ if (e.key === KEY.TAB)
29
+ return handleTabKey(e);
30
+ }, [history]);
31
+ return { onKeyDown };
32
+ };
@@ -0,0 +1,8 @@
1
+ import { KeyboardEvent, RefObject } from "react";
2
+ export interface Refs {
3
+ draftRef: RefObject<string>;
4
+ historyIndexRef: RefObject<number>;
5
+ }
6
+ export interface UseKeyShortCutsProps {
7
+ onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
8
+ }
@@ -0,0 +1,32 @@
1
+ import { KeyboardEvent } from "react";
2
+ import { Message } from "../../../../../state/types";
3
+ import { Refs } from "./types";
4
+ /**
5
+ * Extracts the text of user messages from a list of messages and returns them in reverse order.
6
+ * @param messages - An array of Message objects to extract user messages from.
7
+ * @returns An array of strings containing the text of user messages, ordered from most recent to oldest.
8
+ */
9
+ export declare function getHistory(messages: Message[]): string[];
10
+ /**
11
+ * Handles arrow up/down key presses to navigate through input history.
12
+ * @param e - The keyboard event.
13
+ * @param history - The history entries to navigate.
14
+ * @param refs - Refs for draft text and history index.
15
+ */
16
+ export declare function handleArrowKey(e: KeyboardEvent<HTMLInputElement>, history: string[], refs: Refs): void;
17
+ /**
18
+ * Handles the Enter key press to submit the form, or allows newline on Shift+Enter.
19
+ * @param e - The keyboard event.
20
+ */
21
+ export declare function handleEnterKey(e: KeyboardEvent<HTMLInputElement>): void;
22
+ /**
23
+ * Handles the Escape key press to clear the input and reset history navigation.
24
+ * @param e - The keyboard event.
25
+ * @param refs - Refs for draft text and history index.
26
+ */
27
+ export declare function handleEscapeKey(e: KeyboardEvent<HTMLInputElement>, refs: Refs): void;
28
+ /**
29
+ * Handles the Tab key press to auto-fill the input with the placeholder.
30
+ * @param e - The keyboard event.
31
+ */
32
+ export declare function handleTabKey(e: KeyboardEvent<HTMLInputElement>): void;
@@ -0,0 +1,74 @@
1
+ import { isUserMessage } from "../../../../../state/guards/guards";
2
+ import { KEY } from "./constants";
3
+ /**
4
+ * Extracts the text of user messages from a list of messages and returns them in reverse order.
5
+ * @param messages - An array of Message objects to extract user messages from.
6
+ * @returns An array of strings containing the text of user messages, ordered from most recent to oldest.
7
+ */
8
+ export function getHistory(messages) {
9
+ return messages
10
+ .filter(isUserMessage)
11
+ .map((message) => message.text)
12
+ .reverse();
13
+ }
14
+ /**
15
+ * Handles arrow up/down key presses to navigate through input history.
16
+ * @param e - The keyboard event.
17
+ * @param history - The history entries to navigate.
18
+ * @param refs - Refs for draft text and history index.
19
+ */
20
+ export function handleArrowKey(e, history, refs) {
21
+ const { draftRef, historyIndexRef } = refs;
22
+ const inputEl = e.currentTarget;
23
+ if (e.key === KEY.ARROW_DOWN && historyIndexRef.current === -1) {
24
+ return;
25
+ }
26
+ if (historyIndexRef.current === -1) {
27
+ draftRef.current = inputEl.value;
28
+ }
29
+ const currentIndex = historyIndexRef.current;
30
+ const newIndex = e.key === KEY.ARROW_UP
31
+ ? Math.min(currentIndex + 1, history.length - 1)
32
+ : Math.max(currentIndex - 1, -1);
33
+ if (newIndex === -1) {
34
+ inputEl.value = draftRef.current;
35
+ historyIndexRef.current = -1;
36
+ return;
37
+ }
38
+ inputEl.value = history[newIndex] || "";
39
+ historyIndexRef.current = newIndex;
40
+ }
41
+ /**
42
+ * Handles the Enter key press to submit the form, or allows newline on Shift+Enter.
43
+ * @param e - The keyboard event.
44
+ */
45
+ export function handleEnterKey(e) {
46
+ if (e.shiftKey)
47
+ return;
48
+ e.preventDefault();
49
+ const formEl = e.currentTarget.form;
50
+ formEl?.requestSubmit();
51
+ }
52
+ /**
53
+ * Handles the Escape key press to clear the input and reset history navigation.
54
+ * @param e - The keyboard event.
55
+ * @param refs - Refs for draft text and history index.
56
+ */
57
+ export function handleEscapeKey(e, refs) {
58
+ const { draftRef, historyIndexRef } = refs;
59
+ const inputEl = e.currentTarget;
60
+ inputEl.value = "";
61
+ draftRef.current = "";
62
+ historyIndexRef.current = -1;
63
+ }
64
+ /**
65
+ * Handles the Tab key press to auto-fill the input with the placeholder.
66
+ * @param e - The keyboard event.
67
+ */
68
+ export function handleTabKey(e) {
69
+ const inputEl = e.currentTarget;
70
+ if (inputEl.value)
71
+ return;
72
+ e.preventDefault();
73
+ inputEl.value = inputEl.placeholder;
74
+ }
@@ -0,0 +1,9 @@
1
+ import { JSX } from "react";
2
+ import { InputProps } from "./types";
3
+ /**
4
+ * Renders an input component for the research panel.
5
+ * @param props - Component props.
6
+ * @param props.disabled - Disabled state of the input, which is derived from the loading state of the query.
7
+ * @returns Research panel input component.
8
+ */
9
+ export declare const Input: ({ disabled, ...props }: InputProps) => JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { IconButton, InputBase, Stack } from "@mui/material";
3
+ import { INPUT_BASE_PROPS } from "./constants";
4
+ import { StyledBox, StyledPaper } from "./input.styles";
5
+ import { UpArrowIcon } from "../../../../../components/common/CustomIcon/components/UpArrowIcon/upArrowIcon";
6
+ import { ICON_BUTTON_PROPS } from "../../../../../styles/common/mui/iconButton";
7
+ import { SVG_ICON_PROPS } from "../../../../../styles/common/mui/svgIcon";
8
+ import { STACK_PROPS } from "../../../../../styles/common/mui/stack";
9
+ import { useKeyShortCuts } from "./hooks/UseKeyShortCuts/hook";
10
+ /**
11
+ * Renders an input component for the research panel.
12
+ * @param props - Component props.
13
+ * @param props.disabled - Disabled state of the input, which is derived from the loading state of the query.
14
+ * @returns Research panel input component.
15
+ */
16
+ export const Input = ({ disabled, ...props }) => {
17
+ const { onKeyDown } = useKeyShortCuts();
18
+ return (_jsx(StyledBox, { children: _jsxs(StyledPaper, { elevation: 0, children: [_jsx(InputBase, { ...INPUT_BASE_PROPS, onKeyDown: onKeyDown, ...props }), _jsx(Stack, { direction: STACK_PROPS.DIRECTION.ROW, gap: 2, children: _jsx(IconButton, { color: ICON_BUTTON_PROPS.COLOR.SECONDARY, disabled: disabled, size: ICON_BUTTON_PROPS.SIZE.XSMALL, type: "submit", children: _jsx(UpArrowIcon, { fontSize: SVG_ICON_PROPS.FONT_SIZE.SMALL }) }) })] }) }));
19
+ };
@@ -0,0 +1,8 @@
1
+ export declare const StyledBox: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & {
2
+ theme?: import("@emotion/react").Theme;
3
+ }, {}, {}>;
4
+ export declare const StyledPaper: import("@emotion/styled").StyledComponent<import("../../../../../components/types").BaseComponentProps & import("@mui/material").PaperOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style" | "className" | "classes" | "children" | "sx" | "square" | "elevation" | "variant"> & {
5
+ component?: React.ElementType;
6
+ } & {
7
+ theme?: import("@emotion/react").Theme;
8
+ }, {}, {}>;
@@ -0,0 +1,19 @@
1
+ import styled from "@emotion/styled";
2
+ import { RoundedPaper } from "../../../../../components/common/Paper/components/RoundedPaper/roundedPaper";
3
+ import { Box } from "@mui/material";
4
+ export const StyledBox = styled(Box) `
5
+ padding: 16px;
6
+ `;
7
+ export const StyledPaper = styled(RoundedPaper) `
8
+ display: flex;
9
+ flex-direction: column;
10
+
11
+ .MuiInputBase-root {
12
+ padding: 16px;
13
+ }
14
+
15
+ .MuiStack-root {
16
+ justify-content: flex-end;
17
+ padding: 8px;
18
+ }
19
+ `;
@@ -0,0 +1,6 @@
1
+ import { type Meta, type StoryObj } from "@storybook/nextjs-vite";
2
+ import { Input } from "../input";
3
+ declare const meta: Meta<typeof Input>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Input } from "../input";
3
+ import { Box } from "@mui/material";
4
+ const meta = {
5
+ component: Input,
6
+ decorators: [
7
+ (Story) => (_jsx(Box, { sx: { width: "412px" }, children: _jsx(Story, {}) })),
8
+ ],
9
+ };
10
+ export default meta;
11
+ export const Default = {};
@@ -0,0 +1,2 @@
1
+ import { IconButtonProps, InputBaseProps } from "@mui/material";
2
+ export type InputProps = InputBaseProps & Pick<IconButtonProps, "disabled">;
@@ -0,0 +1,9 @@
1
+ import { ChatState } from "../../../state/types";
2
+ /**
3
+ * Gets the placeholder text for the input field based on the chat state.
4
+ * If there are no messages, it returns a default prompt. If there are messages,
5
+ * it looks for the last prompt message and uses its input prefill as the placeholder.
6
+ * @param state - The current state of the chat.
7
+ * @returns The placeholder text for the input field.
8
+ */
9
+ export declare function getPlaceholder(state: ChatState): string;
@@ -0,0 +1,25 @@
1
+ import { MESSAGE_TYPE, } from "../../../state/types";
2
+ /**
3
+ * Gets the placeholder text for the input field based on the chat state.
4
+ * If there are no messages, it returns a default prompt. If there are messages,
5
+ * it looks for the last prompt message and uses its input prefill as the placeholder.
6
+ * @param state - The current state of the chat.
7
+ * @returns The placeholder text for the input field.
8
+ */
9
+ export function getPlaceholder(state) {
10
+ if (state.messages.length === 0)
11
+ return "Ask anything";
12
+ // Reverse messages, last is the latest.
13
+ const messages = [...state.messages].reverse();
14
+ // Find the last prompt message to use its input prefill as placeholder.
15
+ const lastPrompt = messages.find(isPromptMessage);
16
+ return lastPrompt?.inputPlaceholder || "Ask anything";
17
+ }
18
+ /**
19
+ * Type guard to check if a message is a PromptMessage.
20
+ * @param message - The message to check.
21
+ * @returns True if the message is a PromptMessage, false otherwise.
22
+ */
23
+ function isPromptMessage(message) {
24
+ return message.type === MESSAGE_TYPE.PROMPT;
25
+ }
@@ -0,0 +1,9 @@
1
+ import { JSX } from "react";
2
+ import { AssistantMessageProps } from "./types";
3
+ /**
4
+ * Renders an assistant message.
5
+ * @param props - Component props.
6
+ * @param props.message - Assistant message.
7
+ * @returns The assistant message element.
8
+ */
9
+ export declare const AssistantMessage: ({ message, }: AssistantMessageProps) => JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Stack, Typography } from "@mui/material";
3
+ import { TYPOGRAPHY_PROPS } from "../../../../../../../styles/common/mui/typography";
4
+ import { getMappings, getMentions } from "./utils";
5
+ /**
6
+ * Renders an assistant message.
7
+ * @param props - Component props.
8
+ * @param props.message - Assistant message.
9
+ * @returns The assistant message element.
10
+ */
11
+ export const AssistantMessage = ({ message, }) => {
12
+ const mentions = getMentions(message);
13
+ const mappings = getMappings(message);
14
+ return (_jsxs(Stack, { gap: 2, useFlexGap: true, children: [message.response.message && (_jsx(Typography, { variant: TYPOGRAPHY_PROPS.VARIANT.BODY_400, children: message.response.message })), mentions && (_jsxs(Typography, { variant: TYPOGRAPHY_PROPS.VARIANT.BODY_SMALL_400, children: [_jsx(Typography, { color: TYPOGRAPHY_PROPS.COLOR.INK_LIGHT, variant: TYPOGRAPHY_PROPS.VARIANT.BODY_SMALL_500, children: "Extracted mentions:" }), " ", mentions] })), mappings && (_jsxs(Typography, { variant: TYPOGRAPHY_PROPS.VARIANT.BODY_SMALL_400, children: [_jsx(Typography, { color: TYPOGRAPHY_PROPS.COLOR.INK_LIGHT, variant: TYPOGRAPHY_PROPS.VARIANT.BODY_SMALL_500, children: "Extracted mappings:" }), " ", mappings] }))] }));
15
+ };
@@ -0,0 +1,4 @@
1
+ import { AssistantMessage } from "../../../../../state/types";
2
+ export interface AssistantMessageProps {
3
+ message: AssistantMessage;
4
+ }
@@ -0,0 +1,13 @@
1
+ import { AssistantMessage } from "../../../../../state/types";
2
+ /**
3
+ * Formats mention mappings from an assistant message as a readable string.
4
+ * @param message - Assistant message containing response mentions.
5
+ * @returns Formatted facet-value mappings separated by slashes, or empty string if no mentions.
6
+ */
7
+ export declare function getMappings(message: AssistantMessage): string;
8
+ /**
9
+ * Extracts original mention text from an assistant message.
10
+ * @param message - Assistant message containing response mentions.
11
+ * @returns Comma-separated original mention text, or empty string if no mentions.
12
+ */
13
+ export declare function getMentions(message: AssistantMessage): string;