@databiosphere/findable-ui 48.1.0 → 49.1.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 (355) hide show
  1. package/.github/workflows/release-please.yml +0 -22
  2. package/.release-please-manifest.json +1 -1
  3. package/CHANGELOG.md +39 -0
  4. package/backend/main.py +0 -1
  5. package/lib/common/ai/config/types.d.ts +22 -0
  6. package/lib/common/ai/config/types.js +1 -0
  7. package/lib/common/ai/constants.d.ts +3 -0
  8. package/lib/common/ai/constants.js +3 -0
  9. package/lib/common/categories/config/types.d.ts +2 -1
  10. package/lib/common/chart/sort/constants.d.ts +5 -0
  11. package/lib/common/chart/sort/constants.js +9 -0
  12. package/lib/common/chart/sort/types.d.ts +16 -0
  13. package/lib/common/chart/sort/types.js +8 -0
  14. package/lib/common/chart/sort/utils.d.ts +7 -0
  15. package/lib/common/chart/sort/utils.js +19 -0
  16. package/lib/common/chart/types.d.ts +5 -0
  17. package/lib/common/chart/types.js +1 -0
  18. package/lib/common/entities.d.ts +2 -1
  19. package/lib/components/Export/components/DownloadCurlCommand/downloadCurlCommand.d.ts +0 -2
  20. package/lib/components/Export/components/ExportToTerra/exportToTerra.d.ts +0 -2
  21. package/lib/components/Export/components/ManifestDownload/components/ManifestDownloadEntity/manifestDownloadEntity.d.ts +0 -2
  22. package/lib/components/Export/components/ManifestDownload/manifestDownload.d.ts +0 -2
  23. package/lib/components/Filter/components/FilterLabel/filterLabel.js +1 -1
  24. package/lib/components/Filter/components/FilterLabel/filterLabel.stories.d.ts +3 -0
  25. package/lib/components/Filter/components/FilterLabel/filterLabel.stories.js +5 -0
  26. package/lib/components/Filter/components/Filters/stories/constants.js +21 -1
  27. package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.styles.js +2 -0
  28. package/lib/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/utils.js +1 -1
  29. package/lib/components/Index/components/EntityView/components/views/ChartView/chartView.js +2 -1
  30. package/lib/components/Index/components/EntityView/components/views/ChartView/components/Chart/hooks/UsePlotOptions/hook.js +2 -7
  31. package/lib/components/Index/components/EntityView/components/views/ChartView/components/Chart/stories/args.js +12 -12
  32. package/lib/components/Index/components/EntityView/components/views/ChartView/stories/args.js +3 -3
  33. package/lib/components/Index/components/EntityView/components/views/ChartView/utils.js +1 -1
  34. package/lib/components/Layout/components/Sidebar/components/SidebarTools/sidebarTools.styles.d.ts +4 -0
  35. package/lib/components/Layout/components/Sidebar/components/SidebarTools/sidebarTools.styles.js +4 -0
  36. package/lib/components/common/Chip/components/Beta/beta.d.ts +10 -0
  37. package/lib/components/common/Chip/components/Beta/beta.js +12 -0
  38. package/lib/components/common/Chip/components/Beta/beta.styles.d.ts +3 -0
  39. package/lib/components/common/Chip/components/Beta/beta.styles.js +14 -0
  40. package/lib/components/common/Chip/components/Beta/stories/beta.stories.d.ts +6 -0
  41. package/lib/components/common/Chip/components/Beta/stories/beta.stories.js +6 -0
  42. package/lib/components/common/CustomIcon/components/UpArrowIcon/upArrowIcon.d.ts +6 -0
  43. package/lib/components/common/CustomIcon/components/UpArrowIcon/upArrowIcon.js +8 -0
  44. package/lib/components/common/Tabs/tabs.js +1 -1
  45. package/lib/components/common/ToggleButtonGroup/provider/context.d.ts +2 -0
  46. package/lib/components/common/ToggleButtonGroup/provider/context.js +5 -0
  47. package/lib/components/common/ToggleButtonGroup/provider/hook.d.ts +7 -0
  48. package/lib/components/common/ToggleButtonGroup/provider/hook.js +9 -0
  49. package/lib/components/common/ToggleButtonGroup/provider/provider.d.ts +12 -0
  50. package/lib/components/common/ToggleButtonGroup/provider/provider.js +22 -0
  51. package/lib/components/common/ToggleButtonGroup/provider/types.d.ts +9 -0
  52. package/lib/components/common/ToggleButtonGroup/provider/types.js +1 -0
  53. package/lib/config/entities.d.ts +2 -0
  54. package/lib/hooks/ai/useAiRoutes/hook.d.ts +6 -0
  55. package/lib/hooks/ai/useAiRoutes/hook.js +18 -0
  56. package/lib/hooks/useCategoryFilter.js +1 -1
  57. package/lib/hooks/useFileManifest/common/entities.d.ts +0 -9
  58. package/lib/hooks/useFileManifest/common/entities.js +1 -9
  59. package/lib/styles/common/mui/drawer.d.ts +9 -0
  60. package/lib/styles/common/mui/drawer.js +15 -0
  61. package/lib/styles/common/mui/inputBase.d.ts +13 -0
  62. package/lib/styles/common/mui/inputBase.js +25 -0
  63. package/lib/styles/common/mui/stack.d.ts +11 -0
  64. package/lib/styles/common/mui/stack.js +22 -0
  65. package/lib/tests/testIds.d.ts +3 -0
  66. package/lib/tests/testIds.js +3 -0
  67. package/lib/views/EntityDetailView/entityDetailView.js +2 -2
  68. package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.d.ts +7 -0
  69. package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.js +18 -0
  70. package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.styles.d.ts +6 -0
  71. package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.styles.js +23 -0
  72. package/lib/views/ExploreView/entityList/filters/filters.styles.d.ts +7 -0
  73. package/lib/views/ExploreView/entityList/filters/filters.styles.js +17 -0
  74. package/lib/views/ExploreView/exploreView.js +3 -2
  75. package/lib/views/ResearchView/adapter/useAdapter.d.ts +6 -0
  76. package/lib/views/ResearchView/adapter/useAdapter.js +15 -0
  77. package/lib/views/ResearchView/assistant/assistant.d.ts +6 -0
  78. package/lib/views/ResearchView/assistant/assistant.js +18 -0
  79. package/lib/views/ResearchView/assistant/components/Drawer/drawer.d.ts +9 -0
  80. package/lib/views/ResearchView/assistant/components/Drawer/drawer.js +15 -0
  81. package/lib/views/ResearchView/assistant/components/Drawer/drawer.styles.d.ts +4 -0
  82. package/lib/views/ResearchView/assistant/components/Drawer/drawer.styles.js +21 -0
  83. package/lib/views/ResearchView/assistant/components/Drawer/types.d.ts +4 -0
  84. package/lib/views/ResearchView/assistant/components/Drawer/types.js +1 -0
  85. package/lib/views/ResearchView/assistant/components/Form/constants.d.ts +3 -0
  86. package/lib/views/ResearchView/assistant/components/Form/constants.js +3 -0
  87. package/lib/views/ResearchView/assistant/components/Form/form.d.ts +12 -0
  88. package/lib/views/ResearchView/assistant/components/Form/form.js +40 -0
  89. package/lib/views/ResearchView/assistant/components/Form/form.styles.d.ts +4 -0
  90. package/lib/views/ResearchView/assistant/components/Form/form.styles.js +7 -0
  91. package/lib/views/ResearchView/assistant/components/Form/types.d.ts +4 -0
  92. package/lib/views/ResearchView/assistant/components/Form/types.js +1 -0
  93. package/lib/views/ResearchView/assistant/components/Form/utils.d.ts +16 -0
  94. package/lib/views/ResearchView/assistant/components/Form/utils.js +41 -0
  95. package/lib/views/ResearchView/assistant/components/Input/constants.d.ts +2 -0
  96. package/lib/views/ResearchView/assistant/components/Input/constants.js +14 -0
  97. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/constants.d.ts +7 -0
  98. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/constants.js +7 -0
  99. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/hook.d.ts +6 -0
  100. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/hook.js +32 -0
  101. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/types.d.ts +8 -0
  102. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/types.js +1 -0
  103. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/utils.d.ts +32 -0
  104. package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/utils.js +74 -0
  105. package/lib/views/ResearchView/assistant/components/Input/input.d.ts +9 -0
  106. package/lib/views/ResearchView/assistant/components/Input/input.js +19 -0
  107. package/lib/views/ResearchView/assistant/components/Input/input.styles.d.ts +8 -0
  108. package/lib/views/ResearchView/assistant/components/Input/input.styles.js +19 -0
  109. package/lib/views/ResearchView/assistant/components/Input/stories/input.stories.d.ts +6 -0
  110. package/lib/views/ResearchView/assistant/components/Input/stories/input.stories.js +11 -0
  111. package/lib/views/ResearchView/assistant/components/Input/types.d.ts +2 -0
  112. package/lib/views/ResearchView/assistant/components/Input/types.js +1 -0
  113. package/lib/views/ResearchView/assistant/components/Input/utils.d.ts +9 -0
  114. package/lib/views/ResearchView/assistant/components/Input/utils.js +25 -0
  115. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/assistantMessage.d.ts +9 -0
  116. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/assistantMessage.js +15 -0
  117. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/types.d.ts +4 -0
  118. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/types.js +1 -0
  119. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/utils.d.ts +13 -0
  120. package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/utils.js +25 -0
  121. package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/errorMessage.d.ts +9 -0
  122. package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/errorMessage.js +12 -0
  123. package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/types.d.ts +4 -0
  124. package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/types.js +1 -0
  125. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.d.ts +3 -0
  126. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.js +10 -0
  127. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.styles.d.ts +3 -0
  128. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.styles.js +26 -0
  129. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/types.d.ts +5 -0
  130. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/types.js +1 -0
  131. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/promptMessage.d.ts +10 -0
  132. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/promptMessage.js +14 -0
  133. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/types.d.ts +5 -0
  134. package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/types.js +1 -0
  135. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/types.d.ts +4 -0
  136. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/types.js +1 -0
  137. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/useMessage.styles.d.ts +5 -0
  138. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/useMessage.styles.js +10 -0
  139. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/userMessage.d.ts +9 -0
  140. package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/userMessage.js +13 -0
  141. package/lib/views/ResearchView/assistant/components/Messages/hooks/UseScroll/hook.d.ts +7 -0
  142. package/lib/views/ResearchView/assistant/components/Messages/hooks/UseScroll/hook.js +17 -0
  143. package/lib/views/ResearchView/assistant/components/Messages/messages.d.ts +9 -0
  144. package/lib/views/ResearchView/assistant/components/Messages/messages.js +16 -0
  145. package/lib/views/ResearchView/assistant/components/Messages/messages.styles.d.ts +3 -0
  146. package/lib/views/ResearchView/assistant/components/Messages/messages.styles.js +9 -0
  147. package/lib/views/ResearchView/assistant/components/Messages/selector/messageSelector.d.ts +17 -0
  148. package/lib/views/ResearchView/assistant/components/Messages/selector/messageSelector.js +32 -0
  149. package/lib/views/ResearchView/assistant/components/Messages/selector/types.d.ts +5 -0
  150. package/lib/views/ResearchView/assistant/components/Messages/selector/types.js +1 -0
  151. package/lib/views/ResearchView/assistant/components/Messages/stories/args.d.ts +3 -0
  152. package/lib/views/ResearchView/assistant/components/Messages/stories/args.js +109 -0
  153. package/lib/views/ResearchView/assistant/components/Messages/stories/messages.stories.d.ts +6 -0
  154. package/lib/views/ResearchView/assistant/components/Messages/stories/messages.stories.js +14 -0
  155. package/lib/views/ResearchView/assistant/components/Messages/types.d.ts +4 -0
  156. package/lib/views/ResearchView/assistant/components/Messages/types.js +1 -0
  157. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/stories/toggleButtonGroup.stories.d.ts +6 -0
  158. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/stories/toggleButtonGroup.stories.js +12 -0
  159. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.d.ts +7 -0
  160. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.js +17 -0
  161. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.styles.d.ts +6 -0
  162. package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.styles.js +20 -0
  163. package/lib/views/ResearchView/assistant/stories/args.d.ts +4 -0
  164. package/lib/views/ResearchView/assistant/stories/args.js +30 -0
  165. package/lib/views/ResearchView/assistant/stories/assistant.stories.d.ts +6 -0
  166. package/lib/views/ResearchView/assistant/stories/assistant.stories.js +23 -0
  167. package/lib/views/ResearchView/query/constants.d.ts +5 -0
  168. package/lib/views/ResearchView/query/constants.js +5 -0
  169. package/lib/views/ResearchView/query/fetch.d.ts +17 -0
  170. package/lib/views/ResearchView/query/fetch.js +44 -0
  171. package/lib/views/ResearchView/query/types.d.ts +31 -0
  172. package/lib/views/ResearchView/query/types.js +1 -0
  173. package/lib/views/ResearchView/query/useQuery.d.ts +7 -0
  174. package/lib/views/ResearchView/query/useQuery.js +44 -0
  175. package/lib/views/ResearchView/researchView.d.ts +10 -0
  176. package/lib/views/ResearchView/researchView.js +13 -0
  177. package/lib/views/ResearchView/state/actions/setError/action.d.ts +10 -0
  178. package/lib/views/ResearchView/state/actions/setError/action.js +17 -0
  179. package/lib/views/ResearchView/state/actions/setError/dispatch.d.ts +7 -0
  180. package/lib/views/ResearchView/state/actions/setError/dispatch.js +12 -0
  181. package/lib/views/ResearchView/state/actions/setError/types.d.ts +14 -0
  182. package/lib/views/ResearchView/state/actions/setError/types.js +1 -0
  183. package/lib/views/ResearchView/state/actions/setMessage/action.d.ts +10 -0
  184. package/lib/views/ResearchView/state/actions/setMessage/action.js +21 -0
  185. package/lib/views/ResearchView/state/actions/setMessage/dispatch.d.ts +7 -0
  186. package/lib/views/ResearchView/state/actions/setMessage/dispatch.js +12 -0
  187. package/lib/views/ResearchView/state/actions/setMessage/types.d.ts +15 -0
  188. package/lib/views/ResearchView/state/actions/setMessage/types.js +1 -0
  189. package/lib/views/ResearchView/state/actions/setQuery/action.d.ts +10 -0
  190. package/lib/views/ResearchView/state/actions/setQuery/action.js +17 -0
  191. package/lib/views/ResearchView/state/actions/setQuery/dispatch.d.ts +7 -0
  192. package/lib/views/ResearchView/state/actions/setQuery/dispatch.js +12 -0
  193. package/lib/views/ResearchView/state/actions/setQuery/types.d.ts +14 -0
  194. package/lib/views/ResearchView/state/actions/setQuery/types.js +1 -0
  195. package/lib/views/ResearchView/state/actions/setStatus/action.d.ts +10 -0
  196. package/lib/views/ResearchView/state/actions/setStatus/action.js +13 -0
  197. package/lib/views/ResearchView/state/actions/setStatus/dispatch.d.ts +7 -0
  198. package/lib/views/ResearchView/state/actions/setStatus/dispatch.js +12 -0
  199. package/lib/views/ResearchView/state/actions/setStatus/types.d.ts +14 -0
  200. package/lib/views/ResearchView/state/actions/setStatus/types.js +1 -0
  201. package/lib/views/ResearchView/state/actions/types.d.ts +17 -0
  202. package/lib/views/ResearchView/state/actions/types.js +10 -0
  203. package/lib/views/ResearchView/state/constants.d.ts +5 -0
  204. package/lib/views/ResearchView/state/constants.js +7 -0
  205. package/lib/views/ResearchView/state/context.d.ts +5 -0
  206. package/lib/views/ResearchView/state/context.js +9 -0
  207. package/lib/views/ResearchView/state/guards/guards.d.ts +33 -0
  208. package/lib/views/ResearchView/state/guards/guards.js +41 -0
  209. package/lib/views/ResearchView/state/hooks/UseChatDispatch/hook.d.ts +6 -0
  210. package/lib/views/ResearchView/state/hooks/UseChatDispatch/hook.js +26 -0
  211. package/lib/views/ResearchView/state/hooks/UseChatDispatch/types.d.ts +10 -0
  212. package/lib/views/ResearchView/state/hooks/UseChatDispatch/types.js +1 -0
  213. package/lib/views/ResearchView/state/hooks/UseChatReducer/hook.d.ts +8 -0
  214. package/lib/views/ResearchView/state/hooks/UseChatReducer/hook.js +12 -0
  215. package/lib/views/ResearchView/state/hooks/UseChatState/hook.d.ts +7 -0
  216. package/lib/views/ResearchView/state/hooks/UseChatState/hook.js +11 -0
  217. package/lib/views/ResearchView/state/initializer/initializer.d.ts +8 -0
  218. package/lib/views/ResearchView/state/initializer/initializer.js +22 -0
  219. package/lib/views/ResearchView/state/initializer/types.d.ts +2 -0
  220. package/lib/views/ResearchView/state/initializer/types.js +1 -0
  221. package/lib/views/ResearchView/state/provider.d.ts +16 -0
  222. package/lib/views/ResearchView/state/provider.js +17 -0
  223. package/lib/views/ResearchView/state/reducer.d.ts +10 -0
  224. package/lib/views/ResearchView/state/reducer.js +32 -0
  225. package/lib/views/ResearchView/state/types.d.ts +125 -0
  226. package/lib/views/ResearchView/state/types.js +22 -0
  227. package/package.json +1 -1
  228. package/src/common/ai/config/types.ts +25 -0
  229. package/src/common/ai/constants.ts +3 -0
  230. package/src/common/categories/config/types.ts +2 -1
  231. package/src/common/chart/sort/constants.ts +13 -0
  232. package/src/common/chart/sort/types.ts +22 -0
  233. package/src/common/chart/sort/utils.ts +22 -0
  234. package/src/common/chart/types.ts +6 -0
  235. package/src/common/entities.ts +2 -1
  236. package/src/components/Export/components/DownloadCurlCommand/downloadCurlCommand.tsx +0 -2
  237. package/src/components/Export/components/ExportToTerra/exportToTerra.tsx +0 -2
  238. package/src/components/Export/components/ManifestDownload/components/ManifestDownloadEntity/manifestDownloadEntity.tsx +0 -2
  239. package/src/components/Export/components/ManifestDownload/manifestDownload.tsx +0 -2
  240. package/src/components/Filter/components/FilterLabel/filterLabel.stories.tsx +6 -0
  241. package/src/components/Filter/components/FilterLabel/filterLabel.tsx +6 -1
  242. package/src/components/Filter/components/Filters/stories/constants.ts +25 -1
  243. package/src/components/Filter/components/SearchAllFilters/searchAllFilters.styles.ts +2 -0
  244. package/src/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/utils.ts +1 -1
  245. package/src/components/Index/components/EntityView/components/views/ChartView/chartView.tsx +8 -2
  246. package/src/components/Index/components/EntityView/components/views/ChartView/components/Chart/hooks/UsePlotOptions/hook.ts +2 -7
  247. package/src/components/Index/components/EntityView/components/views/ChartView/components/Chart/stories/args.ts +12 -12
  248. package/src/components/Index/components/EntityView/components/views/ChartView/stories/args.ts +3 -3
  249. package/src/components/Index/components/EntityView/components/views/ChartView/utils.ts +1 -1
  250. package/src/components/Layout/components/Sidebar/components/SidebarTools/sidebarTools.styles.ts +4 -0
  251. package/src/components/common/Chip/components/Beta/beta.styles.ts +15 -0
  252. package/src/components/common/Chip/components/Beta/beta.tsx +25 -0
  253. package/src/components/common/Chip/components/Beta/stories/beta.stories.tsx +12 -0
  254. package/src/components/common/CustomIcon/components/UpArrowIcon/upArrowIcon.tsx +21 -0
  255. package/src/components/common/Tabs/tabs.tsx +5 -1
  256. package/src/components/common/ToggleButtonGroup/provider/context.ts +9 -0
  257. package/src/components/common/ToggleButtonGroup/provider/hook.ts +16 -0
  258. package/src/components/common/ToggleButtonGroup/provider/provider.tsx +37 -0
  259. package/src/components/common/ToggleButtonGroup/provider/types.ts +17 -0
  260. package/src/config/entities.ts +2 -0
  261. package/src/hooks/ai/useAiRoutes/hook.ts +22 -0
  262. package/src/hooks/useCategoryFilter.ts +1 -1
  263. package/src/hooks/useFileManifest/common/entities.ts +0 -11
  264. package/src/styles/common/mui/drawer.ts +24 -0
  265. package/src/styles/common/mui/inputBase.ts +38 -0
  266. package/src/styles/common/mui/stack.ts +33 -0
  267. package/src/tests/testIds.ts +3 -0
  268. package/src/views/EntityDetailView/entityDetailView.tsx +1 -3
  269. package/src/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.styles.ts +25 -0
  270. package/src/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.tsx +31 -0
  271. package/src/views/ExploreView/entityList/filters/filters.styles.ts +19 -0
  272. package/src/views/ExploreView/exploreView.tsx +16 -12
  273. package/src/views/ResearchView/adapter/useAdapter.ts +19 -0
  274. package/src/views/ResearchView/assistant/assistant.tsx +30 -0
  275. package/src/views/ResearchView/assistant/components/Drawer/drawer.styles.ts +24 -0
  276. package/src/views/ResearchView/assistant/components/Drawer/drawer.tsx +26 -0
  277. package/src/views/ResearchView/assistant/components/Drawer/types.ts +5 -0
  278. package/src/views/ResearchView/assistant/components/Form/constants.ts +3 -0
  279. package/src/views/ResearchView/assistant/components/Form/form.styles.ts +8 -0
  280. package/src/views/ResearchView/assistant/components/Form/form.tsx +55 -0
  281. package/src/views/ResearchView/assistant/components/Form/types.ts +11 -0
  282. package/src/views/ResearchView/assistant/components/Form/utils.ts +51 -0
  283. package/src/views/ResearchView/assistant/components/Input/constants.ts +16 -0
  284. package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/constants.ts +7 -0
  285. package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/hook.ts +45 -0
  286. package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/types.ts +10 -0
  287. package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/utils.ts +93 -0
  288. package/src/views/ResearchView/assistant/components/Input/input.styles.ts +21 -0
  289. package/src/views/ResearchView/assistant/components/Input/input.tsx +37 -0
  290. package/src/views/ResearchView/assistant/components/Input/stories/input.stories.tsx +21 -0
  291. package/src/views/ResearchView/assistant/components/Input/types.ts +3 -0
  292. package/src/views/ResearchView/assistant/components/Input/utils.ts +34 -0
  293. package/src/views/ResearchView/assistant/components/Messages/components/AssistantMessage/assistantMessage.tsx +49 -0
  294. package/src/views/ResearchView/assistant/components/Messages/components/AssistantMessage/types.ts +5 -0
  295. package/src/views/ResearchView/assistant/components/Messages/components/AssistantMessage/utils.ts +31 -0
  296. package/src/views/ResearchView/assistant/components/Messages/components/ErrorMessage/errorMessage.tsx +21 -0
  297. package/src/views/ResearchView/assistant/components/Messages/components/ErrorMessage/types.ts +5 -0
  298. package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.styles.ts +27 -0
  299. package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.tsx +31 -0
  300. package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/types.ts +6 -0
  301. package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/promptMessage.tsx +26 -0
  302. package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/types.ts +6 -0
  303. package/src/views/ResearchView/assistant/components/Messages/components/UserMessage/types.ts +5 -0
  304. package/src/views/ResearchView/assistant/components/Messages/components/UserMessage/useMessage.styles.ts +11 -0
  305. package/src/views/ResearchView/assistant/components/Messages/components/UserMessage/userMessage.tsx +21 -0
  306. package/src/views/ResearchView/assistant/components/Messages/hooks/UseScroll/hook.ts +22 -0
  307. package/src/views/ResearchView/assistant/components/Messages/messages.styles.ts +10 -0
  308. package/src/views/ResearchView/assistant/components/Messages/messages.tsx +29 -0
  309. package/src/views/ResearchView/assistant/components/Messages/selector/messageSelector.tsx +37 -0
  310. package/src/views/ResearchView/assistant/components/Messages/selector/types.ts +6 -0
  311. package/src/views/ResearchView/assistant/components/Messages/stories/args.ts +115 -0
  312. package/src/views/ResearchView/assistant/components/Messages/stories/messages.stories.tsx +24 -0
  313. package/src/views/ResearchView/assistant/components/Messages/types.ts +5 -0
  314. package/src/views/ResearchView/assistant/components/ToggleButtonGroup/stories/toggleButtonGroup.stories.tsx +22 -0
  315. package/src/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.styles.ts +22 -0
  316. package/src/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.tsx +30 -0
  317. package/src/views/ResearchView/assistant/stories/args.ts +36 -0
  318. package/src/views/ResearchView/assistant/stories/assistant.stories.tsx +39 -0
  319. package/src/views/ResearchView/query/constants.ts +5 -0
  320. package/src/views/ResearchView/query/fetch.ts +58 -0
  321. package/src/views/ResearchView/query/types.ts +37 -0
  322. package/src/views/ResearchView/query/useQuery.ts +60 -0
  323. package/src/views/ResearchView/researchView.tsx +19 -0
  324. package/src/views/ResearchView/state/actions/setError/action.ts +22 -0
  325. package/src/views/ResearchView/state/actions/setError/dispatch.ts +14 -0
  326. package/src/views/ResearchView/state/actions/setError/types.ts +16 -0
  327. package/src/views/ResearchView/state/actions/setMessage/action.ts +26 -0
  328. package/src/views/ResearchView/state/actions/setMessage/dispatch.ts +14 -0
  329. package/src/views/ResearchView/state/actions/setMessage/types.ts +19 -0
  330. package/src/views/ResearchView/state/actions/setQuery/action.ts +22 -0
  331. package/src/views/ResearchView/state/actions/setQuery/dispatch.ts +14 -0
  332. package/src/views/ResearchView/state/actions/setQuery/types.ts +16 -0
  333. package/src/views/ResearchView/state/actions/setStatus/action.ts +19 -0
  334. package/src/views/ResearchView/state/actions/setStatus/dispatch.ts +14 -0
  335. package/src/views/ResearchView/state/actions/setStatus/types.ts +16 -0
  336. package/src/views/ResearchView/state/actions/types.ts +23 -0
  337. package/src/views/ResearchView/state/constants.ts +9 -0
  338. package/src/views/ResearchView/state/context.ts +11 -0
  339. package/src/views/ResearchView/state/guards/guards.ts +58 -0
  340. package/src/views/ResearchView/state/hooks/UseChatDispatch/hook.ts +46 -0
  341. package/src/views/ResearchView/state/hooks/UseChatDispatch/types.ts +11 -0
  342. package/src/views/ResearchView/state/hooks/UseChatReducer/hook.ts +15 -0
  343. package/src/views/ResearchView/state/hooks/UseChatState/hook.ts +14 -0
  344. package/src/views/ResearchView/state/initializer/initializer.ts +23 -0
  345. package/src/views/ResearchView/state/initializer/types.ts +3 -0
  346. package/src/views/ResearchView/state/provider.tsx +27 -0
  347. package/src/views/ResearchView/state/reducer.ts +34 -0
  348. package/src/views/ResearchView/state/types.ts +149 -0
  349. package/tests/chartSortUtils.test.ts +119 -0
  350. package/tests/research.assistantMessageUtils.test.ts +149 -0
  351. package/tests/research.chatState.test.ts +463 -0
  352. package/tests/research.fetchResponse.test.ts +164 -0
  353. package/tests/research.useKeyShortCuts.test.ts +254 -0
  354. package/tests/research.useQuery.test.ts +165 -0
  355. package/tests/toggleButtonGroupProvider.test.tsx +125 -0
