@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.
- package/.github/workflows/release-please.yml +0 -22
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +39 -0
- package/backend/main.py +0 -1
- package/lib/common/ai/config/types.d.ts +22 -0
- package/lib/common/ai/config/types.js +1 -0
- package/lib/common/ai/constants.d.ts +3 -0
- package/lib/common/ai/constants.js +3 -0
- package/lib/common/categories/config/types.d.ts +2 -1
- package/lib/common/chart/sort/constants.d.ts +5 -0
- package/lib/common/chart/sort/constants.js +9 -0
- package/lib/common/chart/sort/types.d.ts +16 -0
- package/lib/common/chart/sort/types.js +8 -0
- package/lib/common/chart/sort/utils.d.ts +7 -0
- package/lib/common/chart/sort/utils.js +19 -0
- package/lib/common/chart/types.d.ts +5 -0
- package/lib/common/chart/types.js +1 -0
- package/lib/common/entities.d.ts +2 -1
- package/lib/components/Export/components/DownloadCurlCommand/downloadCurlCommand.d.ts +0 -2
- package/lib/components/Export/components/ExportToTerra/exportToTerra.d.ts +0 -2
- package/lib/components/Export/components/ManifestDownload/components/ManifestDownloadEntity/manifestDownloadEntity.d.ts +0 -2
- package/lib/components/Export/components/ManifestDownload/manifestDownload.d.ts +0 -2
- package/lib/components/Filter/components/FilterLabel/filterLabel.js +1 -1
- package/lib/components/Filter/components/FilterLabel/filterLabel.stories.d.ts +3 -0
- package/lib/components/Filter/components/FilterLabel/filterLabel.stories.js +5 -0
- package/lib/components/Filter/components/Filters/stories/constants.js +21 -1
- package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.styles.js +2 -0
- package/lib/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/utils.js +1 -1
- package/lib/components/Index/components/EntityView/components/views/ChartView/chartView.js +2 -1
- package/lib/components/Index/components/EntityView/components/views/ChartView/components/Chart/hooks/UsePlotOptions/hook.js +2 -7
- package/lib/components/Index/components/EntityView/components/views/ChartView/components/Chart/stories/args.js +12 -12
- package/lib/components/Index/components/EntityView/components/views/ChartView/stories/args.js +3 -3
- package/lib/components/Index/components/EntityView/components/views/ChartView/utils.js +1 -1
- package/lib/components/Layout/components/Sidebar/components/SidebarTools/sidebarTools.styles.d.ts +4 -0
- package/lib/components/Layout/components/Sidebar/components/SidebarTools/sidebarTools.styles.js +4 -0
- package/lib/components/common/Chip/components/Beta/beta.d.ts +10 -0
- package/lib/components/common/Chip/components/Beta/beta.js +12 -0
- package/lib/components/common/Chip/components/Beta/beta.styles.d.ts +3 -0
- package/lib/components/common/Chip/components/Beta/beta.styles.js +14 -0
- package/lib/components/common/Chip/components/Beta/stories/beta.stories.d.ts +6 -0
- package/lib/components/common/Chip/components/Beta/stories/beta.stories.js +6 -0
- package/lib/components/common/CustomIcon/components/UpArrowIcon/upArrowIcon.d.ts +6 -0
- package/lib/components/common/CustomIcon/components/UpArrowIcon/upArrowIcon.js +8 -0
- package/lib/components/common/Tabs/tabs.js +1 -1
- package/lib/components/common/ToggleButtonGroup/provider/context.d.ts +2 -0
- package/lib/components/common/ToggleButtonGroup/provider/context.js +5 -0
- package/lib/components/common/ToggleButtonGroup/provider/hook.d.ts +7 -0
- package/lib/components/common/ToggleButtonGroup/provider/hook.js +9 -0
- package/lib/components/common/ToggleButtonGroup/provider/provider.d.ts +12 -0
- package/lib/components/common/ToggleButtonGroup/provider/provider.js +22 -0
- package/lib/components/common/ToggleButtonGroup/provider/types.d.ts +9 -0
- package/lib/components/common/ToggleButtonGroup/provider/types.js +1 -0
- package/lib/config/entities.d.ts +2 -0
- package/lib/hooks/ai/useAiRoutes/hook.d.ts +6 -0
- package/lib/hooks/ai/useAiRoutes/hook.js +18 -0
- package/lib/hooks/useCategoryFilter.js +1 -1
- package/lib/hooks/useFileManifest/common/entities.d.ts +0 -9
- package/lib/hooks/useFileManifest/common/entities.js +1 -9
- package/lib/styles/common/mui/drawer.d.ts +9 -0
- package/lib/styles/common/mui/drawer.js +15 -0
- package/lib/styles/common/mui/inputBase.d.ts +13 -0
- package/lib/styles/common/mui/inputBase.js +25 -0
- package/lib/styles/common/mui/stack.d.ts +11 -0
- package/lib/styles/common/mui/stack.js +22 -0
- package/lib/tests/testIds.d.ts +3 -0
- package/lib/tests/testIds.js +3 -0
- package/lib/views/EntityDetailView/entityDetailView.js +2 -2
- package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.d.ts +7 -0
- package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.js +18 -0
- package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.styles.d.ts +6 -0
- package/lib/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.styles.js +23 -0
- package/lib/views/ExploreView/entityList/filters/filters.styles.d.ts +7 -0
- package/lib/views/ExploreView/entityList/filters/filters.styles.js +17 -0
- package/lib/views/ExploreView/exploreView.js +3 -2
- package/lib/views/ResearchView/adapter/useAdapter.d.ts +6 -0
- package/lib/views/ResearchView/adapter/useAdapter.js +15 -0
- package/lib/views/ResearchView/assistant/assistant.d.ts +6 -0
- package/lib/views/ResearchView/assistant/assistant.js +18 -0
- package/lib/views/ResearchView/assistant/components/Drawer/drawer.d.ts +9 -0
- package/lib/views/ResearchView/assistant/components/Drawer/drawer.js +15 -0
- package/lib/views/ResearchView/assistant/components/Drawer/drawer.styles.d.ts +4 -0
- package/lib/views/ResearchView/assistant/components/Drawer/drawer.styles.js +21 -0
- package/lib/views/ResearchView/assistant/components/Drawer/types.d.ts +4 -0
- package/lib/views/ResearchView/assistant/components/Drawer/types.js +1 -0
- package/lib/views/ResearchView/assistant/components/Form/constants.d.ts +3 -0
- package/lib/views/ResearchView/assistant/components/Form/constants.js +3 -0
- package/lib/views/ResearchView/assistant/components/Form/form.d.ts +12 -0
- package/lib/views/ResearchView/assistant/components/Form/form.js +40 -0
- package/lib/views/ResearchView/assistant/components/Form/form.styles.d.ts +4 -0
- package/lib/views/ResearchView/assistant/components/Form/form.styles.js +7 -0
- package/lib/views/ResearchView/assistant/components/Form/types.d.ts +4 -0
- package/lib/views/ResearchView/assistant/components/Form/types.js +1 -0
- package/lib/views/ResearchView/assistant/components/Form/utils.d.ts +16 -0
- package/lib/views/ResearchView/assistant/components/Form/utils.js +41 -0
- package/lib/views/ResearchView/assistant/components/Input/constants.d.ts +2 -0
- package/lib/views/ResearchView/assistant/components/Input/constants.js +14 -0
- package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/constants.d.ts +7 -0
- package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/constants.js +7 -0
- package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/hook.d.ts +6 -0
- package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/hook.js +32 -0
- package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/types.d.ts +8 -0
- package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/types.js +1 -0
- package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/utils.d.ts +32 -0
- package/lib/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/utils.js +74 -0
- package/lib/views/ResearchView/assistant/components/Input/input.d.ts +9 -0
- package/lib/views/ResearchView/assistant/components/Input/input.js +19 -0
- package/lib/views/ResearchView/assistant/components/Input/input.styles.d.ts +8 -0
- package/lib/views/ResearchView/assistant/components/Input/input.styles.js +19 -0
- package/lib/views/ResearchView/assistant/components/Input/stories/input.stories.d.ts +6 -0
- package/lib/views/ResearchView/assistant/components/Input/stories/input.stories.js +11 -0
- package/lib/views/ResearchView/assistant/components/Input/types.d.ts +2 -0
- package/lib/views/ResearchView/assistant/components/Input/types.js +1 -0
- package/lib/views/ResearchView/assistant/components/Input/utils.d.ts +9 -0
- package/lib/views/ResearchView/assistant/components/Input/utils.js +25 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/assistantMessage.d.ts +9 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/assistantMessage.js +15 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/types.d.ts +4 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/types.js +1 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/utils.d.ts +13 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/utils.js +25 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/errorMessage.d.ts +9 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/errorMessage.js +12 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/types.d.ts +4 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/types.js +1 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.d.ts +3 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.js +10 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.styles.d.ts +3 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.styles.js +26 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/types.d.ts +5 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/types.js +1 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/promptMessage.d.ts +10 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/promptMessage.js +14 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/types.d.ts +5 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/types.js +1 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/types.d.ts +4 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/types.js +1 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/useMessage.styles.d.ts +5 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/useMessage.styles.js +10 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/userMessage.d.ts +9 -0
- package/lib/views/ResearchView/assistant/components/Messages/components/UserMessage/userMessage.js +13 -0
- package/lib/views/ResearchView/assistant/components/Messages/hooks/UseScroll/hook.d.ts +7 -0
- package/lib/views/ResearchView/assistant/components/Messages/hooks/UseScroll/hook.js +17 -0
- package/lib/views/ResearchView/assistant/components/Messages/messages.d.ts +9 -0
- package/lib/views/ResearchView/assistant/components/Messages/messages.js +16 -0
- package/lib/views/ResearchView/assistant/components/Messages/messages.styles.d.ts +3 -0
- package/lib/views/ResearchView/assistant/components/Messages/messages.styles.js +9 -0
- package/lib/views/ResearchView/assistant/components/Messages/selector/messageSelector.d.ts +17 -0
- package/lib/views/ResearchView/assistant/components/Messages/selector/messageSelector.js +32 -0
- package/lib/views/ResearchView/assistant/components/Messages/selector/types.d.ts +5 -0
- package/lib/views/ResearchView/assistant/components/Messages/selector/types.js +1 -0
- package/lib/views/ResearchView/assistant/components/Messages/stories/args.d.ts +3 -0
- package/lib/views/ResearchView/assistant/components/Messages/stories/args.js +109 -0
- package/lib/views/ResearchView/assistant/components/Messages/stories/messages.stories.d.ts +6 -0
- package/lib/views/ResearchView/assistant/components/Messages/stories/messages.stories.js +14 -0
- package/lib/views/ResearchView/assistant/components/Messages/types.d.ts +4 -0
- package/lib/views/ResearchView/assistant/components/Messages/types.js +1 -0
- package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/stories/toggleButtonGroup.stories.d.ts +6 -0
- package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/stories/toggleButtonGroup.stories.js +12 -0
- package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.d.ts +7 -0
- package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.js +17 -0
- package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.styles.d.ts +6 -0
- package/lib/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.styles.js +20 -0
- package/lib/views/ResearchView/assistant/stories/args.d.ts +4 -0
- package/lib/views/ResearchView/assistant/stories/args.js +30 -0
- package/lib/views/ResearchView/assistant/stories/assistant.stories.d.ts +6 -0
- package/lib/views/ResearchView/assistant/stories/assistant.stories.js +23 -0
- package/lib/views/ResearchView/query/constants.d.ts +5 -0
- package/lib/views/ResearchView/query/constants.js +5 -0
- package/lib/views/ResearchView/query/fetch.d.ts +17 -0
- package/lib/views/ResearchView/query/fetch.js +44 -0
- package/lib/views/ResearchView/query/types.d.ts +31 -0
- package/lib/views/ResearchView/query/types.js +1 -0
- package/lib/views/ResearchView/query/useQuery.d.ts +7 -0
- package/lib/views/ResearchView/query/useQuery.js +44 -0
- package/lib/views/ResearchView/researchView.d.ts +10 -0
- package/lib/views/ResearchView/researchView.js +13 -0
- package/lib/views/ResearchView/state/actions/setError/action.d.ts +10 -0
- package/lib/views/ResearchView/state/actions/setError/action.js +17 -0
- package/lib/views/ResearchView/state/actions/setError/dispatch.d.ts +7 -0
- package/lib/views/ResearchView/state/actions/setError/dispatch.js +12 -0
- package/lib/views/ResearchView/state/actions/setError/types.d.ts +14 -0
- package/lib/views/ResearchView/state/actions/setError/types.js +1 -0
- package/lib/views/ResearchView/state/actions/setMessage/action.d.ts +10 -0
- package/lib/views/ResearchView/state/actions/setMessage/action.js +21 -0
- package/lib/views/ResearchView/state/actions/setMessage/dispatch.d.ts +7 -0
- package/lib/views/ResearchView/state/actions/setMessage/dispatch.js +12 -0
- package/lib/views/ResearchView/state/actions/setMessage/types.d.ts +15 -0
- package/lib/views/ResearchView/state/actions/setMessage/types.js +1 -0
- package/lib/views/ResearchView/state/actions/setQuery/action.d.ts +10 -0
- package/lib/views/ResearchView/state/actions/setQuery/action.js +17 -0
- package/lib/views/ResearchView/state/actions/setQuery/dispatch.d.ts +7 -0
- package/lib/views/ResearchView/state/actions/setQuery/dispatch.js +12 -0
- package/lib/views/ResearchView/state/actions/setQuery/types.d.ts +14 -0
- package/lib/views/ResearchView/state/actions/setQuery/types.js +1 -0
- package/lib/views/ResearchView/state/actions/setStatus/action.d.ts +10 -0
- package/lib/views/ResearchView/state/actions/setStatus/action.js +13 -0
- package/lib/views/ResearchView/state/actions/setStatus/dispatch.d.ts +7 -0
- package/lib/views/ResearchView/state/actions/setStatus/dispatch.js +12 -0
- package/lib/views/ResearchView/state/actions/setStatus/types.d.ts +14 -0
- package/lib/views/ResearchView/state/actions/setStatus/types.js +1 -0
- package/lib/views/ResearchView/state/actions/types.d.ts +17 -0
- package/lib/views/ResearchView/state/actions/types.js +10 -0
- package/lib/views/ResearchView/state/constants.d.ts +5 -0
- package/lib/views/ResearchView/state/constants.js +7 -0
- package/lib/views/ResearchView/state/context.d.ts +5 -0
- package/lib/views/ResearchView/state/context.js +9 -0
- package/lib/views/ResearchView/state/guards/guards.d.ts +33 -0
- package/lib/views/ResearchView/state/guards/guards.js +41 -0
- package/lib/views/ResearchView/state/hooks/UseChatDispatch/hook.d.ts +6 -0
- package/lib/views/ResearchView/state/hooks/UseChatDispatch/hook.js +26 -0
- package/lib/views/ResearchView/state/hooks/UseChatDispatch/types.d.ts +10 -0
- package/lib/views/ResearchView/state/hooks/UseChatDispatch/types.js +1 -0
- package/lib/views/ResearchView/state/hooks/UseChatReducer/hook.d.ts +8 -0
- package/lib/views/ResearchView/state/hooks/UseChatReducer/hook.js +12 -0
- package/lib/views/ResearchView/state/hooks/UseChatState/hook.d.ts +7 -0
- package/lib/views/ResearchView/state/hooks/UseChatState/hook.js +11 -0
- package/lib/views/ResearchView/state/initializer/initializer.d.ts +8 -0
- package/lib/views/ResearchView/state/initializer/initializer.js +22 -0
- package/lib/views/ResearchView/state/initializer/types.d.ts +2 -0
- package/lib/views/ResearchView/state/initializer/types.js +1 -0
- package/lib/views/ResearchView/state/provider.d.ts +16 -0
- package/lib/views/ResearchView/state/provider.js +17 -0
- package/lib/views/ResearchView/state/reducer.d.ts +10 -0
- package/lib/views/ResearchView/state/reducer.js +32 -0
- package/lib/views/ResearchView/state/types.d.ts +125 -0
- package/lib/views/ResearchView/state/types.js +22 -0
- package/package.json +1 -1
- package/src/common/ai/config/types.ts +25 -0
- package/src/common/ai/constants.ts +3 -0
- package/src/common/categories/config/types.ts +2 -1
- package/src/common/chart/sort/constants.ts +13 -0
- package/src/common/chart/sort/types.ts +22 -0
- package/src/common/chart/sort/utils.ts +22 -0
- package/src/common/chart/types.ts +6 -0
- package/src/common/entities.ts +2 -1
- package/src/components/Export/components/DownloadCurlCommand/downloadCurlCommand.tsx +0 -2
- package/src/components/Export/components/ExportToTerra/exportToTerra.tsx +0 -2
- package/src/components/Export/components/ManifestDownload/components/ManifestDownloadEntity/manifestDownloadEntity.tsx +0 -2
- package/src/components/Export/components/ManifestDownload/manifestDownload.tsx +0 -2
- package/src/components/Filter/components/FilterLabel/filterLabel.stories.tsx +6 -0
- package/src/components/Filter/components/FilterLabel/filterLabel.tsx +6 -1
- package/src/components/Filter/components/Filters/stories/constants.ts +25 -1
- package/src/components/Filter/components/SearchAllFilters/searchAllFilters.styles.ts +2 -0
- package/src/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/utils.ts +1 -1
- package/src/components/Index/components/EntityView/components/views/ChartView/chartView.tsx +8 -2
- package/src/components/Index/components/EntityView/components/views/ChartView/components/Chart/hooks/UsePlotOptions/hook.ts +2 -7
- package/src/components/Index/components/EntityView/components/views/ChartView/components/Chart/stories/args.ts +12 -12
- package/src/components/Index/components/EntityView/components/views/ChartView/stories/args.ts +3 -3
- package/src/components/Index/components/EntityView/components/views/ChartView/utils.ts +1 -1
- package/src/components/Layout/components/Sidebar/components/SidebarTools/sidebarTools.styles.ts +4 -0
- package/src/components/common/Chip/components/Beta/beta.styles.ts +15 -0
- package/src/components/common/Chip/components/Beta/beta.tsx +25 -0
- package/src/components/common/Chip/components/Beta/stories/beta.stories.tsx +12 -0
- package/src/components/common/CustomIcon/components/UpArrowIcon/upArrowIcon.tsx +21 -0
- package/src/components/common/Tabs/tabs.tsx +5 -1
- package/src/components/common/ToggleButtonGroup/provider/context.ts +9 -0
- package/src/components/common/ToggleButtonGroup/provider/hook.ts +16 -0
- package/src/components/common/ToggleButtonGroup/provider/provider.tsx +37 -0
- package/src/components/common/ToggleButtonGroup/provider/types.ts +17 -0
- package/src/config/entities.ts +2 -0
- package/src/hooks/ai/useAiRoutes/hook.ts +22 -0
- package/src/hooks/useCategoryFilter.ts +1 -1
- package/src/hooks/useFileManifest/common/entities.ts +0 -11
- package/src/styles/common/mui/drawer.ts +24 -0
- package/src/styles/common/mui/inputBase.ts +38 -0
- package/src/styles/common/mui/stack.ts +33 -0
- package/src/tests/testIds.ts +3 -0
- package/src/views/EntityDetailView/entityDetailView.tsx +1 -3
- package/src/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.styles.ts +25 -0
- package/src/views/ExploreView/entityList/filters/components/ToggleButtonGroup/toggleButtonGroup.tsx +31 -0
- package/src/views/ExploreView/entityList/filters/filters.styles.ts +19 -0
- package/src/views/ExploreView/exploreView.tsx +16 -12
- package/src/views/ResearchView/adapter/useAdapter.ts +19 -0
- package/src/views/ResearchView/assistant/assistant.tsx +30 -0
- package/src/views/ResearchView/assistant/components/Drawer/drawer.styles.ts +24 -0
- package/src/views/ResearchView/assistant/components/Drawer/drawer.tsx +26 -0
- package/src/views/ResearchView/assistant/components/Drawer/types.ts +5 -0
- package/src/views/ResearchView/assistant/components/Form/constants.ts +3 -0
- package/src/views/ResearchView/assistant/components/Form/form.styles.ts +8 -0
- package/src/views/ResearchView/assistant/components/Form/form.tsx +55 -0
- package/src/views/ResearchView/assistant/components/Form/types.ts +11 -0
- package/src/views/ResearchView/assistant/components/Form/utils.ts +51 -0
- package/src/views/ResearchView/assistant/components/Input/constants.ts +16 -0
- package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/constants.ts +7 -0
- package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/hook.ts +45 -0
- package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/types.ts +10 -0
- package/src/views/ResearchView/assistant/components/Input/hooks/UseKeyShortCuts/utils.ts +93 -0
- package/src/views/ResearchView/assistant/components/Input/input.styles.ts +21 -0
- package/src/views/ResearchView/assistant/components/Input/input.tsx +37 -0
- package/src/views/ResearchView/assistant/components/Input/stories/input.stories.tsx +21 -0
- package/src/views/ResearchView/assistant/components/Input/types.ts +3 -0
- package/src/views/ResearchView/assistant/components/Input/utils.ts +34 -0
- package/src/views/ResearchView/assistant/components/Messages/components/AssistantMessage/assistantMessage.tsx +49 -0
- package/src/views/ResearchView/assistant/components/Messages/components/AssistantMessage/types.ts +5 -0
- package/src/views/ResearchView/assistant/components/Messages/components/AssistantMessage/utils.ts +31 -0
- package/src/views/ResearchView/assistant/components/Messages/components/ErrorMessage/errorMessage.tsx +21 -0
- package/src/views/ResearchView/assistant/components/Messages/components/ErrorMessage/types.ts +5 -0
- package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.styles.ts +27 -0
- package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/chips.tsx +31 -0
- package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/components/Chips/types.ts +6 -0
- package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/promptMessage.tsx +26 -0
- package/src/views/ResearchView/assistant/components/Messages/components/PromptMessage/types.ts +6 -0
- package/src/views/ResearchView/assistant/components/Messages/components/UserMessage/types.ts +5 -0
- package/src/views/ResearchView/assistant/components/Messages/components/UserMessage/useMessage.styles.ts +11 -0
- package/src/views/ResearchView/assistant/components/Messages/components/UserMessage/userMessage.tsx +21 -0
- package/src/views/ResearchView/assistant/components/Messages/hooks/UseScroll/hook.ts +22 -0
- package/src/views/ResearchView/assistant/components/Messages/messages.styles.ts +10 -0
- package/src/views/ResearchView/assistant/components/Messages/messages.tsx +29 -0
- package/src/views/ResearchView/assistant/components/Messages/selector/messageSelector.tsx +37 -0
- package/src/views/ResearchView/assistant/components/Messages/selector/types.ts +6 -0
- package/src/views/ResearchView/assistant/components/Messages/stories/args.ts +115 -0
- package/src/views/ResearchView/assistant/components/Messages/stories/messages.stories.tsx +24 -0
- package/src/views/ResearchView/assistant/components/Messages/types.ts +5 -0
- package/src/views/ResearchView/assistant/components/ToggleButtonGroup/stories/toggleButtonGroup.stories.tsx +22 -0
- package/src/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.styles.ts +22 -0
- package/src/views/ResearchView/assistant/components/ToggleButtonGroup/toggleButtonGroup.tsx +30 -0
- package/src/views/ResearchView/assistant/stories/args.ts +36 -0
- package/src/views/ResearchView/assistant/stories/assistant.stories.tsx +39 -0
- package/src/views/ResearchView/query/constants.ts +5 -0
- package/src/views/ResearchView/query/fetch.ts +58 -0
- package/src/views/ResearchView/query/types.ts +37 -0
- package/src/views/ResearchView/query/useQuery.ts +60 -0
- package/src/views/ResearchView/researchView.tsx +19 -0
- package/src/views/ResearchView/state/actions/setError/action.ts +22 -0
- package/src/views/ResearchView/state/actions/setError/dispatch.ts +14 -0
- package/src/views/ResearchView/state/actions/setError/types.ts +16 -0
- package/src/views/ResearchView/state/actions/setMessage/action.ts +26 -0
- package/src/views/ResearchView/state/actions/setMessage/dispatch.ts +14 -0
- package/src/views/ResearchView/state/actions/setMessage/types.ts +19 -0
- package/src/views/ResearchView/state/actions/setQuery/action.ts +22 -0
- package/src/views/ResearchView/state/actions/setQuery/dispatch.ts +14 -0
- package/src/views/ResearchView/state/actions/setQuery/types.ts +16 -0
- package/src/views/ResearchView/state/actions/setStatus/action.ts +19 -0
- package/src/views/ResearchView/state/actions/setStatus/dispatch.ts +14 -0
- package/src/views/ResearchView/state/actions/setStatus/types.ts +16 -0
- package/src/views/ResearchView/state/actions/types.ts +23 -0
- package/src/views/ResearchView/state/constants.ts +9 -0
- package/src/views/ResearchView/state/context.ts +11 -0
- package/src/views/ResearchView/state/guards/guards.ts +58 -0
- package/src/views/ResearchView/state/hooks/UseChatDispatch/hook.ts +46 -0
- package/src/views/ResearchView/state/hooks/UseChatDispatch/types.ts +11 -0
- package/src/views/ResearchView/state/hooks/UseChatReducer/hook.ts +15 -0
- package/src/views/ResearchView/state/hooks/UseChatState/hook.ts +14 -0
- package/src/views/ResearchView/state/initializer/initializer.ts +23 -0
- package/src/views/ResearchView/state/initializer/types.ts +3 -0
- package/src/views/ResearchView/state/provider.tsx +27 -0
- package/src/views/ResearchView/state/reducer.ts +34 -0
- package/src/views/ResearchView/state/types.ts +149 -0
- package/tests/chartSortUtils.test.ts +119 -0
- package/tests/research.assistantMessageUtils.test.ts +149 -0
- package/tests/research.chatState.test.ts +463 -0
- package/tests/research.fetchResponse.test.ts +164 -0
- package/tests/research.useKeyShortCuts.test.ts +254 -0
- package/tests/research.useQuery.test.ts +165 -0
- package/tests/toggleButtonGroupProvider.test.tsx +125 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { UseQuery } from "../../../query/types";
|
|
2
|
+
import { BaseComponentProps, ChildrenProps } from "../../../../../components/types";
|
|
3
|
+
import { ChatState } from "../../../state/types";
|
|
4
|
+
export type FormProps = BaseComponentProps & ChildrenProps & Pick<UseQuery, "actions"> & Pick<ChatState, "status">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FormEvent } from "react";
|
|
2
|
+
import { OnSubmitPayload } from "../../../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,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,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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
};
|
package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/utils.d.ts
ADDED
|
@@ -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;
|
package/lib/views/ResearchView/assistant/components/Messages/components/AssistantMessage/utils.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats mention mappings from an assistant message as a readable string.
|
|
3
|
+
* @param message - Assistant message containing response mentions.
|
|
4
|
+
* @returns Formatted facet-value mappings separated by slashes, or empty string if no mentions.
|
|
5
|
+
*/
|
|
6
|
+
export function getMappings(message) {
|
|
7
|
+
const mappings = message.response.query.mentions.reduce((acc, m) => {
|
|
8
|
+
const key = m.exclude ? `${m.facet} (exclude)` : m.facet;
|
|
9
|
+
acc[key] = [...(acc[key] || []), ...m.values];
|
|
10
|
+
return acc;
|
|
11
|
+
}, {});
|
|
12
|
+
return Object.entries(mappings)
|
|
13
|
+
.map(([facet, values]) => `${facet}: ${values.join(", ")}`)
|
|
14
|
+
.join(" / ");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Extracts original mention text from an assistant message.
|
|
18
|
+
* @param message - Assistant message containing response mentions.
|
|
19
|
+
* @returns Comma-separated original mention text, or empty string if no mentions.
|
|
20
|
+
*/
|
|
21
|
+
export function getMentions(message) {
|
|
22
|
+
return message.response.query.mentions
|
|
23
|
+
.map((mention) => mention.originalText)
|
|
24
|
+
.join(", ");
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { JSX } from "react";
|
|
2
|
+
import { ErrorMessageProps } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Renders an error message.
|
|
5
|
+
* @param props - Component props.
|
|
6
|
+
* @param props.message - Error message.
|
|
7
|
+
* @returns The error message element.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ErrorMessage: ({ message }: ErrorMessageProps) => JSX.Element;
|
package/lib/views/ResearchView/assistant/components/Messages/components/ErrorMessage/errorMessage.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Typography } from "@mui/material";
|
|
3
|
+
import { TYPOGRAPHY_PROPS } from "../../../../../../../styles/common/mui/typography";
|
|
4
|
+
/**
|
|
5
|
+
* Renders an error message.
|
|
6
|
+
* @param props - Component props.
|
|
7
|
+
* @param props.message - Error message.
|
|
8
|
+
* @returns The error message element.
|
|
9
|
+
*/
|
|
10
|
+
export const ErrorMessage = ({ message }) => {
|
|
11
|
+
return (_jsx(Typography, { color: TYPOGRAPHY_PROPS.COLOR.ERROR, variant: TYPOGRAPHY_PROPS.VARIANT.BODY_400, children: message.error }));
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Chip } from "@mui/material";
|
|
3
|
+
import { CHIP_PROPS } from "../../../../../../../../../styles/common/mui/chip";
|
|
4
|
+
import { StyledStack } from "./chips.styles";
|
|
5
|
+
export const Chips = ({ className, message, }) => {
|
|
6
|
+
const suggestions = message.suggestions;
|
|
7
|
+
if (!suggestions || suggestions.length === 0)
|
|
8
|
+
return null;
|
|
9
|
+
return (_jsx(StyledStack, { className: className, gap: 2, useFlexGap: true, children: suggestions.map((suggestion) => (_jsx(Chip, { clickable: true, color: CHIP_PROPS.COLOR.SECONDARY, component: "button", "data-query": suggestion.query, label: suggestion.label, type: "submit", variant: CHIP_PROPS.VARIANT.OUTLINED }, `${suggestion.label}-${suggestion.query}`))) }));
|
|
10
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const StyledStack: import("@emotion/styled").StyledComponent<import("@mui/material").StackOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/material").StackOwnProps> & {
|
|
2
|
+
theme?: import("@emotion/react").Theme;
|
|
3
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Stack } from "@mui/material";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { PALETTE } from "../../../../../../../../../styles/common/constants/palette";
|
|
4
|
+
export const StyledStack = styled(Stack) `
|
|
5
|
+
align-items: flex-start;
|
|
6
|
+
|
|
7
|
+
.MuiChip-root {
|
|
8
|
+
background-color: ${PALETTE.COMMON_WHITE};
|
|
9
|
+
border-color: ${PALETTE.SMOKE_MAIN};
|
|
10
|
+
color: ${PALETTE.INK_MAIN};
|
|
11
|
+
height: unset;
|
|
12
|
+
padding: 8px 12px;
|
|
13
|
+
|
|
14
|
+
&.MuiChip-clickable:hover {
|
|
15
|
+
background-color: transparent;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:active {
|
|
19
|
+
box-shadow: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.MuiChip-label {
|
|
23
|
+
padding: 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSX } from "react";
|
|
2
|
+
import { PromptMessageProps } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Renders a prompt message, and chip suggestions if present (and if it's the last message).
|
|
5
|
+
* @param props - Component props.
|
|
6
|
+
* @param props.isLast - Whether message is the last.
|
|
7
|
+
* @param props.message - Prompt message.
|
|
8
|
+
* @returns The prompt message element.
|
|
9
|
+
*/
|
|
10
|
+
export declare const PromptMessage: ({ isLast, message, }: PromptMessageProps) => JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { Chips } from "./components/Chips/chips";
|
|
5
|
+
/**
|
|
6
|
+
* Renders a prompt message, and chip suggestions if present (and if it's the last message).
|
|
7
|
+
* @param props - Component props.
|
|
8
|
+
* @param props.isLast - Whether message is the last.
|
|
9
|
+
* @param props.message - Prompt message.
|
|
10
|
+
* @returns The prompt message element.
|
|
11
|
+
*/
|
|
12
|
+
export const PromptMessage = ({ isLast, message, }) => {
|
|
13
|
+
return (_jsxs(Stack, { gap: 4, useFlexGap: true, children: [_jsx(Typography, { variant: TYPOGRAPHY_PROPS.VARIANT.BODY_400, children: message.text }), isLast && _jsx(Chips, { message: message })] }));
|
|
14
|
+
};
|
package/lib/views/ResearchView/assistant/components/Messages/components/PromptMessage/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const StyledRoundedPaper: 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"> & {
|
|
2
|
+
component?: React.ElementType;
|
|
3
|
+
} & {
|
|
4
|
+
theme?: import("@emotion/react").Theme;
|
|
5
|
+
}, {}, {}>;
|