import type { ChangeEvent } from 'react'; import { BsHexagon, BsHexagonFill } from 'react-icons/bs'; import { FaICursor, FaRegTrashAlt } from 'react-icons/fa'; import { IoSearchOutline } from 'react-icons/io5'; import { TbBinaryTree } from 'react-icons/tb'; import type { ToolbarItemProps } from 'react-science/ui'; import { PanelHeader, Toolbar } from 'react-science/ui'; import { useChartData } from '../../context/ChartContext.js'; import { useDispatch } from '../../context/DispatchContext.js'; import Input from '../../elements/Input.js'; import Select from '../../elements/Select.js'; import { ToolbarButton } from '../../elements/toolbar_button.tsx'; import useToolsFunctions from '../../hooks/useToolsFunctions.js'; import { options } from '../../toolbar/ToolTypes.js'; import type { DatabaseSearchKeywords, DatabaseSearchResultEntry, Databases, } from './DatabasePanel.js'; interface DatabaseSearchOptionsProps { databases: Databases; defaultDatabase: string; keywords: DatabaseSearchKeywords; result: DatabaseSearchResultEntry; idCode?: string; total: number; availableNuclei: string[]; selectedNucleus?: string; onKeywordsChange: (k: Partial) => void; onSettingClick: () => void; onStructureClick: ToolbarItemProps['onClick']; onDatabaseChange: (databaseKey: string) => void; onNucleiChange: (nucleus: string) => void; onRemoveAll: () => void; } export function DatabaseSearchOptions(props: DatabaseSearchOptionsProps) { const { databases, defaultDatabase, keywords, result, idCode, total, availableNuclei, selectedNucleus, onKeywordsChange, onSettingClick, onStructureClick, onDatabaseChange, onNucleiChange, onRemoveAll, } = props; const { handleChangeOption } = useToolsFunctions(); const { view: { spectra: { showSimilarityTree, activeTab }, }, toolOptions: { selectedTool }, } = useChartData(); const dispatch = useDispatch(); function enableFilterHandler() { const tool = selectedTool === options.databaseRangesSelection.id ? options.zoom.id : options.databaseRangesSelection.id; handleChangeOption(tool); } function handleSolventChange(value: string | number) { onKeywordsChange({ solvent: String(value) }); } function handleKeywordsInputChange(event: ChangeEvent) { onKeywordsChange({ searchKeywords: event.target.value }); } function clearHandler() { onKeywordsChange({ searchKeywords: '' }); } function handleShowSimilarityTree() { dispatch({ type: 'TOGGLE_SIMILARITY_TREE' }); } const nucleusItems = availableNuclei.map((n) => ({ key: n, label: n })); return ( <>
} active={showSimilarityTree} onClick={handleShowSimilarityTree} /> )} } style={{ inputWrapper: { flex: 3, margin: '0 5px' } }} className="search-input" type="text" debounceTime={250} placeholder="Search for parameter..." onChange={handleKeywordsInputChange} onClear={clearHandler} canClear /> : } intent="success" active={!!idCode} onClick={onStructureClick} /> } intent="danger" onClick={onRemoveAll} />
); }