@@ -0,0 +1,55 @@
1
+ import { JSX } from "react";
2
+ import { TEST_IDS } from "../../../../../tests/testIds";
3
+ import { useChatDispatch } from "../../../state/hooks/UseChatDispatch/hook";
4
+ import { MessageResponse } from "../../../state/types";
5
+ import { FIELD_NAME } from "./constants";
6
+ import { FormProps } from "./types";
7
+ import { getPayload } from "./utils";
8
+ import { StyledForm } from "./form.styles";
9
+
10
+ /**
11
+ * Renders the research form.
12
+ * @param props - Component props.
13
+ * @param props.actions - Form actions.
14
+ * @param props.children - Form children.
15
+ * @param props.className - Class name for styling.
16
+ * @param props.status - Form status.
17
+ * @returns The research form container element.
18
+ */
19
+ export const Form = ({
20
+ actions,
21
+ children,
22
+ className,
23
+ status,
24
+ }: FormProps): JSX.Element => {
25
+ const dispatch = useChatDispatch();
26
+ return (
27
+ <StyledForm
28
+ className={className}
29
+ data-testid={TEST_IDS.RESEARCH_FORM}
30
+ onSubmit={async (e) => {
31
+ await actions.onSubmit(e, getPayload(e), {
32
+ onError: (error) => {
33
+ dispatch.onSetError(error.message);
34
+ },
35
+ onMutate: (form, query) => {
36
+ dispatch.onSetQuery(query);
37
+ dispatch.onSetStatus(true);
38
+ form.reset();
39
+ },
40
+ onSettled: (form) => {
41
+ dispatch.onSetStatus(false);
42
+ const input = form.elements.namedItem(FIELD_NAME.AI_PROMPT);
43
+ if (input instanceof HTMLElement) input.focus();
44
+ },
45
+ onSuccess: (data) => {
46
+ dispatch.onSetMessage(data as MessageResponse);
47
+ },
48
+ status,
49
+ });
50
+ }}
51
+ >
52
+ {children}
53
+ </StyledForm>
54
+ );
55
+ };
@@ -0,0 +1,11 @@
1
+ import { UseQuery } from "../../../query/types";
2
+ import {
3
+ BaseComponentProps,
4
+ ChildrenProps,
5
+ } from "../../../../../components/types";
6
+ import { ChatState } from "../../../state/types";
7
+
8
+ export type FormProps = BaseComponentProps &
9
+ ChildrenProps &
10
+ Pick<UseQuery, "actions"> &
11
+ Pick<ChatState, "status">;
@@ -0,0 +1,51 @@
1
+ import { FormEvent } from "react";
2
+ import { FIELD_NAME } from "./constants";
3
+ import { OnSubmitPayload } from "../../../query/types";
4
+
5
+ /**
6
+ * Extracts and trims form values from a form element.
7
+ * @param form - Form element.
8
+ * @returns An object mapping form field names to their trimmed string values.
9
+ */
10
+ export const getFormValues = (
11
+ form: HTMLFormElement,
12
+ ): Record<string, string> => {
13
+ const formData = new FormData(form);
14
+
15
+ const values: Record<string, string> = {};
16
+ formData.forEach((value, key) => {
17
+ values[key] = value.toString().trim();
18
+ });
19
+
20
+ return values;
21
+ };
22
+
23
+ /**
24
+ * Returns the payload for the query form submission.
25
+ * If the submitter has a data-query attribute (e.g. a suggestion chip), uses that as the query.
26
+ * Otherwise, falls back to the form input value.
27
+ * @param e - Form event.
28
+ * @returns The payload object containing the query value.
29
+ */
30
+ export const getPayload = (e: FormEvent<HTMLFormElement>): OnSubmitPayload => {
31
+ // Check for a query from the submitter's data-query attribute first
32
+ const query = getSubmitterQuery(e);
33
+
34
+ // The onSubmit handler will ignore empty queries which acts as a safeguard against empty data-query values.
35
+ if (query !== undefined) return { query };
36
+
37
+ // If no submitter query, fall back to form values
38
+ const formValues = getFormValues(e.currentTarget);
39
+ return { query: formValues[FIELD_NAME.AI_PROMPT] || "" };
40
+ };
41
+
42
+ /**
43
+ * Returns the query from the form submitter's data-query attribute, if present.
44
+ * @param e - Form event.
45
+ * @returns The query string, or undefined if the submitter has no data-query.
46
+ */
47
+ function getSubmitterQuery(e: FormEvent<HTMLFormElement>): string | undefined {
48
+ const submitter = (e.nativeEvent as SubmitEvent).submitter;
49
+ // We should expect a defined value here if the submitter is a data-query element, but we trim it just in case.
50
+ return submitter?.dataset.query?.trim();
51
+ }
@@ -0,0 +1,16 @@
1
+ import { InputBaseProps } from "@mui/material";
2
+ import { INPUT_BASE_PROPS as MUI_INPUT_BASE_PROPS } from "../../../../../styles/common/mui/inputBase";
3
+ import { FIELD_NAME } from "../Form/constants";
4
+
5
+ export const INPUT_BASE_PROPS: InputBaseProps = {
6
+ autoFocus: true,
7
+ color: MUI_INPUT_BASE_PROPS.COLOR.PRIMARY,
8
+ fullWidth: true,
9
+ inputProps: { autoComplete: "off", spellCheck: false },
10
+ margin: MUI_INPUT_BASE_PROPS.MARGIN.DENSE,
11
+ maxRows: 4,
12
+ minRows: 1,
13
+ multiline: true,
14
+ name: FIELD_NAME.AI_PROMPT,
15
+ placeholder: "Ask anything",
16
+ };
@@ -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
+ } as const;
@@ -0,0 +1,45 @@
1
+ import { KeyboardEvent, useCallback, useEffect, useRef } from "react";
2
+ import { useChatState } from "../../../../../state/hooks/UseChatState/hook";
3
+ import { KEY } from "./constants";
4
+ import { UseKeyShortCutsProps } from "./types";
5
+ import {
6
+ getHistory,
7
+ handleArrowKey,
8
+ handleEnterKey,
9
+ handleEscapeKey,
10
+ handleTabKey,
11
+ } from "./utils";
12
+
13
+ /**
14
+ * Provides a keydown handler that implements keyboard shortcuts for the assistant input.
15
+ * @returns An object containing the onKeyDown handler.
16
+ */
17
+ export const useKeyShortCuts = (): UseKeyShortCutsProps => {
18
+ const { state } = useChatState();
19
+ const { messages } = state;
20
+
21
+ const history = getHistory(messages);
22
+
23
+ const draftRef = useRef<string>("");
24
+ const historyIndexRef = useRef<number>(-1);
25
+
26
+ useEffect(() => {
27
+ // Resets history navigation when messages change.
28
+ draftRef.current = "";
29
+ historyIndexRef.current = -1;
30
+ }, [messages]);
31
+
32
+ const onKeyDown = useCallback(
33
+ (e: KeyboardEvent<HTMLInputElement>) => {
34
+ const refs = { draftRef, historyIndexRef };
35
+ if (e.key === KEY.ENTER) return handleEnterKey(e);
36
+ if (e.key === KEY.ESCAPE) return handleEscapeKey(e, refs);
37
+ if (e.key === KEY.ARROW_UP || e.key === KEY.ARROW_DOWN)
38
+ return handleArrowKey(e, history, refs);
39
+ if (e.key === KEY.TAB) return handleTabKey(e);
40
+ },
41
+ [history],
42
+ );
43
+
44
+ return { onKeyDown };
45
+ };
@@ -0,0 +1,10 @@
1
+ import { KeyboardEvent, RefObject } from "react";
2
+
3
+ export interface Refs {
4
+ draftRef: RefObject<string>;
5
+ historyIndexRef: RefObject<number>;
6
+ }
7
+
8
+ export interface UseKeyShortCutsProps {
9
+ onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
10
+ }
@@ -0,0 +1,93 @@
1
+ import { KeyboardEvent } from "react";
2
+ import { isUserMessage } from "../../../../../state/guards/guards";
3
+ import { Message } from "../../../../../state/types";
4
+ import { Refs } from "./types";
5
+ import { KEY } from "./constants";
6
+
7
+ /**
8
+ * Extracts the text of user messages from a list of messages and returns them in reverse order.
9
+ * @param messages - An array of Message objects to extract user messages from.
10
+ * @returns An array of strings containing the text of user messages, ordered from most recent to oldest.
11
+ */
12
+ export function getHistory(messages: Message[]): string[] {
13
+ return messages
14
+ .filter(isUserMessage)
15
+ .map((message) => message.text)
16
+ .reverse();
17
+ }
18
+
19
+ /**
20
+ * Handles arrow up/down key presses to navigate through input history.
21
+ * @param e - The keyboard event.
22
+ * @param history - The history entries to navigate.
23
+ * @param refs - Refs for draft text and history index.
24
+ */
25
+ export function handleArrowKey(
26
+ e: KeyboardEvent<HTMLInputElement>,
27
+ history: string[],
28
+ refs: Refs,
29
+ ): void {
30
+ const { draftRef, historyIndexRef } = refs;
31
+ const inputEl = e.currentTarget;
32
+
33
+ if (e.key === KEY.ARROW_DOWN && historyIndexRef.current === -1) {
34
+ return;
35
+ }
36
+
37
+ if (historyIndexRef.current === -1) {
38
+ draftRef.current = inputEl.value;
39
+ }
40
+
41
+ const currentIndex = historyIndexRef.current;
42
+ const newIndex =
43
+ e.key === KEY.ARROW_UP
44
+ ? Math.min(currentIndex + 1, history.length - 1)
45
+ : Math.max(currentIndex - 1, -1);
46
+
47
+ if (newIndex === -1) {
48
+ inputEl.value = draftRef.current;
49
+ historyIndexRef.current = -1;
50
+ return;
51
+ }
52
+
53
+ inputEl.value = history[newIndex] || "";
54
+ historyIndexRef.current = newIndex;
55
+ }
56
+
57
+ /**
58
+ * Handles the Enter key press to submit the form, or allows newline on Shift+Enter.
59
+ * @param e - The keyboard event.
60
+ */
61
+ export function handleEnterKey(e: KeyboardEvent<HTMLInputElement>): void {
62
+ if (e.shiftKey) return;
63
+ e.preventDefault();
64
+ const formEl = e.currentTarget.form;
65
+ formEl?.requestSubmit();
66
+ }
67
+
68
+ /**
69
+ * Handles the Escape key press to clear the input and reset history navigation.
70
+ * @param e - The keyboard event.
71
+ * @param refs - Refs for draft text and history index.
72
+ */
73
+ export function handleEscapeKey(
74
+ e: KeyboardEvent<HTMLInputElement>,
75
+ refs: Refs,
76
+ ): void {
77
+ const { draftRef, historyIndexRef } = refs;
78
+ const inputEl = e.currentTarget;
79
+ inputEl.value = "";
80
+ draftRef.current = "";
81
+ historyIndexRef.current = -1;
82
+ }
83
+
84
+ /**
85
+ * Handles the Tab key press to auto-fill the input with the placeholder.
86
+ * @param e - The keyboard event.
87
+ */
88
+ export function handleTabKey(e: KeyboardEvent<HTMLInputElement>): void {
89
+ const inputEl = e.currentTarget;
90
+ if (inputEl.value) return;
91
+ e.preventDefault();
92
+ inputEl.value = inputEl.placeholder;
93
+ }
@@ -0,0 +1,21 @@
1
+ import styled from "@emotion/styled";
2
+ import { RoundedPaper } from "../../../../../components/common/Paper/components/RoundedPaper/roundedPaper";
3
+ import { Box } from "@mui/material";
4
+
5
+ export const StyledBox = styled(Box)`
6
+ padding: 16px;
7
+ `;
8
+
9
+ export const StyledPaper = styled(RoundedPaper)`
10
+ display: flex;
11
+ flex-direction: column;
12
+
13
+ .MuiInputBase-root {
14
+ padding: 16px;
15
+ }
16
+
17
+ .MuiStack-root {
18
+ justify-content: flex-end;
19
+ padding: 8px;
20
+ }
21
+ `;
@@ -0,0 +1,37 @@
1
+ import { IconButton, InputBase, Stack } from "@mui/material";
2
+ import { JSX } from "react";
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 { InputProps } from "./types";
10
+ import { useKeyShortCuts } from "./hooks/UseKeyShortCuts/hook";
11
+
12
+ /**
13
+ * Renders an input component for the research panel.
14
+ * @param props - Component props.
15
+ * @param props.disabled - Disabled state of the input, which is derived from the loading state of the query.
16
+ * @returns Research panel input component.
17
+ */
18
+ export const Input = ({ disabled, ...props }: InputProps): JSX.Element => {
19
+ const { onKeyDown } = useKeyShortCuts();
20
+ return (
21
+ <StyledBox>
22
+ <StyledPaper elevation={0}>
23
+ <InputBase {...INPUT_BASE_PROPS} onKeyDown={onKeyDown} {...props} />
24
+ <Stack direction={STACK_PROPS.DIRECTION.ROW} gap={2}>
25
+ <IconButton
26
+ color={ICON_BUTTON_PROPS.COLOR.SECONDARY}
27
+ disabled={disabled}
28
+ size={ICON_BUTTON_PROPS.SIZE.XSMALL}
29
+ type="submit"
30
+ >
31
+ <UpArrowIcon fontSize={SVG_ICON_PROPS.FONT_SIZE.SMALL} />
32
+ </IconButton>
33
+ </Stack>
34
+ </StyledPaper>
35
+ </StyledBox>
36
+ );
37
+ };
@@ -0,0 +1,21 @@
1
+ import { type Meta, type StoryObj } from "@storybook/nextjs-vite";
2
+ import { Input } from "../input";
3
+ import { Box } from "@mui/material";
4
+ import { JSX } from "react";
5
+
6
+ const meta: Meta<typeof Input> = {
7
+ component: Input,
8
+ decorators: [
9
+ (Story): JSX.Element => (
10
+ <Box sx={{ width: "412px" }}>
11
+ <Story />
12
+ </Box>
13
+ ),
14
+ ],
15
+ };
16
+
17
+ export default meta;
18
+
19
+ type Story = StoryObj<typeof meta>;
20
+
21
+ export const Default: Story = {};
@@ -0,0 +1,3 @@
1
+ import { IconButtonProps, InputBaseProps } from "@mui/material";
2
+
3
+ export type InputProps = InputBaseProps & Pick<IconButtonProps, "disabled">;
@@ -0,0 +1,34 @@
1
+ import {
2
+ ChatState,
3
+ Message,
4
+ MESSAGE_TYPE,
5
+ PromptMessage,
6
+ } from "../../../state/types";
7
+
8
+ /**
9
+ * Gets the placeholder text for the input field based on the chat state.
10
+ * If there are no messages, it returns a default prompt. If there are messages,
11
+ * it looks for the last prompt message and uses its input prefill as the placeholder.
12
+ * @param state - The current state of the chat.
13
+ * @returns The placeholder text for the input field.
14
+ */
15
+ export function getPlaceholder(state: ChatState): string {
16
+ if (state.messages.length === 0) return "Ask anything";
17
+
18
+ // Reverse messages, last is the latest.
19
+ const messages = [...state.messages].reverse();
20
+
21
+ // Find the last prompt message to use its input prefill as placeholder.
22
+ const lastPrompt = messages.find(isPromptMessage);
23
+
24
+ return lastPrompt?.inputPlaceholder || "Ask anything";
25
+ }
26
+
27
+ /**
28
+ * Type guard to check if a message is a PromptMessage.
29
+ * @param message - The message to check.
30
+ * @returns True if the message is a PromptMessage, false otherwise.
31
+ */
32
+ function isPromptMessage(message: Message): message is PromptMessage {
33
+ return message.type === MESSAGE_TYPE.PROMPT;
34
+ }
@@ -0,0 +1,49 @@
1
+ import { Stack, Typography } from "@mui/material";
2
+ import { JSX } from "react";
3
+ import { AssistantMessageProps } from "./types";
4
+ import { TYPOGRAPHY_PROPS } from "../../../../../../../styles/common/mui/typography";
5
+ import { getMappings, getMentions } from "./utils";
6
+
7
+ /**
8
+ * Renders an assistant message.
9
+ * @param props - Component props.
10
+ * @param props.message - Assistant message.
11
+ * @returns The assistant message element.
12
+ */
13
+ export const AssistantMessage = ({
14
+ message,
15
+ }: AssistantMessageProps): JSX.Element => {
16
+ const mentions = getMentions(message);
17
+ const mappings = getMappings(message);
18
+ return (
19
+ <Stack gap={2} useFlexGap>
20
+ {message.response.message && (
21
+ <Typography variant={TYPOGRAPHY_PROPS.VARIANT.BODY_400}>
22
+ {message.response.message}
23
+ </Typography>
24
+ )}
25
+ {mentions && (
26
+ <Typography variant={TYPOGRAPHY_PROPS.VARIANT.BODY_SMALL_400}>
27
+ <Typography
28
+ color={TYPOGRAPHY_PROPS.COLOR.INK_LIGHT}
29
+ variant={TYPOGRAPHY_PROPS.VARIANT.BODY_SMALL_500}
30
+ >
31
+ Extracted mentions:
32
+ </Typography>{" "}
33
+ {mentions}
34
+ </Typography>
35
+ )}
36
+ {mappings && (
37
+ <Typography variant={TYPOGRAPHY_PROPS.VARIANT.BODY_SMALL_400}>
38
+ <Typography
39
+ color={TYPOGRAPHY_PROPS.COLOR.INK_LIGHT}
40
+ variant={TYPOGRAPHY_PROPS.VARIANT.BODY_SMALL_500}
41
+ >
42
+ Extracted mappings:
43
+ </Typography>{" "}
44
+ {mappings}
45
+ </Typography>
46
+ )}
47
+ </Stack>
48
+ );
49
+ };
@@ -0,0 +1,5 @@
1
+ import { AssistantMessage } from "../../../../../state/types";
2
+
3
+ export interface AssistantMessageProps {
4
+ message: AssistantMessage;
5
+ }
@@ -0,0 +1,31 @@
1
+ import { AssistantMessage } from "../../../../../state/types";
2
+
3
+ /**
4
+ * Formats mention mappings from an assistant message as a readable string.
5
+ * @param message - Assistant message containing response mentions.
6
+ * @returns Formatted facet-value mappings separated by slashes, or empty string if no mentions.
7
+ */
8
+ export function getMappings(message: AssistantMessage): string {
9
+ const mappings = message.response.query.mentions.reduce<
10
+ Record<string, string[]>
11
+ >((acc, m) => {
12
+ const key = m.exclude ? `${m.facet} (exclude)` : m.facet;
13
+ acc[key] = [...(acc[key] || []), ...m.values];
14
+ return acc;
15
+ }, {});
16
+
17
+ return Object.entries(mappings)
18
+ .map(([facet, values]) => `${facet}: ${values.join(", ")}`)
19
+ .join(" / ");
20
+ }
21
+
22
+ /**
23
+ * Extracts original mention text from an assistant message.
24
+ * @param message - Assistant message containing response mentions.
25
+ * @returns Comma-separated original mention text, or empty string if no mentions.
26
+ */
27
+ export function getMentions(message: AssistantMessage): string {
28
+ return message.response.query.mentions
29
+ .map((mention) => mention.originalText)
30
+ .join(", ");
31
+ }
@@ -0,0 +1,21 @@
1
+ import { Typography } from "@mui/material";
2
+ import { JSX } from "react";
3
+ import { ErrorMessageProps } from "./types";
4
+ import { TYPOGRAPHY_PROPS } from "../../../../../../../styles/common/mui/typography";
5
+
6
+ /**
7
+ * Renders an error message.
8
+ * @param props - Component props.
9
+ * @param props.message - Error message.
10
+ * @returns The error message element.
11
+ */
12
+ export const ErrorMessage = ({ message }: ErrorMessageProps): JSX.Element => {
13
+ return (
14
+ <Typography
15
+ color={TYPOGRAPHY_PROPS.COLOR.ERROR}
16
+ variant={TYPOGRAPHY_PROPS.VARIANT.BODY_400}
17
+ >
18
+ {message.error}
19
+ </Typography>
20
+ );
21
+ };
@@ -0,0 +1,5 @@
1
+ import { ErrorMessage } from "../../../../../state/types";
2
+
3
+ export interface ErrorMessageProps {
4
+ message: ErrorMessage;
5
+ }
@@ -0,0 +1,27 @@
1
+ import { Stack } from "@mui/material";
2
+ import styled from "@emotion/styled";
3
+ import { PALETTE } from "../../../../../../../../../styles/common/constants/palette";
4
+
5
+ export const StyledStack = styled(Stack)`
6
+ align-items: flex-start;
7
+
8
+ .MuiChip-root {
9
+ background-color: ${PALETTE.COMMON_WHITE};
10
+ border-color: ${PALETTE.SMOKE_MAIN};
11
+ color: ${PALETTE.INK_MAIN};
12
+ height: unset;
13
+ padding: 8px 12px;
14
+
15
+ &.MuiChip-clickable:hover {
16
+ background-color: transparent;
17
+ }
18
+
19
+ &:active {
20
+ box-shadow: none;
21
+ }
22
+
23
+ .MuiChip-label {
24
+ padding: 0;
25
+ }
26
+ }
27
+ `;
@@ -0,0 +1,31 @@
1
+ import { JSX } from "react";
2
+ import { ChipsProps } from "./types";
3
+ import { Chip } from "@mui/material";
4
+ import { CHIP_PROPS } from "../../../../../../../../../styles/common/mui/chip";
5
+ import { StyledStack } from "./chips.styles";
6
+
7
+ export const Chips = ({
8
+ className,
9
+ message,
10
+ }: ChipsProps): JSX.Element | null => {
11
+ const suggestions = message.suggestions;
12
+
13
+ if (!suggestions || suggestions.length === 0) return null;
14
+
15
+ return (
16
+ <StyledStack className={className} gap={2} useFlexGap>
17
+ {suggestions.map((suggestion) => (
18
+ <Chip
19
+ key={`${suggestion.label}-${suggestion.query}`}
20
+ clickable
21
+ color={CHIP_PROPS.COLOR.SECONDARY}
22
+ component="button"
23
+ data-query={suggestion.query}
24
+ label={suggestion.label}
25
+ type="submit"
26
+ variant={CHIP_PROPS.VARIANT.OUTLINED}
27
+ />
28
+ ))}
29
+ </StyledStack>
30
+ );
31
+ };
@@ -0,0 +1,6 @@
1
+ import { BaseComponentProps } from "../../../../../../../../../components/types";
2
+ import { PromptMessage } from "../../../../../../../state/types";
3
+
4
+ export interface ChipsProps extends BaseComponentProps {
5
+ message: PromptMessage;
6
+ }
@@ -0,0 +1,26 @@
1
+ import { Stack, Typography } from "@mui/material";
2
+ import { JSX } from "react";
3
+ import { PromptMessageProps } from "./types";
4
+ import { TYPOGRAPHY_PROPS } from "../../../../../../../styles/common/mui/typography";
5
+ import { Chips } from "./components/Chips/chips";
6
+
7
+ /**
8
+ * Renders a prompt message, and chip suggestions if present (and if it's the last message).
9
+ * @param props - Component props.
10
+ * @param props.isLast - Whether message is the last.
11
+ * @param props.message - Prompt message.
12
+ * @returns The prompt message element.
13
+ */
14
+ export const PromptMessage = ({
15
+ isLast,
16
+ message,
17
+ }: PromptMessageProps): JSX.Element => {
18
+ return (
19
+ <Stack gap={4} useFlexGap>
20
+ <Typography variant={TYPOGRAPHY_PROPS.VARIANT.BODY_400}>
21
+ {message.text}
22
+ </Typography>
23
+ {isLast && <Chips message={message} />}
24
+ </Stack>
25
+ );
26
+ };
@@ -0,0 +1,6 @@
1
+ import { PromptMessage } from "../../../../../state/types";
2
+
3
+ export interface PromptMessageProps {
4
+ isLast: boolean;
5
+ message: PromptMessage;
6
+ }
@@ -0,0 +1,5 @@
1
+ import { UserMessage } from "../../../../../state/types";
2
+
3
+ export interface UserMessageProps {
4
+ message: UserMessage;
5
+ }
@@ -0,0 +1,11 @@
1
+ import styled from "@emotion/styled";
2
+ import { RoundedPaper } from "../../../../../../../components/common/Paper/components/RoundedPaper/roundedPaper";
3
+ import { PALETTE } from "../../../../../../../styles/common/constants/palette";
4
+
5
+ export const StyledRoundedPaper = styled(RoundedPaper)`
6
+ align-self: flex-end;
7
+ background-color: ${PALETTE.SMOKE_MAIN};
8
+ max-width: 332px;
9
+ min-height: fit-content;
10
+ padding: 8px 12px;
11
+ `;